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 color
= this.turn
;
65 const lastRank
= (color
== 'w' ? 0 : 7);
66 V
.steps
[V
.KNIGHT
].forEach(step
=> {
67 // Pawns cannot go backward:
71 (color
== 'w' && step
[0] > 0) ||
72 (color
== 'b' && step
[0] < 0)
77 const [i
, j
] = [x
+ step
[0], y
+ step
[1]];
80 this.board
[i
][j
] == V
.EMPTY
&&
81 // Pawns don't promote with a knight move
82 (piece
!= V
.PAWN
|| i
!= lastRank
)
84 moves
.push(this.getBasicMove([x
, y
], [i
, j
]));
91 getPotentialMammothMoves(sq
) {
92 return this.getSlideNJumpMoves(sq
, V
.steps
[V
.MAMMOTH
], "oneStep");
95 isAttacked(sq
, color
) {
97 super.isAttacked(sq
, color
) ||
98 this.isAttackedByMammoth(sq
, color
)
102 isAttackedByMammoth(sq
, color
) {
104 this.isAttackedBySlideNJump(
105 sq
, color
, V
.MAMMOTH
, V
.steps
[V
.MAMMOTH
], "oneStep")
109 static get SEARCH_DEPTH() {
113 static get VALUES() {
114 return Object
.assign(
115 // A mammoth is probably worth a little more than a knight