Fix Chess960 bug when castling does not move the rook.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 9 Feb 2018 19:16:46 +0000 (20:16 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 9 Feb 2018 19:16:46 +0000 (20:16 +0100)
www/js/chess.js
www/js/remoteglot.js

index 6d6623e..9da372c 100644 (file)
@@ -997,14 +997,14 @@ var Chess = function(fen) {
       if (move.flags & BITS.KSIDE_CASTLE) {
         var castling_to = move.to - 1;
         var castling_from = move.rook_sq;
-        board[castling_to] = board[castling_from];
-        if(castling_from !== move.to)
+        board[castling_to] = {type: ROOK, color: us};
+        if(castling_from !== move.to && castling_from !== castling_to)
           board[castling_from] = null;
       } else if (move.flags & BITS.QSIDE_CASTLE) {
         var castling_to = move.to + 1;
         var castling_from = move.rook_sq;
-        board[castling_to] = board[castling_from];
-        if(castling_from !== move.to)
+        board[castling_to] = {type: ROOK, color: us};
+        if(castling_from !== move.to && castling_from !== castling_to)
           board[castling_from] = null;
       }
 
@@ -1105,7 +1105,7 @@ var Chess = function(fen) {
       }
 
       board[castling_to] = board[castling_from];
-      if(castling_from !== move.from)
+      if(castling_from !== move.from && castling_from !== castling_to)
         board[castling_from] = null;
     }
 
index f6c06bb..b3b8163 100644 (file)
@@ -7,7 +7,7 @@
  * @type {Number}
  * @const
  * @private */
-var SCRIPT_VERSION = 2016113002;
+var SCRIPT_VERSION = 2016113007;
 
 /**
  * The current backend URL.