New variant idea
[xogo.git] / variants / Progressive / class.js
CommitLineData
a7d09201
BA
1import ChessRules from "/base_rules.js";
2
3export default class ProgressiveRules extends ChessRules {
4
5 static get Options() {
6 return {
7 select: C.Options.select,
535c464b 8 input: [
a7d09201
BA
9 {
10 label: "Logical",
535c464b
BA
11 variable: "logical",
12 type: "checkbox",
13 defaut: false
a7d09201 14 }
535c464b 15 ].concat(C.Options.input),
a7d09201
BA
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};