Add lore depth, fix recruit click bug, add localStorage save
- 20+ new events drawing from Anders Fager, Kult, and Call of Cthulhu: ICA cashiers who never blink, SJ trains stopping in non-existent tunnels, Kult lictors as city officials, death servants finishing lectures, Deep Ones, investigators dreaming about us, stars being right over Lund Observatory - Rewrite upgrade descriptions to match the register: mundane detail, matter-of-fact horror, no melodrama - Add a new mid-game upgrade (Paktens Förnyelse) to smooth the progression - Fix recruit button: was destroying DOM every 30fps tick, killing mousedown→click events; now only rebuilds when availability/affordability actually changes - Fix double andakt deduction in recruit effect - Fix map growing over log (proper flex constraints) - Add localStorage save/load with versioned key (SAVE_VERSION bump invalidates old saves); autosaves every 10s and on upgrade purchase, clears on restart Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -1,19 +1,22 @@
|
||||
import './style.css';
|
||||
import { createState, tick, buyUpgrade } from './engine.ts';
|
||||
import { createState, tick, buyUpgrade, saveState, loadState, clearSave } from './engine.ts';
|
||||
import { initUI, renderState } from './ui.ts';
|
||||
import { initMap, updateMap } from './map.ts';
|
||||
|
||||
let state = createState();
|
||||
let state = loadState() ?? createState();
|
||||
let lastTime = 0;
|
||||
const TARGET_FPS = 30;
|
||||
const FRAME_MS = 1000 / TARGET_FPS;
|
||||
const SAVE_INTERVAL_MS = 10_000;
|
||||
let lastSaveTime = 0;
|
||||
|
||||
function start(): void {
|
||||
const app = document.getElementById('app')!;
|
||||
|
||||
initUI(app,
|
||||
(id) => { state = buyUpgrade(state, id); renderState(state); },
|
||||
(id) => { state = buyUpgrade(state, id); renderState(state); saveState(state); },
|
||||
() => {
|
||||
clearSave();
|
||||
state = createState();
|
||||
document.getElementById('overlay')!.classList.remove('visible');
|
||||
renderState(state);
|
||||
@@ -34,6 +37,10 @@ function loop(now: number): void {
|
||||
renderState(state);
|
||||
updateMap(state.dread, state.areas);
|
||||
}
|
||||
if (now - lastSaveTime >= SAVE_INTERVAL_MS) {
|
||||
lastSaveTime = now;
|
||||
saveState(state);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(loop);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user