Merge task #3: pouch 8 base, Bigger pouch upgrade to 16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-05 14:50:44 -04:00
commit 5b72e830db
4 changed files with 54 additions and 5 deletions

View file

@ -32,6 +32,10 @@ costs = {
"patch": { "patch": {
"straw": 2 "straw": 2
}, },
"pouch_upgrade": {
"straw": 8,
"wood": 10
},
"pumpkin_bomb": { "pumpkin_bomb": {
"scrap": 6, "scrap": 6,
"straw": 12 "straw": 12
@ -91,6 +95,13 @@ upgrades = {
"text": "Turrets reach 30% farther", "text": "Turrets reach 30% farther",
"track": "Defenses" "track": "Defenses"
}, },
"pouch_upgrade": {
"add": 8,
"name": "Bigger pouch",
"stat": "pouch_capacity",
"text": "+8 pouch capacity (16 total)",
"track": "Scarecrow"
},
"pumpkin_bomb": { "pumpkin_bomb": {
"name": "Pumpkin bombs", "name": "Pumpkin bombs",
"text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)",

View file

@ -99,13 +99,15 @@ extends Resource
@export_range(0, 999) var start_straw: int = 4 @export_range(0, 999) var start_straw: int = 4
@export_range(0, 999) var start_alien_goop: int = 0 @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. ## The scarecrow's pouch holds this many units in total; it empties into the shed on entry.
@export_range(1, 200) var pouch_capacity: int = 16 ## Raised to 16 by 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). ## Seconds of holding interact per gather (each takes one charge of the gather point).
@export var gather_time: float = 1.5 @export var gather_time: float = 1.5
## What things cost: name -> {material: amount}: patching up, the buildables, and the upgrades. ## What things cost: name -> {material: amount}: patching up, the buildables, and the upgrades.
@export var costs: Dictionary = { @export var costs: Dictionary = {
"patch": {"straw": 2}, "patch": {"straw": 2},
"straw_stuffing": {"straw": 12, "wood": 4}, "straw_stuffing": {"straw": 12, "wood": 4},
"pouch_upgrade": {"wood": 10, "straw": 8},
"sprint": {"wood": 8, "straw": 6}, "sprint": {"wood": 8, "straw": 6},
"corn_shooter": {"scrap": 10, "wood": 4}, "corn_shooter": {"scrap": 10, "wood": 4},
"pumpkin_bomb": {"straw": 12, "scrap": 6}, "pumpkin_bomb": {"straw": 12, "scrap": 6},
@ -136,6 +138,7 @@ extends Resource
"wide_fear": {"name": "Wide fear", "text": "Fear reaches 30% farther", "track": "Fear", "stat": "fear_radius", "mult": 1.3}, "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}, "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}, "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},
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"}, "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}, "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}, "long_range": {"name": "Long-range defenses", "text": "Turrets reach 30% farther", "track": "Defenses", "stat": "turret_range", "mult": 1.3},

View file

@ -6,13 +6,14 @@ extends RefCounted
## Systems ask value() for a stat with the owned upgrades applied instead of reading GameConfig ## 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' ## 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 ## health (barrier_hp), the automated defense's range, and the traps' slow time. Straw stuffing
## raises the scarecrow's max health (FarmState) when bought. Sprint, the corn shooter, and ## raises the scarecrow's max health (FarmState) when bought, and the Bigger pouch upgrade raises
## pumpkin bombs change no stat: owning them unlocks sprinting (PlayerCharacter) and the two ## pouch_capacity (ResourceStore) the same way. Sprint, the corn shooter, and pumpkin bombs change
## weapons (ScarecrowCombat). Rapid fire and heavy seeds need the corn shooter first ("requires"). ## no stat: owning them unlocks sprinting (PlayerCharacter) and the two weapons (ScarecrowCombat).
## Rapid fire and heavy seeds need the corn shooter first ("requires").
## Menu order, grouped by track. ## Menu order, grouped by track.
const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "wide_fear", "quick_fear", const ORDER: Array[String] = ["corn_shooter", "rapid_fire", "heavy_seeds", "pumpkin_bomb", "wide_fear", "quick_fear",
"straw_stuffing", "sprint", "reinforced_fences", "long_range", "sticky_tar"] "straw_stuffing", "pouch_upgrade", "sprint", "reinforced_fences", "long_range", "sticky_tar"]
static func owned(state: FarmState, id: String) -> bool: static func owned(state: FarmState, id: String) -> bool:
@ -104,4 +105,6 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS
for e in s.structures: for e in s.structures:
if e["type"] == "fence" or e["type"] == "gate": 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) 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, 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()] return "%s done: %s" % [u.get("name", id), String(u.get("text", "")).to_lower()]

View file

@ -18,6 +18,7 @@ func run(r: GameTestRunner) -> void:
_store(r) _store(r)
_state(r) _state(r)
_goop_persistence(r) _goop_persistence(r)
_pouch_upgrade(r)
await _hidden_items(r) await _hidden_items(r)
var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D
r.root.add_child(farm) r.root.add_child(farm)
@ -105,6 +106,37 @@ func _goop_persistence(r: GameTestRunner) -> void:
r.check(back != null and back.resources.shed.get("alien_goop", -1) == 0, "the morning snapshot (what's saved) round-trips Alien Goop through JSON") r.check(back != null and back.resources.shed.get("alien_goop", -1) == 0, "the morning snapshot (what's saved) round-trips Alien Goop through JSON")
## Pouch capacity (#3): a flat 16 is now a base of 8, raised to 16 by the Bigger pouch upgrade
## (bought once at the workbench, like straw_stuffing raises scarecrow_max_hp). The upgrade writes
## straight to the live ResourceStore value (FarmState.create() only seeds it from GameConfig at
## the start of a vacation), so like scarecrow_max_hp it carries into the next morning (FarmState's
## "resources" field round-trips through JSON) and survives a save and a retry from a morning on
## or after the day it was bought.
func _pouch_upgrade(r: GameTestRunner) -> void:
var cfg := (load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig
var c := r.make_campaign(cfg)
var s := c.state
r.check(cfg.pouch_capacity == 8 and s.resources.pouch_capacity == 8, "the pouch starts at the base 8 units")
c.begin_day()
s.resources.shed = cfg.costs["pouch_upgrade"].duplicate()
var msg := Upgrades.buy(c, "pouch_upgrade")
r.check(Upgrades.owned(s, "pouch_upgrade") and msg.contains("done:") and s.resources.pouch_capacity == 16,
"Bigger pouch raises capacity from 8 to 16 (%s)" % msg)
r.check(s.resources.shed_total() == 0, "it costs the configured materials")
r.check(Upgrades.buy(c, "pouch_upgrade").contains("already done"), "it can only be bought once")
# It carries into the next morning (same mechanic as straw_stuffing/scarecrow_max_hp).
while s.phase != P.MORNING:
c.advance_phase()
r.check(s.resources.pouch_capacity == 16, "the bigger pouch carries into the next morning")
var back := FarmState.from_dict(JSON.parse_string(JSON.stringify(s.to_dict())))
r.check(back != null and back.resources.pouch_capacity == 16, "and through a save")
# And a retry from that (later) morning keeps it, same as the upgrades dict itself.
c.begin_day()
c.advance_phase() # DAY -> DUSK
c.advance_phase() # DUSK -> NIGHT
r.check(c.retry_night() and c.state.resources.pouch_capacity == 16, "a retry from that morning keeps the bigger pouch")
## Hidden shop items (#5): an item definition can set "hidden": true (optionally its own ## Hidden shop items (#5): an item definition can set "hidden": true (optionally its own
## "reveal_goop", else GameConfig.hidden_reveal_goop) so the workbench shows only a bare "?" (no ## "reveal_goop", else GameConfig.hidden_reveal_goop) so the workbench shows only a bare "?" (no
## name, text, or cost) and refuses the purchase (blocker()/buy(), so this also covers the co-op ## name, text, or cost) and refuses the purchase (blocker()/buy(), so this also covers the co-op