From fbb3929d0a3ac819814da7fed2b629548170382f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 25 Nov 2015 16:30:18 +0100 Subject: [PATCH] * Fixed some adjustTargets methods of cards were that the target adjustment could be applied to abilities not intended (fixes #1384). --- .../mage/sets/alliances/GorillaShaman1.java | 6 ++++- .../sets/apocalypse/DwarvenLandslide.java | 7 ++++-- .../MinamoSightbender.java | 14 ++++++----- .../betrayersofkamigawa/QuillmaneBaku.java | 5 +++- .../bornofthegods/ChampionOfStraySouls.java | 19 ++++++++------ .../sets/championsofkamigawa/HearthKami.java | 15 ++++++----- .../src/mage/sets/coldsnap/MartyrOfBones.java | 25 +++++++++++-------- .../sets/commander2013/DeepfireElemental.java | 9 +++++-- .../sets/commander2014/TyrantsFamiliar.java | 13 ++++++---- .../src/mage/sets/exodus/OathOfDruids.java | 5 +++- .../src/mage/sets/exodus/OathOfLieges.java | 5 +++- .../sets/futuresight/LinessaZephyrMage.java | 6 ++++- .../sets/magic2014/MasterOfDiversion.java | 7 ++++-- .../SentinelOfTheEternalWatch.java | 16 +++++++----- .../src/mage/sets/mirage/SidarJabari.java | 11 +++++--- .../sets/morningtide/DeclarationOfNaught.java | 9 ++++--- .../src/mage/sets/odyssey/BurningSands.java | 9 ++++--- .../sets/saviorsofkamigawa/SkyfireKirin.java | 10 +++++--- .../scarsofmirrodin/GethLordOfTheVault.java | 8 ++++-- .../src/mage/sets/tempest/LegacysAllure.java | 8 ++++-- .../src/mage/sets/theros/PolisCrusher.java | 6 ++++- .../mage/sets/timeshifted/Pandemonium.java | 18 +++++++------ .../mage/sets/urzasdestiny/SigilOfSleep.java | 6 ++++- .../mage/sets/worldwake/MarshalsAnthem.java | 17 ++++++++----- .../src/mage/sets/worldwake/VoyagerDrake.java | 12 ++++++--- Mage/src/mage/abilities/AbilityImpl.java | 5 ++-- 26 files changed, 179 insertions(+), 92 deletions(-) diff --git a/Mage.Sets/src/mage/sets/alliances/GorillaShaman1.java b/Mage.Sets/src/mage/sets/alliances/GorillaShaman1.java index edb27282bc..3fd9f9e798 100644 --- a/Mage.Sets/src/mage/sets/alliances/GorillaShaman1.java +++ b/Mage.Sets/src/mage/sets/alliances/GorillaShaman1.java @@ -52,6 +52,8 @@ import mage.target.TargetPermanent; */ public class GorillaShaman1 extends CardImpl { + private final UUID originalId; + public GorillaShaman1(UUID ownerId) { super(ownerId, 106, "Gorilla Shaman", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{R}"); this.expansionSetCode = "ALL"; @@ -63,12 +65,13 @@ public class GorillaShaman1 extends CardImpl { // {X}{X}{1}: Destroy target noncreature artifact with converted mana cost X. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{X}{X}{1}")); ability.addTarget(new TargetPermanent(new FilterArtifactPermanent("noncreature artifact with converted mana cost X"))); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int xValue = ability.getManaCostsToPay().getX(); ability.getTargets().clear(); FilterArtifactPermanent filter = new FilterArtifactPermanent(new StringBuilder("noncreature artifact with converted mana cost ").append(xValue).toString()); @@ -81,6 +84,7 @@ public class GorillaShaman1 extends CardImpl { public GorillaShaman1(final GorillaShaman1 card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java b/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java index c6168855cc..65b47b76d2 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java +++ b/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java @@ -29,6 +29,7 @@ package mage.sets.apocalypse; import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.condition.common.KickedCondition; import mage.abilities.costs.Cost; import mage.abilities.costs.Costs; @@ -72,8 +73,10 @@ public class DwarvenLandslide extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { - if (KickedCondition.getInstance().apply(game, ability)) { - getSpellAbility().addTarget(new TargetLandPermanent(new FilterLandPermanent("land (Kicker)"))); + if (ability instanceof SpellAbility) { + if (KickedCondition.getInstance().apply(game, ability)) { + getSpellAbility().addTarget(new TargetLandPermanent(new FilterLandPermanent("land (Kicker)"))); + } } } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java index e10d726216..60331f9d60 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/MinamoSightbender.java @@ -28,9 +28,6 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -39,6 +36,8 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.Filter; import mage.filter.common.FilterCreaturePermanent; @@ -54,6 +53,7 @@ import mage.target.common.TargetCreaturePermanent; public class MinamoSightbender extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power X or less"); + private final UUID originalId; public MinamoSightbender(UUID ownerId) { super(ownerId, 41, "Minamo Sightbender", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}"); @@ -69,19 +69,20 @@ public class MinamoSightbender extends CardImpl { Target target = new TargetCreaturePermanent(filter); ability.addTarget(target); ability.addCost(new TapSourceCost()); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { - for (Effect effect :ability.getEffects()) { + if (ability.getOriginalId().equals(originalId)) { + for (Effect effect : ability.getEffects()) { if (effect instanceof CantBeBlockedTargetEffect) { int manaX = ability.getManaCostsToPay().getX(); ability.getTargets().clear(); FilterCreaturePermanent newFilter = new FilterCreaturePermanent(new StringBuilder("creature with power ").append(manaX).append(" or less").toString()); - filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, manaX +1)); + filter.add(new PowerPredicate(Filter.ComparisonType.LessThan, manaX + 1)); Target target = new TargetCreaturePermanent(newFilter); ability.addTarget(target); break; @@ -92,6 +93,7 @@ public class MinamoSightbender extends CardImpl { public MinamoSightbender(final MinamoSightbender card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/QuillmaneBaku.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/QuillmaneBaku.java index b367b8f020..f20848de39 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/QuillmaneBaku.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/QuillmaneBaku.java @@ -59,6 +59,7 @@ import mage.target.common.TargetCreaturePermanent; public class QuillmaneBaku extends CardImpl { private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard(); + private final UUID originalId; public QuillmaneBaku(UUID ownerId) { super(ownerId, 48, "Quillmane Baku", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}"); @@ -76,12 +77,13 @@ public class QuillmaneBaku extends CardImpl { ability.addCost(new TapSourceCost()); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.KI.createInstance(1))); ability.addTarget(new TargetCreaturePermanent()); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int maxConvManaCost = 0; for (Cost cost : ability.getCosts()) { if (cost instanceof RemoveVariableCountersSourceCost) { @@ -98,6 +100,7 @@ public class QuillmaneBaku extends CardImpl { public QuillmaneBaku(final QuillmaneBaku card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/bornofthegods/ChampionOfStraySouls.java b/Mage.Sets/src/mage/sets/bornofthegods/ChampionOfStraySouls.java index a59de28186..421d4ef273 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/ChampionOfStraySouls.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/ChampionOfStraySouls.java @@ -27,6 +27,7 @@ */ package mage.sets.bornofthegods; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -47,14 +48,13 @@ import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.target.common.TargetCardInYourGraveyard; -import java.util.UUID; - /** * * @author LevelX2 */ public class ChampionOfStraySouls extends CardImpl { + private final UUID originalId; private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("other creatures"); static { @@ -71,8 +71,9 @@ public class ChampionOfStraySouls extends CardImpl { this.toughness = new MageInt(4); /** - * You choose the targets of the first ability as you activate that ability, - * before you pay any costs. You can't target any of the creatures you sacrifice. + * You choose the targets of the first ability as you activate that + * ability, before you pay any costs. You can't target any of the + * creatures you sacrifice. */ // {3}{B}{B}, {T}, Sacrifice X other creatures: Return X target creatures from your graveyard to the battlefield. Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); @@ -80,11 +81,12 @@ public class ChampionOfStraySouls extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{3}{B}{B}")); ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeXTargetCost(filter)); - ability.addTarget(new TargetCardInYourGraveyard(0,Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your graveyard"))); + ability.addTarget(new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your graveyard"))); + originalId = ability.getOriginalId(); this.addAbility(ability); // {5}{B}{B}: Put Champion of Stray Souls on top of your library from your graveyard. - this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, + this.addAbility(new SimpleActivatedAbility(Zone.GRAVEYARD, new PutOnLibrarySourceEffect(true, "Put {this} on top of your library from your graveyard"), new ManaCostsImpl("{5}{B}{B}"))); @@ -92,12 +94,12 @@ public class ChampionOfStraySouls extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { for (Effect effect : ability.getEffects()) { if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) { int xValue = new GetXValue().calculate(game, ability, null); ability.getTargets().clear(); - ability.addTarget(new TargetCardInYourGraveyard(xValue,xValue, new FilterCreatureCard("creature cards from your graveyard"))); + ability.addTarget(new TargetCardInYourGraveyard(xValue, xValue, new FilterCreatureCard("creature cards from your graveyard"))); } } } @@ -105,6 +107,7 @@ public class ChampionOfStraySouls extends CardImpl { public ChampionOfStraySouls(final ChampionOfStraySouls card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HearthKami.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HearthKami.java index 1b9764a391..8920c45bf6 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/HearthKami.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HearthKami.java @@ -25,20 +25,19 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.championsofkamigawa; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; -import mage.abilities.costs.mana.*; +import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.Filter; import mage.filter.common.FilterArtifactPermanent; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; @@ -51,6 +50,8 @@ import mage.target.TargetPermanent; */ public class HearthKami extends CardImpl { + private final UUID originalId; + public HearthKami(UUID ownerId) { super(ownerId, 171, "Hearth Kami", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{R}"); this.expansionSetCode = "CHK"; @@ -63,12 +64,13 @@ public class HearthKami extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{X}")); ability.addCost(new SacrificeSourceCost()); ability.addTarget(new TargetPermanent(new FilterArtifactPermanent("artifact with converted mana cost X"))); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int xValue = ability.getManaCostsToPay().getX(); ability.getTargets().clear(); FilterArtifactPermanent filter = new FilterArtifactPermanent(new StringBuilder("artifact with converted mana cost ").append(xValue).toString()); @@ -80,6 +82,7 @@ public class HearthKami extends CardImpl { public HearthKami(final HearthKami card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/coldsnap/MartyrOfBones.java b/Mage.Sets/src/mage/sets/coldsnap/MartyrOfBones.java index a08beb1ada..0c017fd378 100644 --- a/Mage.Sets/src/mage/sets/coldsnap/MartyrOfBones.java +++ b/Mage.Sets/src/mage/sets/coldsnap/MartyrOfBones.java @@ -57,6 +57,8 @@ import mage.target.common.TargetCardInHand; */ public class MartyrOfBones extends CardImpl { + private final UUID originalId; + public MartyrOfBones(UUID ownerId) { super(ownerId, 65, "Martyr of Bones", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{B}"); this.expansionSetCode = "CSP"; @@ -72,16 +74,18 @@ public class MartyrOfBones extends CardImpl { ability.addCost(new RevealVariableBlackCardsFromHandCost()); ability.addCost(new SacrificeSourceCost()); ability.addTarget(new TargetCardInASingleGraveyard(0, 1, new FilterCard("cards in a single graveyard"))); + originalId = ability.getOriginalId(); this.addAbility(ability); } - + public MartyrOfBones(final MartyrOfBones card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int amount = 0; for (Cost cost : ability.getCosts()) { if (cost instanceof RevealVariableBlackCardsFromHandCost) { @@ -100,36 +104,37 @@ public class MartyrOfBones extends CardImpl { } class RevealVariableBlackCardsFromHandCost extends VariableCostImpl { - + private static final FilterCard filter = new FilterCard("X black cards from your hand"); + static { filter.add(new ColorPredicate(ObjectColor.BLACK)); } - + RevealVariableBlackCardsFromHandCost() { super("black cards to reveal"); this.text = new StringBuilder("Reveal ").append(xText).append(" black cards from {this}").toString(); } - + RevealVariableBlackCardsFromHandCost(final RevealVariableBlackCardsFromHandCost cost) { super(cost); } - + @Override public RevealVariableBlackCardsFromHandCost copy() { return new RevealVariableBlackCardsFromHandCost(this); } - + @Override public Cost getFixedCostsFromAnnouncedValue(int xValue) { return new RevealTargetFromHandCost(new TargetCardInHand(0, xValue, filter)); } - + @Override public int getMinValue(Ability source, Game game) { return 0; } - + @Override public int getMaxValue(Ability source, Game game) { Player player = game.getPlayer(source.getControllerId()); @@ -138,4 +143,4 @@ class RevealVariableBlackCardsFromHandCost extends VariableCostImpl { } return 0; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/commander2013/DeepfireElemental.java b/Mage.Sets/src/mage/sets/commander2013/DeepfireElemental.java index e49ad954f6..d3b093498b 100644 --- a/Mage.Sets/src/mage/sets/commander2013/DeepfireElemental.java +++ b/Mage.Sets/src/mage/sets/commander2013/DeepfireElemental.java @@ -52,11 +52,14 @@ import mage.target.TargetPermanent; */ public class DeepfireElemental extends CardImpl { + private final UUID originalId; + private static final FilterPermanent filter = new FilterPermanent("artifact or creature with converted mana cost X"); + static { filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE))); } - + public DeepfireElemental(UUID ownerId) { super(ownerId, 185, "Deepfire Elemental", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{4}{B}{R}"); this.expansionSetCode = "C13"; @@ -68,12 +71,13 @@ public class DeepfireElemental extends CardImpl { // {X}{X}{1}: Destroy target artifact or creature with converted mana cost X. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{X}{X}{1}")); ability.addTarget(new TargetPermanent(filter)); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); FilterPermanent newFilter = filter.copy(); newFilter.setMessage(new StringBuilder("artifact or creature with converted mana cost {").append(ability.getManaCostsToPay().getX()).append("}").toString()); @@ -85,6 +89,7 @@ public class DeepfireElemental extends CardImpl { public DeepfireElemental(final DeepfireElemental card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/commander2014/TyrantsFamiliar.java b/Mage.Sets/src/mage/sets/commander2014/TyrantsFamiliar.java index df09c2e46e..38017589d0 100644 --- a/Mage.Sets/src/mage/sets/commander2014/TyrantsFamiliar.java +++ b/Mage.Sets/src/mage/sets/commander2014/TyrantsFamiliar.java @@ -38,7 +38,6 @@ import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.HasteAbility; import mage.cards.CardImpl; -import mage.constants.AbilityType; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; @@ -52,6 +51,8 @@ import mage.target.common.TargetCreaturePermanent; */ public class TyrantsFamiliar extends CardImpl { + private final UUID originalId; + public TyrantsFamiliar(UUID ownerId) { super(ownerId, 39, "Tyrant's Familiar", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{5}{R}{R}"); this.expansionSetCode = "C14"; @@ -62,30 +63,32 @@ public class TyrantsFamiliar extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - + // Haste this.addAbility(HasteAbility.getInstance()); - + // Lieutenant - As long as you control your commander, Tyrant's Familiar gets +2/+2 and has "Whenever Tyrant's Familiar attacks, it deals 7 damage to target creature defending player controls." Ability gainedAbility = new AttacksTriggeredAbility(new DamageTargetEffect(7), false); gainedAbility.addTarget(new TargetCreaturePermanent()); ContinuousEffect effect = new GainAbilitySourceEffect(gainedAbility); effect.setText("and has \"Whenever {this} attacks, it deals 7 damage to target creature defending player controls\""); + originalId = gainedAbility.getOriginalId(); this.addAbility(new LieutenantAbility(effect)); } public TyrantsFamiliar(final TyrantsFamiliar card) { super(card); + this.originalId = card.originalId; } @Override public TyrantsFamiliar copy() { return new TyrantsFamiliar(this); } - + @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java index e613109d66..261c3b9185 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfDruids.java @@ -55,6 +55,7 @@ import mage.target.TargetPlayer; */ public class OathOfDruids extends CardImpl { + private final UUID originalId; private static final FilterPlayer filter = new FilterPlayer(); static { @@ -68,12 +69,13 @@ public class OathOfDruids extends CardImpl { // At the beginning of each player's upkeep, that player chooses target player who controls more creatures than he or she does and is his or her opponent. The first player may reveal cards from the top of his or her library until he or she reveals a creature card. If he or she does, that player puts that card onto the battlefield and all other cards revealed this way into his or her graveyard. Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfDruidsEffect(), TargetController.ANY, true); ability.addTarget(new TargetPlayer(1, 1, false, filter)); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof BeginningOfUpkeepTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); if (activePlayer != null) { ability.setControllerId(activePlayer.getId()); @@ -86,6 +88,7 @@ public class OathOfDruids extends CardImpl { public OathOfDruids(final OathOfDruids card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java index ad31783661..6a2c327935 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java @@ -54,6 +54,7 @@ import mage.target.targetpointer.FixedTarget; */ public class OathOfLieges extends CardImpl { + private final UUID originalId; private static final FilterPlayer filter = new FilterPlayer("player who controls more lands than you do and is his your opponent"); static { @@ -69,16 +70,18 @@ public class OathOfLieges extends CardImpl { effect.setText("that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library"); Ability ability = new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, true); ability.addTarget(new TargetPlayer(1, 1, false, filter)); + originalId = ability.getOriginalId(); this.addAbility(ability); } public OathOfLieges(final OathOfLieges card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof BeginningOfUpkeepTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); if (activePlayer != null) { ability.getTargets().clear(); diff --git a/Mage.Sets/src/mage/sets/futuresight/LinessaZephyrMage.java b/Mage.Sets/src/mage/sets/futuresight/LinessaZephyrMage.java index 2d70219a2a..8e3e97682c 100644 --- a/Mage.Sets/src/mage/sets/futuresight/LinessaZephyrMage.java +++ b/Mage.Sets/src/mage/sets/futuresight/LinessaZephyrMage.java @@ -61,6 +61,8 @@ import mage.target.common.TargetCreaturePermanent; */ public class LinessaZephyrMage extends CardImpl { + private final UUID originalId; + public LinessaZephyrMage(UUID ownerId) { super(ownerId, 51, "Linessa, Zephyr Mage", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}"); this.expansionSetCode = "FUT"; @@ -75,6 +77,7 @@ public class LinessaZephyrMage extends CardImpl { Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(), new ManaCostsImpl("{X}{U}{U}")); ability.addCost(new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); + originalId = ability.getOriginalId(); this.addAbility(ability); // Grandeur - Discard another card named Linessa, Zephyr Mage: Target player returns a creature he or she controls to its owner's hand, then repeats this process for an artifact, an enchantment, and a land. @@ -85,11 +88,12 @@ public class LinessaZephyrMage extends CardImpl { public LinessaZephyrMage(final LinessaZephyrMage card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int xValue = ability.getManaCostsToPay().getX(); ability.getTargets().clear(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost " + xValue); diff --git a/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java b/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java index 3c7072088f..2503b681a8 100644 --- a/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java +++ b/Mage.Sets/src/mage/sets/magic2014/MasterOfDiversion.java @@ -33,7 +33,6 @@ import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.effects.common.TapTargetEffect; import mage.cards.CardImpl; -import mage.constants.AbilityType; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; @@ -47,6 +46,8 @@ import mage.target.common.TargetCreaturePermanent; */ public class MasterOfDiversion extends CardImpl { + private final UUID originalId; + public MasterOfDiversion(UUID ownerId) { super(ownerId, 24, "Master of Diversion", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{W}"); this.expansionSetCode = "M14"; @@ -59,17 +60,19 @@ public class MasterOfDiversion extends CardImpl { // Whenever Master of Diversion attacks, tap target creature defending player controls. Ability ability = new AttacksTriggeredAbility(new TapTargetEffect(), false); ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature defending player controls"))); + originalId = ability.getOriginalId(); this.addAbility(ability); } public MasterOfDiversion(final MasterOfDiversion card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/magicorigins/SentinelOfTheEternalWatch.java b/Mage.Sets/src/mage/sets/magicorigins/SentinelOfTheEternalWatch.java index 7571edab19..cc05fd5e1d 100644 --- a/Mage.Sets/src/mage/sets/magicorigins/SentinelOfTheEternalWatch.java +++ b/Mage.Sets/src/mage/sets/magicorigins/SentinelOfTheEternalWatch.java @@ -53,6 +53,8 @@ import mage.target.targetpointer.FirstTargetPointer; */ public class SentinelOfTheEternalWatch extends CardImpl { + private final UUID originalId; + public SentinelOfTheEternalWatch(UUID ownerId) { super(ownerId, 30, "Sentinel of the Eternal Watch", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{5}{W}"); this.expansionSetCode = "ORI"; @@ -64,12 +66,15 @@ public class SentinelOfTheEternalWatch extends CardImpl { // Vigilance this.addAbility(VigilanceAbility.getInstance()); // At the beginning of combat on each opponent's turn, tap target creature that player controls. - this.addAbility(new BeginningOfCombatTriggeredAbility(Zone.BATTLEFIELD, new TapTargetEffect("target creature that player controls"), TargetController.OPPONENT, false, true)); - + Ability ability = new BeginningOfCombatTriggeredAbility(Zone.BATTLEFIELD, new TapTargetEffect("target creature that player controls"), TargetController.OPPONENT, false, true); + originalId = ability.getOriginalId(); + this.addAbility(ability); + } public SentinelOfTheEternalWatch(final SentinelOfTheEternalWatch card) { super(card); + this.originalId = card.originalId; } @Override @@ -79,8 +84,8 @@ public class SentinelOfTheEternalWatch extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof BeginningOfCombatTriggeredAbility) { - for (Effect effect: ability.getEffects()) { + if (ability.getOriginalId().equals(originalId)) { + for (Effect effect : ability.getEffects()) { UUID opponentId = effect.getTargetPointer().getFirst(game, ability); Player opponent = game.getPlayer(opponentId); if (opponent != null) { @@ -93,6 +98,5 @@ public class SentinelOfTheEternalWatch extends CardImpl { } } } - - + } diff --git a/Mage.Sets/src/mage/sets/mirage/SidarJabari.java b/Mage.Sets/src/mage/sets/mirage/SidarJabari.java index ad3b3bc31f..5334d42ffb 100644 --- a/Mage.Sets/src/mage/sets/mirage/SidarJabari.java +++ b/Mage.Sets/src/mage/sets/mirage/SidarJabari.java @@ -34,7 +34,6 @@ import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.keyword.FlankingAbility; import mage.cards.CardImpl; -import mage.constants.AbilityType; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; @@ -48,6 +47,8 @@ import mage.target.common.TargetCreaturePermanent; */ public class SidarJabari extends CardImpl { + private final UUID originalId; + public SidarJabari(UUID ownerId) { super(ownerId, 243, "Sidar Jabari", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{W}"); this.expansionSetCode = "MIR"; @@ -59,20 +60,22 @@ public class SidarJabari extends CardImpl { // Flanking this.addAbility(new FlankingAbility()); - + // Whenever Sidar Jabari attacks, tap target creature defending player controls. Ability ability = new AttacksTriggeredAbility(new TapTargetEffect(), false); ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature defending player controls"))); + originalId = ability.getOriginalId(); this.addAbility(ability); } public SidarJabari(final SidarJabari card) { super(card); + this.originalId = card.originalId; } - + @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls"); UUID defenderId = game.getCombat().getDefenderId(ability.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/morningtide/DeclarationOfNaught.java b/Mage.Sets/src/mage/sets/morningtide/DeclarationOfNaught.java index 7f91e4a9af..38c343102a 100644 --- a/Mage.Sets/src/mage/sets/morningtide/DeclarationOfNaught.java +++ b/Mage.Sets/src/mage/sets/morningtide/DeclarationOfNaught.java @@ -48,7 +48,8 @@ import mage.target.TargetSpell; * @author jeffwadsworth */ public class DeclarationOfNaught extends CardImpl { - + + private final UUID originalId; static final private FilterSpell filter = new FilterSpell("spell with the chosen name"); public DeclarationOfNaught(UUID ownerId) { @@ -61,13 +62,14 @@ public class DeclarationOfNaught extends CardImpl { // {U}: Counter target spell with the chosen name. SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CounterTargetEffect(), new ManaCostsImpl("{U}")); ability.addTarget(new TargetSpell(filter)); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); FilterSpell filter2 = new FilterSpell("spell with the chosen name"); filter2.add(new NamePredicate((String) game.getState().getValue(ability.getSourceId().toString() + NameACardEffect.INFO_KEY))); @@ -78,10 +80,11 @@ public class DeclarationOfNaught extends CardImpl { public DeclarationOfNaught(final DeclarationOfNaught card) { super(card); + this.originalId = card.originalId; } @Override public DeclarationOfNaught copy() { return new DeclarationOfNaught(this); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/odyssey/BurningSands.java b/Mage.Sets/src/mage/sets/odyssey/BurningSands.java index de47ee2833..fbea465432 100644 --- a/Mage.Sets/src/mage/sets/odyssey/BurningSands.java +++ b/Mage.Sets/src/mage/sets/odyssey/BurningSands.java @@ -46,20 +46,22 @@ import mage.target.targetpointer.FixedTarget; */ public class BurningSands extends CardImpl { + private final UUID originalId; private static final FilterLandPermanent filter = new FilterLandPermanent("a land"); public BurningSands(UUID ownerId) { super(ownerId, 180, "Burning Sands", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}{R}"); this.expansionSetCode = "ODY"; - // Whenever a creature dies, that creature's controller sacrifices a land. - this.addAbility(new DiesCreatureTriggeredAbility(new SacrificeEffect(filter, 1, "that creature's controller"), false, false, true)); + Ability ability = new DiesCreatureTriggeredAbility(new SacrificeEffect(filter, 1, "that creature's controller"), false, false, true); + originalId = ability.getOriginalId(); + this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof DiesCreatureTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { UUID creatureId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability); Permanent creature = (Permanent) game.getLastKnownInformation(creatureId, Zone.BATTLEFIELD); if (creature != null) { @@ -70,6 +72,7 @@ public class BurningSands extends CardImpl { public BurningSands(final BurningSands card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java index 7fce270492..8cbed9fd44 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java @@ -35,9 +35,7 @@ import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.AbilityType; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; @@ -60,6 +58,8 @@ import mage.target.targetpointer.FixedTarget; */ public class SkyfireKirin extends CardImpl { + private final UUID originalId; + public SkyfireKirin(UUID ownerId) { super(ownerId, 113, "Skyfire Kirin", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}{R}"); this.expansionSetCode = "SOK"; @@ -75,12 +75,13 @@ public class SkyfireKirin extends CardImpl { // Whenever you cast a Spirit or Arcane spell, you may gain control of target creature with that spell's converted mana cost until end of turn. Ability ability = new SpellCastControllerTriggeredAbility(Zone.BATTLEFIELD, new SkyfireKirinEffect(), new FilterSpiritOrArcaneCard(), true, true); ability.addTarget(new TargetCreaturePermanent()); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { + if (ability.getOriginalId().equals(originalId)) { Spell spell = game.getStack().getSpell(ability.getEffects().get(0).getTargetPointer().getFirst(game, ability)); if (spell != null) { int cmc = spell.getConvertedManaCost(); @@ -94,6 +95,7 @@ public class SkyfireKirin extends CardImpl { public SkyfireKirin(final SkyfireKirin card) { super(card); + this.originalId = card.originalId; } @Override @@ -121,7 +123,7 @@ class SkyfireKirinEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent targetCreature = null; - for(Target target: source.getTargets()) { + for (Target target : source.getTargets()) { if (target instanceof TargetPermanent) { targetCreature = game.getPermanent(target.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/GethLordOfTheVault.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/GethLordOfTheVault.java index 7e0ccb7435..789abba3b4 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/GethLordOfTheVault.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/GethLordOfTheVault.java @@ -56,6 +56,8 @@ import mage.target.common.TargetCardInOpponentsGraveyard; */ public class GethLordOfTheVault extends CardImpl { + private final UUID originalId; + public GethLordOfTheVault(UUID ownerId) { super(ownerId, 64, "Geth, Lord of the Vault", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{B}{B}"); this.expansionSetCode = "SOM"; @@ -70,16 +72,17 @@ public class GethLordOfTheVault extends CardImpl { // {X}{B}: Put target artifact or creature card with converted mana cost X from an opponent's graveyard onto the battlefield under your control tapped. // Then that player puts the top X cards of his or her library into his or her graveyard. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GethLordOfTheVaultEffect(), new ManaCostsImpl("{X}{B}")); + originalId = ability.getOriginalId(); ability.addTarget(new TargetCardInOpponentsGraveyard(new FilterCard("artifact or creature card with converted mana cost X from an opponent's graveyard"))); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { int xValue = ability.getManaCostsToPay().getX(); ability.getTargets().clear(); - FilterCard filter = new FilterCard(new StringBuilder("artifact or creature card with converted mana cost ").append(xValue).append(" from an opponent's graveyard").toString()); + FilterCard filter = new FilterCard("artifact or creature card with converted mana cost " + xValue + " from an opponent's graveyard"); filter.add(Predicates.or( new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE))); @@ -91,6 +94,7 @@ public class GethLordOfTheVault extends CardImpl { public GethLordOfTheVault(final GethLordOfTheVault card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/tempest/LegacysAllure.java b/Mage.Sets/src/mage/sets/tempest/LegacysAllure.java index 902a744273..88294061de 100644 --- a/Mage.Sets/src/mage/sets/tempest/LegacysAllure.java +++ b/Mage.Sets/src/mage/sets/tempest/LegacysAllure.java @@ -54,6 +54,8 @@ import mage.target.common.TargetCreaturePermanent; */ public class LegacysAllure extends CardImpl { + private final UUID originalId; + public LegacysAllure(UUID ownerId) { super(ownerId, 71, "Legacy's Allure", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}"); this.expansionSetCode = "TMP"; @@ -62,18 +64,20 @@ public class LegacysAllure extends CardImpl { this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(new Counter("treasure")), TargetController.YOU, true)); // Sacrifice Legacy's Allure: Gain control of target creature with power less than or equal to the number of treasure counters on Legacy's Allure. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true),new SacrificeSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlTargetEffect(Duration.EndOfGame, true), new SacrificeSourceCost()); ability.addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature with power less than or equal to the number of treasure counters on " + getLogName()))); + originalId = ability.getOriginalId(); this.addAbility(ability); } public LegacysAllure(final LegacysAllure card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { + if (ability.getOriginalId().equals(originalId)) { Permanent sourcePermanent = game.getPermanent(ability.getSourceId()); if (sourcePermanent != null) { int numbCounters = sourcePermanent.getCounters().getCount("treasure"); diff --git a/Mage.Sets/src/mage/sets/theros/PolisCrusher.java b/Mage.Sets/src/mage/sets/theros/PolisCrusher.java index 2d169d8085..84757edc1f 100644 --- a/Mage.Sets/src/mage/sets/theros/PolisCrusher.java +++ b/Mage.Sets/src/mage/sets/theros/PolisCrusher.java @@ -64,6 +64,8 @@ public class PolisCrusher extends CardImpl { filter.add(new CardTypePredicate(CardType.ENCHANTMENT)); } + private final UUID originalId; + public PolisCrusher(UUID ownerId) { super(ownerId, 198, "Polis Crusher", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}{G}"); this.expansionSetCode = "THS"; @@ -83,16 +85,18 @@ public class PolisCrusher extends CardImpl { new DealsCombatDamageToAPlayerTriggeredAbility(new DestroyTargetEffect(), false, true), MonstrousCondition.getInstance(), "Whenever {this} deals combat damage to a player, if {this} is monstrous, destroy target enchantment that player controls."); + originalId = ability.getOriginalId(); this.addAbility(ability); } public PolisCrusher(final PolisCrusher card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof ConditionalTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { for (Effect effect : ability.getEffects()) { if (effect instanceof DestroyTargetEffect) { Player attackedPlayer = game.getPlayer(effect.getTargetPointer().getFirst(game, ability)); diff --git a/Mage.Sets/src/mage/sets/timeshifted/Pandemonium.java b/Mage.Sets/src/mage/sets/timeshifted/Pandemonium.java index 588ee3e077..b7e23c7c34 100644 --- a/Mage.Sets/src/mage/sets/timeshifted/Pandemonium.java +++ b/Mage.Sets/src/mage/sets/timeshifted/Pandemonium.java @@ -49,6 +49,8 @@ import mage.target.common.TargetCreatureOrPlayer; */ public class Pandemonium extends CardImpl { + private final UUID originalId; + public Pandemonium(UUID ownerId) { super(ownerId, 68, "Pandemonium", Rarity.SPECIAL, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}"); this.expansionSetCode = "TSB"; @@ -56,22 +58,24 @@ public class Pandemonium extends CardImpl { // Whenever a creature enters the battlefield, that creature's controller may have it deal damage equal to its power to target creature or player of his or her choice. Ability ability = new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new PandemoniumEffect(), new FilterCreaturePermanent(), false, SetTargetPointer.PERMANENT, ""); ability.addTarget(new TargetCreatureOrPlayer()); + originalId = ability.getOriginalId(); this.addAbility(ability); } public Pandemonium(final Pandemonium card) { super(card); + this.originalId = card.originalId; } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof EntersBattlefieldAllTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { UUID creatureId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability); Permanent creature = game.getPermanent(creatureId); if (creature != null) { ability.getTargets().get(0).setTargetController(creature.getControllerId()); } - } + } } @Override @@ -81,21 +85,21 @@ public class Pandemonium extends CardImpl { } class PandemoniumEffect extends OneShotEffect { - + public PandemoniumEffect() { super(Outcome.Benefit); this.staticText = "that creature's controller may have it deal damage equal to its power to target creature or player of his or her choice"; } - + public PandemoniumEffect(final PandemoniumEffect effect) { super(effect); } - + @Override public PandemoniumEffect copy() { return new PandemoniumEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -106,7 +110,7 @@ class PandemoniumEffect extends OneShotEffect { if (targetPermanent != null) { targetPermanent.damage(enteringCreature.getPower().getValue(), source.getSourceId(), game, false, true); } else { - Player targetPlayer = game.getPlayer(source.getTargets().getFirstTarget()); + Player targetPlayer = game.getPlayer(source.getTargets().getFirstTarget()); if (targetPlayer != null) { targetPlayer.damage(enteringCreature.getPower().getValue(), source.getSourceId(), game, false, true); } diff --git a/Mage.Sets/src/mage/sets/urzasdestiny/SigilOfSleep.java b/Mage.Sets/src/mage/sets/urzasdestiny/SigilOfSleep.java index 8594f497f6..7db5c8d1b9 100644 --- a/Mage.Sets/src/mage/sets/urzasdestiny/SigilOfSleep.java +++ b/Mage.Sets/src/mage/sets/urzasdestiny/SigilOfSleep.java @@ -52,6 +52,8 @@ import mage.target.targetpointer.FirstTargetPointer; */ public class SigilOfSleep extends CardImpl { + private final UUID originalId; + public SigilOfSleep(UUID ownerId) { super(ownerId, 46, "Sigil of Sleep", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{U}"); this.expansionSetCode = "UDS"; @@ -67,13 +69,14 @@ public class SigilOfSleep extends CardImpl { Effect effect = new ReturnToHandTargetEffect(); effect.setText("return target creature that player controls to its owner's hand"); ability = new DealsDamageToAPlayerAttachedTriggeredAbility(effect, "enchanted", false, true, false); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof DealsDamageToAPlayerAttachedTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { UUID playerId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability); if (playerId != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls"); @@ -89,6 +92,7 @@ public class SigilOfSleep extends CardImpl { public SigilOfSleep(final SigilOfSleep card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/worldwake/MarshalsAnthem.java b/Mage.Sets/src/mage/sets/worldwake/MarshalsAnthem.java index a86eb44cc2..1c65922201 100644 --- a/Mage.Sets/src/mage/sets/worldwake/MarshalsAnthem.java +++ b/Mage.Sets/src/mage/sets/worldwake/MarshalsAnthem.java @@ -27,6 +27,7 @@ */ package mage.sets.worldwake; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; @@ -37,7 +38,11 @@ import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffec import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.abilities.keyword.MultikickerAbility; import mage.cards.CardImpl; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; import mage.filter.FilterCard; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.CardTypePredicate; @@ -45,8 +50,6 @@ import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.target.common.TargetCardInYourGraveyard; -import java.util.UUID; - /** * * @author jeffwadsworth @@ -62,11 +65,12 @@ public class MarshalsAnthem extends CardImpl { filterCard.add(new CardTypePredicate(CardType.CREATURE)); } + private final UUID originalId; + public MarshalsAnthem(UUID ownerId) { super(ownerId, 15, "Marshal's Anthem", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); this.expansionSetCode = "WWK"; - // Multikicker {1}{W} this.addAbility(new MultikickerAbility("{1}{W}")); @@ -74,18 +78,18 @@ public class MarshalsAnthem extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false))); // When Marshal's Anthem enters the battlefield, return up to X target creature cards from your graveyard to the battlefield, where X is the number of times Marshal's Anthem was kicked. - Ability ability = new ConditionalTriggeredAbility( new EntersBattlefieldTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect(), false), KickedCondition.getInstance(), "When {this} enters the battlefield, return up to X target creature cards from your graveyard to the battlefield, where X is the number of times {this} was kicked."); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof ConditionalTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); int numbTargets = new MultikickerCount().calculate(game, ability, null); if (numbTargets > 0) { @@ -96,6 +100,7 @@ public class MarshalsAnthem extends CardImpl { public MarshalsAnthem(final MarshalsAnthem card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage.Sets/src/mage/sets/worldwake/VoyagerDrake.java b/Mage.Sets/src/mage/sets/worldwake/VoyagerDrake.java index 63fc3e0458..393be9eb6d 100644 --- a/Mage.Sets/src/mage/sets/worldwake/VoyagerDrake.java +++ b/Mage.Sets/src/mage/sets/worldwake/VoyagerDrake.java @@ -27,6 +27,7 @@ */ package mage.sets.worldwake; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; @@ -43,14 +44,14 @@ import mage.constants.Rarity; import mage.game.Game; import mage.target.common.TargetCreaturePermanent; -import java.util.UUID; - /** * * @author jeffwadsworth */ public class VoyagerDrake extends CardImpl { + private final UUID originalId; + public VoyagerDrake(UUID ownerId) { super(ownerId, 45, "Voyager Drake", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{U}"); this.expansionSetCode = "WWK"; @@ -70,21 +71,24 @@ public class VoyagerDrake extends CardImpl { new EntersBattlefieldTriggeredAbility(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn), false), KickedCondition.getInstance(), "When {this} enters the battlefield, up to X target creatures gain flying until end of turn, where X is the number of times {this} was kicked."); + originalId = ability.getOriginalId(); this.addAbility(ability); } @Override public void adjustTargets(Ability ability, Game game) { - if (ability instanceof ConditionalTriggeredAbility) { + if (ability.getOriginalId().equals(originalId)) { ability.getTargets().clear(); int numbTargets = new MultikickerCount().calculate(game, ability, null); if (numbTargets > 0) { - ability.addTarget(new TargetCreaturePermanent(0,numbTargets)); + ability.addTarget(new TargetCreaturePermanent(0, numbTargets)); } } } + public VoyagerDrake(final VoyagerDrake card) { super(card); + this.originalId = card.originalId; } @Override diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 4043b0701e..79734e2023 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -516,12 +516,11 @@ public abstract class AbilityImpl implements Ability { // set the xcosts to paid variableCost.setAmount(xValue); ((Cost) variableCost).setPaid(); - String message = new StringBuilder(controller.getLogName()) - .append(" announces a value of ").append(xValue).append(" (").append(variableCost.getActionText()).append(")").toString(); + String message = controller.getLogName() + " announces a value of " + xValue + " (" + variableCost.getActionText() + ")"; if (announceString == null) { announceString = message; } else { - announceString = new StringBuilder(announceString).append(" ").append(message).toString(); + announceString = announceString + " " + message; } } }