diff --git a/Mage.Sets/src/mage/cards/b/BreakTheSpell.java b/Mage.Sets/src/mage/cards/b/BreakTheSpell.java new file mode 100644 index 00000000000..e02f386bc92 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BreakTheSpell.java @@ -0,0 +1,74 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetEnchantmentPermanent; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class BreakTheSpell extends CardImpl { + + public BreakTheSpell(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}"); + + // Destroy target enchantment. If a permanent you controlled or a token was destroyed this way, draw a card. + this.getSpellAbility().addEffect(new BreakTheSpellEffect()); + this.getSpellAbility().addTarget(new TargetEnchantmentPermanent()); + } + + private BreakTheSpell(final BreakTheSpell card) { + super(card); + } + + @Override + public BreakTheSpell copy() { + return new BreakTheSpell(this); + } +} + +class BreakTheSpellEffect extends OneShotEffect { + + BreakTheSpellEffect() { + super(Outcome.DestroyPermanent); + staticText = "Destroy target enchantment. If a permanent you controlled or " + + "a token was destroyed this way, draw a card."; + } + + private BreakTheSpellEffect(final BreakTheSpellEffect effect) { + super(effect); + } + + @Override + public BreakTheSpellEffect copy() { + return new BreakTheSpellEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + boolean followupEffect = permanent.isControlledBy(source.getControllerId()) + || StaticFilters.FILTER_PERMANENT_TOKEN.match(permanent, game); + boolean destroyed = permanent.destroy(source, game, false); + game.getState().processAction(game); + + if (followupEffect && destroyed) { + new DrawCardSourceControllerEffect(1).apply(game, source); + } + + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraine.java b/Mage.Sets/src/mage/sets/WildsOfEldraine.java index 1dfa13d3f90..c1c713738cf 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraine.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraine.java @@ -22,6 +22,7 @@ public final class WildsOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Ash, Party Crasher", 201, Rarity.UNCOMMON, mage.cards.a.AshPartyCrasher.class)); cards.add(new SetCardInfo("Beanstalk Wurm", 161, Rarity.COMMON, mage.cards.b.BeanstalkWurm.class)); + cards.add(new SetCardInfo("Break the Spell", 5, Rarity.COMMON, mage.cards.b.BreakTheSpell.class)); cards.add(new SetCardInfo("Cruel Somnophage", 222, Rarity.RARE, mage.cards.c.CruelSomnophage.class)); cards.add(new SetCardInfo("Elvish Archivist", 168, Rarity.RARE, mage.cards.e.ElvishArchivist.class)); cards.add(new SetCardInfo("Evolving Wilds", 256, Rarity.COMMON, mage.cards.e.EvolvingWilds.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index 9ef0e4dde28..529edf54ae8 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -1011,6 +1011,13 @@ public final class StaticFilters { FILTER_SPELL_KICKED_A.setLockedFilter(true); } + public static final FilterPermanent FILTER_PERMANENT_TOKEN = new FilterPermanent("token"); + + static { + FILTER_PERMANENT_TOKEN.add(TokenPredicate.TRUE); + FILTER_PERMANENT_TOKEN.setLockedFilter(true); + } + public static final FilterCreaturePermanent FILTER_CREATURE_TOKEN = new FilterCreaturePermanent("creature token"); static {