From: Steinar H. Gunderson Date: Fri, 9 Feb 2018 19:16:46 +0000 (+0100) Subject: Fix Chess960 bug when castling does not move the rook. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=b4059a786029132eb27769a42ca52eca6d8b44cc Fix Chess960 bug when castling does not move the rook. --- diff --git a/www/js/chess.js b/www/js/chess.js index 6d6623e..9da372c 100644 --- a/www/js/chess.js +++ b/www/js/chess.js @@ -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; } diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index f6c06bb..b3b8163 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -7,7 +7,7 @@ * @type {Number} * @const * @private */ -var SCRIPT_VERSION = 2016113002; +var SCRIPT_VERSION = 2016113007; /** * The current backend URL.