diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/ResourceCollection.java b/game-app/game-core/src/main/java/games/strategy/engine/data/ResourceCollection.java index fa81b8cec7f..8e709ccae93 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/ResourceCollection.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/ResourceCollection.java @@ -50,7 +50,7 @@ public void removeResource(final Resource resource, final int quantity) { final int current = getQuantity(resource); if ((current - quantity) < 0) { throw new IllegalArgumentException( - "Cant remove more than player has of resource: " + "Can't remove more than player has of resource: " + resource.getName() + ". current:" + current @@ -60,10 +60,6 @@ public void removeResource(final Resource resource, final int quantity) { change(resource, -quantity); } - public void removeAllOfResource(final Resource resource) { - resources.removeKey(resource); - } - private void change(final Resource resource, final int quantity) { resources.add(resource, quantity); } diff --git a/game-app/game-core/src/main/java/games/strategy/engine/history/History.java b/game-app/game-core/src/main/java/games/strategy/engine/history/History.java index 1ebfbaa79af..145ef588410 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/history/History.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/history/History.java @@ -88,7 +88,7 @@ private int getLastChange(final HistoryNode node) { } else if (node instanceof EventChild) { lastChangeIndex = ((Event) node.getParent()).getChangeEndIndex(); } else if (node instanceof IndexedHistoryNode) { - lastChangeIndex = ((IndexedHistoryNode) node).getChangeStartIndex(); + lastChangeIndex = ((IndexedHistoryNode) node).getChangeEndIndex(); } else { lastChangeIndex = 0; } @@ -114,7 +114,7 @@ public Change getDelta(final HistoryNode start, final HistoryNode end) { /** Changes the game state to reflect the historical state at {@code node}. */ public synchronized void gotoNode(final HistoryNode node) { assertCorrectThread(); - getGameData().acquireWriteLock(); + gameData.acquireWriteLock(); try { if (currentNode == null) { currentNode = getLastNode(); @@ -125,7 +125,7 @@ public synchronized void gotoNode(final HistoryNode node) { gameData.performChange(dataChange); } } finally { - getGameData().releaseWriteLock(); + gameData.releaseWriteLock(); } } @@ -136,7 +136,7 @@ public synchronized void gotoNode(final HistoryNode node) { public synchronized void removeAllHistoryAfterNode(final HistoryNode removeAfterNode) { gotoNode(removeAfterNode); assertCorrectThread(); - getGameData().acquireWriteLock(); + gameData.acquireWriteLock(); try { final int lastChange = getLastChange(removeAfterNode) + 1; while (changes.size() > lastChange) { @@ -163,7 +163,7 @@ public synchronized void removeAllHistoryAfterNode(final HistoryNode removeAfter this.removeNodeFromParent(nodesToRemove.remove(0)); } } finally { - getGameData().releaseWriteLock(); + gameData.releaseWriteLock(); } }