Make progress survive a browser refresh. A real game remembers you.
Without persistence, closing the browser erases everything. We use localStorage to save and load the game state. But not everything should persist — some things are intentionally reset. What you choose to save is a design decision, not just a technical one.
What persists: Banked XP.
What does NOT persist: Unbanked XP. It is "at risk" — closing the browser is like dying. This reinforces the banking mechanic.
What persists: Karma and debt.
What does NOT persist: Active jobs. You have to accept new jobs each session. This means every play session starts with a fresh decision.
Save game state to localStorage:
Load game state on page start:
Call saveGame() whenever state changes (after banking, after resolution). Call loadGame() on page load:
Add a "New Game" button that clears everything:
Refresh the browser. Banked progress remains. Unbanked progress is gone. This is intentional design.
No cloud saves. Local only. No save slots. One save per game.
Saving everything — including things that should reset. Be deliberate about what persists.
Not parsing JSON on load — localStorage.getItem() returns a string. You must JSON.parse() it.
Overwriting saved data with default state on load — make sure you load before initializing defaults, not after.
Not handling the case where no save exists — the first time, getItem() returns null. Check for it.
Ask: "Why should some things persist and others not?" This teaches that persistence is a design choice, not just a technical feature. The decision about what to save IS game design. Unbanked XP resetting on refresh reinforces the banking mechanic from Day 13 — it makes the browser itself part of the risk system.