magarena/release/Magarena/scripts/Fettergeist.groovy

43 lines
1.6 KiB
Groovy
Raw Normal View History

2013-06-06 06:03:49 -07:00
def action = {
final MagicGame game, final MagicEvent event ->
if (event.isNo()) {
game.doAction(new MagicSacrificeAction(event.getPermanent()));
2013-05-29 22:38:01 -07:00
}
2013-06-06 06:03:49 -07:00
} as MagicEventAction ;
2013-05-29 22:38:01 -07:00
2013-06-23 18:29:26 -07:00
[
2013-05-29 22:38:01 -07:00
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(
final MagicGame game,
final MagicPermanent permanent,
final MagicPlayer upkeepPlayer) {
2013-06-06 06:03:49 -07:00
return permanent.isController(upkeepPlayer) ?
2013-05-29 22:38:01 -07:00
new MagicEvent(
permanent,
this,
"Sacrifice SN unless you pay " +
"{1} for each other creature you control."
) :
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
final int x = event.getPlayer().controlsPermanent(event.getPermanent()) ? 1 : 0;
final int amount = event.getPlayer().getNrOfPermanents(MagicType.Creature) - x;
2013-05-29 22:38:01 -07:00
final MagicManaCost cost = MagicManaCost.create("{"+amount+"}");
final MagicEvent triggerEvent = new MagicEvent(
event.getSource(),
event.getPlayer(),
new MagicMayChoice(
new MagicPayManaCostChoice(cost)
),
2013-06-06 06:03:49 -07:00
action,
2013-05-29 22:38:01 -07:00
"You may\$ pay " + cost.getText() + "\$. If you don't, sacrifice SN."
);
2013-06-23 18:29:26 -07:00
game.doAction(new MagicPutItemOnStackAction(new MagicTriggerOnStack(triggerEvent)));
2013-05-29 22:38:01 -07:00
}
}
]