New variant idea
[xogo.git] / variants / Bicolour / class.js
index fd2cdb0..e049e0c 100644 (file)
@@ -2,16 +2,40 @@ import ChessRules from "/base_rules.js";
 import {Random} from "/utils/alea.js";
 import {ArrayFun} from "/utils/array.js";
 
-export class BicolourRules extends ChessRules {
+export default class BicolourRules extends ChessRules {
 
-  // TODO: Options
+  static get Options() {
+    return {
+      select: C.Options.select,
+      input: [
+        {
+          label: "King takes all",
+          variable: "takeboth",
+          type: "checkbox",
+          defaut: true
+        },
+        {
+          label: "Capture king",
+          variable: "taking",
+          type: "checkbox",
+          defaut: false
+        }
+      ],
+      styles: ["balance", "capture", "cylinder", "dark",
+               "doublemove", "madrasi", "progressive", "zen"]
+    };
+  }
 
   get hasFlags() {
     return false;
   }
 
   canTake([x1, y1], [x2, y2]) {
-    return (this.getPiece(x2, y2) == 'k' || super.canTake([x1, y1], [x2, y2]));
+    return (
+      this.getPiece(x2, y2) == 'k' ||
+      (this.getPiece(x1, y1) == 'k' && this.options["takeboth"]) ||
+      super.canTake([x1, y1], [x2, y2])
+    );
   }
 
   genRandInitBaseFen() {
@@ -103,9 +127,8 @@ export class BicolourRules extends ChessRules {
     };
   }
 
-  underCheck(color) {
-    const kingPos = this.searchKingPos(color)[0],
-    return (this.underAttack(kingPos, 'w') || this.underAttack(kingPos, 'b'));
+  underCheck(square_s) {
+    return super.underCheck(square_s, ['w', 'b']);
   }
 
 };