Menu

Submission for Inner Sanctum

134

Config

name=Inner Sanctum
image=http://mtgimage.com/card/inner%20sanctum.jpg
value=2.500
rarity=R
type=Enchantment
cost={1}{W}{W}
timing=enchantment
requires_groovy_code
oracle=Cumulative upkeep—Pay 2 life. Prevent all damage that would be dealt to creatures you control.

Script

[
    new MagicAtYourUpkeepTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
            game.doAction(new MagicChangeCountersAction(
                permanent,
                MagicCounterType.Age,
                1
            ));
            return new MagicEvent(
                permanent,
                new MagicMayChoice("Pay cumulative upkeep?"),
                this,
                "PN may\$ lose 2 life for each Age counter on SN. " +
                " If he or she doesn't, sacrifice SN."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            if (event.isYes()) {
                game.doAction(new MagicChangeLifeAction(event.getPlayer(),-2 * event.getPermanent().getCounters(MagicCounterType.Age)));
            } else {
                game.doAction(new MagicSacrificeAction(event.getPermanent()));
            }
        }
    },
    new MagicIfDamageWouldBeDealtTrigger(MagicTrigger.PREVENT_DAMAGE) {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicDamage damage) {
            if (damage.isTargetCreature()) {
                final MagicPermanent creature = damage.getTargetPermanent();
                if (creature.isFriend(permanent)) {
                    // Prevention effect.
                    damage.prevent();
                }
            }
            return MagicEvent.NONE;
        }
    }
]
Pushed