Menu

Submission for Essence Filter

160

Config

name=Essence Filter
image=http://mtgimage.com/card/essence%20filter.jpg
value=2.500
rarity=C
type=Sorcery
cost={1}{G}{G}
timing=main
requires_groovy_code
oracle=Destroy all enchantments or all nonwhite enchantments.

Script

def NONWHITE_ENCHANTMENT=new MagicPermanentFilterImpl() {
    public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
        return !target.hasColor(MagicColor.White) && target.isEnchantment();
    } 
};

def EFFECT1 = MagicRuleEventAction.create("Destroy all enchantments.");

[
    new MagicSpellCardEvent() {
        @Override
        public MagicEvent getEvent(final MagicCardOnStack cardOnStack, final MagicPayedCost payedCost) {
            return new MagicEvent(
                cardOnStack,
                new MagicOrChoice(
                    MagicChoice.NONE,
                    MagicChoice.NONE
                ),
                this,
                "Choose one\$ - destroy all enchantments; " +
                "or destroy all nonwhite enchantments.\$" 
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            if (event.isMode(2)) {
            final Collection<MagicPermanent> targets = game.filterPermanents(NONWHITE_ENCHANTMENT);
                game.doAction(new MagicDestroyAction(targets));
            } else {
                event.executeModalEvent(game, EFFECT1, EFFECT1, EFFECT1);
            }
        }
    }
]
Pushed