Fix silently-dropped log entries past the 40-line cap, add pause, clarify locations panel
All checks were successful
Docker / build-and-push (push) Successful in 42s
All checks were successful
Docker / build-and-push (push) Successful in 42s
- The log view only re-rendered when state.log.length changed, but the log is capped at 40 entries — so once a run had logged 40+ things (easy in a normal session), every entry after that point, including choice-event outcomes, upgrade purchases, and location visits, stopped appearing even though the underlying state updated. Fixed by tracking a monotonic logSeq counter that increments on every push regardless of the cap, and rendering off that instead of array length. Consolidated the repeated unshift+cap logic into one pushLog() helper so future call sites can't reintroduce the bug. - Added a pause button (and "PAUSAD" indicator) that freezes the tick loop without touching game state, so a hectic run can be paused to think without it counting as a save-scummy state mutation. Manual actions (buying upgrades, visiting locations) still work while paused, since that's usually the point of pausing. - The "Aktiva områden" sidebar only ever listed the 3 story-gated core areas, while the map has 7 clickable locations — making it look like 4 of the map pins didn't really exist. Split the panel into "Ritualens kärnplatser" (the 3 gated ones, unlock status shown as before) and "Övriga platser" (the 4 always-open flavor locations), so the sidebar and map agree. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import './style.css';
|
||||
import { createState, tick, buyUpgrade, visitLocation, resolveEventChoice, startGame, abandonGame, saveState, loadState, clearSave } from './engine.ts';
|
||||
import { initUI, renderState } from './ui.ts';
|
||||
import { initUI, renderState, setPausedUI } from './ui.ts';
|
||||
import { initMap, updateMap } from './map.ts';
|
||||
|
||||
let state = loadState() ?? createState();
|
||||
let visitCooldowns = new Map<string, number>();
|
||||
let paused = false;
|
||||
let lastTime = 0;
|
||||
const TARGET_FPS = 30;
|
||||
const FRAME_MS = 1000 / TARGET_FPS;
|
||||
@@ -25,7 +26,8 @@ function start(): void {
|
||||
},
|
||||
(index) => { state = resolveEventChoice(state, index); renderState(state); saveState(state); },
|
||||
() => { state = startGame(state); renderState(state); saveState(state); },
|
||||
() => { state = abandonGame(state); renderState(state); saveState(state); }
|
||||
() => { state = abandonGame(state); renderState(state); saveState(state); },
|
||||
() => { paused = !paused; setPausedUI(paused); }
|
||||
);
|
||||
|
||||
initMap('map', (locationId) => {
|
||||
@@ -42,7 +44,7 @@ function start(): void {
|
||||
function loop(now: number): void {
|
||||
if (now - lastTime >= FRAME_MS) {
|
||||
lastTime = now;
|
||||
if (state.phase === 'playing') {
|
||||
if (state.phase === 'playing' && !paused) {
|
||||
state = tick(state);
|
||||
renderState(state);
|
||||
updateMap(state.dread, state.areas);
|
||||
|
||||
Reference in New Issue
Block a user