Merge task #5: hidden/reveal shop items gated on Alien Goop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
d68d37b40f
4 changed files with 111 additions and 2 deletions
|
|
@ -141,6 +141,12 @@ extends Resource
|
|||
"long_range": {"name": "Long-range defenses", "text": "Turrets reach 30% farther", "track": "Defenses", "stat": "turret_range", "mult": 1.3},
|
||||
"sticky_tar": {"name": "Sticky tar", "text": "Tar patches hold 50% longer", "track": "Defenses", "stat": "trap_slow_time", "mult": 1.5},
|
||||
}
|
||||
## An upgrade with "hidden": true (e.g. Alien Ray, Radar, #7/#8) shows only a "?" (no name, text,
|
||||
## or cost) and can't be bought until the player has collected this much Alien Goop in total
|
||||
## (Upgrades.goop_collected); then it shows and buys normally for its defined cost. Overridable
|
||||
## per item with its own "reveal_goop". 5 is about 15 Alien kills at the default 33% drop chance
|
||||
## (alien_goop_drop_chance) — a few kills in, not instant and not a grind.
|
||||
@export_range(0, 999) var hidden_reveal_goop: int = 5
|
||||
|
||||
@export_group("Assessment")
|
||||
## The final assessment's weight per category (Assessment): the score is the weighted share of
|
||||
|
|
|
|||
|
|
@ -112,6 +112,11 @@ func refresh() -> void:
|
|||
var why := Upgrades.blocker(campaign, id)
|
||||
if Upgrades.owned(s, id):
|
||||
done += 1
|
||||
if not Upgrades.revealed(s, cfg, id):
|
||||
# Hidden: no name, description, or cost until its reveal condition is met.
|
||||
b.text = "?"
|
||||
b.disabled = true
|
||||
continue
|
||||
var price := "Done" if Upgrades.owned(s, id) else ResourceStore.describe(Upgrades.cost(cfg, id))
|
||||
b.text = "%s — %s (%s)" % [u["name"], u["text"], price]
|
||||
if why != "" and why != "Done":
|
||||
|
|
|
|||
|
|
@ -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