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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user