Fix memory leak of moves hash on server side. Draft Align4
[xogo.git] / variants / Madrasi / class.js
1 import ChessRules from "/base_rules.js";
2
3 export default class MadrasiRules extends ChessRules {
4
5 static get Options() {
6 return {
7 select: C.Options.select,
8 input: [
9 {
10 label: "Rex Incl.",
11 variable: "rexincl",
12 type: "checkbox",
13 defaut: false
14 }
15 ].concat(C.Options.input),
16 styles: C.Options.styles.filter(s => s != "madrasi")
17 };
18 }
19
20 constructor(o) {
21 o.options["madrasi"] = true;
22 super(o);
23 }
24
25 underCheck([x, y], color) {
26 if (this.options["rexincl"]) {
27 // If Rex Inclusive, kings do not check each other:
28 // we just replace it very temporarily.
29 const [ox, oy] = this.searchKingPos(color);
30 const saveOppKing = this.board[ox][oy];
31 this.board[ox][oy] = C.GetOppCol(color) + "q"; //arbitrary
32 const res = super.underCheck([x, y], color);
33 this.board[ox][oy] = saveOppKing;
34 return res;
35 }
36 return super.underCheck([x, y], color);
37 }
38
39 };