From 7c2f76b46bafc0ad5d0503947b09184de52aaebf Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Mon, 12 Sep 2022 08:54:45 -0400 Subject: [PATCH] Remove custom multitarget handling from ReturnToHandTargetEffect (use EachTargetPointer instead) --- Mage.Sets/src/mage/cards/a/AetherHelix.java | 6 ++- Mage.Sets/src/mage/cards/a/AetherTide.java | 23 +++----- .../src/mage/cards/a/AetherTradewinds.java | 6 +-- .../src/mage/cards/c/CaptivatingGyre.java | 2 +- Mage.Sets/src/mage/cards/c/ChurningEddy.java | 7 +-- .../src/mage/cards/c/ClutchOfCurrents.java | 2 +- Mage.Sets/src/mage/cards/c/CropSigil.java | 36 ++++++------- Mage.Sets/src/mage/cards/e/EnigmaThief.java | 4 +- Mage.Sets/src/mage/cards/j/JediSentinel.java | 4 +- .../mage/cards/m/MuYanlingCelestialWind.java | 2 +- .../src/mage/cards/p/PeelFromReality.java | 4 +- Mage.Sets/src/mage/cards/r/Recantation.java | 2 +- .../src/mage/cards/r/ReconstructHistory.java | 9 ++-- .../mage/cards/r/RestorationSpecialist.java | 19 +++---- Mage.Sets/src/mage/cards/r/RiteOfUndoing.java | 4 +- .../src/mage/cards/r/RunAwayTogether.java | 4 +- .../src/mage/cards/s/SelectiveSnare.java | 2 +- ...ReturnFromGraveyardToHandTargetEffect.java | 21 +------- .../common/ReturnToHandTargetEffect.java | 52 ++----------------- 19 files changed, 63 insertions(+), 146 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AetherHelix.java b/Mage.Sets/src/mage/cards/a/AetherHelix.java index df27bab0ac..50251ffb0d 100644 --- a/Mage.Sets/src/mage/cards/a/AetherHelix.java +++ b/Mage.Sets/src/mage/cards/a/AetherHelix.java @@ -1,5 +1,6 @@ package mage.cards.a; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -7,6 +8,7 @@ import mage.constants.CardType; import mage.filter.StaticFilters; import mage.target.TargetPermanent; import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.SecondTargetPointer; import java.util.UUID; @@ -19,8 +21,8 @@ public final class AetherHelix extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{U}"); // Return target permanent to its owner's hand. Return target permanent card from your graveyard to your hand. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true).setText("return target " + - "permanent to its owner's hand. Return target permanent card from your graveyard to your hand")); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); + this.getSpellAbility().addEffect(new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new SecondTargetPointer())); this.getSpellAbility().addTarget(new TargetPermanent()); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_PERMANENT)); } diff --git a/Mage.Sets/src/mage/cards/a/AetherTide.java b/Mage.Sets/src/mage/cards/a/AetherTide.java index 3ada4c22e5..b8a9bba528 100644 --- a/Mage.Sets/src/mage/cards/a/AetherTide.java +++ b/Mage.Sets/src/mage/cards/a/AetherTide.java @@ -12,12 +12,11 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Zone; -import mage.filter.common.FilterCreatureCard; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.StaticFilters; import mage.game.Game; import mage.target.common.TargetCardInHand; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetadjustment.TargetAdjuster; +import mage.target.targetadjustment.XTargetsAdjuster; /** * @@ -34,10 +33,11 @@ public final class AetherTide extends CardImpl { this.addAbility(ability); // Return X target creatures to their owners' hands. - Effect effect = new ReturnToHandTargetEffect(true); + Effect effect = new ReturnToHandTargetEffect(); effect.setText("Return X target creatures to their owners' hands"); this.getSpellAbility().addEffect(effect); - this.getSpellAbility().setTargetAdjuster(AetherTideTargetAdjuster.instance); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().setTargetAdjuster(XTargetsAdjuster.instance); this.getSpellAbility().setCostAdjuster(AetherTideCostAdjuster.instance); } @@ -52,17 +52,6 @@ public final class AetherTide extends CardImpl { } } -enum AetherTideTargetAdjuster implements TargetAdjuster { - instance; - - @Override - public void adjustTargets(Ability ability, Game game) { - ability.getTargets().clear(); - int xValue = ability.getManaCostsToPay().getX(); - ability.addTarget(new TargetCreaturePermanent(xValue, xValue, new FilterCreaturePermanent(), false)); - } -} - enum AetherTideCostAdjuster implements CostAdjuster { instance; @@ -70,7 +59,7 @@ enum AetherTideCostAdjuster implements CostAdjuster { public void adjustCosts(Ability ability, Game game) { int xValue = ability.getManaCostsToPay().getX(); if (xValue > 0) { - ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, new FilterCreatureCard("creature cards")))); + ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CREATURES))); } } } diff --git a/Mage.Sets/src/mage/cards/a/AetherTradewinds.java b/Mage.Sets/src/mage/cards/a/AetherTradewinds.java index cb9da8289c..88f8aae70b 100644 --- a/Mage.Sets/src/mage/cards/a/AetherTradewinds.java +++ b/Mage.Sets/src/mage/cards/a/AetherTradewinds.java @@ -1,4 +1,3 @@ - package mage.cards.a; import java.util.UUID; @@ -11,6 +10,7 @@ import mage.constants.TargetController; import mage.filter.FilterPermanent; import mage.target.TargetPermanent; import mage.target.common.TargetControlledPermanent; +import mage.target.targetpointer.EachTargetPointer; /** * @@ -30,9 +30,7 @@ public final class AetherTradewinds extends CardImpl { // Return target permanent you control and target permanent you don't control to their owners' hands. this.getSpellAbility().addTarget(new TargetControlledPermanent()); this.getSpellAbility().addTarget(new TargetPermanent(filter)); - Effect effect = new ReturnToHandTargetEffect(true); - effect.setText("Return target permanent you control and target permanent you don't control to their owners' hands"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer())); } private AetherTradewinds(final AetherTradewinds card) { diff --git a/Mage.Sets/src/mage/cards/c/CaptivatingGyre.java b/Mage.Sets/src/mage/cards/c/CaptivatingGyre.java index aefe77a180..2b89bdbd65 100644 --- a/Mage.Sets/src/mage/cards/c/CaptivatingGyre.java +++ b/Mage.Sets/src/mage/cards/c/CaptivatingGyre.java @@ -17,7 +17,7 @@ public final class CaptivatingGyre extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); // Return up to three target creatures to their owners' hands. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true)); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 3)); } diff --git a/Mage.Sets/src/mage/cards/c/ChurningEddy.java b/Mage.Sets/src/mage/cards/c/ChurningEddy.java index f8e2cf6105..d402ae6938 100644 --- a/Mage.Sets/src/mage/cards/c/ChurningEddy.java +++ b/Mage.Sets/src/mage/cards/c/ChurningEddy.java @@ -1,14 +1,13 @@ - package mage.cards.c; import java.util.UUID; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetLandPermanent; +import mage.target.targetpointer.EachTargetPointer; /** * @@ -20,9 +19,7 @@ public final class ChurningEddy extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}"); // Return target creature and target land to their owners' hands. - Effect effect = new ReturnToHandTargetEffect(true); - effect.setText("Return target creature and target land to their owners' hands"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer())); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetLandPermanent()); } diff --git a/Mage.Sets/src/mage/cards/c/ClutchOfCurrents.java b/Mage.Sets/src/mage/cards/c/ClutchOfCurrents.java index d35f4e56ca..6eed5aebc3 100644 --- a/Mage.Sets/src/mage/cards/c/ClutchOfCurrents.java +++ b/Mage.Sets/src/mage/cards/c/ClutchOfCurrents.java @@ -19,7 +19,7 @@ public final class ClutchOfCurrents extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}"); // Return target creature to its owner's hand. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(false)); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); // Awaken 3—{4}{U} diff --git a/Mage.Sets/src/mage/cards/c/CropSigil.java b/Mage.Sets/src/mage/cards/c/CropSigil.java index 1efa3cb98b..0c1305ceb9 100644 --- a/Mage.Sets/src/mage/cards/c/CropSigil.java +++ b/Mage.Sets/src/mage/cards/c/CropSigil.java @@ -3,50 +3,46 @@ package mage.cards.c; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.OnEventTriggeredAbility; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.condition.common.DeliriumCondition; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.decorator.ConditionalActivatedAbility; import mage.abilities.effects.common.MillCardsControllerEffect; -import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.abilities.hint.common.CardTypesInGraveyardHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.AbilityWord; import mage.constants.CardType; +import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.events.GameEvent; +import mage.filter.StaticFilters; import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.EachTargetPointer; /** * @author fireshoes */ public final class CropSigil extends CardImpl { - private static final FilterCard filterCreature = new FilterCard("creature card in a graveyard"); - private static final FilterCard filterLand = new FilterCard("land card in a graveyard"); - - static { - filterCreature.add(CardType.CREATURE.getPredicate()); - filterLand.add(CardType.LAND.getPredicate()); - } - public CropSigil(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); - // At the beginning of your upkeep, you may put the top card of your library into your graveyard. - this.addAbility(new OnEventTriggeredAbility(GameEvent.EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new MillCardsControllerEffect(1), true)); + // At the beginning of your upkeep, you may mill a card. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new MillCardsControllerEffect(1), TargetController.YOU, true)); // Delirium — {2}{G}, Sacrifice Crop Sigil: Return up to one target creature card and up to one target land card from your graveyard to your hand. // Activate this ability only if there are four or more card types among cards in your graveyard. - Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(true), new ManaCostsImpl<>("{2}{G}"), - DeliriumCondition.instance, - "Delirium — {2}{G}, Sacrifice {this}: Return up to one target creature card and up to one target land card from your graveyard to your hand. " - + "Activate only if there are four or more card types among cards in your graveyard."); + Ability ability = new ConditionalActivatedAbility( + Zone.BATTLEFIELD, + new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new EachTargetPointer()), + new ManaCostsImpl<>("{2}{G}"), + DeliriumCondition.instance); ability.addCost(new SacrificeSourceCost()); - ability.addTarget(new TargetCardInYourGraveyard(0, 1, filterCreature)); - ability.addTarget(new TargetCardInYourGraveyard(0, 1, filterLand)); + ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE)); + ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_LAND)); + ability.setAbilityWord(AbilityWord.DELIRIUM); ability.addHint(CardTypesInGraveyardHint.YOU); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/e/EnigmaThief.java b/Mage.Sets/src/mage/cards/e/EnigmaThief.java index b6b8b421c0..dfa58772a5 100644 --- a/Mage.Sets/src/mage/cards/e/EnigmaThief.java +++ b/Mage.Sets/src/mage/cards/e/EnigmaThief.java @@ -17,6 +17,7 @@ import mage.game.Game; import mage.players.Player; import mage.target.TargetPermanent; import mage.target.targetadjustment.TargetAdjuster; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; @@ -40,7 +41,8 @@ public final class EnigmaThief extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // When Enigma Thief enters the battlefield, for each opponent, return up to one target nonland permanent that player controls to its owner's hand. - Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(true) + Ability ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect() + .setTargetPointer(new EachTargetPointer()) .setText("for each opponent, return up to one target nonland permanent that player controls to its owner's hand")); ability.setTargetAdjuster(EnigmaThiefAdjuster.instance); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/j/JediSentinel.java b/Mage.Sets/src/mage/cards/j/JediSentinel.java index dbaf877bb7..ff0ee3b6ef 100644 --- a/Mage.Sets/src/mage/cards/j/JediSentinel.java +++ b/Mage.Sets/src/mage/cards/j/JediSentinel.java @@ -15,6 +15,7 @@ import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; @@ -40,8 +41,7 @@ public final class JediSentinel extends CardImpl { this.addAbility(FlashAbility.getInstance()); // When Jedi Sentinel enters the battlefield, return another target creature you control and target creature you don't control to their owners' hands. - Effect effect = new ReturnToHandTargetEffect(true); - effect.setText("return another target creature you control and target creature you don't control to their owners' hands"); + Effect effect = new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer()); Ability ability = new EntersBattlefieldTriggeredAbility(effect); ability.addTarget(new TargetControlledCreaturePermanent(filter1)); ability.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); diff --git a/Mage.Sets/src/mage/cards/m/MuYanlingCelestialWind.java b/Mage.Sets/src/mage/cards/m/MuYanlingCelestialWind.java index 1b9abc9ce0..b64efcc43b 100644 --- a/Mage.Sets/src/mage/cards/m/MuYanlingCelestialWind.java +++ b/Mage.Sets/src/mage/cards/m/MuYanlingCelestialWind.java @@ -42,7 +42,7 @@ public final class MuYanlingCelestialWind extends CardImpl { this.addAbility(ability); // −3: Return up to two target creatures to their owners' hands. - ability = new LoyaltyAbility(new ReturnToHandTargetEffect(true), -3); + ability = new LoyaltyAbility(new ReturnToHandTargetEffect(), -3); ability.addTarget(new TargetCreaturePermanent(0, 2)); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/p/PeelFromReality.java b/Mage.Sets/src/mage/cards/p/PeelFromReality.java index e9c75a5eaf..7d66b23ba7 100644 --- a/Mage.Sets/src/mage/cards/p/PeelFromReality.java +++ b/Mage.Sets/src/mage/cards/p/PeelFromReality.java @@ -7,6 +7,7 @@ import mage.constants.CardType; import mage.filter.StaticFilters; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; @@ -19,8 +20,7 @@ public final class PeelFromReality extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); // Return target creature you control and target creature you don't control to their owners' hands. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true) - .setText("return target creature you control and target creature you don't control to their owners' hands")); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer())); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); } diff --git a/Mage.Sets/src/mage/cards/r/Recantation.java b/Mage.Sets/src/mage/cards/r/Recantation.java index 54bc02834e..dfd61ffeb6 100644 --- a/Mage.Sets/src/mage/cards/r/Recantation.java +++ b/Mage.Sets/src/mage/cards/r/Recantation.java @@ -33,7 +33,7 @@ public final class Recantation extends CardImpl { new AddCountersSourceEffect(CounterType.VERSE.createInstance(), true), TargetController.YOU, true)); // {U}, Sacrifice Recantation: Return up to X target permanents to their owners' hands, where X is the number of verse counters on Recantation. - Effect effect = new ReturnToHandTargetEffect(true); + Effect effect = new ReturnToHandTargetEffect(); effect.setText("Return up to X target permanents to their owners' hands, where X is the number of verse counters on {this}."); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{U}")); ability.addCost(new SacrificeSourceCost()); diff --git a/Mage.Sets/src/mage/cards/r/ReconstructHistory.java b/Mage.Sets/src/mage/cards/r/ReconstructHistory.java index 235df4416b..287b245ea6 100644 --- a/Mage.Sets/src/mage/cards/r/ReconstructHistory.java +++ b/Mage.Sets/src/mage/cards/r/ReconstructHistory.java @@ -1,7 +1,7 @@ package mage.cards.r; import mage.abilities.effects.common.ExileSpellEffect; -import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -10,6 +10,7 @@ import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterEnchantmentCard; import mage.filter.common.FilterPlaneswalkerCard; import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; @@ -23,10 +24,6 @@ public final class ReconstructHistory extends CardImpl { private static final FilterCard filterInstant = new FilterCard("instant card"); private static final FilterCard filterSorcery = new FilterCard("sorcery card"); private static final FilterCard filterPlaneswalker = new FilterPlaneswalkerCard(); - private static final String rule = "return up to one target artifact card, " + - "up to one target enchantment card, up to one target instant card, " + - "up to one target sorcery card, and up to one target planeswalker " + - "card from your graveyard to your hand"; static { filterInstant.add(CardType.INSTANT.getPredicate()); @@ -37,7 +34,7 @@ public final class ReconstructHistory extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}{W}"); // Return up to one target artifact card, up to one target enchantment card, up to one target instant card, up to one target sorcery card, and up to one target planeswalker card from your graveyard to your hand. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true).setText(rule)); + this.getSpellAbility().addEffect(new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new EachTargetPointer())); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard( 0, 1, filterArtifact )); diff --git a/Mage.Sets/src/mage/cards/r/RestorationSpecialist.java b/Mage.Sets/src/mage/cards/r/RestorationSpecialist.java index f2acabba2a..e2667d8177 100644 --- a/Mage.Sets/src/mage/cards/r/RestorationSpecialist.java +++ b/Mage.Sets/src/mage/cards/r/RestorationSpecialist.java @@ -1,4 +1,3 @@ - package mage.cards.r; import mage.MageInt; @@ -7,20 +6,20 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Zone; import mage.filter.StaticFilters; import mage.filter.common.FilterEnchantmentCard; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; /** - * @author Styxo + * @author awjackson */ public final class RestorationSpecialist extends CardImpl { @@ -33,14 +32,12 @@ public final class RestorationSpecialist extends CardImpl { this.toughness = new MageInt(1); // {W}, Sacrifice Restoration Specialist: Return up to one target artifact card and up to one target enchantment card from your graveyard to your hand. - Effect effect = new ReturnToHandTargetEffect(true); - effect.setText("Return up to one target artifact card and up to one target enchantment card from your graveyard to your hand"); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{W}")); - ability.addTarget(new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT_FROM_YOUR_GRAVEYARD)); - ability.addTarget(new TargetCardInGraveyard(0, 1, new FilterEnchantmentCard("enchantment card from your graveyard"))); + Effect effect = new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new EachTargetPointer()); + Ability ability = new SimpleActivatedAbility(effect, new ManaCostsImpl<>("{W}")); + ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT)); + ability.addTarget(new TargetCardInYourGraveyard(0, 1, new FilterEnchantmentCard())); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); - } private RestorationSpecialist(final RestorationSpecialist card) { diff --git a/Mage.Sets/src/mage/cards/r/RiteOfUndoing.java b/Mage.Sets/src/mage/cards/r/RiteOfUndoing.java index afdc5c0fc3..809df0f9c2 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfUndoing.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfUndoing.java @@ -8,6 +8,7 @@ import mage.constants.CardType; import mage.constants.TargetController; import mage.filter.common.FilterNonlandPermanent; import mage.target.common.TargetNonlandPermanent; +import mage.target.targetpointer.EachTargetPointer; import java.util.UUID; @@ -31,8 +32,7 @@ public final class RiteOfUndoing extends CardImpl { this.addAbility(new DelveAbility()); // Return target nonland permanent you control and target nonland permanent you don't control to their owners' hands. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true) - .setText("return target nonland permanent you control and target nonland permanent you don't control to their owners' hands")); + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer())); this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterControlled)); this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterNotControlled)); } diff --git a/Mage.Sets/src/mage/cards/r/RunAwayTogether.java b/Mage.Sets/src/mage/cards/r/RunAwayTogether.java index 03a7ecd3b3..1c5857d2be 100644 --- a/Mage.Sets/src/mage/cards/r/RunAwayTogether.java +++ b/Mage.Sets/src/mage/cards/r/RunAwayTogether.java @@ -22,7 +22,7 @@ public final class RunAwayTogether extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); // Choose two target creatures controlled by different players. Return those creatures to their owners' hands. - this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true) + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect() .setText("Choose two target creatures controlled by different players. " + "Return those creatures to their owners' hands.") ); @@ -75,4 +75,4 @@ class RunAwayTogetherTarget extends TargetCreaturePermanent { ); } } -// give carly rae jepsen a sword \ No newline at end of file +// give carly rae jepsen a sword diff --git a/Mage.Sets/src/mage/cards/s/SelectiveSnare.java b/Mage.Sets/src/mage/cards/s/SelectiveSnare.java index 3521354510..512f7b411f 100644 --- a/Mage.Sets/src/mage/cards/s/SelectiveSnare.java +++ b/Mage.Sets/src/mage/cards/s/SelectiveSnare.java @@ -28,7 +28,7 @@ public final class SelectiveSnare extends CardImpl { // Return X target creatures of the creature type of your choice to their owner's hand. this.getSpellAbility().addEffect( - new ReturnToHandTargetEffect(true) + new ReturnToHandTargetEffect() .setText("Return X target creatures of " + "the creature type of your choice " + "to their owner's hand") diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java index 5a50db9c3f..15bc051767 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnFromGraveyardToHandTargetEffect.java @@ -46,24 +46,7 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - StringBuilder sb = new StringBuilder(); - Target target = mode.getTargets().get(0); - sb.append("return "); - if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) { - sb.append("up to "); - sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' '); - } else if (target.getMaxNumberOfTargets() > 1) { - sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(' '); - } - if (!target.getTargetName().startsWith("another")) { - sb.append("target "); - } - sb.append(target.getTargetName()); - if (!target.getTargetName().endsWith("graveyard")) { - sb.append(" from your graveyard"); - } - sb.append(" to your hand"); - return sb.toString(); + String targetDescription = getTargetPointer().describeTargets(mode.getTargets(), ""); + return "return " + targetDescription + (targetDescription.contains("graveyard") ? " to your hand" : " from your graveyard to your hand"); } - } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java index 355a735150..213b3a6af2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandTargetEffect.java @@ -20,20 +20,12 @@ import java.util.*; */ public class ReturnToHandTargetEffect extends OneShotEffect { - protected boolean multitargetHandling; - public ReturnToHandTargetEffect() { - this(false); - } - - public ReturnToHandTargetEffect(boolean multitargetHandling) { super(Outcome.ReturnToHand); - this.multitargetHandling = multitargetHandling; } public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) { super(effect); - this.multitargetHandling = effect.multitargetHandling; } @Override @@ -49,18 +41,6 @@ public class ReturnToHandTargetEffect extends OneShotEffect { } List copyIds = new ArrayList<>(); Set cards = new LinkedHashSet<>(); - if (multitargetHandling) { - for (Target target : source.getTargets()) { - for (UUID targetId : target.getTargets()) { - MageObject mageObject = game.getObject(targetId); - if (mageObject instanceof Spell && mageObject.isCopy()) { - copyIds.add(targetId); - } else if (mageObject instanceof Card) { - cards.add((Card) mageObject); - } - } - } - } else { for (UUID targetId : targetPointer.getTargets(game, source)) { MageObject mageObject = game.getObject(targetId); if (mageObject != null) { @@ -72,7 +52,6 @@ public class ReturnToHandTargetEffect extends OneShotEffect { } } } - } for (UUID copyId : copyIds) { game.getStack().remove(game.getSpell(copyId), game); } @@ -80,35 +59,12 @@ public class ReturnToHandTargetEffect extends OneShotEffect { } @Override - public String getText(Mode mode - ) { + public String getText(Mode mode) + { if (staticText != null && !staticText.isEmpty()) { return staticText; } - if (mode.getTargets().size() < 1) { - return ""; - } - Target target = mode.getTargets().get(0); - StringBuilder sb = new StringBuilder("return "); - if (target.getMinNumberOfTargets() == 0 && target.getMaxNumberOfTargets() >= 1) { - sb.append("up to "); - sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" "); - } else if (!(target.getMinNumberOfTargets() == 1 || target.getMaxNumberOfTargets() == 1)) { - sb.append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" "); - } - if (!target.getTargetName().contains("target")) { - sb.append("target "); - } - sb.append(target.getTargetName()); - if (target.getMaxNumberOfTargets() > 1 && !target.getTargetName().endsWith("s") && !target.getTargetName().endsWith("control")) { - sb.append('s'); - } - if (target.getMaxNumberOfTargets() > 1) { - sb.append(" to their owners' hands"); - } else { - sb.append(" to its owner's hand"); - } - return sb.toString(); + return "return " + getTargetPointer().describeTargets(mode.getTargets(), "") + + (getTargetPointer().isPlural(mode.getTargets()) ? " to their owners' hands" : " to its owner's hand"); } - }