Fix Chaining variant
[xogo.git] / variants / Progressive / class.js
1 import ChessRules from "/base_rules.js";
2
3 export default class ProgressiveRules extends ChessRules {
4
5 static get Options() {
6 return {
7 select: C.Options.select,
8 input: [
9 {
10 label: "Logical",
11 variable: "logical",
12 type: "checkbox",
13 defaut: false
14 }
15 ].concat(C.Options.input),
16 styles: C.Options.styles.filter(s => s != "progressive")
17 };
18 }
19
20 constructor(o) {
21 o.options["progressive"] = true;
22 super(o);
23 }
24
25 get hasCastle() {
26 return !this.options["logical"];
27 }
28
29 pieces(color, x, y) {
30 let res = super.pieces(color, x, y);
31 if (this.options["logical"]) {
32 const pawnShift = (color == "w" ? -1 : 1);
33 res["p"].moves[0] = {
34 steps: [[pawnShift, 0]],
35 range: 1 //always
36 };
37 }
38 return res;
39 }
40
41 };