From f8d47a3b73805f9cf0ad1a19cf82befa3db123f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 10 Jan 2021 21:23:01 +0200 Subject: [PATCH] When switching king position, don't redo moves player had undone --- takhta.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/takhta.html b/takhta.html index 2e494ec..037453f 100644 --- a/takhta.html +++ b/takhta.html @@ -713,6 +713,7 @@ let blackQueen = blackKing === 'd8' ? 'e8' : 'd8'; // Undo all moves + let historylength = moveHistory.length; while (moveHistory.length > 0) { undoMove(); } @@ -723,8 +724,8 @@ document.getElementById(blackKing).firstChild.data = '♚'; document.getElementById(blackQueen).firstChild.data = '♛'; - // Redo all the moves we can - while (moveFuture.length > 0) { + // Redo until we can or until the point where we were before, whichever is first + while (moveHistory.length < historylength) { if (!redoMove()) { break; }