fixed Charmbreaker Devils

master
beholder 2011-09-24 15:17:12 +02:00
parent 48419bec44
commit 942e00d389
1 changed files with 22 additions and 22 deletions

View File

@ -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<MagicTarget> 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<MagicTarget> 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));
}
}
};