summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2014-09-02 22:10:27 +0200
committerSébastien Dailly <sebastien@chimrod.com>2014-09-02 22:10:27 +0200
commit57ddb2dfff768d323f2dae0af56fc086a66b0044 (patch)
treeb0c17a740a4096380dd9f08480a0d38063653891
parentfcca4f01fec5c97a0e2a6ca6cd9088a87aa76816 (diff)
Undo correction
-rw-r--r--qml/javascript/goban_util.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/qml/javascript/goban_util.js b/qml/javascript/goban_util.js
index f6f48c9..eec6392 100644
--- a/qml/javascript/goban_util.js
+++ b/qml/javascript/goban_util.js
@@ -162,9 +162,10 @@ function undo(grid, step) {
if (step.suicide) {
fillWith(step.added, step.player);
} else {
- var removed = step.removed;
- if (removed !== undefined) {
- fillWith(step.removed, !step.player);
+ if (step.removed !== undefined) {
+ step.removed.forEach(function(point){
+ fillWith(point, !step.player);
+ });
}
grid.getElementAtIndex(step.added).remove(false);
}
@@ -222,6 +223,7 @@ function addPiece(index, grid, currentPlayer, animation, allowSuicide, allowOver
return step;
}
+ step.removed = [];
var somethingToRemove = false;
var movementAutorized = true;
@@ -236,7 +238,7 @@ function addPiece(index, grid, currentPlayer, animation, allowSuicide, allowOver
var piecesToRemove = getChainToRemove(neighbor, grid, isOponnent);
if (piecesToRemove.length !== 0) {
- step.removed = piecesToRemove[0];
+ step.removed.push(neighbor);
somethingToRemove = true;
piecesToRemove.forEach(function(x) {
grid.getElementAtIndex(x).remove(animation);