From c20dda886a3b543f6a8f06daca5d79b4be03e7ef Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Sun, 15 Mar 2020 13:09:56 -0500 Subject: [PATCH] move both pieces when rook is paired while castling --- js/chess.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/chess.js b/js/chess.js index 860433a..7381e77 100644 --- a/js/chess.js +++ b/js/chess.js @@ -301,13 +301,19 @@ function movePiece(priorBoard, side, from, to){ if (type === 'k' && actuallyFrom[0] === 'e' && to[0] === 'g') { board.move.castle = true; + const alongsideRook = boardGet(board, 'h' + actuallyFrom[1], other); boardPut(board, 'h' + actuallyFrom[1], side, ' '); + boardPut(board, 'h' + actuallyFrom[1], other, ' '); boardPut(board, 'f' + actuallyFrom[1], side, 'r'); + boardPut(board, 'f' + actuallyFrom[1], other, alongsideRook); } else if (type === 'k' && actuallyFrom[0] === 'e' && to[0] === 'c') { board.move.queen_castle = true; + const alongsideRook = boardGet(board, 'a' + actuallyFrom[1], other); boardPut(board, 'a' + actuallyFrom[1], side, ' '); + boardPut(board, 'a' + actuallyFrom[1], other, ' '); boardPut(board, 'd' + actuallyFrom[1], side, 'r'); + boardPut(board, 'd' + actuallyFrom[1], other, alongsideRook); } else if (type === 'p' && alongside === ' ' && replaced === ' ' && to[0] !== actuallyFrom[0]) { let otherBoard = priorBoard;