Add New Zealand Chess
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 22 Mar 2021 22:43:14 +0000 (23:43 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 22 Mar 2021 22:43:14 +0000 (23:43 +0100)
client/src/translations/en.js
client/src/translations/es.js
client/src/translations/fr.js
client/src/translations/rules/Newzealand/en.pug [new file with mode: 0644]
client/src/translations/rules/Newzealand/es.pug [new file with mode: 0644]
client/src/translations/rules/Newzealand/fr.pug [new file with mode: 0644]
client/src/translations/variants/en.pug
client/src/translations/variants/es.pug
client/src/translations/variants/fr.pug
client/src/variants/Newzealand.js [new file with mode: 0644]
server/db/populate.sql

index e93b434..604fbf8 100644 (file)
@@ -245,6 +245,7 @@ export const translations = {
   "Kings cross the 8x8 board": "Kings cross the 8x8 board",
   "Kings cross the 11x11 board": "Kings cross the 11x11 board",
   "Knibis and Bisknis": "Knibis and Bisknis",
   "Kings cross the 8x8 board": "Kings cross the 8x8 board",
   "Kings cross the 11x11 board": "Kings cross the 11x11 board",
   "Knibis and Bisknis": "Knibis and Bisknis",
+  "Kniros and Rosknis": "Kniros and Rosknis",
   "Knight in pocket": "Knight in pocket",
   "Knight versus pawns": "Knight versus pawns",
   "Korean Chess": "Korean Chess",
   "Knight in pocket": "Knight in pocket",
   "Knight versus pawns": "Knight versus pawns",
   "Korean Chess": "Korean Chess",
index d776b26..9a099a2 100644 (file)
@@ -245,6 +245,7 @@ export const translations = {
   "Kings cross the 8x8 board": "Los reyes cruzan el 8x8 tablero",
   "Kings cross the 11x11 board": "Los reyes cruzan el 11x11 tablero",
   "Knibis and Bisknis": "Knibis y Bisknis",
   "Kings cross the 8x8 board": "Los reyes cruzan el 8x8 tablero",
   "Kings cross the 11x11 board": "Los reyes cruzan el 11x11 tablero",
   "Knibis and Bisknis": "Knibis y Bisknis",
+  "Kniros and Rosknis": "Kniros y Rosknis",
   "Knight in pocket": "Caballo en bolsillo",
   "Knight versus pawns": "Caballo contra peones",
   "Korean Chess": "Ajedrez coreano",
   "Knight in pocket": "Caballo en bolsillo",
   "Knight versus pawns": "Caballo contra peones",
   "Korean Chess": "Ajedrez coreano",
index 4752d91..5bd4aea 100644 (file)
@@ -245,6 +245,7 @@ export const translations = {
   "Kings cross the 8x8 board": "Les rois traversent l'échiquier 8x8",
   "Kings cross the 11x11 board": "Les rois traversent l'échiquier 11x11",
   "Knibis and Bisknis": "Knibis et Bisknis",
   "Kings cross the 8x8 board": "Les rois traversent l'échiquier 8x8",
   "Kings cross the 11x11 board": "Les rois traversent l'échiquier 11x11",
   "Knibis and Bisknis": "Knibis et Bisknis",
+  "Kniros and Rosknis": "Kniros et Rosknis",
   "Knight in pocket": "Cavalier en poche",
   "Knight versus pawns": "Cavalier contre pions",
   "Korean Chess": "Échecs coréens",
   "Knight in pocket": "Cavalier en poche",
   "Knight versus pawns": "Cavalier contre pions",
   "Korean Chess": "Échecs coréens",
diff --git a/client/src/translations/rules/Newzealand/en.pug b/client/src/translations/rules/Newzealand/en.pug
new file mode 100644 (file)
index 0000000..0405e15
--- /dev/null
@@ -0,0 +1,17 @@
+p.boxed
+  | Knights capture as rooks, and rooks capture as knights.
+
+figure.diagram-container
+  .diagram.diag12
+    | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  .diagram.diag22
+    | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  figcaption Before and after Nxd8.
+
+h3 Source
+
+p
+  | The variant is mentioned 
+  a(href="https://www.chessvariants.com/play/erf/NewZChss.html")
+    | on chessvariants
+  | . It was probably invented around 1903.
diff --git a/client/src/translations/rules/Newzealand/es.pug b/client/src/translations/rules/Newzealand/es.pug
new file mode 100644 (file)
index 0000000..3a41643
--- /dev/null
@@ -0,0 +1,17 @@
+p.boxed
+  | Los caballos capturan como torres y las torres como caballos.
+
+figure.diagram-container
+  .diagram.diag12
+    | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  .diagram.diag22
+    | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  figcaption Antes y después de Nxd8.
+
+h3 Fuente
+
+p
+  | Se menciona la variante 
+  a(href="https://www.chessvariants.com/play/erf/NewZChss.html")
+    | en chessvariants
+  | . Probablemente fue inventado alrededor de 1903.
diff --git a/client/src/translations/rules/Newzealand/fr.pug b/client/src/translations/rules/Newzealand/fr.pug
new file mode 100644 (file)
index 0000000..e58a693
--- /dev/null
@@ -0,0 +1,17 @@
+p.boxed
+  | Les cavaliers capturent comme des tours, et les tours comme des cavaliers.
+
+figure.diagram-container
+  .diagram.diag12
+    | fen:r1bqr1k1/pp2ppbp/2n2np1/1BpN4/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  .diagram.diag22
+    | fen:r1bNr1k1/pp2ppbp/2n2np1/1Bp5/5P2/4PN2/PPP3PP/R1BQ1RK1:
+  figcaption Avant et après Nxd8.
+
+h3 Source
+
+p
+  | La variante est mentionnée 
+  a(href="https://www.chessvariants.com/play/erf/NewZChss.html")
+    | sur chessvariants
+  | . Elle a probablement été inventée vers 1903.
index a6e5bd8..5c13108 100644 (file)
@@ -124,6 +124,7 @@ p.
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
+    "Newzealand",
     "Omega",
     "Ordamirror",
     "Perfect",
     "Omega",
     "Ordamirror",
     "Perfect",
index 2db4ef9..fa4bab9 100644 (file)
@@ -131,6 +131,7 @@ p.
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
+    "Newzealand",
     "Omega",
     "Ordamirror",
     "Perfect",
     "Omega",
     "Ordamirror",
     "Perfect",
index ba52eca..a2dccae 100644 (file)
@@ -130,6 +130,7 @@ p.
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
     "Grand",
     "Grasshopper",
     "Hoppelpoppel",
+    "Newzealand",
     "Omega",
     "Ordamirror",
     "Perfect",
     "Omega",
     "Ordamirror",
     "Perfect",
diff --git a/client/src/variants/Newzealand.js b/client/src/variants/Newzealand.js
new file mode 100644 (file)
index 0000000..d51eda1
--- /dev/null
@@ -0,0 +1,65 @@
+import { ChessRules } from "@/base_rules";
+
+// NOTE: a lot copy-pasted from Hoppelpoppel
+export class NewzealandRules extends ChessRules {
+
+  getSlideNJumpMoves_([x, y], steps, oneStep, options) {
+    options = options || {};
+    let moves = [];
+    outerLoop: for (let step of steps) {
+      let i = x + step[0];
+      let j = y + step[1];
+      while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
+        if (!options.onlyTake) moves.push(this.getBasicMove([x, y], [i, j]));
+        if (!!oneStep) continue outerLoop;
+        i += step[0];
+        j += step[1];
+      }
+      if (V.OnBoard(i, j) && this.canTake([x, y], [i, j]) && !options.onlyMove)
+        moves.push(this.getBasicMove([x, y], [i, j]));
+    }
+    return moves;
+  }
+
+  getPotentialKnightMoves(sq) {
+    // The knight captures like a rook
+    return (
+      this.getSlideNJumpMoves_(
+        sq, ChessRules.steps[V.KNIGHT], "oneStep", { onlyMove: true })
+      .concat(
+        this.getSlideNJumpMoves_(
+          sq, ChessRules.steps[V.ROOK], null, { onlyTake: true }))
+    );
+  }
+
+  getPotentialRookMoves(sq) {
+    // The rook captures like a knight
+    return (
+      this.getSlideNJumpMoves_(
+        sq, ChessRules.steps[V.ROOK], null, { onlyMove: true })
+      .concat(
+        this.getSlideNJumpMoves_(
+          sq, ChessRules.steps[V.KNIGHT], "oneStep", { onlyTake: true }))
+    );
+  }
+
+  isAttackedByKnight([x, y], color) {
+    return super.isAttackedBySlideNJump(
+      [x, y],
+      color,
+      V.KNIGHT,
+      V.steps[V.ROOK]
+    );
+  }
+
+  isAttackedByROOK([x, y], color) {
+    return super.isAttackedBySlideNJump(
+      [x, y],
+      color,
+      V.ROOK,
+      V.steps[V.KNIGHT],
+      "oneStep"
+    );
+  }
+
+};
index 97ccdd6..1a13014 100644 (file)
@@ -114,6 +114,7 @@ insert or ignore into Variants (name, description) values
   ('Monocolor', 'All of the same color'),
   ('Monster', 'White move twice'),
   ('Musketeer', 'New fairy pieces'),
   ('Monocolor', 'All of the same color'),
   ('Monster', 'White move twice'),
   ('Musketeer', 'New fairy pieces'),
+  ('Newzealand', 'Kniros and Rosknis'),
   ('Omega', 'A wizard in the corner'),
   ('Orda', 'Mongolian Horde (v1)'),
   ('Ordamirror', 'Mongolian Horde (v2)'),
   ('Omega', 'A wizard in the corner'),
   ('Orda', 'Mongolian Horde (v1)'),
   ('Ordamirror', 'Mongolian Horde (v2)'),