From 3c5c1ff1bc78f7b545a24588b9d9d5e5f650fef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 10 Jan 2021 21:43:42 +0200 Subject: [PATCH] Support promotions without the = as well --- takhta.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/takhta.html b/takhta.html index 037453f..fae0274 100644 --- a/takhta.html +++ b/takhta.html @@ -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)