return true;
}
+ loseOnRepetition() {
+ // If current side is under check: lost
+ return this.underCheck(this.turn);
+ }
+
static IsGoodFen(fen) {
if (!ChessRules.IsGoodFen(fen)) return false;
const fenParsed = V.ParseFen(fen);
if (p == V.PAWN) {
// Do not drop on checkmate:
this.play(mv);
- const res = (this.underCheck(oppCol) && !this.atLeastOneMove());
+ const res = (
+ this.underCheck(oppCol) && !this.atLeastOneMove("noReserve")
+ );
this.undo(mv);
if (res) continue;
}
return this.filterValid(moves);
}
- atLeastOneMove() {
+ atLeastOneMove(noReserve) {
if (!super.atLeastOneMove()) {
- // Search one reserve move
- for (let i = 0; i < V.RESERVE_PIECES.length; i++) {
- let moves = this.filterValid(
- this.getReserveMoves([V.size.x + (this.turn == "w" ? 0 : 1), i])
- );
- if (moves.length > 0) return true;
+ if (!noReserve) {
+ // Search one reserve move
+ for (let i = 0; i < V.RESERVE_PIECES.length; i++) {
+ let moves = this.filterValid(
+ this.getReserveMoves([V.size.x + (this.turn == "w" ? 0 : 1), i])
+ );
+ if (moves.length > 0) return true;
+ }
}
return false;
}