From ee2417f73085a1b759b609dbcc9b290428759f69 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Tue, 25 Oct 2011 12:12:13 +0400 Subject: [PATCH] Fixed Issue 332 --- .../sets/championsofkamigawa/Mindblaze.java | 19 +++++++++++-- .../src/mage/sets/innistrad/Nevermore.java | 5 +++- .../mage/sets/magic2011/ConundrumSphinx.java | 8 ++++-- .../sets/magic2012/AdaptiveAutomaton.java | 9 +++--- .../mirrodinbesieged/PhyrexianRevoker.java | 8 +++++- .../src/mage/sets/newphyrexia/Xenograft.java | 7 +++-- .../mage/sets/scarsofmirrodin/Memoricide.java | 10 ++++++- Mage/src/mage/game/Game.java | 1 + Mage/src/mage/game/GameImpl.java | 28 +++++++++++-------- 9 files changed, 70 insertions(+), 25 deletions(-) diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/Mindblaze.java b/Mage.Sets/src/mage/sets/championsofkamigawa/Mindblaze.java index 9610a4bedb..37e7a3282d 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/Mindblaze.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/Mindblaze.java @@ -58,6 +58,11 @@ public class Mindblaze extends CardImpl { super(ownerId, 180, "Mindblaze", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{5}{R}"); this.expansionSetCode = "CHK"; this.color.setRed(true); + + // Name a nonland card and choose a number greater than 0. Target player reveals his or her library. + // If that library contains exactly the chosen number of the named card, + // Mindblaze deals 8 damage to that player. + // Then that player shuffles his or her library. this.getSpellAbility().addEffect(new MindblazeEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); } @@ -98,8 +103,18 @@ class MindblazeEffect extends OneShotEffect { numbers.add(Integer.toString(i)); } numberChoice.setChoices(numbers); - playerControls.choose(Constants.Outcome.Neutral, cardChoice, game); - playerControls.choose(Constants.Outcome.Neutral, numberChoice, game); + + while (!playerControls.choose(Constants.Outcome.Neutral, cardChoice, game)) { + game.debugMessage("player canceled choosing name. retrying."); + } + + while (!playerControls.choose(Constants.Outcome.Neutral, numberChoice, game)) { + game.debugMessage("player canceled choosing number. retrying."); + } + + game.informPlayers("Mindblaze, named card: [" + cardChoice.getChoice() + "]"); + game.informPlayers("Mindblaze, chosen number: [" + numberChoice.getChoice() + "]"); + Cards cards = new CardsImpl(); cards.addAll(player.getLibrary().getCards(game)); playerControls.revealCards("Library", cards, game); diff --git a/Mage.Sets/src/mage/sets/innistrad/Nevermore.java b/Mage.Sets/src/mage/sets/innistrad/Nevermore.java index e10f20f221..5b6891f841 100644 --- a/Mage.Sets/src/mage/sets/innistrad/Nevermore.java +++ b/Mage.Sets/src/mage/sets/innistrad/Nevermore.java @@ -95,8 +95,11 @@ class NevermoreEffect1 extends OneShotEffect { Choice cardChoice = new ChoiceImpl(); cardChoice.setChoices(Sets.getNonLandCardNames()); cardChoice.clearChoice(); - controller.choose(Outcome.Detriment, cardChoice, game); + while (!controller.choose(Outcome.Detriment, cardChoice, game)) { + game.debugMessage("player canceled choosing name. retrying."); + } String cardName = cardChoice.getChoice(); + game.informPlayers("Nevermore, named card: [" + cardName + "]"); game.getState().setValue(source.getSourceId().toString(), cardName); } return false; diff --git a/Mage.Sets/src/mage/sets/magic2011/ConundrumSphinx.java b/Mage.Sets/src/mage/sets/magic2011/ConundrumSphinx.java index b0b7293eb7..ed787d39b4 100644 --- a/Mage.Sets/src/mage/sets/magic2011/ConundrumSphinx.java +++ b/Mage.Sets/src/mage/sets/magic2011/ConundrumSphinx.java @@ -95,12 +95,16 @@ class ConundrumSphinxEffect extends OneShotEffect { for (Player player: game.getPlayers().values()) { if(player.getLibrary().size() > 0){ cardChoice.clearChoice(); - player.choose(Outcome.DrawCard, cardChoice, game); + while (!player.choose(Outcome.DrawCard, cardChoice, game)) { + game.debugMessage("player canceled choosing name. retrying."); + } + String cardName = cardChoice.getChoice(); + game.informPlayers("Conundrum Sphinx, player: " + player.getName() + ", named card: [" + cardName + "]"); Card card = player.getLibrary().removeFromTop(game); Cards cards = new CardsImpl(); cards.add(card); player.revealCards("Conundrum Sphinx", cards, game); - if (card.getName().equals(cardChoice.getChoice())) { + if (card.getName().equals(cardName)) { card.moveToZone(Zone.HAND, source.getId(), game, true); } else { diff --git a/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java b/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java index ee9c89e4a6..e30e2bf22a 100644 --- a/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java +++ b/Mage.Sets/src/mage/sets/magic2012/AdaptiveAutomaton.java @@ -97,10 +97,11 @@ class AdaptiveAutomatonEffect extends OneShotEffect { if (player != null && permanent != null) { Choice typeChoice = new ChoiceImpl(true); typeChoice.setChoices(Sets.getCreatureTypes()); - if (player.choose(Constants.Outcome.BoostCreature, typeChoice, game)) { - game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice()); - game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice()); - } + while (!player.choose(Constants.Outcome.BoostCreature, typeChoice, game)) { + game.debugMessage("player canceled choosing type. retrying."); + } + game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice()); + game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice()); } return false; } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java index 3fcfedff6d..7aeab3cf07 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java @@ -63,7 +63,10 @@ public class PhyrexianRevoker extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(1); + // As Phyrexian Revoker enters the battlefield, name a nonland card. this.addAbility(new EntersBattlefieldTriggeredAbility(new PhyrexianRevokerEffect1())); + + // Activated abilities of sources with the chosen name can't be activated. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhyrexianRevokerEffect2())); } @@ -96,8 +99,11 @@ class PhyrexianRevokerEffect1 extends OneShotEffect { Choice cardChoice = new ChoiceImpl(); cardChoice.setChoices(Sets.getNonLandCardNames()); cardChoice.clearChoice(); - controller.choose(Outcome.Detriment, cardChoice, game); + while (!controller.choose(Outcome.Detriment, cardChoice, game)) { + game.debugMessage("player canceled choosing name. retrying."); + } String cardName = cardChoice.getChoice(); + game.informPlayers("Phyrexian Revoker, named card: [" + cardName + "]"); game.getState().setValue(source.getSourceId().toString(), cardName); } return false; diff --git a/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java b/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java index 46bed32ea7..9f5135ef3e 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/Xenograft.java @@ -96,10 +96,11 @@ class XenograftEffect extends OneShotEffect { if (player != null && permanent != null) { Choice typeChoice = new ChoiceImpl(true); typeChoice.setChoices(Sets.getCreatureTypes()); - if (player.choose(Outcome.BoostCreature, typeChoice, game)) { - game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice()); - game.getState().setValue(source.getSourceId() + "_XenograftType", typeChoice.getChoice()); + while (!player.choose(Outcome.BoostCreature, typeChoice, game)) { + game.debugMessage("player canceled choosing type. retrying."); } + game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice()); + game.getState().setValue(source.getSourceId() + "_XenograftType", typeChoice.getChoice()); } return false; } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Memoricide.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Memoricide.java index 15a8c1c09b..b37849c2cd 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Memoricide.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Memoricide.java @@ -54,6 +54,9 @@ public class Memoricide extends CardImpl { super(ownerId, 69, "Memoricide", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}"); this.expansionSetCode = "SOM"; this.color.setBlack(true); + + // Name a nonland card. Search target player's graveyard, hand, and library for any number of cards with + // that name and exile them. Then that player shuffles his or her library this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addEffect(new MemoricideEffect()); } @@ -88,8 +91,13 @@ class MemoricideEffect extends OneShotEffect { Choice cardChoice = new ChoiceImpl(); cardChoice.setChoices(Sets.getNonLandCardNames()); cardChoice.clearChoice(); - controller.choose(Outcome.Exile, cardChoice, game); + + while (!controller.choose(Outcome.Exile, cardChoice, game)) { + game.debugMessage("player canceled choosing name. retrying."); + } + String cardName = cardChoice.getChoice(); + game.informPlayers("Memoricide, named card: [" + cardName + "]"); for (Card card: player.getGraveyard().getCards(game)) { if (card.getName().equals(cardName)) { card.moveToExile(null, "", source.getId(), game); diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index c1be2ee37d..643664733b 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -134,6 +134,7 @@ public interface Game extends MageItem, Serializable { public void fireInformEvent(String message); public void fireUpdatePlayersEvent(); public void informPlayers(String message); + public void debugMessage(String message); public void fireErrorEvent(String message, Exception ex); //game event methods diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index af768d9421..99d313f165 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -31,11 +31,14 @@ package mage.game; import mage.Constants.*; import mage.MageObject; import mage.abilities.*; +import mage.abilities.common.ChancellorAbility; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffects; import mage.abilities.keyword.LeylineAbility; +import mage.abilities.mana.TriggeredManaAbility; import mage.cards.Card; import mage.cards.Cards; +import mage.cards.CardsImpl; import mage.cards.decks.Deck; import mage.choices.Choice; import mage.counters.CounterType; @@ -45,7 +48,10 @@ import mage.filter.common.*; import mage.game.combat.Combat; import mage.game.events.*; import mage.game.events.TableEvent.EventType; -import mage.game.permanent.*; +import mage.game.permanent.Battlefield; +import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; +import mage.game.permanent.PermanentImpl; import mage.game.stack.SpellStack; import mage.game.stack.StackObject; import mage.game.turn.Phase; @@ -54,22 +60,17 @@ import mage.game.turn.Turn; import mage.players.Player; import mage.players.PlayerList; import mage.players.Players; +import mage.target.Target; +import mage.target.TargetPermanent; import mage.target.TargetPlayer; import mage.watchers.Watcher; +import mage.watchers.common.CastSpellLastTurnWatcher; +import mage.watchers.common.MorbidWatcher; +import org.apache.log4j.Logger; import java.io.IOException; import java.io.Serializable; import java.util.*; -import java.util.Map.Entry; -import mage.abilities.common.ChancellorAbility; - -import mage.abilities.mana.TriggeredManaAbility; -import mage.cards.CardsImpl; -import mage.target.Target; -import mage.target.TargetPermanent; -import mage.watchers.common.CastSpellLastTurnWatcher; -import mage.watchers.common.MorbidWatcher; -import org.apache.log4j.Logger; public abstract class GameImpl> implements Game, Serializable { @@ -931,6 +932,11 @@ public abstract class GameImpl> implements Game, Serializa fireInformEvent(message); } + @Override + public void debugMessage(String message) { + logger.warn(message); + } + @Override public void fireInformEvent(String message) { tableEventSource.fireTableEvent(EventType.INFO, message, this);