mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
Correct handling of extra turns.
This commit is contained in:
parent
fc04cb2d22
commit
1b045ccf37
2 changed files with 35 additions and 16 deletions
|
@ -451,29 +451,48 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
PlayerList players = state.getPlayerList(nextPlayerId);
|
||||
Player player = getPlayer(players.get());
|
||||
while (!isPaused() && !isGameOver()) {
|
||||
// if (simulation)
|
||||
// logger.info("Turn " + Integer.toString(state.getTurnNum()));
|
||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
||||
if (checkStopOnTurnOption()) return;
|
||||
state.setActivePlayerId(player.getId());
|
||||
player.becomesActivePlayer();
|
||||
state.getTurn().play(this, player.getId());
|
||||
if (isPaused() || isGameOver())
|
||||
|
||||
if (!playTurn(player)) {
|
||||
break;
|
||||
endOfTurn();
|
||||
player = players.getNext(this);
|
||||
}
|
||||
|
||||
state.setTurnNum(state.getTurnNum() + 1);
|
||||
|
||||
//20091005 - 500.7
|
||||
while (getState().getTurnMods().extraTurn(player.getId())) {
|
||||
playTurn(player);
|
||||
state.setTurnNum(state.getTurnNum() + 1);
|
||||
}
|
||||
|
||||
player = players.getNext(this);
|
||||
}
|
||||
}
|
||||
if (isGameOver())
|
||||
winnerId = findWinnersAndLosers();
|
||||
}
|
||||
|
||||
private boolean playTurn(Player player) {
|
||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
||||
if (checkStopOnTurnOption()) {
|
||||
return false;
|
||||
}
|
||||
state.setActivePlayerId(player.getId());
|
||||
player.becomesActivePlayer();
|
||||
state.getTurn().play(this, player.getId());
|
||||
if (isPaused() || isGameOver()) {
|
||||
return false;
|
||||
}
|
||||
endOfTurn();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean checkStopOnTurnOption() {
|
||||
if (gameOptions.stopOnTurn != null && gameOptions.stopAtStep == PhaseStep.UNTAP) {
|
||||
if (gameOptions.stopOnTurn.equals(state.getTurnNum())) {
|
||||
winnerId = null; //DRAW
|
||||
saveState();
|
||||
//saveState();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1556,4 +1575,5 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
public void setStateCheckRequired() {
|
||||
stateCheckRequired = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -132,8 +132,7 @@ public class Turn implements Serializable {
|
|||
if (!currentPhase.equals(phase)) // phase was changed from the card
|
||||
break;
|
||||
}
|
||||
//20091005 - 500.7
|
||||
playExtraTurns(game);
|
||||
|
||||
}
|
||||
|
||||
public void resumePlay(Game game, boolean wasPaused) {
|
||||
|
@ -212,11 +211,11 @@ public class Turn implements Serializable {
|
|||
phase.play(game, activePlayerId);
|
||||
}
|
||||
|
||||
private void playExtraTurns(Game game) {
|
||||
/*protected void playExtraTurns(Game game) {
|
||||
while (game.getState().getTurnMods().extraTurn(activePlayerId)) {
|
||||
this.play(game, activePlayerId);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void endTurn(Game game, UUID activePlayerId) {
|
||||
// Exile all spells and abilities on the stack
|
||||
|
@ -238,7 +237,7 @@ public class Turn implements Serializable {
|
|||
|
||||
Phase phase = new EndPhase();
|
||||
phase.setStep(new CleanupStep());
|
||||
currentPhase = phase;
|
||||
currentPhase = phase;
|
||||
//phase.play(game, activePlayerId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue