mirror of
https://github.com/correl/mage.git
synced 2025-01-13 03:00:10 +00:00
Fixed cards with endless loops if a player left game while he has to make a choice.
This commit is contained in:
parent
8007b16d64
commit
1dabfbb07b
14 changed files with 21 additions and 19 deletions
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue