summaryrefslogtreecommitdiff
path: root/qml/pages/Goban.qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml/pages/Goban.qml')
-rw-r--r--qml/pages/Goban.qml56
1 files changed, 30 insertions, 26 deletions
diff --git a/qml/pages/Goban.qml b/qml/pages/Goban.qml
index f84bb60..0dee0c8 100644
--- a/qml/pages/Goban.qml
+++ b/qml/pages/Goban.qml
@@ -103,8 +103,6 @@ Item {
|| (!limitTop && Actions.isFirstRow(index, goban.columns))
|| (!limitBottom && Actions.isLastRow(index, goban.columns, goban.rows)) ) {
- console.log("click outside", index, goban.rows, Actions.isFirstRow(index, goban.columns));
-
return;
}
@@ -125,29 +123,27 @@ Item {
return repeater.itemAt(x).getType() === (currentPlayer ? "black" : "white");
}
- /*
- * Check for pieces to remove.
- */
- var toRemove = neighbors.filter(isOponnent);
+ function freeOrChain(x) {
+ var pointType = repeater.itemAt(x).getType();
+ return pointType === "" || pointType === (currentPlayer ? "white" : "black");
+ }
-// function freeOrChain(x) {
-// var pointType = repeater.itemAt(x).getType();
-// return pointType === "" || pointType === (currentPlayer ? "white" : "black");
-// }
-// /*
-// * Single suicide is not allowed…
-// */
-// if (neighbors.length !== 0 && toRemove.length === 0 && !neighbors.some(freeOrChain)) {
-// return;
-// }
+ if (neighbors.length !== 0) {
- point.put(currentPlayer, true);
+ var somethingToRemove = false;
- if (neighbors.length !== 0) {
+ point.put(currentPlayer, true);
+
+ /*
+ * Check for pieces to remove.
+ */
+ neighbors.filter(isOponnent).forEach(function(neighbor) {
- toRemove.forEach(function(neighbor) {
- Actions.getChainToRemove(neighbor, repeater, goban.columns, goban.rows, isOponnent).
- forEach(function(x) {
+ var piecesToRemove = Actions.getChainToRemove(neighbor, repeater, goban.columns, goban.rows, isOponnent);
+ if (piecesToRemove.length !== 0) {
+ somethingToRemove = true;
+ }
+ piecesToRemove.forEach(function(x) {
repeater.itemAt(x).remove(true);
})
});
@@ -155,10 +151,17 @@ Item {
/*
* Check for suicide.
*/
- Actions.getChainToRemove(index, repeater, goban.columns, goban.rows, isPlayer).
- forEach(function(x) {
- repeater.itemAt(x).remove(true);
- });
+ if (!somethingToRemove) {
+ var suicides = Actions.getChainToRemove(index, repeater, goban.columns, goban.rows, isPlayer);
+ if (suicides.length !== 0) {
+// suicides.forEach(function(x) {
+// repeater.itemAt(x).remove(true);
+// });
+ point.remove(false);
+ currentPlayer = !currentPlayer;
+ }
+
+ }
/*
* Remove the marks in the cases.
@@ -173,7 +176,6 @@ Item {
for (var i = 0; i < goban.columns * goban.rows; i++) {
repeater.itemAt(i).mark = false;
}
-
}
currentPlayer = !currentPlayer;
@@ -203,7 +205,9 @@ Item {
width: goban.width - caseSize;
color: "black"
+
visible: (!((index === goban.rows - 1 && !limitBottom) || (index === 0 && !limitTop)))
+
height: 1
}