Fix typo, add draft new variant (Lostqueen, to be edited)
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 26 Dec 2020 10:40:06 +0000 (11:40 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 26 Dec 2020 10:40:06 +0000 (11:40 +0100)
client/src/translations/rules/Lostqueen/en.pug [new file with mode: 0644]
client/src/translations/rules/Lostqueen/es.pug [new file with mode: 0644]
client/src/translations/rules/Lostqueen/fr.pug [new file with mode: 0644]
client/src/translations/rules/Parachute/fr.pug
client/src/variants/Lostqueen.js [new file with mode: 0644]

diff --git a/client/src/translations/rules/Lostqueen/en.pug b/client/src/translations/rules/Lostqueen/en.pug
new file mode 100644 (file)
index 0000000..c3a5920
--- /dev/null
@@ -0,0 +1,4 @@
+p.boxed
+  | The goal is to lose the queen.
+
+p TODO
diff --git a/client/src/translations/rules/Lostqueen/es.pug b/client/src/translations/rules/Lostqueen/es.pug
new file mode 100644 (file)
index 0000000..254e04c
--- /dev/null
@@ -0,0 +1,4 @@
+p.boxed
+  | El objetivo es perder a la dama.
+
+p TODO
diff --git a/client/src/translations/rules/Lostqueen/fr.pug b/client/src/translations/rules/Lostqueen/fr.pug
new file mode 100644 (file)
index 0000000..46aefd1
--- /dev/null
@@ -0,0 +1,4 @@
+p.boxed
+  | L'objectif est de perdre la dame.
+
+p TODO
index c0a2a9f..a34040e 100644 (file)
@@ -32,6 +32,6 @@ p
   a(href="https://www.chessvariants.com/diffsetup.dir/unachess.html")
     | variante Unachess II
   | &nbsp;sur chessvariants.com. Unachess I donne un trop grand avantage
-  aux blancs, dans les quelques parties que j'ai pu jouer.
+  aux blancs, dans les quelques parties que j'ai pu jouer.
 
 p Inventeurs : Jeff Miller et Edward Jackman (1995)
diff --git a/client/src/variants/Lostqueen.js b/client/src/variants/Lostqueen.js
new file mode 100644 (file)
index 0000000..3b64008
--- /dev/null
@@ -0,0 +1,36 @@
+import { ChessRules } from "@/base_rules";
+
+export class LostqueenRules extends ChessRules {
+
+  // The king can move like a knight:
+  getPotentialKingMoves(sq) {
+    return (
+      super.getPotentialKingMoves(sq).concat(
+      super.getSlideNJumpMoves(sq, ChessRules.steps[V.KNIGHT], "oneStep"))
+    );
+  }
+
+  // Goal is to lose the queen (or be checkmated):
+  getCurrentScore() {
+    // If my queen disappeared, I win
+    const color = this.turn;
+    let haveQueen = false;
+    outerLoop: for (let i=0; i<V.size.x; i++) {
+      for (let j=0; j<V.size.y; j++) {
+        if (
+          this.board[i][j] != V.EMPTY &&
+          this.getColor(i,j) == color &&
+          this.getPiece(i,j) == V.QUEEN
+        ) {
+          haveQueen = true;
+          break outerLoop;
+        }
+      }
+    }
+    if (!haveQueen) return color == "w" ? "1-0" : "0-1";
+    if (this.atLeastOneMove()) return "*";
+    // No valid move: the side who cannot move (or is checkmated) wins
+    return this.turn == "w" ? "1-0" : "0-1";
+  }
+
+};