diff --git a/js/board.js b/js/board.js index 266c347..91779da 100644 --- a/js/board.js +++ b/js/board.js @@ -53,7 +53,7 @@ function updateBoard() { const nonResultMoves = currentGame.moves.filter(m => !m.isResult); - if (currentMoveIndex >= nonResultMoves.length || currentMoveIndex < -1) { + if (currentMoveIndex >= nonResultMoves.length || currentMoveIndex <= -1) { currentMoveIndex = nonResultMoves.length - 1; } else if (previousMoveCount >= 0 && currentMoveIndex === previousMoveCount - 1 && nonResultMoves.length > previousMoveCount) { currentMoveIndex = nonResultMoves.length - 1; diff --git a/js/data.js b/js/data.js index 7e09ca3..e745f62 100644 --- a/js/data.js +++ b/js/data.js @@ -48,6 +48,13 @@ async function loadPGN(showOverlay = true) { const liveGame = getLiveGame(allLaraGames); const todaysGames = getTodaysGames(allLaraGames); currentGame = liveGame || (todaysGames.length > 0 ? getLatestGame(todaysGames) : getLatestGame(allLaraGames)); + } else if (currentGame) { + const updatedGame = allLaraGames.find(g => + g.white === currentGame.white && + g.black === currentGame.black && + g.round === currentGame.round + ); + if (updatedGame) currentGame = updatedGame; } updateBoard(); updatePlayerInfo();