Session 16: Global 'Buy All Buildings' bulk-buy feature Added
Adds a global Buy All button to the Buildings panel that purchases as many of every building type the player can afford at once, bringing Plants in line with the Upgrades (Buy All) and Prestige (Buy Max) panels. - game.js: Game.buyAllBuildings() loops buyMaxBuilding() per building type - ui.js: UI.updateBuyAllBuildings() shows/hides + enables/disables live each tick - index.html: Buy All button in Buildings panel header (reuses .upgrades-header/.buy-all-btn) - Added headless test buy-all-buildings-test.mjs (31/31 pass); all existing suites green
This commit is contained in:
@@ -442,3 +442,29 @@ Wrote a headless Node.js test (`/opt/data/idle-game-test/prestige-buy-max-test.m
|
||||
- Potential new building tiers or prestige milestones / new prestige upgrades.
|
||||
- Sound variations or background music.
|
||||
- Consider a global "Buy Max" for buildings across all types at once (currently per-building).
|
||||
|
||||
---
|
||||
|
||||
### Session 16 - 2026-08-24 (Afternoon)
|
||||
**Status:** ✅ Global "Buy All Buildings" Bulk-Buy Added
|
||||
|
||||
#### What was done:
|
||||
- Followed up on Sessions 10, 14, and 15's recurring bulk-buy convention by adding a **global "Buy All buildings"** button that purchases as many of *every* building type the player can afford at once — previously you could only Buy Max per individual building card (Session 10), while upgrades got Buy All (Session 14) and prestige upgrades got Buy Max (Session 15). This brings the Plants panel in line with the rest of the game.
|
||||
- Added `Game.buyAllBuildings()` to `js/game.js`. It loops through every entry in `BUILDINGS`, calling the existing read-only-friendly `buyMaxBuilding()` for each, until a full pass purchases nothing (loop kept for symmetry with `buyAllUpgrades` / `buyMaxPrestigeUpgrades` and to stay safe if future buildings gain requirement gates; in practice a single pass suffices since cost-scales independently per type). Returns the total number of buildings purchased. Reuses `buyMaxBuilding`, so it correctly respects per-building cost scaling, prestige costReduction upgrades, purchase notifications, audio, and building-purchase particle effects.
|
||||
- Wired a "Buy All" button into the Buildings panel header in `index.html` (`#buy-all-buildings`, reusing the existing `.upgrades-header` flex layout + `.buy-all-btn` gold theme — no new CSS needed). Added a click listener in `Game.setupEventListeners()`.
|
||||
- Added `UI.updateBuyAllBuildings()` (called from `UI.updateBuildings()` each tick) which shows/hides and enables/disables the button based on whether any unlocked building type is currently affordable — a read-only state check mirroring `UI.updateBuyAllButton()`. Locked buildings (unlockAt not reached, count 0) are skipped so the button only appears once at least one plant is available.
|
||||
- **Bug found & fixed during testing:** the first test run failed because `buyMaxBuilding()` calls `Particles.createBuildingEffect()`, which the initial Particles stub didn't provide — this confirmed the integration point and was added to the stub (not a game bug). A second test asserted the leftover stardust would be < cheapest base cost, which is incorrect under geometric cost scaling (the leftover can exceed a base cost while still being unable to afford the next scaled unit); replaced with the correct end-state invariant that no further single purchase is possible across any building type.
|
||||
|
||||
#### Files modified:
|
||||
- `js/game.js` - added `buyAllBuildings()` method; wired Buy All buildings button click listener in setupEventListeners()
|
||||
- `js/ui.js` - added `updateBuyAllBuildings()`; called it from `updateBuildings()` each tick
|
||||
- `index.html` - added Buy All button to the Buildings panel header (reuses `.upgrades-header` + `.buy-all-btn`)
|
||||
- `dev-journal.md` - appended Session 16 entry
|
||||
|
||||
#### Verification:
|
||||
Wrote a headless Node.js test (`/opt/data/idle-game-test/buy-all-buildings-test.mjs`) that loads the real `game.js` and `ui.js` in-process with DOM/audio/particle stubs and the *real* `BUILDINGS` data. **31/31 checks pass**, covering: no-op when nothing affordable, bulk purchase across every building type matching a hand-computed cost-scaling reference (exact per-type counts + exact stardust depletion), the end-state invariant that no further single purchase is possible, idempotent second call, notification-on-purchase vs silence on no-op, top-up behavior from a mixed starting state (already-own-one case), and the real `UI.updateBuyAllBuildings()` show/hide/enabled/disabled state against actual `BUILDINGS` data. All existing suites re-ran clean with no regressions: buy-max 6/6, golden-bloom 22/22, prestige-buy-max 22/22, slot-preview 22/22, buy-all-upgrades 24/24. All modified JS files pass `node --check`.
|
||||
|
||||
#### Next goals:
|
||||
- Potential new building tiers or prestige milestones / new prestige upgrades.
|
||||
- Sound variations or background music.
|
||||
- Consider a "Buy Max" toggle (buy one-at-a-time vs bulk) or per-building Buy Max count display.
|
||||
|
||||
Reference in New Issue
Block a user