Early draft of TitanChess
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 17 Nov 2020 10:57:38 +0000 (11:57 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 17 Nov 2020 10:57:38 +0000 (11:57 +0100)
client/src/variants/Titan.js [new file with mode: 0644]

diff --git a/client/src/variants/Titan.js b/client/src/variants/Titan.js
new file mode 100644 (file)
index 0000000..9e147cd
--- /dev/null
@@ -0,0 +1,50 @@
+import { ChessRules } from "@/base_rules";
+
+export class TitanRules extends ChessRules {
+  // Idea: yellow = bishop, orange = knight (for white)
+  // and, red = bishop + purple = knight (black side)
+  // (avoid using a bigger board, or complicated drawings)
+
+  // TODO: decode if piece + bishop or knight
+  getPiece() {}
+
+  // Code: a/c = bishop + knight/bishop j/l for king,
+  // m/o for knight, s/t for queen, u/v for rook
+  static get AUGMENTED_PIECES() {
+    return {
+      // ...
+    };
+  }
+  // or:
+  getExtraPiece(symbol) {
+    // TODO: switch ... case ... return b or n
+  }
+
+  // TODO: hook after any move from 1st rank,
+  // if piece not in usual list, bishop or knight appears.
+  getPotentialMovesFrom(sq) {
+    let moves = super.getPotentialMovesFrom(sq);
+    const color = this.turn;
+    if (
+      !ChessRules.PIECES.includes(this.board[sq[0]][sq[1]][1]) &&
+      ((color == 'w' && sq[0] == 7) || (color == "b" && sq[0] == 0))
+    ) {
+      // (or lookup table)
+      const newPiece = this.getExtraPiece(this.board[sq[0]][sq[1]][1])
+      moves.forEach(m => {
+        m.appear.push(
+          new PiPo({
+            p: newPiece,
+            c: color,
+            x: sq[0],
+            y: sq[1]
+          })
+        );
+      });
+    }
+    return moves;
+  }
+
+  // TODO: special case of move 1 = choose squares, knight first, then bishop
+  // (just click ?)
+};