From b2185637d39de193e6b7ad324d55c7b7ca2366b1 Mon Sep 17 00:00:00 2001 From: Merlin Date: Mon, 19 Aug 2019 10:29:32 -0600 Subject: [PATCH] Prevented crash from faulty data Chess.js library returns a location string with only a number and causes the player to be locked with the piece, not letting them move it at all. This code checks if the string is the correct length before allowing it through in hideMoves and showMoves to prevent the error from being thrown, as it runs just fine so long as that faulty object is excluded. --- js/app.js | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/js/app.js b/js/app.js index da1d1686..5c3518ba 100644 --- a/js/app.js +++ b/js/app.js @@ -145,26 +145,41 @@ function moveScene(event) { function showMoves(Target) { var validMoves = chess.moves({ target: Target, verbose: true }); + console.log(validMoves); for(var i=0; i