Add TurnId to GameState (for Final Fortune card)

This commit is contained in:
Quercitron 2014-05-23 23:48:13 +04:00
parent 3417be4a78
commit d7489789d9
3 changed files with 18 additions and 4 deletions

View file

@ -597,11 +597,16 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
state.setTurnNum(state.getTurnNum() + 1);
//20091005 - 500.7
while (getState().getTurnMods().extraTurn(player.getId())) {
UUID extraTurnId = getState().getTurnMods().getExtraTurn(player.getId());
while (extraTurnId != null) {
state.setExtraTurn(true);
state.setTurnId(extraTurnId);
playTurn(player);
state.setTurnNum(state.getTurnNum() + 1);
extraTurnId = getState().getTurnMods().getExtraTurn(player.getId());
}
state.setTurnId(null);
state.setExtraTurn(false);
player = players.getNext(this);
}

View file

@ -105,6 +105,7 @@ public class GameState implements Serializable, Copyable<GameState> {
private Exile exile;
private Battlefield battlefield;
private int turnNum = 1;
private UUID turnId = null;
private boolean extraTurn = false;
private boolean legendaryRuleActive = true;
private boolean gameOver;
@ -358,6 +359,14 @@ public class GameState implements Serializable, Copyable<GameState> {
this.turnNum = turnNum;
}
public UUID getTurnId() {
return this.turnId;
}
public void setTurnId(UUID turnId) {
this.turnId = turnId;
}
public boolean isExtraTurn() {
return extraTurn;
}

View file

@ -49,16 +49,16 @@ public class TurnMods extends ArrayList<TurnMod> {
}
}
public boolean extraTurn(UUID playerId) {
public UUID getExtraTurn(UUID playerId) {
ListIterator<TurnMod> it = this.listIterator(this.size());
while (it.hasPrevious()) {
TurnMod turnMod = it.previous();
if (turnMod.isExtraTurn() == true && turnMod.getPlayerId().equals(playerId)) {
it.remove();
return true;
return turnMod.getId();
}
}
return false;
return null;
}
public boolean skipTurn(UUID playerId) {