magarena/release/Magarena/scripts/Ghoulraiser.groovy

26 lines
1.2 KiB
Groovy
Raw Normal View History

2013-05-25 22:44:00 -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
return new MagicEvent(
2013-05-25 22:44:00 -07:00
permanent,
this,
"Return a Zombie card at random from your graveyard to your hand."
);
2013-04-12 19:32:25 -07:00
}
@Override
2013-05-25 22:44:00 -07:00
public void executeEvent(final MagicGame game, final MagicEvent event) {
2013-04-12 19:32:25 -07:00
final MagicPlayer player = event.getPlayer();
final List<MagicCard> targets = game.filterCards(player,MagicTargetFilter.TARGET_ZOMBIE_CARD_FROM_GRAVEYARD);
if (targets.size() > 0) {
final MagicPermanent permanent = event.getPermanent();
final magic.MersenneTwisterFast rng = new magic.MersenneTwisterFast(player.getGraveyard().getStateId());
final int index = rng.nextInt(targets.size());
final MagicCard card = targets.get(index);
game.doAction(new MagicRemoveCardAction(card,MagicLocationType.Graveyard));
game.doAction(new MagicMoveCardAction(card,MagicLocationType.Graveyard,MagicLocationType.OwnersHand));
}
}
2013-05-25 22:44:00 -07:00
}
]