Task #5: generic hidden/reveal shop item system
An item definition in GameConfig.upgrades can set "hidden": true (optionally its own "reveal_goop", else the new config-tunable hidden_reveal_goop) so the workbench shows only a bare "?" (no name, text, or cost), disabled, until the player has collected that much Alien Goop in total. Upgrades.goop_collected()/revealed() derive this from FarmState.totals() (completed nights) plus night_events (the current cycle), so it persists through save and retry without any new stored state. blocker() and buy() both gate on it (covering the co-op buy-request path too), and UpgradePanel.refresh() shows the "?" row. No real upgrade ships hidden yet; #7/#8 (Alien Ray, Radar) will use this mechanism. Test flags a duplicated long_range/sticky_tar hidden to exercise it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
30e64ebeec
commit
45f3e83e54
4 changed files with 111 additions and 2 deletions
|
|
@ -23,6 +23,27 @@ static func cost(cfg: GameConfig, id: String) -> Dictionary:
|
|||
return cfg.costs.get(id, {})
|
||||
|
||||
|
||||
## Total Alien Goop collected this vacation so far: every completed night's "gathered_alien_goop"
|
||||
## (FarmState.totals(), from night_log) plus the current cycle's own count (night_events). This is
|
||||
## a running total, not a current balance (spending or being robbed of goop doesn't un-reveal
|
||||
## anything), so it's unaffected by the shed/pouch and persists through save (night_log is saved)
|
||||
## and retry (retry restores the morning snapshot, dropping the failed night's own goop).
|
||||
static func goop_collected(state: FarmState) -> int:
|
||||
if state == null:
|
||||
return 0
|
||||
return int(state.totals().get("gathered_alien_goop", 0)) + int(state.night_events.get("gathered_alien_goop", 0))
|
||||
|
||||
|
||||
## Whether a shop item's reveal condition is met (always true unless its definition sets
|
||||
## "hidden": true). A hidden item reveals once goop_collected() reaches its "reveal_goop" (falls
|
||||
## back to GameConfig.hidden_reveal_goop).
|
||||
static func revealed(state: FarmState, cfg: GameConfig, id: String) -> bool:
|
||||
var u: Dictionary = cfg.upgrades.get(id, {})
|
||||
if not bool(u.get("hidden", false)):
|
||||
return true
|
||||
return goop_collected(state) >= int(u.get("reveal_goop", cfg.hidden_reveal_goop))
|
||||
|
||||
|
||||
## A stat with every owned upgrade applied (barrier_hp is a multiplier, 1 without upgrades).
|
||||
static func value(cfg: GameConfig, state: FarmState, stat: String) -> float:
|
||||
var v := 1.0 if stat == "barrier_hp" else float(cfg.get(stat))
|
||||
|
|
@ -47,6 +68,8 @@ static func blocker(campaign: CampaignController, id: String) -> String:
|
|||
return "No such upgrade"
|
||||
if owned(s, id):
|
||||
return "Done"
|
||||
if not revealed(s, cfg, id):
|
||||
return "Not discovered yet"
|
||||
var needs := String(cfg.upgrades[id].get("requires", ""))
|
||||
if needs != "" and not owned(s, needs):
|
||||
return "Needs the %s first" % String(cfg.upgrades.get(needs, {}).get("name", needs)).to_lower()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue