Menu

Scripts for Search for Azcanta

Config

CodeRay output
name=Search for Azcanta
image=https://magiccards.info/scans/en/xln/74a.jpg
value=2.500
rarity=R
type=Legendary,Enchantment
cost={1}{U}
transform=Azcanta, the Sunken Ruin
timing=enchantment
requires_groovy_code
oracle=At the beginning of your upkeep, look at the top card of your library. You may put it into your graveyard. Then if you have seven or more cards in your graveyard, you may transform Search for Azcanta.

Script

CodeRay output
def transformAction = {
    final MagicGame game, final MagicEvent event ->
    if (event.isYes()) {
        game.doAction(new TransformAction(event.getPermanent()));
    }
}

def putIntoGraveyardAction = {
    final MagicGame game, final MagicEvent event ->
    if (event.isYes()) {
        game.doAction(new ShiftCardAction(event.getRefCard(), MagicLocationType.OwnersLibrary, MagicLocationType.Graveyard));
    }
    if (event.getPlayer().getGraveyard().size() >= 7) {
        game.addEvent(new MagicEvent(
            event.getSource(),
            new MagicMayChoice("Transfrom ${event.getPermanent()}"),
            transformAction,
            "PN may\$ transform SN."
        ));
    }
}

[
    new AtUpkeepTrigger() {
        @Override
        public boolean accept(final MagicPermanent permanent, final MagicPlayer upkeepPlayer) {
            return permanent.isController(upkeepPlayer);
        }
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPlayer upkeepPlayer) {
            return new MagicEvent(
                permanent,
                this,
                "PN looks at the top card of PN's library."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            event.getPlayer().getLibrary().getCardsFromTop(1).each {
                game.doAction(new LookAction(it, event.getPlayer(), "top card of your library"));
                game.addEvent(new MagicEvent(
                    event.getSource(),
                    new MagicMayChoice("Put the card into your graveyard?"),
                    it,
                    putIntoGraveyardAction,
                    "PN may\$ put it into PN's graveyard."
                ));
            }
        }
    }
]