Menu

Submission for Thought Lash

70

Config

name=Thought Lash
image=http://mtgimage.com/card/thought%20lash.jpg
value=2.500
rarity=R
type=Enchantment
cost={2}{U}{U}
ability=Exile the top card of your library: Prevent the next 1 damage that would be dealt to you this turn.
timing=enchantment
requires_groovy_code
oracle=Cumulative upkeep—Exile the top card of your library. When a player doesn't pay Thought Lash's cumulative upkeep, that player exiles all cards from his or her library. Exile the top card of your library: Prevent the next 1 damage that would be dealt to you this turn.

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\$ exile one card from the top of his or her library for each Age counter on SN. " +
                " If he or she doesn't, sacrifice SN and exile all cards from PN's library."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            if (event.isYes()) {  
                final MagicCardList topN = event.getPlayer().getLibrary().getCardsFromTop(event.getPermanent().getCounters(MagicCounterType.Age));
            for (final MagicCard card : topN) {
                game.doAction(new MagicRemoveCardAction(
                    card,
                    MagicLocationType.OwnersLibrary
                ));
                game.doAction(new MagicMoveCardAction(
                    card,
                    MagicLocationType.OwnersLibrary,
                    MagicLocationType.Exile
                ));
            }
        } else {
            game.doAction(new MagicSacrificeAction(event.getPermanent()));
            for (final MagicCard card : new MagicCardList(event.getPlayer().getLibrary())) {
                game.doAction(new MagicRemoveCardAction(card, MagicLocationType.OwnersLibrary));
                game.doAction(new MagicMoveCardAction(card, MagicLocationType.OwnersLibrary, MagicLocationType.Exile));
                }
            }
        }
    }
]
Pushed