mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
* Prevent undo if game has already ended. Probably related to #433.
This commit is contained in:
parent
ae4c07da9d
commit
09afaaf9ab
2 changed files with 2 additions and 4 deletions
|
@ -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)");
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue