Menu

Submission for Rakdos the Defiler

129

Config

name=Rakdos the Defiler
image=http://mtgimage.com/card/rakdos%20the%20defiler.jpg
value=2.500
rarity=R
type=Legendary,Creature
subtype=Demon
cost={2}{B}{B}{R}{R}
pt=7/6
ability=Flying; trample
timing=main
requires_groovy_code
oracle=Flying, trample. Whenever Rakdos the Defiler attacks, sacrifice half the non-Demon permanents you control, rounded up. Whenever Rakdos deals combat damage to a player, that player sacrifices half the non-Demon permanents he or she controls, rounded up.

Script

def NON_DEMON_PERMANENT_YOU_CONTROL = new MagicPermanentFilterImpl() {
    public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
        return target.isController(player) && !target.hasSubType(MagicSubType.Demon)
    } 
};

def A_NON_DEMON_PERMANENT_YOU_CONTROL = new MagicTargetChoice(
    NON_DEMON_PERMANENT_YOU_CONTROL,
    "a non-Demon permanent to sacrifice"
);

[
    new MagicWhenSelfAttacksTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPermanent creature) {
            return new MagicEvent(
                permanent,
                this,
                "PN sacrifices half the non-Demon permanents he or she controls, rounded up."
            );
        }

        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            game.addEvent(new MagicRepeatedPermanentsEvent(
                event.getSource(),
                A_NON_DEMON_PERMANENT_YOU_CONTROL,
                (int)Math.ceil(event.getPlayer().getNrOfPermanents(NON_DEMON_PERMANENT_YOU_CONTROL)/2),
                MagicChainEventFactory.Sac
            ));
        }
    },
   new MagicWhenSelfCombatDamagePlayerTrigger() {
        @Override
        public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicDamage damage) {
            return new MagicEvent(
                permanent,
                damage.getTargetPlayer(),
                this,
                "PN sacrifices half the non-Demon permanents he or she controls, rounded up."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event) {
            final int n = (int)Math.ceil(event.getPlayer().getNrOfPermanents(NON_DEMON_PERMANENT_YOU_CONTROL)/2);
            for (int i=n;i>0;i--) {
                game.addEvent(new MagicSacrificePermanentEvent(
                    event.getSource(),
                    event.getPlayer(),
                    A_NON_DEMON_PERMANENT_YOU_CONTROL
                ));
            }      
        }
    }
]
Pushed