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

@ -541,9 +541,9 @@ func _do_request(r: Array) -> void:
var id := String(r[1])
if Upgrades.shop_of(c.config, id) == "workbench" and (sim.structures == null or not sim.structures.workbench_available()):
return
var was := Upgrades.owned(c.state, id)
var was := Upgrades.level(c.state, id)
Upgrades.buy(c, id, sim.structures, a.slot) # paid from P2's pouch, then the shed
if not was and Upgrades.owned(c.state, id):
if Upgrades.level(c.state, id) > was:
_events.append(["bought", a.slot, id]) # the buyer's game: a new weapon into its hand

View file

@ -110,7 +110,7 @@ extends Resource
@export_range(0, 999) var start_straw: int = 4
@export_range(0, 999) var start_alien_goop: int = 0
## The scarecrow's pouch holds this many units in total; it empties into the shed on entry.
## Raised to 16 by the Bigger pouch upgrade (Upgrades, "pouch_capacity").
## Raised by each level of the Bigger pouch upgrade (Upgrades, "pouch_capacity").
@export_range(1, 200) var pouch_capacity: int = 8
## Seconds of holding interact per gather (each takes one charge of the gather point).
@export var gather_time: float = 1.5
@ -141,32 +141,59 @@ extends Resource
}
@export_group("Upgrades")
## Bought once each by day, for costs[id] (Upgrades), either at the work area's workbench (the
## default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
## items, Upgrades.shop_of, UpgradePanel's shop filter). Each changes one stat: "mult" multiplies
## it, "add" adds to it. Stats are GameConfig settings, plus scarecrow_max_hp (the scarecrow's, in
## FarmState) and barrier_hp (fences' and gates' health). One without a stat unlocks something
## instead (sprint: PlayerCharacter; the corn shooter and pumpkin bombs: ScarecrowCombat).
## "requires": another upgrade that must be bought first (from either shop).
## What the two shops sell (Upgrades), by day, for costs[id]: either the work area's workbench
## (the default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
## items, Upgrades.shop_of, UpgradePanel's shop filter). The keys:
## "name", "track" (the menu's heading), "text": what it does.
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
## unlocks something instead (sprint: PlayerCharacter; the weapons: ScarecrowCombat; radar:
## RadarHud).
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
## with one entry per level. Each owned level's entry applies in turn, so they stack.
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
## upgrade_cost_growth^(L - 1) and opens on day upgrade_level_days[L - 1] (or its own
## "level_days": [day, ...]).
## "texts": one description per level, shown instead of "text" (the menu shows the next one).
## "from_day": the day it arrives in stock, before which it can't be bought (1 by default).
## Day N is the day before night N (FarmState.night).
## "requires": another upgrade that must be bought first (from either shop).
## "hidden", "reveal_goop": see hidden_reveal_goop below.
@export var upgrades: Dictionary = {
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed"},
"rapid_fire": {"name": "Rapid fire", "text": "The corn shooter fires a third faster", "track": "Weapon", "stat": "fire_rate", "mult": 1.333, "requires": "corn_shooter"},
"heavy_seeds": {"name": "Heavy seeds", "text": "Each kernel does 2 damage", "track": "Weapon", "stat": "shot_damage", "add": 1, "requires": "corn_shooter"},
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed"},
"potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed"},
"shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed"},
"propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed"},
"alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true},
"radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true},
"wide_fear": {"name": "Wide fear", "text": "Fear reaches 30% farther", "track": "Fear", "stat": "fear_radius", "mult": 1.3},
"quick_fear": {"name": "Quick fear", "text": "Fear recharges 20% faster", "track": "Fear", "stat": "fear_cooldown", "mult": 0.8},
"straw_stuffing": {"name": "Straw stuffing", "text": "+2 max health", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": 2},
"pouch_upgrade": {"name": "Bigger pouch", "text": "+8 pouch capacity (16 total)", "track": "Scarecrow", "stat": "pouch_capacity", "add": 8},
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed", "from_day": 1},
"rapid_fire": {"name": "Rapid fire", "track": "Weapon", "stat": "fire_rate", "mult": [1.333, 1.25, 1.25], "levels": 3, "requires": "corn_shooter",
"texts": ["The corn shooter fires a third faster", "The corn shooter fires another 25% faster", "The corn shooter fires 25% faster again"]},
"heavy_seeds": {"name": "Heavy seeds", "track": "Weapon", "stat": "shot_damage", "add": [1, 1, 1], "levels": 3, "requires": "corn_shooter",
"texts": ["Each kernel does 2 damage", "Each kernel does 3 damage", "Each kernel does 4 damage"]},
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed", "from_day": 3},
"potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed", "from_day": 6},
"shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed", "from_day": 2},
"propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed", "from_day": 10},
"alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true, "from_day": 14},
"radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true, "from_day": 8},
"wide_fear": {"name": "Wide fear", "track": "Fear", "stat": "fear_radius", "mult": [1.3, 1.15, 1.15], "levels": 3,
"texts": ["Fear reaches 30% farther", "Fear reaches another 15% farther", "Fear reaches 15% farther again"]},
"quick_fear": {"name": "Quick fear", "track": "Fear", "stat": "fear_cooldown", "mult": [0.8, 0.9, 0.9], "levels": 3,
"texts": ["Fear recharges 20% faster", "Fear recharges another 10% faster", "Fear recharges 10% faster again"]},
"straw_stuffing": {"name": "Straw stuffing", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": [2, 2, 2], "levels": 3,
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
"reinforced_fences": {"name": "Reinforced fences", "text": "Fences and gates +50% health", "track": "Defenses", "stat": "barrier_hp", "mult": 1.5},
"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},
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
"texts": ["Turrets reach 30% farther", "Turrets reach another 15% farther", "Turrets reach 15% farther again"]},
"sticky_tar": {"name": "Sticky tar", "track": "Defenses", "stat": "trap_slow_time", "mult": [1.5, 1.25, 1.25], "levels": 3,
"texts": ["Tar patches hold 50% longer", "Tar patches hold another 25% longer", "Tar patches hold 25% longer again"]},
}
## Each further level of an upgrade with "levels" costs this many times the one before: level L
## costs costs[id] x upgrade_cost_growth^(L - 1), each material rounded up (Upgrades.cost).
@export_range(1.0, 5.0, 0.05) var upgrade_cost_growth: float = 1.8
## The day each level of an upgrade with "levels" can first be bought: level L from day
## upgrade_level_days[L - 1] (the last entry for any level past its end). An upgrade's own
## "level_days" overrides it. Day N is the day before night N.
@export var upgrade_level_days: Array[int] = [1, 8, 16]
## 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

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)

View file

@ -1,32 +1,115 @@
class_name Upgrades
extends RefCounted
## The farm's upgrades and shop items (definitions in GameConfig.upgrades, costs in
## GameConfig.costs): bought once each, by day, at one of two shops (shop_of, "workbench" by
## default: player/weapon stat and buildable upgrades, at the work area; "shed": weapons and
## other purchasable items, at the supply shed's counter), each its own UpgradePanel instance.
## Bought ones are kept in FarmState.upgrades (id -> 1), so they carry over between nights and
## come back with a retry. Systems ask value() for a stat with the owned upgrades applied instead
## of reading GameConfig directly: the corn shooter's fire rate and shot damage, fear's radius and
## cooldown, fences' and gates' health (barrier_hp), the automated defense's range, and the traps'
## slow time. Straw stuffing raises the scarecrow's max health (FarmState) when bought, and the
## Bigger pouch upgrade raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch
## grows) the same way. The buyer pays from their own pouch and the shed (slot). Sprint, the corn
## shooter, and pumpkin bombs change no stat: owning them unlocks sprinting (PlayerCharacter) and
## the two weapons (ScarecrowCombat). Rapid fire and heavy seeds (bought at the workbench) need
## the corn shooter (bought at the shed) first ("requires" crosses shops freely).
## GameConfig.costs), bought by day at one of two shops (shop_of, "workbench" by default:
## player/weapon stat and buildable upgrades, at the work area; "shed": weapons and other
## purchasable items, at the supply shed's counter), each its own UpgradePanel instance. Most are
## bought once; the workbench's stat upgrades have levels ("levels", #26): each buy() takes one to
## the next level, which costs upgrade_cost_growth times the one before (cost()) and opens on a
## later day (upgrade_level_days, level_day()), and each owned level's effect stacks. Shed items
## arrive in stock on set days ("from_day"). Bought ones are kept in FarmState.upgrades
## (id -> level), so they carry over between nights and come back with a retry. Systems ask
## value() for a stat with the owned upgrades applied instead of reading GameConfig directly: the
## corn shooter's fire rate and shot damage, fear's radius and cooldown, fences' and gates' health
## (barrier_hp), the automated defense's range, and the traps' slow time. Straw stuffing raises
## the scarecrow's max health (FarmState) when a level is bought, and the Bigger pouch upgrade
## raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch grows) the same way. The
## buyer pays from their own pouch and the shed (slot). Sprint, the weapons, and radar change no
## stat: owning them (owned(): level 1 or more) unlocks sprinting (PlayerCharacter), the weapons
## (ScarecrowCombat), and the minimap (RadarHud). Rapid fire and heavy seeds (bought at the
## workbench) need the corn shooter (bought at the shed) first ("requires" crosses shops freely).
## Menu order, grouped by track.
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "potato_cannon", "shurikens",
"propane_torch", "alien_ray", "radar", "wide_fear", "quick_fear",
"straw_stuffing", "pouch_upgrade", "sprint", "reinforced_fences", "long_range", "sticky_tar"]
const ROMAN: Array[String] = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]
## The level of an upgrade the farm owns (0: not bought).
static func level(state: FarmState, id: String) -> int:
return int(state.upgrades.get(id, 0)) if state != null else 0
## Owned at any level (level 1 or more): what "requires" and the unlocks (sprint, the weapons,
## radar) ask.
static func owned(state: FarmState, id: String) -> bool:
return int(state.upgrades.get(id, 0)) > 0
return level(state, id) > 0
static func cost(cfg: GameConfig, id: String) -> Dictionary:
return cfg.costs.get(id, {})
## How many levels an upgrade has (its "levels", 1 by default).
static func max_level(cfg: GameConfig, id: String) -> int:
return maxi(1, int(cfg.upgrades.get(id, {}).get("levels", 1)))
## Bought to its last level.
static func maxed(cfg: GameConfig, state: FarmState, id: String) -> bool:
return level(state, id) >= max_level(cfg, id)
## What buying this level costs: costs[id] for level 1, and upgrade_cost_growth times as much
## for each level after it (costs[id] x growth^(level - 1)), each material rounded up.
## next_cost() is the one the farm would buy now.
static func cost(cfg: GameConfig, id: String, lvl: int = 1) -> Dictionary:
var base: Dictionary = cfg.costs.get(id, {})
if lvl <= 1:
return base
var k := pow(cfg.upgrade_cost_growth, lvl - 1)
var out := {}
for m in base:
out[m] = ceili(int(base[m]) * k - 0.0001) # (25 x 1.8^2 is 81.00000000000001)
return out
static func next_cost(cfg: GameConfig, state: FarmState, id: String) -> Dictionary:
return cost(cfg, id, level(state, id) + 1)
## One level's entry of a per-level definition key ("mult", "add"): a number is the same every
## level; an Array has one entry per level (its last entry repeats past its end).
static func per_level(entry: Variant, lvl: int, fallback: float = 0.0) -> float:
if entry is Array:
var a: Array = entry
return float(a[clampi(lvl - 1, 0, a.size() - 1)]) if not a.is_empty() else fallback
return float(entry) if entry != null else fallback
## What a level does: its "texts" entry, else the one "text".
static func text_at(cfg: GameConfig, id: String, lvl: int) -> String:
var u: Dictionary = cfg.upgrades.get(id, {})
var texts: Array = u.get("texts", [])
if not texts.is_empty():
return String(texts[clampi(lvl - 1, 0, texts.size() - 1)])
return String(u.get("text", ""))
## Its name at a level: "Rapid fire II" (no numeral on an upgrade with a single level).
static func name_at(cfg: GameConfig, id: String, lvl: int) -> String:
var n := String(cfg.upgrades.get(id, {}).get("name", id))
return n if max_level(cfg, id) <= 1 else "%s %s" % [n, roman(lvl)]
static func roman(n: int) -> String:
return ROMAN[n] if n >= 0 and n < ROMAN.size() else str(n)
## The day a shop item arrives in stock (its "from_day", 1 by default). Day N is the day before
## night N (FarmState.night).
static func from_day(cfg: GameConfig, id: String) -> int:
return int(cfg.upgrades.get(id, {}).get("from_day", 1))
## The day a level can first be bought: upgrade_level_days[level - 1] (the last entry for any
## level past its end), or the upgrade's own "level_days". Level 1 also waits for from_day.
static func level_day(cfg: GameConfig, id: String, lvl: int) -> int:
var days: Array = cfg.upgrades.get(id, {}).get("level_days", cfg.upgrade_level_days)
var day := int(days[clampi(lvl - 1, 0, days.size() - 1)]) if not days.is_empty() else 1
return maxi(day, from_day(cfg, id)) if lvl <= 1 else day
## Whether a shop item has arrived by this farm's day (from_day).
static func arrived(state: FarmState, cfg: GameConfig, id: String) -> bool:
return state != null and state.night >= level_day(cfg, id, 1)
## Which shop sells an upgrade: "workbench" (the default: player/weapon stat and buildable
@ -58,45 +141,52 @@ static func revealed(state: FarmState, cfg: GameConfig, id: String) -> bool:
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).
## A stat with every owned upgrade applied, each of its owned levels in turn (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))
if state == null:
return v
for id: String in cfg.upgrades:
var u: Dictionary = cfg.upgrades[id]
if String(u.get("stat", "")) != stat or not owned(state, id):
if String(u.get("stat", "")) != stat:
continue
if u.has("mult"):
v *= float(u["mult"])
if u.has("add"):
v += float(u["add"])
for lvl in range(1, mini(level(state, id), max_level(cfg, id)) + 1):
if u.has("mult"):
v *= per_level(u["mult"], lvl, 1.0)
if u.has("add"):
v += per_level(u["add"], lvl, 0.0)
return v
## Why an upgrade can't be bought right now ("" if it can), by the scarecrow in this avatar slot
## (its pouch and the shed pay).
## Why an upgrade's next level can't be bought right now ("" if it can), by the scarecrow in this
## avatar slot (its pouch and the shed pay).
static func blocker(campaign: CampaignController, id: String, slot: int = 0) -> String:
var cfg := campaign.config
var s := campaign.state
if not cfg.upgrades.has(id):
return "No such upgrade"
if owned(s, id):
var next := level(s, id) + 1
if next > max_level(cfg, id):
return "Done"
if next == 1 and not arrived(s, cfg, id):
return "Arrives on day %d" % level_day(cfg, id, 1)
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()
if next > 1 and s.night < level_day(cfg, id, next):
return "Level %d opens on day %d" % [next, level_day(cfg, id, next)]
if not campaign.is_daytime():
return "The work area is for daytime"
if not s.resources.can_afford(cost(cfg, id), slot):
return "Need %s more" % ResourceStore.describe(s.resources.missing(cost(cfg, id), slot))
if not s.resources.can_afford(cost(cfg, id, next), slot):
return "Need %s more" % ResourceStore.describe(s.resources.missing(cost(cfg, id, next), slot))
return ""
## Buys an upgrade if it can be bought, paid by the scarecrow in this avatar slot (its pouch,
## then the shed). Returns the message for the player.
## Buys an upgrade's next level if it can be bought, paid by the scarecrow in this avatar slot
## (its pouch, then the shed). Returns the message for the player.
static func buy(campaign: CampaignController, id: String, structures: StructureSystem = null, slot: int = 0) -> String:
var cfg := campaign.config
var s := campaign.state
@ -104,16 +194,18 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS
var why := blocker(campaign, id, slot)
if why != "":
return "%s: %s" % [u.get("name", id), why.to_lower() if why != "Done" else "already done"]
var lvl := level(s, id) + 1
var add := roundi(per_level(u.get("add", 0), lvl))
var barrier_before := value(cfg, s, "barrier_hp")
s.pay(cost(cfg, id), slot)
s.upgrades[id] = 1
s.record_event("upgrades_bought")
s.pay(cost(cfg, id, lvl), slot)
s.upgrades[id] = lvl
s.record_event("upgrades_bought") # every level counts
match String(u.get("stat", "")):
"scarecrow_max_hp": # both scarecrows'
s.scarecrow_max_hp += int(u.get("add", 0))
s.scarecrow_hp += int(u.get("add", 0))
s.partner_max_hp += int(u.get("add", 0))
s.partner_hp += int(u.get("add", 0))
s.scarecrow_max_hp += add
s.scarecrow_hp += add
s.partner_max_hp += add
s.partner_hp += add
"barrier_hp":
# Standing fences and gates keep their share of health.
var k := value(cfg, s, "barrier_hp") / barrier_before
@ -121,5 +213,5 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS
if e["type"] == "fence" or e["type"] == "gate":
e["hp"] = mini(roundi(int(e["hp"]) * k), structures.max_hp(e["type"]) if structures != null else 1 << 20)
"pouch_capacity": # the live value lives in ResourceStore (one for every pouch), not read from cfg each time
s.resources.pouch_capacity += int(u.get("add", 0))
return "%s done: %s" % [u.get("name", id), String(u.get("text", "")).to_lower()]
s.resources.pouch_capacity += add
return "%s done: %s" % [name_at(cfg, id, lvl), text_at(cfg, id, lvl).to_lower()]