fix .cb-legal and .cb-start classes not placed correctly in some corner cases

This commit is contained in:
Jesse D. McDonald 2020-03-15 14:31:21 -05:00
parent 0769d7579b
commit 85375530a9
1 changed files with 9 additions and 7 deletions

View File

@ -554,6 +554,7 @@ function renderBoard(board){
$('#cb_board .cb-piece').attr('style', '').appendTo('#cb_hidden');
$('#cb_board .cb-start').removeClass('cb-start');
$('#cb_board .cb-end').removeClass('cb-end');
$('#cb_board .cb-legal').removeClass('cb-legal');
$('#cb_phantom').appendTo('#cb_hidden');
for (const side of ['light', 'dark']) {
@ -588,13 +589,14 @@ function renderBoard(board){
}
}
if (board.move) {
if (board.move.from === 'phantom') {
$('#cb_' + board.prior.move.to).addClass('cb-start');
} else {
$('#cb_' + board.move.from).addClass('cb-start');
}
$('#cb_' + board.move.to).addClass('cb-end');
const start = movedFrom(board);
if (start) {
$('#cb_' + start).addClass('cb-start');
}
const end = movedTo(board);
if (end) {
$('#cb_' + end).addClass('cb-end');
}
let msg = '';