1 import ChessRules
from "/base_rules.js";
3 export default class CoregalRules
extends ChessRules
{
6 const s
= FenUtil
.setupPieces(
7 ['r', 'n', 'b', 'l', 'k', 'b', 'n', 'r'],
9 randomness: this.options
["randomness"],
10 between: [{p1: 'k', p2: 'r'}, {p1: 'l', p2: 'r'}],
12 // 'k' and 'l' useful only to get relative position
13 flags: ['r', 'k', 'l']
17 fen: s
.b
.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
18 s
.w
.join("").toUpperCase(),
19 // TODO: re-arrange flags, use another init variable "relPos" (in o)
20 // (maybe after FEN parsing, easier?)
21 o: {flags: s
.flags
+ s
.flags
} //second set for royal queen
26 let res
= super.pieces();
27 res
['l'] = JSON
.parse(JSON
.stringify(res
['q']));
28 // TODO: CSS royal queen symbol (with cross?)
29 res
['l']["class"] = "royal_queen";
33 // TODO: something like that indeed (+ flags to FEN)
36 'k': { 'w': [...Array(4)], b: [...Array(4)] },
37 'l': { 'w': [...Array(4)], b: [...Array(4)] }
39 for (let i
= 0; i
< 8; i
++) {
40 this.castleFlags
[i
< 4 ? "k" : "l"][i
% 4 < 2 ? "w" : "b"] =
41 parseInt(fenflags
.charAt(i
), 10);
47 p
= this.getPiece(x
, y
);
48 ['k', 'l'].includes(p
); //no cannibal mode
51 getCastleMoves([x
, y
]) {
52 const c
= this.getColor(x
, y
),
53 p
= this.getPiece(x
, y
);
54 // Relative position of the selected piece: left or right ?
55 // If left: small castle left, large castle right.
56 // If right: usual situation.
57 const finalSquares
= [
58 this.relPos
[c
][p
] == "left" ? [1, 2] : [2, 3],
59 this.relPos
[c
][p
] == "right" ? [6, 5] : [5, 4]
62 super.getCastleMoves([x
, y
], finalSquares
, null, this.castleFlags
[p
]);
66 // TODO: updateFlags (just pass castleFlags arg)