magarena/release/Magarena/scripts/Tajuru_Archer.groovy

45 lines
1.9 KiB
Groovy
Raw Normal View History

2013-05-29 23:26:39 -07:00
[
new MagicWhenOtherComesIntoPlayTrigger() {
2013-04-12 19:32:25 -07:00
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPermanent other) {
final int numAllies = permanent.getController().getNrOfPermanentsWithSubType(MagicSubType.Ally);
return (other.isFriend(permanent) &&
other.hasSubType(MagicSubType.Ally)) ?
new MagicEvent(
permanent,
new MagicMayChoice(
MagicTargetChoice.NEG_TARGET_CREATURE_WITH_FLYING
),
// estimated. Amount of damage can be different on resolution
new MagicDamageTargetPicker(numAllies),
this,
2013-05-29 23:26:39 -07:00
"PN may\$ have SN deal " +
"damage to target creature with flying\$ equal to " +
"the number of Allies he or she controls."
) :
2013-04-12 19:32:25 -07:00
MagicEvent.NONE;
}
2013-06-23 18:29:26 -07:00
2013-04-12 19:32:25 -07:00
@Override
2013-05-29 23:26:39 -07:00
public void executeEvent(final MagicGame game, final MagicEvent event) {
2013-04-12 19:32:25 -07:00
if (event.isYes()) {
event.processTargetPermanent(game,new MagicPermanentAction() {
public void doAction(final MagicPermanent creature) {
final MagicPlayer player = event.getPlayer();
final int amount =
player.getNrOfPermanentsWithSubType(MagicSubType.Ally);
if (amount > 0) {
final MagicDamage damage = new MagicDamage(
event.getPermanent(),
creature,
amount
);
game.doAction(new MagicDealDamageAction(damage));
}
}
});
2013-06-23 18:29:26 -07:00
}
}
2013-05-29 23:26:39 -07:00
}
]