Support promotions without the = as well

This commit is contained in:
Juhani Krekelä 2021-01-10 21:43:42 +02:00
parent f8d47a3b73
commit 3c5c1ff1bc
1 changed files with 4 additions and 1 deletions

View File

@ -348,11 +348,11 @@
if (move.slice(index, index + 1) === '=') {
index++;
switch (move.slice(index, index + 1)) {
case 'K':
case 'Q':
case 'B':
case 'N':
case 'R':
case 'K':
case 'P':
promotion = move.slice(index, index + 1);
break;
@ -360,6 +360,9 @@
return {error: 'Unrecognized piece: ' + move.slice(index, index + 1)};
}
index++;
} else if (['K', 'Q', 'B', 'N', 'R', 'P'].includes(move.slice(index, index + 1))) {
promotion = move.slice(index, index + 1);
index++;
}
// Check(mate)