magarena/release/Magarena/scripts/Skullmulcher.groovy

58 lines
2.3 KiB
Groovy
Raw Normal View History

2013-05-30 19:34:19 -07:00
def drawCards = {
final MagicGame game,final MagicPermanent permanent ->
if (permanent.hasCounters()) {
game.doAction(new MagicDrawAction(
permanent.getController(),
permanent.getCounters(
MagicCounterType.PlusOne)
));
2013-04-12 19:32:25 -07:00
}
2013-05-30 19:34:19 -07:00
}
[
new MagicWhenComesIntoPlayTrigger() {
2013-04-12 19:32:25 -07:00
@Override
2013-06-19 07:23:35 -07:00
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent, final MagicPayedCost payedCost) {
final MagicTargetFilter<MagicPermanent> targetFilter=new MagicOtherPermanentTargetFilter(
2013-04-12 19:32:25 -07:00
MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL,permanent);
final MagicTargetChoice targetChoice=new MagicTargetChoice(
targetFilter,false,MagicTargetHint.None,"a creature other than "+permanent+" to sacrifice");
2013-06-19 07:23:35 -07:00
if (permanent.getController().getNrOfPermanentsWithType(MagicType.Creature)>1) {
2013-04-12 19:32:25 -07:00
return new MagicEvent(
permanent,
new MagicMayChoice(targetChoice),
MagicSacrificeTargetPicker.create(),
this,
2013-05-30 19:34:19 -07:00
"You may\$ sacrifice a creature\$ to SN."
2013-04-12 19:32:25 -07:00
);
}
2013-05-30 19:34:19 -07:00
drawCards(game, permanent);
2013-04-12 19:32:25 -07:00
return MagicEvent.NONE;
}
@Override
public boolean usesStack() {
return false;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final MagicPermanent permanent=event.getPermanent();
if (event.isYes()) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicSacrificeAction(creature));
game.doAction(new MagicChangeCountersAction(permanent,MagicCounterType.PlusOne,1,true));
final MagicEvent newEvent=executeTrigger(game,permanent,permanent.getController());
if (newEvent.isValid()) {
game.addEvent(newEvent);
}
}
});
} else {
drawCards(game,permanent);
}
}
2013-05-30 19:34:19 -07:00
}
]