]> git.sesse.net Git - remoteglot/commitdiff
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 6d6623e4d90005e7b5616346ca920391a4963d17..9da372c9d920526f9802dc8fa63a9c0bed97c35f 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 f6c06bb56aa8acb9de5178458787d6b33a57f10d..b3b8163f0bd1dca60ca0c495eda7b987c413b0bd 100644 (file)
@@ -7,7 +7,7 @@
  * @type {Number}
  * @const
  * @private */
-var SCRIPT_VERSION = 2016113002;
+var SCRIPT_VERSION = 2016113007;
 
 /**
  * The current backend URL.