1 import { ChessRules
} from "@/base_rules";
3 export class BalaklavaRules
extends ChessRules
{
5 static get PawnSpecs() {
9 { promotions: [V
.ROOK
, V
.MAMMOTH
, V
.BISHOP
, V
.QUEEN
] }
13 static get HasEnpassant() {
18 return (b
[1] == V
.MAMMOTH
? "Balaklava/" : "") + b
;
22 static get MAMMOTH() {
27 return [V
.PAWN
, V
.ROOK
, V
.MAMMOTH
, V
.BISHOP
, V
.QUEEN
, V
.KING
];
49 static GenRandInitFen(randomness
) {
50 // No collision between 'n' and castle flags, so next replacement is fine
52 ChessRules
.GenRandInitFen(randomness
)
53 .replace(/n
/g
, 'm').replace(/N
/g
, 'M')
57 getPotentialMovesFrom([x
, y
]) {
58 const piece
= this.getPiece(x
, y
);
61 ? this.getPotentialMammothMoves([x
, y
])
62 : super.getPotentialMovesFrom([x
, y
]);
63 if (piece
!= V
.KING
) {
64 // Add non-capturing knight movements
65 const color
= this.turn
;
66 const lastRank
= (color
== 'w' ? 0 : 7);
67 V
.steps
[V
.KNIGHT
].forEach(step
=> {
68 // Pawns cannot go backward:
72 (color
== 'w' && step
[0] > 0) ||
73 (color
== 'b' && step
[0] < 0)
78 const [i
, j
] = [x
+ step
[0], y
+ step
[1]];
81 this.board
[i
][j
] == V
.EMPTY
&&
82 // Pawns don't promote with a knight move
83 (piece
!= V
.PAWN
|| i
!= lastRank
)
85 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
92 getPotentialMammothMoves(sq
) {
93 return this.getSlideNJumpMoves(sq
, V
.steps
[V
.MAMMOTH
], "oneStep");
96 isAttacked(sq
, color
) {
98 super.isAttacked(sq
, color
) ||
99 this.isAttackedByMammoth(sq
, color
)
103 isAttackedByMammoth(sq
, color
) {
105 this.isAttackedBySlideNJump(
106 sq
, color
, V
.MAMMOTH
, V
.steps
[V
.MAMMOTH
], "oneStep")
110 static get SEARCH_DEPTH() {
114 static get VALUES() {
115 return Object
.assign(
116 // A mammoth is probably worth a little more than a knight