Menu

Submission for Shuriken

160

Config

name=Shuriken
url=http://magiccards.info/query?q=%21shuriken
image=http://mtgimage.com/card/shuriken.jpg
value=3.330
rarity=U
type=Artifact
subtype=Equipment
cost={1}
equip={2}
timing=equipment
requires_groovy_code

Script

def public MagicPermanentActivation ThrowIt(final MagicPermanent source) {
    return new MagicPermanentActivation(new MagicActivationHints(MagicTiming.Removal),"Damage"){
        @Override
        public Iterable<MagicEvent> getCostEvent(final MagicPermanent permanent) {
            return [new MagicTapEvent(permanent)];
        }
        @Override
        public MagicEvent getPermanentEvent(final MagicPermanent permanent,final MagicPayedCost payedCost) {
            return new MagicEvent(
                permanent,
                new MagicTargetChoice(MagicTargetFilterFactory.CREATURE,"target creature."),
                source,
                this,
                "Unattach RN from SN, RN deals 2 damage to target creature\$."
            );
        }
        @Override
        public void executeEvent(final MagicGame game, final MagicEvent event){
            game.doAction(new MagicAttachAction(source, MagicPermanent.NONE));
            event.processTarget(game,{
                final MagicTarget target ->
                final MagicDamage damage = new MagicDamage(source, target, 2);
                game.doAction(new MagicDealDamageAction(damage));
                if(!event.getPermanent().hasSubType(MagicSubType.Ninja)) {
                    game.doAction(new MagicGainControlAction(target.getController(), source, MagicStatic.Forever));
                }
            });
        }   
    }
};
[
    new MagicStatic(MagicLayer.Ability) {
        @Override
        public void modAbilityFlags(final MagicPermanent source, final MagicPermanent permanent, final Set<MagicAbility> flags) {
            permanent.addAbility(ThrowIt(source));
        }
        @Override
        public boolean accept(final MagicGame game,final MagicPermanent source,final MagicPermanent target) { 
            return MagicStatic.acceptLinked(game, source, target);
        }
    }
]
Pushed