Menu

Submission for Undergrowth

87

Config

name=Undergrowth
image=http://mtgimage.com/card/undergrowth.jpg
value=2.500
rarity=C
type=Instant
cost={G}
ability=Kicker {2}{R}
timing=block
requires_groovy_code
oracle=As an additional cost to cast Undergrowth, you may pay {2}{R}. Prevent all combat damage that would be dealt this turn. If its additional cost was paid, Undergrowth doesn't affect combat damage that would be dealt by red creatures.

Script

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

[
    new MagicSpellCardEvent() {
        @Override
        public MagicEvent getEvent(final MagicCardOnStack cardOnStack, final MagicPayedCost payedCost) {
            return new MagicEvent(
                cardOnStack,
                this,
                "Prevent all combat damage that would be dealt this turn. " +
                "If its additional cost was paid, SN doesn't affect combat damage that would be dealt by red creatures."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            if (event.isKicked()) {
            final Collection<MagicPermanent> targets = game.filterPermanents(NONRED_CREATURES);
            for (final MagicPermanent target : targets) {
                game.doAction(new MagicAddTurnTriggerAction(
                    MagicIfDamageWouldBeDealtTrigger.PreventCombatDamage
                ));
            }
        } else {
            game.doAction(new MagicAddTurnTriggerAction(MagicIfDamageWouldBeDealtTrigger.PreventCombatDamage));
            } 
        }
    }
]
Pushed