magarena/release/Magarena/scripts/Tuktuk_Scrapper.groovy

48 lines
2.1 KiB
Groovy
Raw Normal View History

2013-05-30 05:45:08 -07:00
[
new MagicWhenOtherComesIntoPlayTrigger() {
2013-04-12 19:32:25 -07:00
@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 MagicMayChoice(
MagicTargetChoice.NEG_TARGET_ARTIFACT
),
MagicDestroyTargetPicker.Destroy,
2013-04-12 19:32:25 -07:00
this,
2013-05-30 05:54:04 -07:00
"PN may\$ destroy target artifact\$. " +
2013-05-30 05:45:08 -07:00
"If that artifact is put into a graveyard this way, SN deals damage to that artifact's controller equal to the number of Allies you control."
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-30 05:45:08 -07:00
public void executeEvent(final MagicGame game, final MagicEvent event) {
2013-04-12 19:32:25 -07:00
if (event.isYes()) {
2013-12-01 04:55:24 -08:00
event.processTargetPermanent(game, {
final MagicPermanent target ->
game.doAction(new MagicDestroyAction(target));
final MagicCard card = target.getCard();
final MagicPlayer player = event.getPlayer();
// only deal damage when the target is destroyed
if (card.isInGraveyard()
||
(card.isToken() && !card.getOwner().getPermanents().contains(target))) {
final int amount =
player.getNrOfPermanents(MagicSubType.Ally);
if (amount > 0) {
final MagicDamage damage = new MagicDamage(
event.getPermanent(),
card.getOwner(),
amount
);
game.doAction(new MagicDealDamageAction(damage));
2013-04-12 19:32:25 -07:00
}
}
});
2013-06-23 18:29:26 -07:00
}
}
2013-05-30 05:45:08 -07:00
}
2013-05-30 05:45:24 -07:00
]