Remove custom multitarget handling from ReturnToHandTargetEffect (use EachTargetPointer instead)

This commit is contained in:
Alex W. Jackson 2022-09-12 08:54:45 -04:00
parent dc33531792
commit 7c2f76b46b
19 changed files with 63 additions and 146 deletions

View file

@ -1,5 +1,6 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -7,6 +8,7 @@ import mage.constants.CardType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.SecondTargetPointer;
import java.util.UUID; import java.util.UUID;
@ -19,8 +21,8 @@ public final class AetherHelix extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{U}"); 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. // 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 " + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
"permanent to its owner's hand. Return target permanent card from your graveyard to your hand")); this.getSpellAbility().addEffect(new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new SecondTargetPointer()));
this.getSpellAbility().addTarget(new TargetPermanent()); this.getSpellAbility().addTarget(new TargetPermanent());
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_PERMANENT)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_PERMANENT));
} }

View file

@ -12,12 +12,11 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard; import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent; 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); this.addAbility(ability);
// Return X target creatures to their owners' hands. // 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"); effect.setText("Return X target creatures to their owners' hands");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
this.getSpellAbility().setTargetAdjuster(AetherTideTargetAdjuster.instance); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().setTargetAdjuster(XTargetsAdjuster.instance);
this.getSpellAbility().setCostAdjuster(AetherTideCostAdjuster.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 { enum AetherTideCostAdjuster implements CostAdjuster {
instance; instance;
@ -70,7 +59,7 @@ enum AetherTideCostAdjuster implements CostAdjuster {
public void adjustCosts(Ability ability, Game game) { public void adjustCosts(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX(); int xValue = ability.getManaCostsToPay().getX();
if (xValue > 0) { 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)));
} }
} }
} }

View file

@ -1,4 +1,3 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID; import java.util.UUID;
@ -11,6 +10,7 @@ import mage.constants.TargetController;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetControlledPermanent; 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. // 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 TargetControlledPermanent());
this.getSpellAbility().addTarget(new TargetPermanent(filter)); this.getSpellAbility().addTarget(new TargetPermanent(filter));
Effect effect = new ReturnToHandTargetEffect(true); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer()));
effect.setText("Return target permanent you control and target permanent you don't control to their owners' hands");
this.getSpellAbility().addEffect(effect);
} }
private AetherTradewinds(final AetherTradewinds card) { private AetherTradewinds(final AetherTradewinds card) {

View file

@ -17,7 +17,7 @@ public final class CaptivatingGyre extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}");
// Return up to three target creatures to their owners' hands. // 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)); this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 3));
} }

View file

@ -1,14 +1,13 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetLandPermanent; 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}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}");
// Return target creature and target land to their owners' hands. // Return target creature and target land to their owners' hands.
Effect effect = new ReturnToHandTargetEffect(true); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer()));
effect.setText("Return target creature and target land to their owners' hands");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addTarget(new TargetLandPermanent()); this.getSpellAbility().addTarget(new TargetLandPermanent());
} }

View file

@ -19,7 +19,7 @@ public final class ClutchOfCurrents extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{U}");
// Return target creature to its owner's hand. // Return target creature to its owner's hand.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(false)); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Awaken 3{4}{U} // Awaken 3{4}{U}

View file

@ -3,50 +3,46 @@ package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.DeliriumCondition; import mage.abilities.condition.common.DeliriumCondition;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalActivatedAbility; import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.common.MillCardsControllerEffect; 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.abilities.hint.common.CardTypesInGraveyardHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.StaticFilters;
import mage.game.events.GameEvent;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.EachTargetPointer;
/** /**
* @author fireshoes * @author fireshoes
*/ */
public final class CropSigil extends CardImpl { 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) { public CropSigil(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); 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. // At the beginning of your upkeep, you may mill a card.
this.addAbility(new OnEventTriggeredAbility(GameEvent.EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new MillCardsControllerEffect(1), true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new MillCardsControllerEffect(1), TargetController.YOU, true));
// <i>Delirium</i> &mdash; {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. // <i>Delirium</i> &mdash; {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. // 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}"), Ability ability = new ConditionalActivatedAbility(
DeliriumCondition.instance, Zone.BATTLEFIELD,
"<i>Delirium</i> &mdash; {2}{G}, Sacrifice {this}: Return up to one target creature card and up to one target land card from your graveyard to your hand. " new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new EachTargetPointer()),
+ "Activate only if there are four or more card types among cards in your graveyard."); new ManaCostsImpl<>("{2}{G}"),
DeliriumCondition.instance);
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetCardInYourGraveyard(0, 1, filterCreature)); ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE));
ability.addTarget(new TargetCardInYourGraveyard(0, 1, filterLand)); ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_LAND));
ability.setAbilityWord(AbilityWord.DELIRIUM);
ability.addHint(CardTypesInGraveyardHint.YOU); ability.addHint(CardTypesInGraveyardHint.YOU);
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -17,6 +17,7 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster; import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; import java.util.UUID;
@ -40,7 +41,8 @@ public final class EnigmaThief extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); 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. // 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")); .setText("for each opponent, return up to one target nonland permanent that player controls to its owner's hand"));
ability.setTargetAdjuster(EnigmaThiefAdjuster.instance); ability.setTargetAdjuster(EnigmaThiefAdjuster.instance);
this.addAbility(ability); this.addAbility(ability);

View file

@ -15,6 +15,7 @@ import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate; import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; import java.util.UUID;
@ -40,8 +41,7 @@ public final class JediSentinel extends CardImpl {
this.addAbility(FlashAbility.getInstance()); 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. // 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 effect = new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer());
effect.setText("return another target creature you control and target creature you don't control to their owners' hands");
Ability ability = new EntersBattlefieldTriggeredAbility(effect); Ability ability = new EntersBattlefieldTriggeredAbility(effect);
ability.addTarget(new TargetControlledCreaturePermanent(filter1)); ability.addTarget(new TargetControlledCreaturePermanent(filter1));
ability.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); ability.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));

View file

@ -42,7 +42,7 @@ public final class MuYanlingCelestialWind extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// 3: Return up to two target creatures to their owners' hands. // 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)); ability.addTarget(new TargetCreaturePermanent(0, 2));
this.addAbility(ability); this.addAbility(ability);

View file

@ -7,6 +7,7 @@ import mage.constants.CardType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; import java.util.UUID;
@ -19,8 +20,7 @@ public final class PeelFromReality extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); 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. // Return target creature you control and target creature you don't control to their owners' hands.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true) this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer()));
.setText("return target creature you control and target creature you don't control to their owners' hands"));
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));
} }

View file

@ -33,7 +33,7 @@ public final class Recantation extends CardImpl {
new AddCountersSourceEffect(CounterType.VERSE.createInstance(), true), TargetController.YOU, true)); 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. // {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}."); 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 ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{U}"));
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());

View file

@ -1,7 +1,7 @@
package mage.cards.r; package mage.cards.r;
import mage.abilities.effects.common.ExileSpellEffect; 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.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -10,6 +10,7 @@ import mage.filter.common.FilterArtifactCard;
import mage.filter.common.FilterEnchantmentCard; import mage.filter.common.FilterEnchantmentCard;
import mage.filter.common.FilterPlaneswalkerCard; import mage.filter.common.FilterPlaneswalkerCard;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; 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 filterInstant = new FilterCard("instant card");
private static final FilterCard filterSorcery = new FilterCard("sorcery card"); private static final FilterCard filterSorcery = new FilterCard("sorcery card");
private static final FilterCard filterPlaneswalker = new FilterPlaneswalkerCard(); 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 { static {
filterInstant.add(CardType.INSTANT.getPredicate()); 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}"); 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. // 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( this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(
0, 1, filterArtifact 0, 1, filterArtifact
)); ));

View file

@ -1,4 +1,3 @@
package mage.cards.r; package mage.cards.r;
import mage.MageInt; import mage.MageInt;
@ -7,20 +6,20 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.filter.common.FilterEnchantmentCard; import mage.filter.common.FilterEnchantmentCard;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; import java.util.UUID;
/** /**
* @author Styxo * @author awjackson
*/ */
public final class RestorationSpecialist extends CardImpl { public final class RestorationSpecialist extends CardImpl {
@ -33,14 +32,12 @@ public final class RestorationSpecialist extends CardImpl {
this.toughness = new MageInt(1); 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. // {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 effect = new ReturnFromGraveyardToHandTargetEffect().setTargetPointer(new EachTargetPointer());
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(effect, new ManaCostsImpl<>("{W}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{W}")); ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT));
ability.addTarget(new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT_FROM_YOUR_GRAVEYARD)); ability.addTarget(new TargetCardInYourGraveyard(0, 1, new FilterEnchantmentCard()));
ability.addTarget(new TargetCardInGraveyard(0, 1, new FilterEnchantmentCard("enchantment card from your graveyard")));
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
private RestorationSpecialist(final RestorationSpecialist card) { private RestorationSpecialist(final RestorationSpecialist card) {

View file

@ -8,6 +8,7 @@ import mage.constants.CardType;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.filter.common.FilterNonlandPermanent; import mage.filter.common.FilterNonlandPermanent;
import mage.target.common.TargetNonlandPermanent; import mage.target.common.TargetNonlandPermanent;
import mage.target.targetpointer.EachTargetPointer;
import java.util.UUID; import java.util.UUID;
@ -31,8 +32,7 @@ public final class RiteOfUndoing extends CardImpl {
this.addAbility(new DelveAbility()); this.addAbility(new DelveAbility());
// Return target nonland permanent you control and target nonland permanent you don't control to their owners' hands. // Return target nonland permanent you control and target nonland permanent you don't control to their owners' hands.
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect(true) this.getSpellAbility().addEffect(new ReturnToHandTargetEffect().setTargetPointer(new EachTargetPointer()));
.setText("return target nonland permanent you control and target nonland permanent you don't control to their owners' hands"));
this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterControlled)); this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterControlled));
this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterNotControlled)); this.getSpellAbility().addTarget(new TargetNonlandPermanent(filterNotControlled));
} }

View file

@ -22,7 +22,7 @@ public final class RunAwayTogether extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Choose two target creatures controlled by different players. Return those creatures to their owners' hands. // 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. " + .setText("Choose two target creatures controlled by different players. " +
"Return those creatures to their owners' hands.") "Return those creatures to their owners' hands.")
); );

View file

@ -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. // Return X target creatures of the creature type of your choice to their owner's hand.
this.getSpellAbility().addEffect( this.getSpellAbility().addEffect(
new ReturnToHandTargetEffect(true) new ReturnToHandTargetEffect()
.setText("Return X target creatures of " .setText("Return X target creatures of "
+ "the creature type of your choice " + "the creature type of your choice "
+ "to their owner's hand") + "to their owner's hand")

View file

@ -46,24 +46,7 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) { if (staticText != null && !staticText.isEmpty()) {
return staticText; return staticText;
} }
StringBuilder sb = new StringBuilder(); String targetDescription = getTargetPointer().describeTargets(mode.getTargets(), "");
Target target = mode.getTargets().get(0); return "return " + targetDescription + (targetDescription.contains("graveyard") ? " to your hand" : " from your graveyard to your hand");
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();
} }
} }

View file

@ -20,20 +20,12 @@ import java.util.*;
*/ */
public class ReturnToHandTargetEffect extends OneShotEffect { public class ReturnToHandTargetEffect extends OneShotEffect {
protected boolean multitargetHandling;
public ReturnToHandTargetEffect() { public ReturnToHandTargetEffect() {
this(false);
}
public ReturnToHandTargetEffect(boolean multitargetHandling) {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.multitargetHandling = multitargetHandling;
} }
public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) { public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) {
super(effect); super(effect);
this.multitargetHandling = effect.multitargetHandling;
} }
@Override @Override
@ -49,18 +41,6 @@ public class ReturnToHandTargetEffect extends OneShotEffect {
} }
List<UUID> copyIds = new ArrayList<>(); List<UUID> copyIds = new ArrayList<>();
Set<Card> cards = new LinkedHashSet<>(); Set<Card> 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)) { for (UUID targetId : targetPointer.getTargets(game, source)) {
MageObject mageObject = game.getObject(targetId); MageObject mageObject = game.getObject(targetId);
if (mageObject != null) { if (mageObject != null) {
@ -72,7 +52,6 @@ public class ReturnToHandTargetEffect extends OneShotEffect {
} }
} }
} }
}
for (UUID copyId : copyIds) { for (UUID copyId : copyIds) {
game.getStack().remove(game.getSpell(copyId), game); game.getStack().remove(game.getSpell(copyId), game);
} }
@ -80,35 +59,12 @@ public class ReturnToHandTargetEffect extends OneShotEffect {
} }
@Override @Override
public String getText(Mode mode public String getText(Mode mode)
) { {
if (staticText != null && !staticText.isEmpty()) { if (staticText != null && !staticText.isEmpty()) {
return staticText; return staticText;
} }
if (mode.getTargets().size() < 1) { return "return " + getTargetPointer().describeTargets(mode.getTargets(), "") +
return ""; (getTargetPointer().isPlural(mode.getTargets()) ? " to their owners' hands" : " to its owner's hand");
}
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();
} }
} }