Implemented Selective Snare

This commit is contained in:
Evan Kranzler 2018-09-20 20:43:12 -04:00
parent beb190a47b
commit 18ba009667
2 changed files with 71 additions and 0 deletions

View file

@ -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));
}
}

View file

@ -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));