From: Steinar H. Gunderson Date: Sun, 25 Dec 2022 19:34:55 +0000 (+0100) Subject: Chess.js bugfixes. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=9a650e4ec1cd349367ab7c59a9ec47a8cdbb79c9 Chess.js bugfixes. --- diff --git a/www/js/chess.js b/www/js/chess.js index 91f6c1d..531a08f 100644 --- a/www/js/chess.js +++ b/www/js/chess.js @@ -1178,8 +1178,8 @@ var Chess = function(fen) { // Find all pseudolegal moves featuring the given piece attacking // the given square (using symmetry of all non-pawn-or-castle moves, - // we simply generate // moves backwards). Does not support kings - // or pawns. Assumes there's // not already a piece of our own color + // we simply generate moves backwards). Does not support kings + // or pawns. Assumes there's not already a piece of our own color // on the destination square. function find_attacking_moves(to, piece, us) { let moves = []; @@ -1195,7 +1195,7 @@ var Chess = function(fen) { if (square & 0x88) break; if (board[square] != null) { - if (board[square].color !== us) break; + if (board[square].color !== us || board[square].type !== piece) break; if (board[to] == null) { add_move(board, moves, square, to, BITS.NORMAL); } else {