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;
}
castling_from = move.to + 1;
}
- board[castling_to] = board[castling_from];
- if(castling_from !== move.from)
+ board[castling_to] = {type: ROOK, color: us};
+ if(castling_from !== move.from && castling_from !== castling_to)
board[castling_from] = null;
}