Allow overriding localStorage save key via ?game= query param

Defaults to 'incgame' when the query param is absent, preserving current behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ohELX137NFgWryS3BAY88
This commit is contained in:
azykov@mail.ru
2026-09-04 13:59:14 +03:00
co-authored by Claude Sonnet 5
parent 1553c48807
commit 9caa47a830
+8 -3
View File
@@ -5,15 +5,20 @@ export const saveParams = {
path: 'default',
}
const KEY_GAME = 'incgame';
const DEFAULT_KEY_GAME = 'incgame';
function getKeyGame(): string {
const params = new URLSearchParams(window.location.search);
return params.get('game') || DEFAULT_KEY_GAME;
}
export function save(game: Game) {
localStorage.setItem(`${saveParams.path}_${KEY_GAME}`, serializeGameToString(game));
localStorage.setItem(`${saveParams.path}_${getKeyGame()}`, serializeGameToString(game));
}
export function load(): Game {
try {
const raw = localStorage.getItem(`${saveParams.path}_${KEY_GAME}`);
const raw = localStorage.getItem(`${saveParams.path}_${getKeyGame()}`);
if (raw)
return deserializeGameFromString(raw);
} catch (e) {