import { ChessRules, PiPo, Move } from "@/base_rules";
export class BenedictRules extends ChessRules {
+
static get HasEnpassant() {
return false;
}
);
}
- // TODO(?): some duplicated code in 2 next functions
- getSlideNJumpMoves([x, y], steps, oneStep) {
- let moves = [];
- outerLoop: for (let loop = 0; loop < steps.length; loop++) {
- const step = steps[loop];
- let i = x + step[0];
- let j = y + step[1];
- while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
- moves.push(this.getBasicMove([x, y], [i, j]));
- if (oneStep) continue outerLoop;
- i += step[0];
- j += step[1];
- }
- // No capture check: handled elsewhere (next method)
- }
- return moves;
+ canTake() {
+ return false;
}
// Find possible captures from a square
// Stop at the first move found
atLeastOneMove() {
const color = this.turn;
- const oppCol = V.GetOppCol(color);
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
- if (this.board[i][j] != V.EMPTY && this.getColor(i, j) != oppCol) {
- const moves = this.getPotentialMovesFrom([i, j]);
- if (moves.length > 0)
- return true;
+ if (this.board[i][j] != V.EMPTY && this.getColor(i, j) == color) {
+ if (this.getPotentialMovesFrom([i, j]).length > 0) return true;
}
}
}
const kp = this.kingPos[color];
if (this.getColor(kp[0], kp[1]) != color)
return color == "w" ? "0-1" : "1-0";
- if (this.atLeastOneMove())
- return "*";
+ if (this.atLeastOneMove()) return "*";
// Stalemate:
return "1/2";
}
};
return super.getNotation(basicMove);
}
+
};