From b84286c011d48e4450224d3ca62b200af45b4aa5 Mon Sep 17 00:00:00 2001 From: GuillaumeSD <47183782+GuillaumeSD@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:38:46 +0200 Subject: [PATCH] fix : analysis fails on getIsPieceSacrifice throw --- src/lib/chess.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/chess.ts b/src/lib/chess.ts index 345bb1d..d953c18 100644 --- a/src/lib/chess.ts +++ b/src/lib/chess.ts @@ -202,13 +202,18 @@ export const getIsPieceSacrifice = ( b: [], }; for (const move of moves) { - const fullMove = game.move(uciMoveParams(move)); - if (fullMove.captured) { - capturedPieces[fullMove.color].push(fullMove.captured); - nonCapturingMovesTemp = 1; - } else { - nonCapturingMovesTemp--; - if (nonCapturingMovesTemp < 0) break; + try { + const fullMove = game.move(uciMoveParams(move)); + if (fullMove.captured) { + capturedPieces[fullMove.color].push(fullMove.captured); + nonCapturingMovesTemp = 1; + } else { + nonCapturingMovesTemp--; + if (nonCapturingMovesTemp < 0) break; + } + } catch (e) { + console.error(e); + return false; } }