Skip to content

Commit

Permalink
Fix DGT ending issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Oct 31, 2022
1 parent 47f4657 commit e684430
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/61_pgn_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e684430

Please sign in to comment.