mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08: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);
|
PlayerList players = state.getPlayerList(nextPlayerId);
|
||||||
Player player = getPlayer(players.get());
|
Player player = getPlayer(players.get());
|
||||||
while (!isPaused() && !isGameOver()) {
|
while (!isPaused() && !isGameOver()) {
|
||||||
// if (simulation)
|
|
||||||
// logger.info("Turn " + Integer.toString(state.getTurnNum()));
|
if (!playTurn(player)) {
|
||||||
fireInformEvent("Turn " + Integer.toString(state.getTurnNum()));
|
|
||||||
if (checkStopOnTurnOption()) return;
|
|
||||||
state.setActivePlayerId(player.getId());
|
|
||||||
player.becomesActivePlayer();
|
|
||||||
state.getTurn().play(this, player.getId());
|
|
||||||
if (isPaused() || isGameOver())
|
|
||||||
break;
|
break;
|
||||||
endOfTurn();
|
}
|
||||||
player = players.getNext(this);
|
|
||||||
state.setTurnNum(state.getTurnNum() + 1);
|
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())
|
if (isGameOver())
|
||||||
winnerId = findWinnersAndLosers();
|
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() {
|
private boolean checkStopOnTurnOption() {
|
||||||
if (gameOptions.stopOnTurn != null && gameOptions.stopAtStep == PhaseStep.UNTAP) {
|
if (gameOptions.stopOnTurn != null && gameOptions.stopAtStep == PhaseStep.UNTAP) {
|
||||||
if (gameOptions.stopOnTurn.equals(state.getTurnNum())) {
|
if (gameOptions.stopOnTurn.equals(state.getTurnNum())) {
|
||||||
winnerId = null; //DRAW
|
winnerId = null; //DRAW
|
||||||
saveState();
|
//saveState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1556,4 +1575,5 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
public void setStateCheckRequired() {
|
public void setStateCheckRequired() {
|
||||||
stateCheckRequired = true;
|
stateCheckRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,7 @@ public class Turn implements Serializable {
|
||||||
if (!currentPhase.equals(phase)) // phase was changed from the card
|
if (!currentPhase.equals(phase)) // phase was changed from the card
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//20091005 - 500.7
|
|
||||||
playExtraTurns(game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resumePlay(Game game, boolean wasPaused) {
|
public void resumePlay(Game game, boolean wasPaused) {
|
||||||
|
|
@ -212,11 +211,11 @@ public class Turn implements Serializable {
|
||||||
phase.play(game, activePlayerId);
|
phase.play(game, activePlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playExtraTurns(Game game) {
|
/*protected void playExtraTurns(Game game) {
|
||||||
while (game.getState().getTurnMods().extraTurn(activePlayerId)) {
|
while (game.getState().getTurnMods().extraTurn(activePlayerId)) {
|
||||||
this.play(game, activePlayerId);
|
this.play(game, activePlayerId);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void endTurn(Game game, UUID activePlayerId) {
|
public void endTurn(Game game, UUID activePlayerId) {
|
||||||
// Exile all spells and abilities on the stack
|
// Exile all spells and abilities on the stack
|
||||||
|
|
@ -238,7 +237,7 @@ public class Turn implements Serializable {
|
||||||
|
|
||||||
Phase phase = new EndPhase();
|
Phase phase = new EndPhase();
|
||||||
phase.setStep(new CleanupStep());
|
phase.setStep(new CleanupStep());
|
||||||
currentPhase = phase;
|
currentPhase = phase;
|
||||||
//phase.play(game, activePlayerId);
|
//phase.play(game, activePlayerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue