diff --git a/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java b/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java index ae363fd9ff..fbe7dd5c91 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java +++ b/Mage.Sets/src/mage/sets/apocalypse/DwarvenLandslide.java @@ -75,7 +75,8 @@ public class DwarvenLandslide extends CardImpl { public void adjustTargets(Ability ability, Game game) { if (ability instanceof SpellAbility) { if (KickedCondition.getInstance().apply(game, ability)) { - getSpellAbility().addTarget(new TargetLandPermanent(new FilterLandPermanent("land (Kicker)"))); + ability.getTargets().clear(); + getSpellAbility().addTarget(new TargetLandPermanent(2)); } } } 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/darkascension/BloodFeud.java b/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java index ce9e8d2015..945a984314 100644 --- a/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java +++ b/Mage.Sets/src/mage/sets/darkascension/BloodFeud.java @@ -50,16 +50,7 @@ public class BloodFeud extends CardImpl { // Target creature fights another target creature. this.getSpellAbility().addEffect(new FightTargetsEffect()); - - TargetCreaturePermanent target = new TargetCreaturePermanent(); - 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); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(2)); } public BloodFeud(final BloodFeud card) { 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); - } - -} diff --git a/Mage.Sets/src/mage/sets/planeshift/RushingRiver.java b/Mage.Sets/src/mage/sets/planeshift/RushingRiver.java index 34b0cee256..68396e02c7 100644 --- a/Mage.Sets/src/mage/sets/planeshift/RushingRiver.java +++ b/Mage.Sets/src/mage/sets/planeshift/RushingRiver.java @@ -75,7 +75,8 @@ public class RushingRiver extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { if (ability instanceof SpellAbility && KickedCondition.getInstance().apply(game, ability)) { - ability.addTarget(new TargetOtherNonlandPermanent(new FilterNonlandPermanent("another target nonland permanent"))); + ability.getTargets().clear(); + ability.addTarget(new TargetNonlandPermanent(2)); } } @@ -89,27 +90,3 @@ public class RushingRiver extends CardImpl { return new RushingRiver(this); } } - -class TargetOtherNonlandPermanent extends TargetNonlandPermanent { - - public TargetOtherNonlandPermanent(FilterNonlandPermanent filter) { - super(filter); - } - - public TargetOtherNonlandPermanent(final TargetOtherNonlandPermanent 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 TargetOtherNonlandPermanent copy() { - return new TargetOtherNonlandPermanent(this); - } -} diff --git a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/DissensionInTheRanks.java b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/DissensionInTheRanks.java index a3f12cdc13..264313b291 100644 --- a/Mage.Sets/src/mage/sets/shadowsoverinnistrad/DissensionInTheRanks.java +++ b/Mage.Sets/src/mage/sets/shadowsoverinnistrad/DissensionInTheRanks.java @@ -56,8 +56,7 @@ public class DissensionInTheRanks extends CardImpl { // Target blocking creature fights another target blocking creature. this.getSpellAbility().addEffect(new FightTargetsEffect()); - this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); - this.getSpellAbility().addTarget(new DissensionInTheRanksTarget(filter)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(2, 2, filter, false)); } @@ -70,28 +69,3 @@ public class DissensionInTheRanks extends CardImpl { return new DissensionInTheRanks(this); } } - -class DissensionInTheRanksTarget extends TargetCreaturePermanent { - - public DissensionInTheRanksTarget(FilterCreaturePermanent filter) { - super(1, 1, filter, false); - } - - public DissensionInTheRanksTarget(final DissensionInTheRanksTarget 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 DissensionInTheRanksTarget copy() { - return new DissensionInTheRanksTarget(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/tempest/Legerdemain.java b/Mage.Sets/src/mage/sets/tempest/Legerdemain.java index 3e84ff97f2..fbbcf371c4 100644 --- a/Mage.Sets/src/mage/sets/tempest/Legerdemain.java +++ b/Mage.Sets/src/mage/sets/tempest/Legerdemain.java @@ -28,6 +28,7 @@ package mage.sets.tempest; import java.util.UUID; +import mage.MageItem; import mage.abilities.Ability; import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect; import mage.cards.CardImpl; @@ -35,10 +36,14 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; import mage.filter.FilterPermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.AnotherTargetPredicate; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; import mage.target.TargetPermanent; /** @@ -47,9 +52,12 @@ import mage.target.TargetPermanent; */ public class Legerdemain extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent("artifact or creature"); + private static final FilterPermanent firstFilter = new FilterPermanent("artifact or creature"); + private static final FilterPermanent secondFilter = new FilterPermanent("another permanent that shares the type of artifact or creature"); static { - filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE))); + firstFilter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT), new CardTypePredicate(CardType.CREATURE))); + secondFilter.add(new AnotherTargetPredicate(2)); + secondFilter.add(new SharesTypePredicate()); } public Legerdemain(UUID ownerId) { @@ -58,8 +66,12 @@ public class Legerdemain extends CardImpl { // Exchange control of target artifact or creature and another target permanent that shares one of those types with it. this.getSpellAbility().addEffect(new ExchangeControlTargetEffect(Duration.EndOfGame, "Exchange control of target artifact or creature and another target permanent that shares one of those types with it", false, true)); - this.getSpellAbility().addTarget(new TargetPermanent(filter)); - this.getSpellAbility().addTarget(new LegerdemainSecondTarget()); + TargetPermanent firstTarget = new TargetPermanent(firstFilter); + firstTarget.setTargetTag(1); + TargetPermanent secondTarget = new TargetPermanent(secondFilter); + secondTarget.setTargetTag(2); + this.getSpellAbility().addTarget(firstTarget); + this.getSpellAbility().addTarget(secondTarget); } public Legerdemain(final Legerdemain card) { @@ -72,34 +84,35 @@ public class Legerdemain extends CardImpl { } } -class LegerdemainSecondTarget extends TargetPermanent { - - LegerdemainSecondTarget() { - super(); - this.targetName = "another permanent that shares one of those types"; - } - - LegerdemainSecondTarget(final LegerdemainSecondTarget target) { - super(target); - } +class SharesTypePredicate implements ObjectSourcePlayerPredicate> { @Override - public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { - Permanent firstPermanent = game.getPermanent(source.getTargets().getFirstTarget()); - Permanent secondPermanent = game.getPermanent(id); - if (firstPermanent != null && secondPermanent != null) { - if (firstPermanent.getCardType().contains(CardType.CREATURE) && secondPermanent.getCardType().contains(CardType.CREATURE)) { + public boolean apply(ObjectSourcePlayer input, Game game) { + StackObject source = game.getStack().getStackObject(input.getSourceId()); + if (source != null) { + if (source.getStackAbility().getTargets().isEmpty() + || source.getStackAbility().getTargets().get(0).getTargets().isEmpty()) { return true; } - if (firstPermanent.getCardType().contains(CardType.ARTIFACT) && secondPermanent.getCardType().contains(CardType.ARTIFACT)) { - return true; + Permanent firstPermanent = game.getPermanent( + source.getStackAbility().getTargets().get(0).getTargets().get(0)); + Permanent secondPermanent = game.getPermanent(input.getObject().getId()); + if (firstPermanent != null && secondPermanent != null) { + if (firstPermanent.getCardType().contains(CardType.CREATURE) && secondPermanent.getCardType().contains(CardType.CREATURE)) { + return true; + } + if (firstPermanent.getCardType().contains(CardType.ARTIFACT) && secondPermanent.getCardType().contains(CardType.ARTIFACT)) { + return true; + } } + return false; } - return false; + return true; } @Override - public LegerdemainSecondTarget copy() { - return new LegerdemainSecondTarget(this); + public String toString() { + return "Target permanent that shares the type of artifact or creature"; } -} + +} \ No newline at end of file