1 import ChessRules
from "/base_rules.js";
2 import {FenUtil
} from "/utils/setupPieces.js";
4 export default class BalaklavaRules
extends ChessRules
{
7 return ['r', 'm', 'b', 'q'];
15 let res
= super.pieces(color
, x
, y
);
16 const knightSpecMoves
= res
['n'].both
;
23 [-2, -2], [-2, 0], [-2, 2],
24 [0, -2], [0, 2], [2, -2],
31 ['p', 'r', 'b', 'm', 'q'].forEach(p
=> {
34 Array
.prototype.push
.apply(res
[p
].moves
, knightSpecMoves
);
39 genRandInitBaseFen() {
40 const s
= FenUtil
.setupPieces(
41 ['r', 'm', 'b', 'q', 'k', 'b', 'm', 'r'],
43 randomness: this.options
["randomness"],
48 fen: s
.b
.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
49 s
.w
.join("").toUpperCase(),
54 pawnPostProcess(moves
) {
55 if (moves
.length
== 0)
57 const color
= moves
[0].vanish
[0].c
;
58 const lastRank
= (color
== 'w' ? 0 : this.size
.x
- 1);
59 const forward
= (color
== 'w' ? -1 : 1);
60 const noKnightPromotions
= moves
.filter(m
=> {
62 (m
.end
.x
- m
.start
.x
) * forward
> 0 &&
64 m
.end
.x
!= lastRank
||
66 Math
.abs(m
.start
.x
- m
.end
.x
) <= 1 &&
67 Math
.abs(m
.start
.y
- m
.end
.y
) <= 1
72 return super.pawnPostProcess(noKnightPromotions
);