forked from External/mage
[WOE] Implement Break the Spell (#10836)
* [WOE] Implement Break the Spell * cleanup * lock static filter
This commit is contained in:
parent
0a1a098ad4
commit
5e9e199922
3 changed files with 82 additions and 0 deletions
74
Mage.Sets/src/mage/cards/b/BreakTheSpell.java
Normal file
74
Mage.Sets/src/mage/cards/b/BreakTheSpell.java
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue