Add a few variants
[xogo.git] / variants / Progressive / class.js
diff --git a/variants/Progressive/class.js b/variants/Progressive/class.js
new file mode 100644 (file)
index 0000000..c209821
--- /dev/null
@@ -0,0 +1,40 @@
+import ChessRules from "/base_rules.js";
+
+export default class ProgressiveRules extends ChessRules {
+
+  static get Options() {
+    return {
+      select: C.Options.select,
+      check: [
+        {
+          label: "Logical",
+          defaut: false,
+          variable: "logical"
+        }
+      ].concat(C.Options.check),
+      styles: C.Options.styles.filter(s => s != "progressive")
+    };
+  }
+
+  constructor(o) {
+    o.options["progressive"] = true;
+    super(o);
+  }
+
+  get hasCastle() {
+    return !this.options["logical"];
+  }
+
+  pieces(color, x, y) {
+    let res = super.pieces(color, x, y);
+    if (this.options["logical"]) {
+      const pawnShift = (color == "w" ? -1 : 1);
+      res["p"].moves[0] = {
+        steps: [[pawnShift, 0]],
+        range: 1 //always
+      };
+    }
+    return res;
+  }
+
+};