diff --git a/css/game.css b/css/game.css index be42713..dc3faba 100644 --- a/css/game.css +++ b/css/game.css @@ -327,6 +327,42 @@ h2, h3 { opacity: 0.4; } +/* Upgrades header + Buy All button */ +.upgrades-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; +} + +.upgrades-header h3 { + margin: 0; +} + +.buy-all-btn { + background: var(--accent-gold); + color: var(--bg-primary, #1a1035); + border: none; + border-radius: 6px; + padding: 6px 14px; + cursor: pointer; + font-weight: bold; + font-size: 0.8rem; + transition: all 0.2s ease; +} + +.buy-all-btn:hover:not(:disabled) { + background: #f1c40f; + transform: scale(1.03); +} + +.buy-all-btn:disabled { + background: var(--text-muted); + color: var(--bg-primary, #1a1035); + cursor: not-allowed; + opacity: 0.4; +} + /* Side Panel Tabs */ .tabs { display: flex; diff --git a/dev-journal.md b/dev-journal.md index f54de9b..53339de 100644 --- a/dev-journal.md +++ b/dev-journal.md @@ -386,3 +386,31 @@ Wrote a headless Node.js test (`/opt/data/idle-game-test/slot-preview-test.mjs`) - 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. + +--- + +### Session 14 - 2026-08-24 (Morning) +**Status:** ✅ Buy All Upgrades (Bulk-Buy for Upgrades) Added + +#### What was done: +- Followed up on Sessions 10, 11, and 13's recurring "next goal" by adding a **Buy All** button to the Upgrades tab. Previously one-time upgrades could only be purchased individually (one click each), which was tedious once dozens were available — buildings already had a Buy Max bulk-buy from Session 10, but upgrades did not. +- Added `Game.buyAllUpgrades()` which loops through every upgrade in `UPGRADES`, skips owned ones, respects each upgrade's `requirements` (building-count gates), and buys everything affordable at once. It runs until a full pass purchases nothing (so buying one upgrade can unlock affordability for another via the stardust re-check), then returns `{ bought: count, ids: [...] }`. +- Wired a **Buy All** button into the Upgrades tab header in `index.html` (`#buy-all-upgrades`). +- Added `UI.updateBuyAllButton()` (called from `UI.updateUpgrades()` each tick) which shows/hides the button based on whether any unowned, requirement-met upgrade is currently affordable, and toggles its disabled state live. +- Added CSS for `.upgrades-header` (flex layout) and `.buy-all-btn` (gold accent theme matching existing buttons, hover scale, disabled state). +- Fixed a latent bug found during testing: the empty-slot branch of `Game.switchSlot()` did not reset `state.productionBoostUntil`, which could leave a stale golden-bloom boost active after switching to a fresh slot. Added `productionBoostUntil: 0` to that branch for symmetry with `reset()`. + +#### Files modified: +- `js/game.js` - added `buyAllUpgrades()` method; wired Buy All button click listener in setupEventListeners(); fixed empty-slot productionBoostUntil reset in switchSlot() +- `js/ui.js` - added `updateBuyAllButton()`; called it from `updateUpgrades()` each tick +- `index.html` - added Buy All button to Upgrades tab header +- `css/game.css` - `.upgrades-header`, `.buy-all-btn` styles +- `dev-journal.md` - appended Session 14 entry + +#### Verification: +Wrote a headless Node.js test (`/opt/data/idle-game-test/buy-all-upgrades-test.mjs`) evaluating the real game.js and ui.js in-process with DOM/audio/particle stubs. **24/24 checks pass**, covering: no-op when nothing affordable, bulk purchase with requirement gating (blocks unmet requirements), chained affordability across loop passes, idempotent second call, already-owned upgrade skipping, notification-on-purchase vs silence on no-op, and the real `UI.updateBuyAllButton()` show/hide/enabled state against actual BUILDINGS/UPGRADES data. Existing buy-max (6/6) and golden-bloom (22/22) tests re-ran clean — no regressions. All modified JS files pass `node --check`. + +#### Next goals: +- Consider adding a "Buy Max" button to the prestige upgrades list as well. +- Potential new building tiers or prestige milestones. +- Sound variations or background music. diff --git a/index.html b/index.html index 44fe786..e7ba9dc 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,10 @@