move both pieces when rook is paired while castling

This commit is contained in:
Jesse D. McDonald 2020-03-15 13:09:56 -05:00
parent def7ccdbcb
commit c20dda886a
1 changed files with 6 additions and 0 deletions

View File

@ -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;