Merge task #26: upgrade tiers and timed shed stock

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	game/scripts/coop_session.gd
This commit is contained in:
Forrest 2026-10-06 16:20:52 -04:00
commit 787b36a1c2
12 changed files with 531 additions and 137 deletions

View file

@ -1,8 +1,10 @@
class_name UpgradePanel
extends CenterContainer
## A shop's menu (Upgrades): one row per upgrade or item sold by this instance's shop (shop,
## Upgrades.shop_of), by track, with what it does and what it costs. A done one says so; one you
## can't afford says what's missing. The work area's instance (shop "workbench": player/weapon
## Upgrades.shop_of), by track, with what its next level does and costs ("Rapid fire II" for one
## with levels). A done one says so ("Max" at the last level); one that can't be bought yet says
## why: what's missing, "Level 2 opens on day 8", or, for a shed item not in stock yet, just its
## name and "Arrives on day 6". The work area's instance (shop "workbench": player/weapon
## stat and buildable upgrades) opens with interact at the workbench by day; the supply shed's
## (shop "shed": weapons and other purchasable items) opens with interact at the shed's counter by
## day (Interactions). Buy with a click, or the arrows / d-pad and Enter / A. Close it with Close,
@ -122,18 +124,25 @@ func refresh() -> void:
var u: Dictionary = cfg.upgrades[id]
var b := _rows[id] as Button
var why := Upgrades.blocker(campaign, id, slot)
if Upgrades.owned(s, id):
var lvl := Upgrades.level(s, id)
var top := Upgrades.max_level(cfg, id)
b.disabled = why != ""
if lvl >= top:
done += 1
b.text = "%s — %s (%s)" % [Upgrades.name_at(cfg, id, top), Upgrades.text_at(cfg, id, top), "Max" if top > 1 else "Done"]
continue
var arrival := "" if Upgrades.arrived(s, cfg, id) else "Arrives on day %d" % Upgrades.level_day(cfg, id, 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
b.text = "?" if arrival == "" else "? %s" % arrival
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":
if arrival != "":
b.text = "%s %s" % [u["name"], arrival] # (greyed: disabled)
continue
b.text = "%s — %s (%s)" % [Upgrades.name_at(cfg, id, lvl + 1), Upgrades.text_at(cfg, id, lvl + 1),
ResourceStore.describe(Upgrades.cost(cfg, id, lvl + 1))]
if why != "":
b.text += " %s" % why
b.disabled = why != ""
var place := "Upgrades at the work area" if shop == "workbench" else "Shop at the supply shed"
_title.text = "%s (%d of %d done)" % [place, done, _rows.size()]
@ -142,9 +151,9 @@ func _buy(id: String) -> void:
if buy_request.is_valid():
buy_request.call(id)
return
var was := Upgrades.owned(campaign.state, id)
var was := Upgrades.level(campaign.state, id)
var text := Upgrades.buy(campaign, id, structures, slot)
if not was and Upgrades.owned(campaign.state, id):
if Upgrades.level(campaign.state, id) > was: # a level went through (every one jingles)
bought.emit(id)
message.emit(text, Color(0.85, 0.75, 1.0) if text.contains("done:") else Color(1.0, 0.8, 0.5))
_after_buy(id)