prevent selection of pieces with no legal moves

This commit is contained in:
Jesse D. McDonald 2020-04-24 22:08:05 -05:00
parent 2171bb00ee
commit db5f56735b
1 changed files with 5 additions and 0 deletions

View File

@ -210,6 +210,11 @@ $(function (){
$('#cb_board .cb-square').off('click.select'); $('#cb_board .cb-square').off('click.select');
clicked.parent().on('click.unselect', squareClickUnselect); clicked.parent().on('click.unselect', squareClickUnselect);
pieceStartMove(clicked, 'click'); pieceStartMove(clicked, 'click');
if ($('#cb_board .cb-legal').length < 1) {
/* cancel the selection since there is nowhere to move the piece to */
renderBoard();
}
} }
function pieceStartDrag(ev, ui) { function pieceStartDrag(ev, ui) {