From 955fbf56ea524b1a219d50b58ba1cae14e59b884 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 26 Dec 2020 11:40:06 +0100
Subject: [PATCH] Fix typo, add draft new variant (Lostqueen, to be edited)

---
 .../src/translations/rules/Lostqueen/en.pug   |  4 +++
 .../src/translations/rules/Lostqueen/es.pug   |  4 +++
 .../src/translations/rules/Lostqueen/fr.pug   |  4 +++
 .../src/translations/rules/Parachute/fr.pug   |  2 +-
 client/src/variants/Lostqueen.js              | 36 +++++++++++++++++++
 5 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 client/src/translations/rules/Lostqueen/en.pug
 create mode 100644 client/src/translations/rules/Lostqueen/es.pug
 create mode 100644 client/src/translations/rules/Lostqueen/fr.pug
 create mode 100644 client/src/variants/Lostqueen.js

diff --git a/client/src/translations/rules/Lostqueen/en.pug b/client/src/translations/rules/Lostqueen/en.pug
new file mode 100644
index 00000000..c3a59204
--- /dev/null
+++ b/client/src/translations/rules/Lostqueen/en.pug
@@ -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
index 00000000..254e04c7
--- /dev/null
+++ b/client/src/translations/rules/Lostqueen/es.pug
@@ -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
index 00000000..46aefd1a
--- /dev/null
+++ b/client/src/translations/rules/Lostqueen/fr.pug
@@ -0,0 +1,4 @@
+p.boxed
+  | L'objectif est de perdre la dame.
+
+p TODO
diff --git a/client/src/translations/rules/Parachute/fr.pug b/client/src/translations/rules/Parachute/fr.pug
index c0a2a9f5..a34040ee 100644
--- a/client/src/translations/rules/Parachute/fr.pug
+++ b/client/src/translations/rules/Parachute/fr.pug
@@ -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
index 00000000..3b640082
--- /dev/null
+++ b/client/src/variants/Lostqueen.js
@@ -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";
+  }
+
+};
-- 
2.44.0