Prevent race condition when selecting multiple abilities using Shift+click

This commit is contained in:
drdev
2014-11-27 02:05:26 +00:00
parent 2cb2c266b3
commit 4c6bd6a715
9 changed files with 77 additions and 149 deletions

View File

@@ -19,6 +19,7 @@ package forge.game.phase;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import forge.card.mana.ManaCost;
import forge.game.*;
import forge.game.ability.AbilityFactory;
@@ -881,7 +882,7 @@ public class PhaseHandler implements java.io.Serializable {
}
game.fireEvent(new GameEventPlayerPriority(playerTurn, phase, getPriorityPlayer()));
SpellAbility chosenSa = null;
List<SpellAbility> chosenSa = null;
int loopCount = 0;
do {
@@ -913,7 +914,9 @@ public class PhaseHandler implements java.io.Serializable {
System.out.print("... " + pPlayerPriority + " plays " + chosenSa);
}
pFirstPriority = pPlayerPriority; // all opponents have to pass before stack is allowed to resolve
pPlayerPriority.getController().playChosenSpellAbility(chosenSa);
for (SpellAbility sa : chosenSa) {
pPlayerPriority.getController().playChosenSpellAbility(sa);
}
loopCount++;
} while (chosenSa != null && (loopCount < 999 || !pPlayerPriority.getController().isAI()));

View File

@@ -233,7 +233,7 @@ public abstract class PlayerController {
public abstract void declareAttackers(Player attacker, Combat combat);
public abstract void declareBlockers(Player defender, Combat combat);
public abstract SpellAbility chooseSpellAbilityToPlay();
public abstract List<SpellAbility> chooseSpellAbilityToPlay();
public abstract void playChosenSpellAbility(SpellAbility sa);
public abstract CardCollection chooseCardsToDiscardToMaximumHandSize(int numDiscard);

View File

@@ -130,7 +130,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
ability.setHostCard(game.getAction().moveToStack(source));
}
}
// Always add the ability here and always unfreeze the stack
add(ability);
unfreezeStack();