Reset game state when new/different game has started

This commit is contained in:
2024-11-24 16:49:00 +01:00
parent f52ae3cb8f
commit 0ae7b8618f

View File

@@ -35,6 +35,9 @@ document.addEventListener('alpine:init', () => {
console.log(result); console.log(result);
this.loading = false; this.loading = false;
if (result.game) { if (result.game) {
if (this.gameID !== result.game) {
this.setEmptyGameState();
}
return this.gameID = result.game; return this.gameID = result.game;
} }
}, },
@@ -116,10 +119,6 @@ document.addEventListener('alpine:init', () => {
this.getGameID(); this.getGameID();
}, },
// # Local Storage Persistence
resetSavedGames() {
localStorage.removeItem(this.savedGameKey);
},
// # Countdown timer // # Countdown timer
getFormattedTime(milliseconds) { getFormattedTime(milliseconds) {
if (!Number.isInteger(milliseconds)) { if (!Number.isInteger(milliseconds)) {