From 942e00d389686a4e5e2ebe526f06218bd146d2fd Mon Sep 17 00:00:00 2001 From: beholder Date: Sat, 24 Sep 2011 15:17:12 +0200 Subject: [PATCH] fixed Charmbreaker Devils --- src/magic/card/Charmbreaker_Devils.java | 44 ++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/magic/card/Charmbreaker_Devils.java b/src/magic/card/Charmbreaker_Devils.java index b25b1e2996..1608b782a8 100644 --- a/src/magic/card/Charmbreaker_Devils.java +++ b/src/magic/card/Charmbreaker_Devils.java @@ -19,28 +19,19 @@ import magic.model.trigger.MagicWhenSpellIsPlayedTrigger; public class Charmbreaker_Devils { - public static final MagicAtUpkeepTrigger T1 = new MagicAtUpkeepTrigger() { + public static final MagicAtUpkeepTrigger T1 = new MagicAtUpkeepTrigger() { @Override public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer data) { final MagicPlayer player = permanent.getController(); - if (player == data) { - final List targets = - game.filterTargets(player,MagicTargetFilter.TARGET_INSTANT_OR_SORCERY_CARD_FROM_GRAVEYARD); - if (targets.size() > 0) { - final magic.MersenneTwisterFast rng = - new magic.MersenneTwisterFast(permanent.getId() + player.getId()); - final int index = rng.nextInt(targets.size()); - final MagicCard card = (MagicCard)targets.get(index); - return new MagicEvent( - permanent, - player, - new Object[]{card}, - this, - "Return an instant or sorcery card at random " + - "from your graveyard to your hand."); - } - } - return MagicEvent.NONE; + return (player == data) ? + new MagicEvent( + permanent, + player, + new Object[]{player,permanent}, + this, + "Return an instant or sorcery card at random " + + "from your graveyard to your hand.") : + MagicEvent.NONE; } @Override public void executeEvent( @@ -48,9 +39,18 @@ public class Charmbreaker_Devils { final MagicEvent event, final Object data[], final Object[] choiceResults) { - final MagicCard card = (MagicCard)data[0]; - game.doAction(new MagicRemoveCardAction(card,MagicLocationType.Graveyard)); - game.doAction(new MagicMoveCardAction(card,MagicLocationType.Graveyard,MagicLocationType.OwnersHand)); + final MagicPlayer player = (MagicPlayer)data[0]; + final List targets = + game.filterTargets(player,MagicTargetFilter.TARGET_INSTANT_OR_SORCERY_CARD_FROM_GRAVEYARD); + if (targets.size() > 0) { + final MagicPermanent permanent = (MagicPermanent)data[1]; + final magic.MersenneTwisterFast rng = + new magic.MersenneTwisterFast(permanent.getId() + player.getId()); + final int index = rng.nextInt(targets.size()); + final MagicCard card = (MagicCard)targets.get(index); + game.doAction(new MagicRemoveCardAction(card,MagicLocationType.Graveyard)); + game.doAction(new MagicMoveCardAction(card,MagicLocationType.Graveyard,MagicLocationType.OwnersHand)); + } } };