magarena/release/Magarena/scripts/Ondu_Cleric.groovy

33 lines
1.2 KiB
Groovy

[
new MagicWhenOtherComesIntoPlayTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent otherPermanent) {
return (otherPermanent.isFriend(permanent) &&
otherPermanent.hasSubType(MagicSubType.Ally)) ?
new MagicEvent(
permanent,
new MagicSimpleMayChoice(
MagicSimpleMayChoice.GAIN_LIFE,
1,
MagicSimpleMayChoice.DEFAULT_YES
),
this,
"PN may\$ gain life equal to " +
"the number of Allies he or she controls."
) :
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.isYes()) {
final MagicPlayer player = event.getPlayer();
final int amount = player.getNrOfPermanents(MagicSubType.Ally);
if (amount > 0) {
game.doAction(new MagicChangeLifeAction(player,amount));
}
}
}
}
]