Skip to content

Commit

Permalink
Reorder the operations do we don't accidentally enter the UCI short-c…
Browse files Browse the repository at this point in the history
…ircuit
  • Loading branch information
rooklift committed Feb 8, 2024
1 parent cfe8feb commit ced19b3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions files/src/renderer/40_position.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,6 @@ const position_prototype = {

parse_pgn: function(s) { // Returns a UCI move and an error message.

// Replace fruity dash characters with proper ASCII dash "-"

for (let n of [8208, 8210, 8211, 8212, 8213, 8722]) {
s = ReplaceAll(s, String.fromCodePoint(n), "-");
}

// Delete things we don't need...

s = ReplaceAll(s, "x", "");
s = ReplaceAll(s, "+", "");
s = ReplaceAll(s, "#", "");
s = ReplaceAll(s, "!", "");
s = ReplaceAll(s, "?", "");

// If the string contains any dots it'll be something like "1.e4" or "...e4" or whatnot...

let lio = s.lastIndexOf(".");
Expand All @@ -784,6 +770,20 @@ const position_prototype = {
}
}

// Replace fruity dash characters with proper ASCII dash "-"

for (let n of [8208, 8210, 8211, 8212, 8213, 8722]) {
s = ReplaceAll(s, String.fromCodePoint(n), "-");
}

// Delete things we don't need...

s = ReplaceAll(s, "x", "");
s = ReplaceAll(s, "+", "");
s = ReplaceAll(s, "#", "");
s = ReplaceAll(s, "!", "");
s = ReplaceAll(s, "?", "");

// Fix castling with zeroes...

s = ReplaceAll(s, "0-0-0", "O-O-O");
Expand Down

0 comments on commit ced19b3

Please sign in to comment.