When switching king position, don't redo moves player had undone
This commit is contained in:
parent
54e4621548
commit
f8d47a3b73
|
@ -713,6 +713,7 @@
|
||||||
let blackQueen = blackKing === 'd8' ? 'e8' : 'd8';
|
let blackQueen = blackKing === 'd8' ? 'e8' : 'd8';
|
||||||
|
|
||||||
// Undo all moves
|
// Undo all moves
|
||||||
|
let historylength = moveHistory.length;
|
||||||
while (moveHistory.length > 0) {
|
while (moveHistory.length > 0) {
|
||||||
undoMove();
|
undoMove();
|
||||||
}
|
}
|
||||||
|
@ -723,8 +724,8 @@
|
||||||
document.getElementById(blackKing).firstChild.data = '♚';
|
document.getElementById(blackKing).firstChild.data = '♚';
|
||||||
document.getElementById(blackQueen).firstChild.data = '♛';
|
document.getElementById(blackQueen).firstChild.data = '♛';
|
||||||
|
|
||||||
// Redo all the moves we can
|
// Redo until we can or until the point where we were before, whichever is first
|
||||||
while (moveFuture.length > 0) {
|
while (moveHistory.length < historylength) {
|
||||||
if (!redoMove()) {
|
if (!redoMove()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue