Draft Capablanca chess + add TODO related to move transmission issues
[xogo.git] / variants / Capablanca / class.js
diff --git a/variants/Capablanca/class.js b/variants/Capablanca/class.js
new file mode 100644 (file)
index 0000000..342429b
--- /dev/null
@@ -0,0 +1,69 @@
+import ChessRules from "/base_rules.js";
+
+export default class CapablancaRules extends ChessRules {
+
+  get pawnPromotions() {
+    return ['q', 'e', 's', 'r', 'n', 'b'];
+  }
+
+  pieces(color, x, y) {
+    let newPieces = {
+      'e': {
+        "class": "empress",
+        both: [
+          {
+            steps: [
+              [1, 0], [-1, 0], [0, 1], [0, -1]
+            ]
+          },
+          {
+            steps: [
+              [1, 2], [1, -2], [-1, 2], [-1, -2],
+              [2, 1], [-2, 1], [2, -1], [-2, -1]
+            ],
+            range: 1
+          }
+        ]
+      },
+      's': {
+        "class": "princess",
+        both: [
+          {
+            steps: [
+              [1, 1], [1, -1], [-1, 1], [-1, -1]
+            ]
+          },
+          {
+            steps: [
+              [1, 2], [1, -2], [-1, 2], [-1, -2],
+              [2, 1], [-2, 1], [2, -1], [-2, -1]
+            ],
+            range: 1
+          }
+        ]
+      }
+    };
+    return Object.assign(newPieces, super.pieces(color, x, y));
+  }
+
+  get size() {
+    return {x: 8, y: 10};
+  }
+
+  genRandInitBaseFen() {
+    const s = FenUtil.setupPieces(
+      ['r', 'n', 's', 'b', 'q', 'k', 'b', 'e', 'n', 'r'],
+      {
+        between: {p1: 'k', p2: 'r'},
+        diffCol: ['b'],
+        flags: ['r']
+      }
+    );
+    return {
+      fen: s.b.join("") + "/pppppppppp/91/91/91/91/PPPPPPPPPP/" +
+           s.w.join("").toUpperCase(),
+      o: {flags: s.flags}
+    };
+  }
+
+};