When switching king position, don't redo moves player had undone

This commit is contained in:
Juhani Krekelä 2021-01-10 21:23:01 +02:00
parent 54e4621548
commit f8d47a3b73
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}