Monochrome: fixing attempt
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 27 Jun 2020 06:43:05 +0000 (08:43 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 27 Jun 2020 06:43:05 +0000 (08:43 +0200)
client/src/translations/rules/Monochrome/en.pug
client/src/translations/rules/Monochrome/es.pug
client/src/translations/rules/Monochrome/fr.pug
client/src/variants/Monochrome.js

index 81175e1..7a10d6d 100644 (file)
@@ -21,9 +21,9 @@ figure.diagram-container
   figcaption Before and after Rxd7
 
 p.
   figcaption Before and after Rxd7
 
 p.
-  Kings have no royal status. There are no en-passant captures, and no castle.
-  "Zen" captures are possible too: if a piece A attacks a piece B
-  (in the usual way), then B can capture A.
+  Kings have no royal status, and move like orthodox queens.
+  Knights become knightriders: they can make any number of knight steps in a
+  direction. There are no en-passant captures, and no castle.
 
 h3 Source
 
 
 h3 Source
 
index f77fc21..526f7bb 100644 (file)
@@ -23,9 +23,10 @@ figure.diagram-container
   figcaption Antes y después de Rxd7
 
 p.
   figcaption Antes y después de Rxd7
 
 p.
-  Los reyes no tienen estatus real. No hay capturas en passant ni enroque.
-  Las capturas "Zen" también son posibles: si una pieza A ataca a un
-  pieza B (en el sentido habitual), entonces B puede capturar a A.
+  Los reyes no tienen estatus real y se mueven como damas.
+  Los caballos se convierten en caballeros: mueven un número
+  arbitrario de casillas en una dirección dada.
+  No hay capturas en passant ni enroque.
 
 h3 Fuente
 
 
 h3 Fuente
 
index 7073855..091d036 100644 (file)
@@ -23,9 +23,10 @@ figure.diagram-container
   figcaption Avant et après Rxd7
 
 p.
   figcaption Avant et après Rxd7
 
 p.
-  Les rois n'ont pas de statut royal. Il n'y a ni prise en passant ni roque.
-  Les captures "Zen" sont possible également : si une pièce A attaque une
-  pièce B (au sens usuel), alors B peut capturer A.
+  Les rois n'ont pas de statut royal, et se déplacent comme des dames.
+  Les cavaliers sont changés en chevaliers : ils se déplacent d'un nombre
+  arbitraire de cases dans une direction donnée.
+  Il n'y a ni prise en passant ni roque.
 
 h3 Source
 
 
 h3 Source
 
index 954a050..8c74961 100644 (file)
@@ -47,79 +47,21 @@ export class MonochromeRules extends ChessRules {
     return ((x1 <= 3 && x2 >= 4) || (x1 >= 4 && x2 <= 3));
   }
 
     return ((x1 <= 3 && x2 >= 4) || (x1 >= 4 && x2 <= 3));
   }
 
-  // follow steps from x,y until something is met.
-  // if met piece is opponent and same movement (asA): eat it!
-  findCaptures_aux([x, y], asA) {
-    let moves = [];
-    const steps =
-      asA != V.PAWN
-        ? [V.QUEEN, V.KING].includes(asA)
-          ? V.steps[V.ROOK].concat(V.steps[V.BISHOP])
-          : V.steps[asA]
-        : this.turn == "w"
-          ? [
-            [-1, -1],
-            [-1, 1]
-          ]
-          : [
-            [1, -1],
-            [1, 1]
-          ];
-    const oneStep = [V.KNIGHT, V.PAWN, V.KING].includes(asA);
-    outerLoop: for (let loop = 0; loop < steps.length; loop++) {
-      const step = steps[loop];
-      let i = x + step[0];
-      let j = y + step[1];
-      while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
-        if (oneStep) continue outerLoop;
-        i += step[0];
-        j += step[1];
-      }
-      if (
-        V.OnBoard(i, j) &&
-        this.getPiece(i, j) == asA &&
-        this.canTake([i, j], [x, y])
-      ) {
-        // eat!
-        moves.push(this.getBasicMove([x, y], [i, j]));
-      }
-    }
-    return moves;
-  }
-
-  // Find possible captures from a square: look in every direction!
-  findCaptures(sq) {
-    let moves = [];
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.PAWN));
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.ROOK));
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.KNIGHT));
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.BISHOP));
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.QUEEN));
-    Array.prototype.push.apply(moves, this.findCaptures_aux(sq, V.KING));
-    return moves;
-  }
-
   // Trim all non-capturing moves
   static KeepCaptures(moves) {
     return moves.filter(m => m.vanish.length == 2);
   }
 
   // Trim all non-capturing moves
   static KeepCaptures(moves) {
     return moves.filter(m => m.vanish.length == 2);
   }
 
-  getPotentialMovesFrom(sq) {
-    const moves = super.getPotentialMovesFrom(sq);
-    const zenCaptures = this.findCaptures(sq);
-    // Remove duplicate captures in a lazy way (TODO: more efficient...)
-    let hashMoves = {};
-    moves.forEach(m => {
-      if (m.vanish.length == 2) {
-        const hash =
-          m.start.x + "." + m.start.y + "." + m.end.x + "." + m.end.y;
-        hashMoves[hash] = true;
-      }
-    });
-    return moves.concat(zenCaptures.filter(m => {
-      const hash = m.start.x + "." + m.start.y + "." + m.end.x + "." + m.end.y;
-      return !hashMoves[hash];
-    }));
+  getPotentialKnightMoves(sq) {
+    // Knight becomes knightrider:
+    return this.getSlideNJumpMoves(sq, V.steps[V.KNIGHT]);
+  }
+
+  getPotentialKingMoves(sq) {
+    // King become queen:
+    return (
+      this.getSlideNJumpMoves(sq, V.steps[V.ROOK].concat(V.steps[V.BISHOP]));
+    )
   }
 
   getAllPotentialMoves() {
   }
 
   getAllPotentialMoves() {