magarena/release/Magarena/scripts/Woodland_Sleuth.groovy

28 lines
1.3 KiB
Groovy
Raw Normal View History

2013-05-26 04:08:15 -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 (game.getCreatureDiedThisTurn()) ?
new MagicEvent(
permanent,
this,
2013-05-26 04:08:15 -07:00
"Return a creature card at random from your graveyard to your hand."
) :
2013-04-12 19:32:25 -07:00
MagicEvent.NONE;
}
@Override
2013-05-26 04:08:15 -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_CREATURE_CARD_FROM_GRAVEYARD);
if (targets.size() > 0) {
final MagicPermanent permanent = event.getPermanent();
final MagicRandom rng = new MagicRandom(player.getGraveyard().getStateId());
2013-04-12 19:32:25 -07:00
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-26 04:08:15 -07:00
}
]