2922b02c5fb7397e869f46abe08aab2cd21bec79
1 import ChessRules
from "/base_rules.js";
3 export default class BalaklavaRules
extends ChessRules
{
6 return ['r', 'm', 'b', 'q'];
14 let res
= super.pieces(color
, x
, y
);
15 const knightSpec
= res
['n'];
22 [-2, -2], [-2, 0], [-2, 2],
23 [0, -2], [0, 2], [2, -2],
30 ['p', 'r', 'b', 'm', 'q'].forEach(p
=> res
[p
].moves
= knightSpec
.moves
);
34 genRandInitBaseFen() {
35 const baseFen
= super.genRandInitBaseFen();
37 fen: baseFen
.fen
.replace(/n
/g
, 'm').replace(/N
/g
, 'M'),
42 pawnPostProcess(moves
) {
43 if (moves
.length
== 0)
45 const color
= moves
[0].vanish
[0].c
;
46 const lastRank
= (color
== 'w' ? 0 : this.size
.x
- 1);
47 const forward
= (color
== 'w' ? -1 : 1);
48 const noKnightPromotions
= moves
.filter(m
=> {
50 (m
.end
.x
- m
.start
.x
) * forward
> 0 &&
52 m
.end
.x
!= lastRank
||
54 Math
.abs(m
.start
.x
- m
.end
.x
) <= 1 &&
55 Math
.abs(m
.start
.y
- m
.end
.y
) <= 1
60 return super.pawnPostProcess(noKnightPromotions
);