From db5f56735b3f1c62d8bbe0a6c65926efcdf64397 Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Fri, 24 Apr 2020 22:08:05 -0500 Subject: [PATCH] prevent selection of pieces with no legal moves --- js/pacosako_ui.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/pacosako_ui.js b/js/pacosako_ui.js index 79ab83a..7ed07c1 100644 --- a/js/pacosako_ui.js +++ b/js/pacosako_ui.js @@ -210,6 +210,11 @@ $(function (){ $('#cb_board .cb-square').off('click.select'); clicked.parent().on('click.unselect', squareClickUnselect); 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) {