* Prevent undo if game has already ended. Probably related to #433.

This commit is contained in:
LevelX2 2014-06-30 17:36:09 +02:00
parent ae4c07da9d
commit 09afaaf9ab
2 changed files with 2 additions and 4 deletions

View file

@ -528,7 +528,7 @@ public abstract class GameImpl implements Game, Serializable {
@Override
public void restoreState(int bookmark) {
if (!simulation) {
if (!simulation && !this.hasEnded()) { // if player left or game is over no undo is possible - this could lead to wrong winner
if (bookmark != 0) {
if (!savedStates.contains(bookmark - 1)) {
throw new UnsupportedOperationException("It was not possible to do the requested undo operation (bookmark " + (bookmark -1) + " does not exist)");

View file

@ -754,9 +754,7 @@ public abstract class PlayerImpl implements Player, Serializable {
resetStoredBookmark(game);
return true;
}
if (!game.hasEnded()) { // if player left or game is over no undo is possible - this could lead to wrong winner
game.restoreState(bookmark);
}
game.restoreState(bookmark);
}
}
return false;