Limit onMouseoverSquare function to the current player's turn

This code change ensures that mouseover triggers on chess pieces only work for the player whose turn it is currently. The function onMouseoverSquare now has a condition that returns nothing if the game's turn does not match the player's color.
This commit is contained in:
Anduin
2024-06-21 14:30:48 +00:00
parent f8b37c1fcb
commit e0a8a833f2
@@ -65,6 +65,10 @@ const initGameBoard = function (color, player, gameId) {
}
function onMouseoverSquare(square, piece) {
if (game.turn() !== color) {
return;
}
var moves = game.moves({
square: square,
verbose: true