Skip to content

Commit 281d8ef

Browse files
committed
Capturing king now means checkmate
1 parent 9e09816 commit 281d8ef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ function get_allowed_moves(piece: [Piece, Color], from: Square, ignore_check: bo
437437
}
438438
return !in_check(piece[1], [piece[0], from, v]);
439439
})
440-
.filter((v) => get_square(v) === null || get_square(v)![0] !== Piece.King);
441440

442441
return allowed_movements;
443442
}
@@ -738,6 +737,10 @@ board.addEventListener('click', function (event) {
738737
}
739738
}
740739

740+
if (get_square(square) !== null && get_square(square)![0] === Piece.King && get_square(square)![1] === Color.opposite(turn)) {
741+
checkmate = true;
742+
}
743+
741744
set_square(square, piece);
742745
set_square(squareToMove, null);
743746

0 commit comments

Comments
 (0)