From fe83f6ac25e375a56f6a51d37e7f5d5455f3f3a6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 15 Apr 2019 19:14:09 -0400 Subject: [PATCH] Implemented The Elderspell --- Mage.Sets/src/mage/cards/t/TheElderspell.java | 87 +++++++++++++++++++ Mage.Sets/src/mage/sets/WarOfTheSpark.java | 1 + .../main/java/mage/filter/StaticFilters.java | 6 ++ 3 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TheElderspell.java diff --git a/Mage.Sets/src/mage/cards/t/TheElderspell.java b/Mage.Sets/src/mage/cards/t/TheElderspell.java new file mode 100644 index 0000000000..0251cb9377 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheElderspell.java @@ -0,0 +1,87 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledPlaneswalkerPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TheElderspell extends CardImpl { + + public TheElderspell(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}{B}"); + + // Destroy any number of target planeswalkers. Choose a planeswalker you control. Put two loyalty counters on it for each planeswalker destroyed this way. + this.getSpellAbility().addEffect(new TheElderspellEffect()); + this.getSpellAbility().addTarget(new TargetPermanent( + 0, Integer.MAX_VALUE, StaticFilters.FILTER_PERMANENT_PLANESWALKERS, false + )); + } + + private TheElderspell(final TheElderspell card) { + super(card); + } + + @Override + public TheElderspell copy() { + return new TheElderspell(this); + } +} + +class TheElderspellEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledPlaneswalkerPermanent(); + + TheElderspellEffect() { + super(Outcome.Benefit); + staticText = "Destroy any number of target planeswalkers. Choose a planeswalker you control. " + + "Put two loyalty counters on it for each planeswalker destroyed this way."; + } + + private TheElderspellEffect(final TheElderspellEffect effect) { + super(effect); + } + + @Override + public TheElderspellEffect copy() { + return new TheElderspellEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int count = 0; + for (UUID permId : source.getTargets().get(0).getTargets()) { + Permanent permanent = game.getPermanent(permId); + if (permanent != null && permanent.destroy(source.getSourceId(), game, false)) { + count++; + } + } + TargetPermanent targetPermanent = new TargetPermanent(filter); + if (!player.choose(outcome, targetPermanent, source.getSourceId(), game)) { + return false; + } + Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget()); + if (permanent == null) { + return false; + } + return permanent.addCounters(CounterType.LOYALTY.createInstance(2 * count), source, game); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/WarOfTheSpark.java b/Mage.Sets/src/mage/sets/WarOfTheSpark.java index 58df373574..b909e594de 100644 --- a/Mage.Sets/src/mage/sets/WarOfTheSpark.java +++ b/Mage.Sets/src/mage/sets/WarOfTheSpark.java @@ -205,6 +205,7 @@ public final class WarOfTheSpark extends ExpansionSet { cards.add(new SetCardInfo("Teyo's Lightshield", 33, Rarity.COMMON, mage.cards.t.TeyosLightshield.class)); cards.add(new SetCardInfo("Teyo, the Shieldmage", 32, Rarity.UNCOMMON, mage.cards.t.TeyoTheShieldmage.class)); cards.add(new SetCardInfo("Tezzeret, Master of the Bridge", 275, Rarity.MYTHIC, mage.cards.t.TezzeretMasterOfTheBridge.class)); + cards.add(new SetCardInfo("The Elderspell", 89, Rarity.RARE, mage.cards.t.TheElderspell.class)); cards.add(new SetCardInfo("The Wanderer", 37, Rarity.UNCOMMON, mage.cards.t.TheWanderer.class)); cards.add(new SetCardInfo("Thundering Ceratok", 179, Rarity.COMMON, mage.cards.t.ThunderingCeratok.class)); cards.add(new SetCardInfo("Tibalt's Rager", 147, Rarity.UNCOMMON, mage.cards.t.TibaltsRager.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index f6439e2125..dba8893667 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -417,6 +417,12 @@ public final class StaticFilters { FILTER_PERMANENT_PLANESWALKER.setLockedFilter(true); } + public static final FilterPlaneswalkerPermanent FILTER_PERMANENT_PLANESWALKERS = new FilterPlaneswalkerPermanent("planeswalkers"); + + static { + FILTER_PERMANENT_PLANESWALKERS.setLockedFilter(true); + } + public static final FilterNonlandPermanent FILTER_PERMANENT_NON_LAND = new FilterNonlandPermanent(); static {