* Fixed while loops running endless if player left game.

This commit is contained in:
LevelX2 2013-10-20 02:40:31 +02:00
parent 038b15f399
commit f430a45157
32 changed files with 121 additions and 58 deletions

View file

@ -102,7 +102,9 @@ class MeddlingMageChooseCardEffect extends OneShotEffect<MeddlingMageChooseCardE
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("MeddlingMage, named card: [" + cardName + "]");

View file

@ -92,7 +92,9 @@ class ThoughtHemorrhageEffect extends OneShotEffect<ThoughtHemorrhageEffect> {
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!you.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!you.isInGame()) {
return false;
}
}
cardName = cardChoice.getChoice();
game.informPlayers("Thought Hemorrhage, named card: [" + cardName + "]");

View file

@ -145,8 +145,10 @@ class TraceOfAbundanceEffect extends ManaEffect<TraceOfAbundanceEffect> {
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
while (!player.choose(outcome, choice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(outcome, choice, game)) {
if (!player.isInGame()) {
return false;
}
}
int amount = 1;
Mana mana = null;

View file

@ -108,8 +108,10 @@ class CavernOfSoulsEffect extends OneShotEffect<CavernOfSoulsEffect> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.Benefit, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.Benefit, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice().toString());
@ -122,10 +124,10 @@ class CavernOfSoulsEffect extends OneShotEffect<CavernOfSoulsEffect> {
public CavernOfSoulsEffect copy() {
return new CavernOfSoulsEffect(this);
}
}
class CavernOfSoulsManaBuilder extends ConditionalManaBuilder {
@Override
public ConditionalMana build(Object... options) {
return new CavernOfSoulsConditionalMana(this.mana);
@ -147,7 +149,7 @@ class CavernOfSoulsConditionalMana extends ConditionalMana {
}
class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
@Override
public boolean apply(Game game, Ability source, UUID manaProducer) {
// check: ... to cast a creature spell
@ -168,7 +170,7 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
class CavernOfSoulsWatcher extends WatcherImpl<CavernOfSoulsWatcher> {
public List<UUID> spells = new ArrayList<UUID>();
public CavernOfSoulsWatcher() {
super("ManaPaidFromCavernOfSoulsWatcher", WatcherScope.GAME);
}
@ -187,7 +189,7 @@ class CavernOfSoulsWatcher extends WatcherImpl<CavernOfSoulsWatcher> {
if (event.getType() == GameEvent.EventType.MANA_PAYED) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals("Cavern of Souls")) {
spells.add(event.getTargetId());
spells.add(event.getTargetId());
}
}
}
@ -197,11 +199,10 @@ class CavernOfSoulsWatcher extends WatcherImpl<CavernOfSoulsWatcher> {
super.reset();
spells.clear();
}
}
class CavernOfSoulsCantCounterEffect extends ReplacementEffectImpl<CavernOfSoulsCantCounterEffect> {
public CavernOfSoulsCantCounterEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = null;
@ -237,5 +238,4 @@ class CavernOfSoulsCantCounterEffect extends ReplacementEffectImpl<CavernOfSouls
}
return false;
}
}

View file

@ -102,10 +102,12 @@ class RidersOfGavonyEffect extends OneShotEffect<RidersOfGavonyEffect> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
if (typeChoice.getChoice() != null) {
if (typeChoice.getChoice() != null) {
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());
permanent.addInfo("chosen type", "<i>Chosen type: " + typeChoice.getChoice().toString() + "</i>");

View file

@ -94,7 +94,9 @@ class CranialExtractionEffect extends OneShotEffect<CranialExtractionEffect> {
cardChoice.clearChoice();
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();

View file

@ -106,11 +106,15 @@ class MindblazeEffect extends OneShotEffect<MindblazeEffect> {
numberChoice.setChoices(numbers);
while (!playerControls.choose(Outcome.Neutral, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!playerControls.isInGame()) {
return false;
}
}
while (!playerControls.choose(Outcome.Neutral, numberChoice, game)) {
game.debugMessage("player canceled choosing number. retrying.");
if (!playerControls.isInGame()) {
return false;
}
}
game.informPlayers("Mindblaze, named card: [" + cardChoice.getChoice() + "]");

View file

@ -114,7 +114,9 @@ class CouncilOfTheAbsoluteChooseCardEffect extends OneShotEffect<CouncilOfTheAbs
cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Council of the Absolute, named card: [" + cardName + "]");

View file

@ -133,8 +133,10 @@ class PlasmCaptureManaEffect extends ManaEffect<PlasmCaptureManaEffect> {
Mana mana = new Mana();
for(int i = 0; i < amountOfMana; i++){
ChoiceColor choiceColor = new ChoiceColor();
while (!player.choose(Outcome.Benefit, choiceColor, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying." );
while (!player.choose(Outcome.Benefit, choiceColor, game)) {
if (!player.isInGame()) {
return false;
}
}
if (choiceColor.getColor().isBlack()) {

View file

@ -140,8 +140,10 @@ class VerdantHavenManaEffect extends ManaEffect<VerdantHavenManaEffect> {
Player player = game.getPlayer(land.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
while (!player.choose(outcome, choice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(outcome, choice, game)) {
if (!player.isInGame()) {
return false;
}
}
int amount = 1;
Mana mana = null;

View file

@ -108,8 +108,10 @@ class OrcishLumberjackManaEffect extends ManaEffect <OrcishLumberjackManaEffect>
for(int i = 0; i < 3; i++){
Mana mana = new Mana();
while (!player.choose(Outcome.Benefit, manaChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
if (manaChoice.getChoice().equals("Green")) {

View file

@ -96,7 +96,9 @@ class NevermoreEffect1 extends OneShotEffect<NevermoreEffect1> {
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Nevermore, named card: [" + cardName + "]");

View file

@ -98,7 +98,9 @@ class CabalTherapyEffect extends OneShotEffect<CabalTherapyEffect> {
cardChoice.clearChoice();
while (!controller.choose(Outcome.Discard, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();

View file

@ -99,8 +99,10 @@ public class MistformSliver extends CardImpl<MistformSliver> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.Detriment, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.Detriment, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice().toString());

View file

@ -116,7 +116,9 @@ class SphinxAmbassadorEffect extends OneShotEffect<SphinxAmbassadorEffect> {
cardChoice.setChoices(choices);
cardChoice.clearChoice();
while (!targetPlayer.choose(Outcome.Benefit, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!targetPlayer.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();

View file

@ -96,7 +96,9 @@ class ConundrumSphinxEffect extends OneShotEffect<ConundrumSphinxEffect> {
if(player.getLibrary().size() > 0){
cardChoice.clearChoice();
while (!player.choose(Outcome.DrawCard, cardChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing name. retrying.");
if (!player.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Conundrum Sphinx, player: " + player.getName() + ", named card: [" + cardName + "]");

View file

@ -95,8 +95,10 @@ class AdaptiveAutomatonEffect extends OneShotEffect<AdaptiveAutomatonEffect> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());

View file

@ -107,8 +107,10 @@ class ChooseCreatureTypeEffect extends OneShotEffect<ChooseCreatureTypeEffect> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice());

View file

@ -100,7 +100,9 @@ class SpoilsOfTheVaultEffect extends OneShotEffect<SpoilsOfTheVaultEffect> {
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
cardName = cardChoice.getChoice();
game.informPlayers("Spoils of the Vault, named card: [" + cardName + "]");

View file

@ -100,7 +100,9 @@ class PhyrexianRevokerEffect1 extends OneShotEffect<PhyrexianRevokerEffect1> {
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Phyrexian Revoker, named card: [" + cardName + "]");

View file

@ -97,8 +97,10 @@ class XenograftEffect extends OneShotEffect<XenograftEffect> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(source.getSourceId() + "_XenograftType", typeChoice.getChoice());

View file

@ -105,8 +105,10 @@ class WordsOfWindEffect extends ReplacementEffectImpl<WordsOfWindEffect> {
TargetControlledPermanent target = new TargetControlledPermanent();
List<Permanent> liste = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), playerId, game);
if(!liste.isEmpty()){
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game) && player.isInGame()){
game.debugMessage("player canceled choosing permanent. retrying.");
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)){
if (!player.isInGame()) {
return false;
}
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {

View file

@ -100,7 +100,9 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect<VoidstoneGargoyleC
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("VoidstoneGargoyle, named card: [" + cardName + "]");

View file

@ -111,8 +111,10 @@ class AxebaneGuardianManaEffect extends ManaEffect<AxebaneGuardianManaEffect> {
Mana mana = new Mana();
for(int i = 0; i < x; i++){
ChoiceColor choiceColor = new ChoiceColor();
while (!player.choose(Outcome.Benefit, choiceColor, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(Outcome.Benefit, choiceColor, game)) {
if (!player.isInGame()) {
return false;
}
}
if (choiceColor.getColor().isBlack()) {

View file

@ -98,7 +98,9 @@ class SlaughterGamesEffect extends SearchTargetGraveyardHandLibraryForCardNameAn
cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName;
cardName = cardChoice.getChoice();

View file

@ -91,8 +91,10 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect<TabletOfThe
String colors;
ChoiceColor colorChoice = new ChoiceColor();
colorChoice.setMessage("Choose the first color");
while (!player.choose(Outcome.GainLife, colorChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
while (!player.choose(Outcome.GainLife, colorChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
game.getState().setValue(permanent.getId() + "_color1", colorChoice.getColor().toString());
colors = colorChoice.getChoice().toLowerCase() + " and ";

View file

@ -90,7 +90,9 @@ class NameCard extends OneShotEffect<NameCard> {
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Pithing Needle, named card: [" + cardName + "]");

View file

@ -93,7 +93,9 @@ class MemoricideEffect extends OneShotEffect<MemoricideEffect> {
cardChoice.clearChoice();
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();

View file

@ -102,7 +102,9 @@ class NameCard extends OneShotEffect<NameCard> {
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!controller.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Runed Halo, named card: [" + cardName + "]");

View file

@ -96,7 +96,10 @@ class CursedScrollEffect extends OneShotEffect<CursedScrollEffect> {
cardChoice.setChoices(CardRepository.instance.getNames());
cardChoice.clearChoice();
while (!you.choose(Outcome.Damage, cardChoice, game)) {
game.debugMessage("player canceled choosing name. retrying.");
if (!you.isInGame()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Cursed Scroll, named card: [" + cardName + "]");

View file

@ -129,10 +129,11 @@ class XenagosManaEffect extends OneShotEffect <XenagosManaEffect> {
for(int i = 0; i < x; i++){
Mana mana = new Mana();
while (!player.choose(Outcome.Benefit, manaChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(Outcome.Benefit, manaChoice, game)) {
if (!player.isInGame()) {
return false;
}
}
if (manaChoice.getChoice().equals("Green")) {
mana.addGreen();
} else if (manaChoice.getChoice().equals("Red")) {

View file

@ -90,9 +90,10 @@ public class EngineeredPlague extends CardImpl<EngineeredPlague> {
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose creature type");
typeChoice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.Detriment, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
while (!player.choose(Outcome.Detriment, typeChoice, game)) {
if (!player.isInGame()) {
return false;
} }
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());
game.getState().setValue(permanent.getId() + "_type", typeChoice.getChoice().toString());
permanent.addInfo("chosen type", "<i>Chosen type: " + typeChoice.getChoice() + "</i>");