Add Doublearmy. Start thinking about Dynamo
[xogo.git] / variants / Doublearmy / class.js
diff --git a/variants/Doublearmy/class.js b/variants/Doublearmy/class.js
new file mode 100644 (file)
index 0000000..abbb564
--- /dev/null
@@ -0,0 +1,43 @@
+import ChessRules from "/base_rules.js";
+
+export default class DoublearmyRules extends ChessRules {
+
+  static get Options() {
+    return {
+      select: C.Options.select,
+      input: C.Options.input,
+      styles: C.Options.styles.filter(s => s != "madrasi")
+    };
+  }
+
+  pieces(color, x, y) {
+    let res = super.pieces(color, x, y);
+    return Object.assign(
+      {
+        'c': {
+          "class": "commoner",
+          moveas: 'k'
+        }
+      },
+      res
+    );
+  }
+
+  genRandInitBaseFen() {
+    const s = super.genRandInitBaseFen();
+    const rows = s.fen.split('/');
+    return {
+      fen:
+        rows[0] + "/" +
+        rows[1] + "/" +
+        rows[0].replace('k', 'c') + "/" +
+        rows[1] + "/" +
+        rows[6] + "/" +
+        rows[7].replace('K', 'C') + "/" +
+        rows[6] + "/" +
+        rows[7],
+      o: s.o
+    };
+  }
+
+};