From 63cd1318559c0522fcdebc76ad25a6d075079389 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 12 Oct 2014 12:37:10 +0200 Subject: [PATCH] * Added context information for restore call to be able to set add info if restore can#t be executed. --- .../src/mage/abilities/costs/mana/ManaCostsImpl.java | 2 +- .../abilities/keyword/CumulativeUpkeepAbility.java | 2 +- Mage/src/mage/game/Game.java | 2 +- Mage/src/mage/game/GameImpl.java | 8 ++++---- Mage/src/mage/players/PlayerImpl.java | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java b/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java index 6eabaf7026..e2cc69ce2a 100644 --- a/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java +++ b/Mage/src/mage/abilities/costs/mana/ManaCostsImpl.java @@ -144,7 +144,7 @@ public class ManaCostsImpl extends ArrayList implements M game.removeBookmark(bookmark); return true; } - game.restoreState(bookmark); + game.restoreState(bookmark, ability.getRule()); return false; } diff --git a/Mage/src/mage/abilities/keyword/CumulativeUpkeepAbility.java b/Mage/src/mage/abilities/keyword/CumulativeUpkeepAbility.java index 1b111f5538..227e9ac9f3 100644 --- a/Mage/src/mage/abilities/keyword/CumulativeUpkeepAbility.java +++ b/Mage/src/mage/abilities/keyword/CumulativeUpkeepAbility.java @@ -131,7 +131,7 @@ class CumulativeUpkeepEffect extends OneShotEffect { return true; } else{ - game.restoreState(bookmark); + game.restoreState(bookmark, source.getRule()); } } permanent.sacrifice(source.getSourceId(), game); diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index 24769cad46..147f8199da 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -264,7 +264,7 @@ public interface Game extends MageItem, Serializable { //game transaction methods void saveState(boolean bookmark); int bookmarkState(); - void restoreState(int bookmark); + void restoreState(int bookmark, String context); void removeBookmark(int bookmark); int getSavedStateSize(); boolean isSaveGame(); diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 5bb82a891e..3431ac7632 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -510,11 +510,11 @@ public abstract class GameImpl implements Game, Serializable { } @Override - public void restoreState(int bookmark) { + public void restoreState(int bookmark, String context) { 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)"); + throw new UnsupportedOperationException("It was not possible to do the requested undo operation (bookmark " + (bookmark -1) + " does not exist) context: " + context); } int stateNum = savedStates.get(bookmark - 1); removeBookmark(bookmark); @@ -1032,7 +1032,7 @@ public abstract class GameImpl implements Game, Serializable { if (player != null) { int bookmark = player.getStoredBookmark(); if (bookmark != -1) { - restoreState(bookmark); + restoreState(bookmark, "undo"); player.setStoredBookmark(-1); fireUpdatePlayersEvent(); } @@ -1122,7 +1122,7 @@ public abstract class GameImpl implements Game, Serializable { logger.fatal("Game exception gameId: " + getId(), ex); ex.printStackTrace(); this.fireErrorEvent("Game exception occurred: ", ex); - restoreState(bookmark); + restoreState(bookmark, ""); bookmark = 0; continue; } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index f27dbfcaf2..102bc3f1c7 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -837,7 +837,7 @@ public abstract class PlayerImpl implements Player, Serializable { resetStoredBookmark(game); return true; } - game.restoreState(bookmark); + game.restoreState(bookmark, ability.getRule()); } } return false; @@ -881,7 +881,7 @@ public abstract class PlayerImpl implements Player, Serializable { return true; } } - game.restoreState(bookmark); + game.restoreState(bookmark, ability.getRule()); } return false; } @@ -900,7 +900,7 @@ public abstract class PlayerImpl implements Player, Serializable { resetStoredBookmark(game); return true; } - game.restoreState(bookmark); + game.restoreState(bookmark, ability.getRule()); } } else { int bookmark = game.bookmarkState(); @@ -910,7 +910,7 @@ public abstract class PlayerImpl implements Player, Serializable { resetStoredBookmark(game); return true; } - game.restoreState(bookmark); + game.restoreState(bookmark, ability.getRule()); } return false; } @@ -928,7 +928,7 @@ public abstract class PlayerImpl implements Player, Serializable { return true; } } - game.restoreState(bookmark); + game.restoreState(bookmark, action.getRule()); } return false; } @@ -998,7 +998,7 @@ public abstract class PlayerImpl implements Player, Serializable { return true; } } - game.restoreState(bookmark); + game.restoreState(bookmark, source.getRule()); return false; }