Session 10: Buy Max bulk-buy feature for buildings
This commit is contained in:
+27
-1
@@ -266,5 +266,31 @@ firstPrestige achievement, save/load round-trip preserving essence.
|
||||
(Requires `pip install py_mini_racer`.)
|
||||
|
||||
#### Next goals:
|
||||
- Achievement progress tracking in stats panel
|
||||
- Consider adding a "next essence at X stardust" progress hint
|
||||
|
||||
---
|
||||
|
||||
### Session 10 - 2026-08-22 (Morning)
|
||||
**Status:** ✅ Buy Max (Bulk-Buy) Feature Added
|
||||
|
||||
#### What was done:
|
||||
- Added a "Buy Max" bulk-buy mechanic — a staple of idle/clicker games that was previously missing (you could only buy one building at a time, forcing many tedious clicks).
|
||||
- Added `Game.getMaxAffordable(buildingId)` which computes how many of a given building the player can afford right now using an iterative cost-scaling loop. It is read-only and does not mutate state.
|
||||
- Added `Game.buyMaxBuilding(buildingId)` which loops buying one at a time until unaffordable, deducting the correct total stardust and incrementing counts properly (respects prestige costReduction upgrades since it reuses `getBuildingCost`).
|
||||
- Wired a "Buy Max" button onto every building card in `UI.renderBuildings()` with an affordable-count badge (e.g. "5x Max").
|
||||
- Updated `UI.updateBuildings()` so the Buy Max badge refreshes its count and enabled/disabled state every game tick, keeping it accurate as stardust accrues.
|
||||
- Added CSS styling for `.buy-max-btn` (purple theme, hover scale, disabled state) to match existing building-card layout.
|
||||
|
||||
#### Files modified:
|
||||
- `js/game.js` - added getMaxAffordable() and buyMaxBuilding() methods
|
||||
- `js/ui.js` - rendered Buy Max button per building card + tick refresh in updateBuildings()
|
||||
- `css/game.css` - .buy-max-btn styles
|
||||
- `dev-journal.md` - appended Session 10 entry
|
||||
|
||||
#### Verification:
|
||||
Wrote a headless Node.js test (`/opt/data/idle-game-test/buy-max-test.mjs`, lives OUTSIDE the repo). Evaluated the real game.js in-process with DOM/UI stubs. 6/6 checks pass: getMaxAffordable matches manual cost-scaling calc, buyMax deducts correct stardust and increments counts correctly, unaffordable purchase returns 0, getMaxAffordable is idempotent, and notifications fire on purchase.
|
||||
|
||||
#### Next goals:
|
||||
- Consider adding "Buy Max" to upgrades too (upgrades are one-time so less critical, but a bulk "buy all affordable" could be nice).
|
||||
- Potential new building tiers or prestige milestones.
|
||||
- Sound variations or background music.
|
||||
|
||||
Reference in New Issue
Block a user