fix for prev_turn has no effect when mid-chain

This commit is contained in:
Jesse D. McDonald 2020-04-05 17:39:47 -05:00
parent cba11ec0c8
commit a7df98a990
1 changed files with 8 additions and 5 deletions

View File

@ -789,14 +789,17 @@ $(function (){
}); });
$('#cb_nav_prev_turn').on('click', function(){ $('#cb_nav_prev_turn').on('click', function(){
if (visibleGame.canUndo) {
visibleGame.undo();
const player = visibleGame.player; const player = visibleGame.player;
while (visibleGame.canUndo) { while (visibleGame.canUndo) {
visibleGame.undo(); visibleGame.undo();
if (visibleGame.player === player) { if (visibleGame.player !== player) {
visibleGame.redo(); visibleGame.redo();
break; break;
} }
} }
}
renderBoard(); renderBoard();
}); });