From e68443046ecd8d3ebe11c0c16cd963ec241ce933 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Mon, 31 Oct 2022 19:41:23 +0000 Subject: [PATCH] Fix DGT ending issue --- src/61_pgn_parse.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/61_pgn_parse.js b/src/61_pgn_parse.js index caa7ac4e..92a5037b 100644 --- a/src/61_pgn_parse.js +++ b/src/61_pgn_parse.js @@ -182,8 +182,19 @@ function LoadPGNRecord(o) { // This can throw! let [move, error] = node.board.parse_pgn(s); if (error) { - DestroyTree(root); // Alternatively, we could just end the parse here and return what we've got so far? - throw `"${s}" -- ${error}`; + + // If the problem specifically is one of Kd4, Ke4, Kd5, Ke5, it's probably just a DGT board thing + // due to the kings being moved to indicate the result. + + if (s.includes("Kd4") || s.includes("Ke4") || s.includes("Kd5") || s.includes("Ke5") || + s.includes("Kxd4") || s.includes("Kxe4") || s.includes("Kxd5") || s.includes("Kxe5")) + { + finished = true; + break; + } else { + DestroyTree(root); + throw `"${s}" -- ${error}`; + } } node = node.make_move(move, true);