Fixed cards with endless loops if a player left game while he has to make a choice.

This commit is contained in:
LevelX2 2013-10-02 08:08:09 +02:00
parent 8007b16d64
commit 1dabfbb07b
14 changed files with 21 additions and 19 deletions

View file

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

View file

@ -108,7 +108,7 @@ 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)) {
while (!player.choose(Outcome.Benefit, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());

View file

@ -102,12 +102,14 @@ 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)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
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());
permanent.addInfo("chosen type", "<i>Chosen type: " + typeChoice.getChoice().toString() + "</i>");
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>");
}
}
return false;
}

View file

@ -133,8 +133,8 @@ 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)) {
game.debugMessage("player canceled choosing color. retrying.");
while (!player.choose(Outcome.Benefit, choiceColor, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying." );
}
if (choiceColor.getColor().isBlack()) {

View file

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

View file

@ -95,7 +95,7 @@ class ConundrumSphinxEffect extends OneShotEffect<ConundrumSphinxEffect> {
for (Player player: game.getPlayers().values()) {
if(player.getLibrary().size() > 0){
cardChoice.clearChoice();
while (!player.choose(Outcome.DrawCard, cardChoice, game)) {
while (!player.choose(Outcome.DrawCard, cardChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing name. retrying.");
}
String cardName = cardChoice.getChoice();

View file

@ -95,7 +95,7 @@ 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)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());

View file

@ -107,7 +107,7 @@ 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)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());

View file

@ -97,7 +97,7 @@ 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)) {
while (!player.choose(Outcome.BoostCreature, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());

View file

@ -105,7 +105,7 @@ 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)){
while (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game) && player.isInGame()){
game.debugMessage("player canceled choosing permanent. retrying.");
}
Permanent permanent = game.getPermanent(target.getFirstTarget());

View file

@ -111,7 +111,7 @@ 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)) {
while (!player.choose(Outcome.Benefit, choiceColor, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
}

View file

@ -91,7 +91,7 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect<TabletOfThe
String colors;
ChoiceColor colorChoice = new ChoiceColor();
colorChoice.setMessage("Choose the first color");
while (!player.choose(Outcome.GainLife, colorChoice, game)) {
while (!player.choose(Outcome.GainLife, colorChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.getState().setValue(permanent.getId() + "_color1", colorChoice.getColor().toString());
@ -99,7 +99,7 @@ class TabletOfTheGuildsEntersBattlefieldEffect extends OneShotEffect<TabletOfThe
colorChoice.getChoices().remove(colorChoice.getChoice());
colorChoice.setMessage("Choose the second color");
while (!player.choose(Outcome.GainLife, colorChoice, game)) {
while (!player.choose(Outcome.GainLife, colorChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.getState().setValue(permanent.getId() + "_color2", colorChoice.getColor().toString());

View file

@ -129,7 +129,7 @@ class XenagosManaEffect extends OneShotEffect <XenagosManaEffect> {
for(int i = 0; i < x; i++){
Mana mana = new Mana();
while (!player.choose(Outcome.Benefit, manaChoice, game)) {
while (!player.choose(Outcome.Benefit, manaChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing color. retrying.");
}

View file

@ -90,7 +90,7 @@ 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)) {
while (!player.choose(Outcome.Detriment, typeChoice, game) && player.isInGame()) {
game.debugMessage("player canceled choosing type. retrying.");
}
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + typeChoice.getChoice());