From c12959e02590b92795a238d7e7ecc7f8b349dbfd Mon Sep 17 00:00:00 2001 From: Samuel Sandeen Date: Mon, 25 Jul 2016 21:58:11 -0400 Subject: [PATCH] Standardize Another target logic in some cases. This removes custom targets and instead uses the AnotherTargetPredicate to filter. --- Mage.Sets/src/mage/sets/apocalypse/Jilt.java | 36 +++++----------- .../sets/avacynrestored/UlvenwaldTracker.java | 37 +++++------------ .../sets/bornofthegods/FallOfTheHammer.java | 41 ++++++------------- .../src/mage/sets/gatecrash/DomriRade.java | 38 +++++------------ .../src/mage/sets/gatecrash/PitFight.java | 39 +++++------------- 5 files changed, 55 insertions(+), 136 deletions(-) diff --git a/Mage.Sets/src/mage/sets/apocalypse/Jilt.java b/Mage.Sets/src/mage/sets/apocalypse/Jilt.java index 1dc7fa14ae..d35fef28dc 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/Jilt.java +++ b/Mage.Sets/src/mage/sets/apocalypse/Jilt.java @@ -40,7 +40,9 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; +import mage.target.Target; import mage.target.common.TargetCreaturePermanent; import mage.target.targetpointer.SecondTargetPointer; @@ -65,13 +67,19 @@ public class Jilt extends CardImpl { "If {this} was kicked, it deals 2 damage to another target creature"); effect.setTargetPointer(new SecondTargetPointer()); this.getSpellAbility().addEffect(effect); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + Target target = new TargetCreaturePermanent(new FilterCreaturePermanent("Target Creature: returned to Hand")); + target.setTargetTag(1); + this.getSpellAbility().addTarget(target); } @Override public void adjustTargets(Ability ability, Game game) { if (ability instanceof SpellAbility && KickedCondition.getInstance().apply(game, ability)) { - ability.addTarget(new TargetOtherCreaturePermanent(new FilterCreaturePermanent("another target creature"))); + FilterCreaturePermanent filter = new FilterCreaturePermanent("Another creature: Damaged"); + filter.add(new AnotherTargetPredicate(2)); + Target target = new TargetCreaturePermanent(filter); + target.setTargetTag(2); + ability.addTarget(target); } } @@ -85,27 +93,3 @@ public class Jilt extends CardImpl { return new Jilt(this); } } - -class TargetOtherCreaturePermanent extends TargetCreaturePermanent { - - public TargetOtherCreaturePermanent(FilterCreaturePermanent filter) { - super(filter); - } - - public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) { - super(target); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().get(0).getTargets().contains(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - - @Override - public TargetOtherCreaturePermanent copy() { - return new TargetOtherCreaturePermanent(this); - } -} diff --git a/Mage.Sets/src/mage/sets/avacynrestored/UlvenwaldTracker.java b/Mage.Sets/src/mage/sets/avacynrestored/UlvenwaldTracker.java index 5ca1f36e21..5335da9a56 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/UlvenwaldTracker.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/UlvenwaldTracker.java @@ -38,7 +38,10 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.FightTargetsEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; +import mage.target.Target; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -60,8 +63,14 @@ public class UlvenwaldTracker extends CardImpl { // {1}{G}, {tap}: Target creature you control fights another target creature. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new FightTargetsEffect(), new ManaCostsImpl("{1}{G}")); ability.addCost(new TapSourceCost()); - ability.addTarget(new TargetControlledCreaturePermanent()); - ability.addTarget(new TargetOtherCreaturePermanent()); + Target controlledTarget = new TargetControlledCreaturePermanent(); + controlledTarget.setTargetTag(1); + ability.addTarget(controlledTarget); + FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature to fight"); + filter.add(new AnotherTargetPredicate(2)); + Target secondTarget = new TargetCreaturePermanent(filter); + secondTarget.setTargetTag(2); + ability.addTarget(secondTarget); this.addAbility(ability); } @@ -74,27 +83,3 @@ public class UlvenwaldTracker extends CardImpl { return new UlvenwaldTracker(this); } } -class TargetOtherCreaturePermanent extends TargetCreaturePermanent { - - public TargetOtherCreaturePermanent() { - super(); - } - - public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) { - super(target); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().get(0).getTargets().contains(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - - @Override - public TargetOtherCreaturePermanent copy() { - return new TargetOtherCreaturePermanent(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/bornofthegods/FallOfTheHammer.java b/Mage.Sets/src/mage/sets/bornofthegods/FallOfTheHammer.java index 9f11f4b40e..eabcf7103f 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/FallOfTheHammer.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/FallOfTheHammer.java @@ -34,7 +34,9 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; @@ -55,8 +57,6 @@ import mage.target.common.TargetCreaturePermanent; */ public class FallOfTheHammer extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another target creature"); - public FallOfTheHammer(UUID ownerId) { super(ownerId, 93, "Fall of the Hammer", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}"); this.expansionSetCode = "BNG"; @@ -64,8 +64,16 @@ public class FallOfTheHammer extends CardImpl { // Target creature you control deals damage equal to its power to another target creature. this.getSpellAbility().addEffect(new FallOfTheHammerDamageEffect()); - this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); - this.getSpellAbility().addTarget(new FallOfTheHammerTargetCreaturePermanent(filter)); + TargetControlledCreaturePermanent target = + new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("Target creature: deals damage")); + target.setTargetTag(1); + this.getSpellAbility().addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent("Another creature: damage dealt to"); + filter.add(new AnotherTargetPredicate(2)); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + this.getSpellAbility().addTarget(target2); } public FallOfTheHammer(final FallOfTheHammer card) { @@ -108,28 +116,3 @@ class FallOfTheHammerDamageEffect extends OneShotEffect { return false; } } - - -class FallOfTheHammerTargetCreaturePermanent extends TargetCreaturePermanent { - - public FallOfTheHammerTargetCreaturePermanent(FilterCreaturePermanent filter) { - super(filter); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - if (source.getTargets().getFirstTarget().equals(id)) { - return false; - } - return super.canTarget(id, source, game); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().getFirstTarget().equals(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - -} diff --git a/Mage.Sets/src/mage/sets/gatecrash/DomriRade.java b/Mage.Sets/src/mage/sets/gatecrash/DomriRade.java index c57464b9e7..7e401dd4e9 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/DomriRade.java +++ b/Mage.Sets/src/mage/sets/gatecrash/DomriRade.java @@ -51,6 +51,8 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.game.command.Emblem; import mage.players.Player; @@ -75,8 +77,15 @@ public class DomriRade extends CardImpl { // -2: Target creature you control fights another target creature. LoyaltyAbility ability2 = new LoyaltyAbility(new FightTargetsEffect(), -2); - ability2.addTarget(new TargetControlledCreaturePermanent()); - ability2.addTarget(new DomriRadeTargetOtherCreaturePermanent()); + TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); + target.setTargetTag(1); + ability2.addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature to fight"); + filter.add(new AnotherTargetPredicate(2)); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + ability2.addTarget(target2); this.addAbility(ability2); // -7: You get an emblem with "Creatures you control have double strike, trample, hexproof and haste." @@ -150,28 +159,3 @@ class DomriRadeEmblem extends Emblem { this.getAbilities().add(ability); } } - -class DomriRadeTargetOtherCreaturePermanent extends TargetCreaturePermanent { - - public DomriRadeTargetOtherCreaturePermanent() { - super(); - } - - public DomriRadeTargetOtherCreaturePermanent(final DomriRadeTargetOtherCreaturePermanent target) { - super(target); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().get(0).getTargets().contains(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - - @Override - public DomriRadeTargetOtherCreaturePermanent copy() { - return new DomriRadeTargetOtherCreaturePermanent(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/gatecrash/PitFight.java b/Mage.Sets/src/mage/sets/gatecrash/PitFight.java index 093aabd528..0bef929276 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/PitFight.java +++ b/Mage.Sets/src/mage/sets/gatecrash/PitFight.java @@ -33,6 +33,8 @@ import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.common.FightTargetsEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.game.Game; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -50,8 +52,15 @@ public class PitFight extends CardImpl { // Target creature you control fights another target creature. this.getSpellAbility().addEffect(new FightTargetsEffect()); - this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); - this.getSpellAbility().addTarget(new TargetOtherCreaturePermanent()); + TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(); + target.setTargetTag(1); + this.getSpellAbility().addTarget(target); + + FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature to fight"); + filter.add(new AnotherTargetPredicate(2)); + TargetCreaturePermanent target2 = new TargetCreaturePermanent(filter); + target2.setTargetTag(2); + this.getSpellAbility().addTarget(target2); } public PitFight(final PitFight card) { @@ -63,29 +72,3 @@ public class PitFight extends CardImpl { return new PitFight(this); } } - - -class TargetOtherCreaturePermanent extends TargetCreaturePermanent { - - public TargetOtherCreaturePermanent() { - super(); - } - - public TargetOtherCreaturePermanent(final TargetOtherCreaturePermanent target) { - super(target); - } - - @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - if (source.getTargets().get(0).getTargets().contains(id)) { - return false; - } - return super.canTarget(controllerId, id, source, game); - } - - @Override - public TargetOtherCreaturePermanent copy() { - return new TargetOtherCreaturePermanent(this); - } - -}