magarena/release/Magarena/scripts/Marrow_Chomper.groovy

48 lines
1.9 KiB
Groovy
Raw Normal View History

2013-05-30 05:30:36 -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) {
2013-04-12 19:32:25 -07:00
final MagicTargetChoice targetChoice=new MagicTargetChoice(
new MagicOtherPermanentTargetFilter(
MagicTargetFilter.TARGET_CREATURE_YOU_CONTROL,
permanent
),
MagicTargetHint.None,
"a creature other than "+permanent+" to sacrifice"
);
return permanent.getController().getNrOfPermanents(MagicType.Creature) > 1 ?
2013-04-12 19:32:25 -07:00
new MagicEvent(
permanent,
new MagicMayChoice(targetChoice),
MagicSacrificeTargetPicker.create(),
this,
2013-05-30 05:30:36 -07:00
"PN may\$ sacrifice a creature\$ to SN."
2013-04-12 19:32:25 -07:00
):
MagicEvent.NONE;
}
@Override
public boolean usesStack() {
return false;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
final MagicPermanent permanent=event.getPermanent();
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
game.doAction(new MagicSacrificeAction(creature));
game.doAction(new MagicChangeCountersAction(permanent,MagicCounterType.PlusOne,2,true));
game.doAction(new MagicChangeLifeAction(event.getPlayer(),2));
final MagicEvent newEvent=executeTrigger(game,permanent,MagicPayedCost.NO_COST);
2013-04-12 19:32:25 -07:00
if (newEvent.isValid()) {
game.addEvent(newEvent);
}
}
});
2013-06-23 18:29:26 -07:00
}
2013-04-12 19:32:25 -07:00
}
2013-05-30 05:30:36 -07:00
}
]