refactor text gen for PutOnTopOrBottomLibraryTargetEffect

This commit is contained in:
xenohedron 2024-01-21 23:24:00 -05:00
parent 6eb1cb834d
commit 340156a84b
16 changed files with 32 additions and 63 deletions

View file

@ -35,7 +35,7 @@ public final class AetherGust extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Choose target spell or permanent that's red or green. Its owner puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(true).setText(
"choose target spell or permanent that's red or green. " +
"Its owner puts it on the top or bottom of their library"
));

View file

@ -18,9 +18,7 @@ public final class Desynchronize extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{U}");
// Target nonland permanent's owner puts it on the top or bottom of their library. Scry 2.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(
"target nonland permanent's owner puts it on the top or bottom of their library"
));
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(false));
this.getSpellAbility().addEffect(new ScryEffect(2, false));
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
}

View file

@ -29,9 +29,7 @@ public final class DiverSkaab extends CardImpl {
this.addAbility(new ExploitAbility());
// When Diver Skaab exploits a creature, target creature's owner puts it on the top or bottom of their library.
Ability ability = new ExploitCreatureTriggeredAbility(new PutOnTopOrBottomLibraryTargetEffect(
"target creature's owner puts it on the top or bottom of their library"
));
Ability ability = new ExploitCreatureTriggeredAbility(new PutOnTopOrBottomLibraryTargetEffect(false));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}

View file

@ -18,7 +18,7 @@ public final class EndlessDetour extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{W}{U}");
// The owner of target spell, nonland permanent, or card in a graveyard puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect());
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(true));
this.getSpellAbility().addTarget(new TargetCardInGraveyardBattlefieldOrStack(
1, 1, StaticFilters.FILTER_CARD, StaticFilters.FILTER_PERMANENT_NON_LAND,
StaticFilters.FILTER_SPELL, "spell, nonland permanent, or card in a graveyard"

View file

@ -52,7 +52,7 @@ public final class HornedLochWhale extends AdventureCard {
// Lagoon Breach
// The owner of target attacking creature you don't control puts it on the top or bottom of their library.
this.getSpellCard().getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect());
this.getSpellCard().getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(true));
this.getSpellCard().getSpellAbility().addTarget(new TargetPermanent(filter));
this.finalizeAdventure();

View file

@ -17,9 +17,7 @@ public final class MisleadingMotes extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}");
// Target creature's owner puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(
"target creature's owner puts it on the top or bottom of their library"
));
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(false));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}

View file

@ -41,7 +41,7 @@ public final class MoonsnarePrototype extends CardImpl {
this.addAbility(ability);
// Channel {4}{U}, Discard Moonsnare Prototype: The owner of target nonland permanent puts it on the top or bottom of their library.
ability = new ChannelAbility("{4}{U}", new PutOnTopOrBottomLibraryTargetEffect());
ability = new ChannelAbility("{4}{U}", new PutOnTopOrBottomLibraryTargetEffect(true));
ability.addTarget(new TargetNonlandPermanent());
this.addAbility(ability);
}

View file

@ -31,7 +31,7 @@ public final class PowerOfPersuasion extends CardImpl {
effect.addTableEntry(1, 9, new ReturnToHandTargetEffect().setText("return it to its owner's hand"));
// 10-19 | Its owner puts it on the top of bottom of their library.
effect.addTableEntry(10, 19, new PutOnTopOrBottomLibraryTargetEffect(
effect.addTableEntry(10, 19, new PutOnTopOrBottomLibraryTargetEffect(false).setText(
"its owner puts it on the top or bottom of their library"
));

View file

@ -19,9 +19,7 @@ public final class RevengeOfTheDrowned extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}");
// Target creature's owner puts it on the top or bottom of their library. You create a 2/2 black Zombie creature token with decayed.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(
"target creature's owner puts it on the top or bottom of their library"
));
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(false));
this.getSpellAbility().addEffect(new CreateTokenEffect(new ZombieDecayedToken()).concatBy("You"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}

View file

@ -23,7 +23,7 @@ public final class RunAshore extends CardImpl {
this.getSpellAbility().getModes().setMaxModes(2);
// The owner of target nonland permanent puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect());
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(true));
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
// Return target nonland permanent to its owner's hand.

View file

@ -17,7 +17,7 @@ public final class RunOutOfTown extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}");
// The owner of target nonland permanent puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect());
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(true));
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
}

View file

@ -53,7 +53,7 @@ public final class Subtlety extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Subtlety enters the battlefield, choose up to one target creature spell or planeswalker spell. Its owner puts it on the top or bottom of their library.
Ability ability = new EntersBattlefieldTriggeredAbility(new PutOnTopOrBottomLibraryTargetEffect(
Ability ability = new EntersBattlefieldTriggeredAbility(new PutOnTopOrBottomLibraryTargetEffect(false).setText(
"choose up to one target creature spell or planeswalker spell. " +
"Its owner puts it on the top or bottom of their library"
));

View file

@ -18,9 +18,7 @@ public final class UnluckyDrop extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}");
// Target artifact or creature's owner puts it on the top or bottom of their library.
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(
"target artifact or creature's owner puts it on the top or bottom of their library"
));
this.getSpellAbility().addEffect(new PutOnTopOrBottomLibraryTargetEffect(false));
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_CREATURE));
}

View file

@ -15,10 +15,6 @@ public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffec
String sourceTargetName;
public DamageWithPowerFromSourceToAnotherTargetEffect() {
this("It");
}
public DamageWithPowerFromSourceToAnotherTargetEffect(String sourceTargetName) {
super(Outcome.Damage);
this.sourceTargetName = sourceTargetName;
@ -36,8 +32,8 @@ public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffec
}
Permanent myPermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Permanent anotherPermanent = game.getPermanent(source.getTargets().get(0).getFirstTarget());
Player anotherPlayer = game.getPlayer(source.getTargets().get(0).getFirstTarget());
Permanent anotherPermanent = game.getPermanent(source.getFirstTarget());
Player anotherPlayer = game.getPlayer(source.getFirstTarget());
if (myPermanent != null && anotherPermanent != null) {
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), source, game, false, true);
@ -65,6 +61,7 @@ public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffec
}
// It deals damage equal to its power to target creature you don't control
return this.sourceTargetName + " deals damage equal to its power to target " + mode.getTargets().get(0).getTargetName();
return sourceTargetName + " deals damage equal to its power to "
+ getTargetPointer().describeTargets(mode.getTargets(), "that creature");
}
}

View file

@ -1,13 +1,11 @@
package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
/**
* @author LevelX2
@ -24,21 +22,14 @@ public class FightTargetSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent creature1 = game.getPermanent(getTargetPointer().getFirst(game, source));
// 20110930 - 701.10
if (creature1 != null && sourcePermanent != null) {
if (creature1.isCreature(game) && sourcePermanent.isCreature(game)) {
return sourcePermanent.fight(creature1, source, game);
}
}
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": Fighting effect has been fizzled.");
}
// 701.12
Permanent sourceCreature = source.getSourcePermanentIfItStillExists(game);
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (sourceCreature == null || !sourceCreature.isCreature(game)
|| targetCreature == null || !targetCreature.isCreature(game)) {
return false;
}
return false;
return sourceCreature.fight(targetCreature, source, game);
}
@Override
@ -51,15 +42,6 @@ public class FightTargetSourceEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
Target target = mode.getTargets().get(0);
StringBuilder sb = new StringBuilder("{this} fights ");
if (target.getMinNumberOfTargets() == 0 && target.getMaxNumberOfTargets() == 1) {
sb.append("up to one ");
}
if (!target.getTargetName().contains("other")) {
sb.append("target ");
}
sb.append(target.getTargetName());
return sb.toString();
return "{this} fights " + getTargetPointer().describeTargets(mode.getTargets(), "that creature");
}
}

View file

@ -12,17 +12,16 @@ import mage.players.Player;
*/
public class PutOnTopOrBottomLibraryTargetEffect extends OneShotEffect {
public PutOnTopOrBottomLibraryTargetEffect() {
this("");
}
private final boolean textOwnerOf;
public PutOnTopOrBottomLibraryTargetEffect(String text) {
super(Outcome.Benefit);
staticText = text;
public PutOnTopOrBottomLibraryTargetEffect(boolean textOwnerOf) {
super(Outcome.ReturnToHand);
this.textOwnerOf = textOwnerOf;
}
private PutOnTopOrBottomLibraryTargetEffect(final PutOnTopOrBottomLibraryTargetEffect effect) {
super(effect);
this.textOwnerOf = effect.textOwnerOf;
}
@Override
@ -48,7 +47,8 @@ public class PutOnTopOrBottomLibraryTargetEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "the owner of target " + mode.getTargets().get(0).getTargetName() +
String targetText = getTargetPointer().describeTargets(mode.getTargets(), "that permanent");
return (textOwnerOf ? "the owner of " + targetText : targetText + "'s owner") +
" puts it on the top or bottom of their library";
}
}