From d0bb1f4433164bc2f7805b62dd013873ac2cd068 Mon Sep 17 00:00:00 2001 From: Forrest Date: Mon, 5 Oct 2026 14:50:15 -0400 Subject: [PATCH] Task #3: pouch capacity rework (8 base, 16 upgraded) Base pouch_capacity drops from a flat 16 to 8 (GameConfig). A new "pouch_upgrade" (Bigger pouch, Scarecrow track, wood 10 + straw 8) raises it to 16, bought once at the workbench like straw_stuffing. Upgrades.buy() special-cases "pouch_capacity" the same way it already does scarecrow_max_hp, writing straight to the live ResourceStore value so it carries into the next morning, survives a save, and comes back with a retry. Co-Authored-By: Claude Sonnet 5 --- game/resources/game_config.tres | 11 +++++++++++ game/scripts/game_config.gd | 5 ++++- game/scripts/upgrades.gd | 11 +++++++---- game/tests/test_economy.gd | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/game/resources/game_config.tres b/game/resources/game_config.tres index 51a20e2..ba13671 100644 --- a/game/resources/game_config.tres +++ b/game/resources/game_config.tres @@ -32,6 +32,10 @@ costs = { "patch": { "straw": 2 }, +"pouch_upgrade": { +"straw": 8, +"wood": 10 +}, "pumpkin_bomb": { "scrap": 6, "straw": 12 @@ -91,6 +95,13 @@ upgrades = { "text": "Turrets reach 30% farther", "track": "Defenses" }, +"pouch_upgrade": { +"add": 8, +"name": "Bigger pouch", +"stat": "pouch_capacity", +"text": "+8 pouch capacity (16 total)", +"track": "Scarecrow" +}, "pumpkin_bomb": { "name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", diff --git a/game/scripts/game_config.gd b/game/scripts/game_config.gd index 118e5e4..afa3749 100644 --- a/game/scripts/game_config.gd +++ b/game/scripts/game_config.gd @@ -99,13 +99,15 @@ 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. -@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). @export var gather_time: float = 1.5 ## What things cost: name -> {material: amount}: patching up, the buildables, and the upgrades. @export var costs: Dictionary = { "patch": {"straw": 2}, "straw_stuffing": {"straw": 12, "wood": 4}, + "pouch_upgrade": {"wood": 10, "straw": 8}, "sprint": {"wood": 8, "straw": 6}, "corn_shooter": {"scrap": 10, "wood": 4}, "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}, "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}, "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}, diff --git a/game/scripts/upgrades.gd b/game/scripts/upgrades.gd index 76c5f1a..5e45806 100644 --- a/game/scripts/upgrades.gd +++ b/game/scripts/upgrades.gd @@ -6,13 +6,14 @@ extends RefCounted ## 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. 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 need the corn shooter first ("requires"). +## raises the scarecrow's max health (FarmState) when bought, and the Bigger pouch upgrade raises +## pouch_capacity (ResourceStore) the same way. 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 need the corn shooter first ("requires"). ## Menu order, grouped by track. 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: @@ -104,4 +105,6 @@ static func buy(campaign: CampaignController, id: String, structures: StructureS for e in s.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, 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()] diff --git a/game/tests/test_economy.gd b/game/tests/test_economy.gd index 54f2db0..cdec278 100644 --- a/game/tests/test_economy.gd +++ b/game/tests/test_economy.gd @@ -18,6 +18,7 @@ func run(r: GameTestRunner) -> void: _store(r) _state(r) _goop_persistence(r) + _pouch_upgrade(r) await _hidden_items(r) var farm := (load("res://game/scenes/farm.tscn") as PackedScene).instantiate() as Node3D 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") +## 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 ## "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