e8506db8a83c85e6581f623132967c52d0a5bd70
1 import ChessRules
from "/base_rules.js";
3 export default class ClorangeRules
extends ChessRules
{
7 select: C
.Options
.select
,
9 C
.Options
.styles
.filter(s
=> !["crazyhouse","recycle"].includes(s
))
18 let res
= super.pieces(color
, x
, y
);
19 res
['s'] = {"class": "nv-pawn", moveas: "p"};
20 res
['u'] = {"class": "nv-rook", moveas: "r"};
21 res
['o'] = {"class": "nv-knight", moveas: "n"};
22 res
['c'] = {"class": "nv-bishop", moveas: "b"};
23 res
['t'] = {"class": "nv-queen", moveas: "q"};
27 static get V_PIECES() {
28 return ['p', 'r', 'n', 'b', 'q'];
30 static get NV_PIECES() {
31 return ['s', 'u', 'o', 'c', 't'];
33 static get ReserveArray() {
34 return V
.V_PIECES
.concat(V
.NV_PIECES
);
37 // Forbid non-violent pieces to capture
38 canTake([x1
, y1
], [x2
, y2
]) {
40 this.getColor(x1
, y1
) !== this.getColor(x2
, y2
) &&
41 (['k'].concat(V
.V_PIECES
)).includes(this.getPiece(x1
, y1
))
45 pawnPostProcess(moves
, color
, oppCols
) {
46 let res
= super.pawnPostProcess(moves
, color
, oppCols
);
47 if (res
.length
> 0 && res
[0].vanish
[0].p
== 's') {
48 // Fix promotions of non-violent pawns (if any)
50 if (m
.appear
[0].p
!= 's')
51 m
.appear
[0].p
= V
.NV_PIECES
[V
.V_PIECES
.indexOf(m
.appear
[0].p
)];
59 // NOTE: drop moves already taken into account in base prePlay()
60 if (move.vanish
.length
== 2 && move.appear
.length
== 1) {
61 const normal
= V
.V_PIECES
.includes(move.vanish
[1].p
);
63 (normal
? V
.V_PIECES : V
.NV_PIECES
).indexOf(move.vanish
[1].p
);
64 const resPiece
= (normal
? V
.NV_PIECES : V
.V_PIECES
)[pIdx
];
65 super.updateReserve(C
.GetOppTurn(this.turn
), resPiece
,
66 this.reserve
[C
.GetOppTurn(this.turn
)][resPiece
] + 1);