1 import { ChessRules
} from "@/base_rules";
3 export class BalaklavaRules
extends ChessRules
{
4 static get PawnSpecs() {
8 { promotions: [V
.ROOK
, V
.MAMMOTH
, V
.BISHOP
, V
.QUEEN
] }
12 static get HasEnpassant() {
17 return (b
[1] == V
.MAMMOTH
? "Balaklava/" : "") + b
;
21 static get MAMMOTH() {
26 return [V
.PAWN
, V
.ROOK
, V
.MAMMOTH
, V
.BISHOP
, V
.QUEEN
, V
.KING
];
48 static GenRandInitFen(randomness
) {
49 // No collision between 'n' and castle flags, so next replacement is fine
51 ChessRules
.GenRandInitFen(randomness
)
52 .replace(/n
/g
, 'm').replace(/N
/g
, 'M')
56 getPotentialMovesFrom([x
, y
]) {
57 const piece
= this.getPiece(x
, y
);
60 ? this.getPotentialMammothMoves([x
, y
])
61 : super.getPotentialMovesFrom([x
, y
]);
62 if (piece
!= V
.KING
) {
63 // Add non-capturing knight movements
64 const lastRank
= (this.turn
== 'w' ? 0 : 7);
65 V
.steps
[V
.KNIGHT
].forEach(step
=> {
66 const [i
, j
] = [x
+ step
[0], y
+ step
[1]];
69 this.board
[i
][j
] == V
.EMPTY
&&
70 // Pawns don't promote with a knight move
71 (piece
!= V
.PAWN
|| i
!= lastRank
)
73 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
80 getPotentialMammothMoves(sq
) {
81 return this.getSlideNJumpMoves(sq
, V
.steps
[V
.MAMMOTH
], "oneStep");
84 isAttacked(sq
, color
) {
86 super.isAttacked(sq
, color
) ||
87 this.isAttackedByMammoth(sq
, color
)
91 isAttackedByMammoth(sq
, color
) {
93 this.isAttackedBySlideNJump(
94 sq
, color
, V
.MAMMOTH
, V
.steps
[V
.MAMMOTH
], "oneStep")
98 static get SEARCH_DEPTH() {
102 static get VALUES() {
103 return Object
.assign(
104 // A mammoth is probably worth a little more than a knight