From 18ba009667feb40fa226858f7197e253f11340a0 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 20 Sep 2018 20:43:12 -0400 Subject: [PATCH] Implemented Selective Snare --- .../src/mage/cards/s/SelectiveSnare.java | 70 +++++++++++++++++++ Mage.Sets/src/mage/sets/GuildsOfRavnica.java | 1 + 2 files changed, 71 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SelectiveSnare.java diff --git a/Mage.Sets/src/mage/cards/s/SelectiveSnare.java b/Mage.Sets/src/mage/cards/s/SelectiveSnare.java new file mode 100644 index 00000000000..61f62f5d605 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SelectiveSnare.java @@ -0,0 +1,70 @@ +package mage.cards.s; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceCreatureType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.targetadjustment.TargetAdjuster; + +/** + * + * @author TheElk801 + */ +public final class SelectiveSnare extends CardImpl { + + public SelectiveSnare(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{U}"); + + // Return X target creatures of the creature type of your choice to their owner's hand. + this.getSpellAbility().addEffect( + new ReturnToHandTargetEffect(true) + .setText("Return X target creatures of " + + "the creature type of your choice " + + "to their owner's hand") + ); + this.getSpellAbility().setTargetAdjuster(SelectiveSnareAdjuster.instance); + } + + public SelectiveSnare(final SelectiveSnare card) { + super(card); + } + + @Override + public SelectiveSnare copy() { + return new SelectiveSnare(this); + } +} + +enum SelectiveSnareAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + Player player = game.getPlayer(ability.getControllerId()); + if (player == null) { + return; + } + Choice choice = new ChoiceCreatureType(); + if (!player.choose(Outcome.Benefit, choice, game)) { + return; + } + SubType subType = SubType.byDescription(choice.getChoice()); + int xValue = ability.getManaCostsToPay().getX(); + FilterPermanent filter = new FilterCreaturePermanent(subType.toString() + " creatures"); + filter.add(new SubtypePredicate(subType)); + ability.getTargets().clear(); + ability.addTarget(new TargetPermanent(xValue, filter)); + } +} diff --git a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java index 62ce736e7ea..c110f841320 100644 --- a/Mage.Sets/src/mage/sets/GuildsOfRavnica.java +++ b/Mage.Sets/src/mage/sets/GuildsOfRavnica.java @@ -220,6 +220,7 @@ public final class GuildsOfRavnica extends ExpansionSet { cards.add(new SetCardInfo("Rubblebelt Boar", 114, Rarity.COMMON, mage.cards.r.RubblebeltBoar.class)); cards.add(new SetCardInfo("Runaway Steam-Kin", 115, Rarity.RARE, mage.cards.r.RunawaySteamKin.class)); cards.add(new SetCardInfo("Sacred Foundry", 254, Rarity.RARE, mage.cards.s.SacredFoundry.class)); + cards.add(new SetCardInfo("Selective Snare", 53, Rarity.UNCOMMON, mage.cards.s.SelectiveSnare.class)); cards.add(new SetCardInfo("Selesnya Guildgate", 255, Rarity.COMMON, mage.cards.s.SelesnyaGuildgate.class)); cards.add(new SetCardInfo("Selesnya Guildgate", 256, Rarity.COMMON, mage.cards.s.SelesnyaGuildgate.class)); cards.add(new SetCardInfo("Selesnya Locket", 240, Rarity.COMMON, mage.cards.s.SelesnyaLocket.class));