Skip to content

Commit

Permalink
refactor code execution
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMuehlbauer committed Apr 29, 2024
1 parent a2f0b56 commit bcb518e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scripts/buildGameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ function loadGameStateFromStorage(id: string): StorableGameState | null {
}
}

function saveGameStateToStorage(id: string, state: string) {
localStorage.setItem(id, state);
function saveGameStateToStorage(id: string, state: DynamicGameState) {
localStorage.setItem(id, JSON.stringify(state));
}

function buildGameStateFromJSON(inputState: StorableGameState): DynamicGameState {
Expand Down Expand Up @@ -197,6 +197,6 @@ export function initGameState(id: string = "game") {
const state = getGameState(id);
Alpine.store(id, state);
Alpine.effect(() => {
saveGameStateToStorage(id, JSON.stringify(Alpine.store(id)));
saveGameStateToStorage(id, Alpine.store(id) as DynamicGameState);
})
}

0 comments on commit bcb518e

Please sign in to comment.