1 import ChessRules
from "/base_rules.js";
3 export default class ClorangeRules
extends ChessRules
{
5 // TODO: options : disable teleport/recycle at least ?
13 return "00000000000000000000";
15 ["w","b"].map(c
=> Object
.values(this.reserve
[c
]).join("")).join("")
20 let res
= super.pieces(color
, x
, y
);
21 res
['s'] = {"class": "nv-pawn", moveas: "p"};
22 res
['u'] = {"class": "nv-rook", moveas: "r"};
23 res
['o'] = {"class": "nv-knight", moveas: "n"};
24 res
['c'] = {"class": "nv-bishop", moveas: "b"};
25 res
['t'] = {"class": "nv-queen", moveas: "q"};
28 setOtherVariables(fen
) {
29 super.setOtherVariables(fen
,
30 ['p', 'r', 'n', 'b', 'q', 's', 'u', 'o', 'c', 't']);
33 postProcessPotentialMoves(moves
) {
34 // Remove captures for non-violent pieces:
35 return super.postProcessPotentialMoves(moves
).filter(m
=> {
37 m
.vanish
.length
!= 2 ||
38 m
.appear
.length
!= 1 ||
39 ['p', 'r', 'n', 'b', 'q'].includes(m
.vanish
[0].p
)
44 canTake([x1
, y1
], [x2
, y2
]) {
46 this.getColor(x1
, y1
) !== this.getColor(x2
, y2
) &&
47 ['p', 'r', 'n', 'b', 'q', 'k'].includes(this.getPiece(x1
, y1
))
53 // No crazyhouse or recycle, so the last call didn't update reserve:
54 if (move.vanish
.length
== 2 && move.appear
.length
== 1) {
55 // Capture: update reserves
56 this.Reserve
[move.vanish
57 const pIdx
= ['p', 'r', 'n', 'b', 'q'].indexOf(move.vanish
[1].p
);
60 ? ChessRules
.PIECES
.findIndex(p
=> p
== move.vanish
[1].p
)
61 : V
.NON_VIOLENT
.findIndex(p
=> p
== move.vanish
[1].p
);
62 const rPiece
= (normal
? V
.NON_VIOLENT : ChessRules
.PIECES
)[pIdx
];
63 this.reserve
[move.vanish
[1].c
][rPiece
]++;