]> git.sesse.net Git - remoteglot/commitdiff
Chess.js bugfixes.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Dec 2022 19:34:55 +0000 (20:34 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Dec 2022 19:34:55 +0000 (20:34 +0100)
www/js/chess.js

index 91f6c1dda7af308f342e08e05095ca26238566c7..531a08fec291ee6f5fb430d7031ef7ff055c95f1 100644 (file)
@@ -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 {