added resume flag to priority

This commit is contained in:
BetaSteward 2011-11-04 22:58:39 -04:00
parent a1f1ed44c0
commit 2987dcc776
4 changed files with 23 additions and 15 deletions

View file

@ -157,7 +157,7 @@ public interface Game extends MageItem, Serializable {
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
public void applyEffects();
public boolean checkStateAndTriggered();
public void playPriority(UUID activePlayerId);
public void playPriority(UUID activePlayerId, boolean resuming);
public boolean endTurn(UUID playerId);
//game transaction methods

View file

@ -361,8 +361,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
Player player = getPlayer(players.get());
state.resume();
if (!isGameOver()) {
if (simulation)
logger.info("Turn " + Integer.toString(state.getTurnNum()));
// if (simulation)
// logger.info("Turn " + Integer.toString(state.getTurnNum()));
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
if (checkStopOnTurnOption()) return;
state.getTurn().resumePlay(this);
@ -573,12 +573,17 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
}
@Override
public void playPriority(UUID activePlayerId) {
public void playPriority(UUID activePlayerId, boolean resuming) {
int bookmark = 0;
try {
while (!isPaused() && !isGameOver()) {
if (!resuming) {
state.getPlayers().resetPassed();
state.getPlayerList().setCurrent(activePlayerId);
}
else {
state.getPlayerList().setCurrent(this.getPriorityPlayerId());
}
Player player;
while (!isPaused() && !isGameOver()) {
try {
@ -587,11 +592,14 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
player = getPlayer(state.getPlayerList().get());
state.setPriorityPlayerId(player.getId());
while (!player.isPassed() && !player.hasLost() && !player.hasLeft() && !isPaused() && !isGameOver()) {
if (!resuming) {
checkStateAndTriggered();
if (isPaused() || isGameOver()) return;
// resetPassed should be called if player performs any action
player.priority(this);
if (isPaused() || isGameOver()) return;
if (isPaused()) return;
}
resuming = false;
applyEffects();
}
if (isPaused() || isGameOver()) return;

View file

@ -173,7 +173,7 @@ public abstract class Phase<T extends Phase<T>> implements Serializable {
if (!currentStep.skipStep(game, activePlayerId)) {
prePriority(game, activePlayerId);
if (!game.isPaused() && !game.isGameOver())
currentStep.priority(game, activePlayerId);
currentStep.priority(game, activePlayerId, false);
if (!game.isPaused() && !game.isGameOver())
postPriority(game, activePlayerId);
}
@ -185,7 +185,7 @@ public abstract class Phase<T extends Phase<T>> implements Serializable {
prePriority(game, activePlayerId);
case PRIORITY:
if (!game.isPaused() && !game.isGameOver())
currentStep.priority(game, activePlayerId);
currentStep.priority(game, activePlayerId, true);
case POST:
if (!game.isPaused() && !game.isGameOver())
postPriority(game, activePlayerId);

View file

@ -77,10 +77,10 @@ public abstract class Step<T extends Step<T>> implements Serializable {
game.fireEvent(new GameEvent(preStepEvent, null, null, activePlayerId));
}
public void priority(Game game, UUID activePlayerId) {
public void priority(Game game, UUID activePlayerId, boolean resuming) {
if (hasPriority) {
stepPart = StepPart.PRIORITY;
game.playPriority(activePlayerId);
game.playPriority(activePlayerId, resuming);
}
}