From 40b85f5707c56c019122b55b1743043f49f2e4e1 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sun, 23 Aug 2026 17:10:56 +0000 Subject: [PATCH] Session 13: Save Slot Preview (footer shows each slot's stardust, buildings, achievements, last-saved; hover to preview) --- css/game.css | 25 +++++++++++++++++ dev-journal.md | 27 ++++++++++++++++++ index.html | 2 ++ js/game.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ js/ui.js | 46 ++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+) diff --git a/css/game.css b/css/game.css index 58d2566..be42713 100644 --- a/css/game.css +++ b/css/game.css @@ -565,6 +565,31 @@ h2, h3 { opacity: 0.5; } +/* Live one-line preview of the active/hovered save slot in the footer */ +.slot-preview { + color: var(--text-secondary); + font-size: 0.78rem; + font-family: monospace; + white-space: nowrap; + max-width: 320px; + overflow: hidden; + text-overflow: ellipsis; + opacity: 0.85; + transition: opacity 0.15s ease, color 0.15s ease; +} + +.slot-preview.empty { + color: var(--text-muted); + font-style: italic; + opacity: 0.6; +} + +#game-footer:hover .slot-preview, +.slot-preview:not(.empty):hover { + opacity: 1; + color: var(--accent-purple); +} + /* Autosave toggle button */ .toggle-btn { background: var(--bg-card); diff --git a/dev-journal.md b/dev-journal.md index 46021b0..df24934 100644 --- a/dev-journal.md +++ b/dev-journal.md @@ -359,3 +359,30 @@ Headless test at /opt/data/idle-game-test/golden-bloom-test.mjs — **22/22 pass - Consider adding "Buy Max" to upgrades too. - Potential new building tiers or prestige milestones. - Sound variations or background music. + +--- + +### Session 13 - 2026-08-23 (Morning) +**Status:** ✅ Save Slot Preview Added + +#### What was done: +- Followed up on Session 12's stated next goal by adding a **save-slot preview** so players can tell their save slots apart at a glance. +- Added `Game.getSlotPreview(slot)` — a read-only helper that reads a given slot's data from localStorage WITHOUT mutating the live game state. It returns: `present` (has any saved data), `stardust`, `totalStardust`, `buildings` (sum of all building counts), `achievements` [count/total], `prestigeCount`, and a human-readable `lastSaved` "time ago" string. +- Added `Game.formatTimeAgo(secs)` — formats a second-count into compact relative labels ("just now", "1m ago", "3h ago", "2d ago", "7mo ago", etc.). +- Wired the preview into the footer: a monospace `.slot-preview` span now shows the active slot's live summary every tick (`Slot N: 1.2K ✨ · 8 plants · 2/33 · just now`). Hovering any slot button swaps the preview to that slot's contents; leaving falls back to the active slot. +- Added CSS for `.slot-preview` (monospace, ellipsis-truncated, dims until hover) and a `.empty` style for unreadable slots ("Slot N: empty"). +- All display logic is read-only — `getSlotPreview()` calls the existing `loadSlot()` and never touches `Game.state`, verified by a dedicated test. + +#### Files modified: +- `js/game.js` - added `getSlotPreview(slot)` + `formatTimeAgo(secs)` methods (inserted before `switchSlot()`) +- `index.html` - added `` inside the footer Slot section +- `js/ui.js` - added `updateSlotPreview()`; called it from `UI.update()` each tick and wired per-slot hover/leave listeners (re-cloning slot buttons each render to avoid duplicate listeners) +- `css/game.css` - `.slot-preview`, `.slot-preview.empty`, and hover-brightening rules + +#### Verification: +Wrote a headless Node.js test (`/opt/data/idle-game-test/slot-preview-test.mjs`) evaluating the real game.js in-process with localStorage + UI stubs. **22/22 checks pass**, covering: empty-slot handling (present:false, zeroed), populated-slot field reads (stardust, totalStardust, summed buildings, achievement count/total, prestigeCount), formatTimeAgo buckets (just now / m / h / d), relative lastSaved strings, read-only guarantee (live state unchanged after previews), and graceful handling of malformed/missing fields (minimal object → present:true zeroed; non-numeric building count coerced to 0 with no crash). Existing golden-bloom test re-ran clean (22/22, no regression). All modified JS files pass `node --check`. + +#### Next goals: +- Consider adding a "Buy Max" button to upgrades too (one-time purchases — less critical). +- Potential new building tiers or prestige milestones. +- Sound variations or background music. diff --git a/index.html b/index.html index 4355eba..44fe786 100644 --- a/index.html +++ b/index.html @@ -108,6 +108,8 @@ + +