Commit graph

3 commits

Author SHA1 Message Date
Forrest
fa7f67fe04 Task #16: per-player pouch in co-op
Each scarecrow carries its own pouch (ResourceStore.pouches by avatar
slot; slot 0 is the solo player / host, `pouch` stays slot 0's), with one
shared pouch_capacity so a Bigger pouch grows both. The shed stays shared.

- Gathering, the shed drop-off, repair, upgrade-in-place, patching,
  building and buying all act on the acting avatar's slot. The host pays
  the partner's "place" and "buy" requests from P2's pouch and the shed.
- The partner's build mode, build hotbar, shop menus and materials HUD
  check affordability against P2's pouch (FarmSim.set_local).
- Alien Goop goes to the killer's pouch: FarmSim sets
  EnemySystem.attacker around each avatar's combat step and shots carry
  their shooter's slot; bomb/turret kills go to the nearest scarecrow.
  The replica no longer rolls goop locally.
- When the partner leaves, their pouch goes into the shed (and is named
  in the toast); a co-op save continued alone banks P2's pouch at morning.
- FarmState.VERSION 7 (resources.partner_pouch) with a v6 migration;
  CoopSession.PROTOCOL 4.
- Tests: per-slot store rules, v6 save migration, and test_coop cases for
  separate gathering, no cross-banking in the shed, own-pouch paying,
  shared capacity, goop credit and leaving. test_coop's crowd case now
  resets the loopback's drop counter so earlier traffic can't change
  which messages it loses.
- Docs: COOP.md and RULES.md no longer say the pouch is shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 13:06:25 -04:00
Forrest
1ab666e5e4 Task #4: Alien Goop resource and drop-on-kill from Aliens
Add alien_goop as a 4th ResourceStore material alongside wood/scrap/straw,
dropped only by killed Aliens (TYPE_THIEF) at a config-tunable rate/quantity
(GameConfig.alien_goop_drop_chance default 0.33, alien_goop_drop_qty default
1), credited straight into the pouch like a gathered material via a new
enemy_removed hook in FarmSim (seeded RNG for reproducible trials). It's
stealable from the shed through the existing most-stocked-material sack
mechanic once it outranks the others (ShedStock gets a placeholder front/
label spot for it, reusing the wood pile's proven-walkable spot; no new art).

ResourceStore.from_dict() now treats a shed/pouch entry missing a material
as 0 instead of rejecting it (old saves predate Alien Goop), and to_dict()
always fills in every material so round-trips are consistent regardless of
how the live dict was built; every method summing across MATERIALS reads
with get(m, 0) so a hand-built 3-key dict elsewhere doesn't error out.

New checks in test_economy.gd: _goop_persistence (retry discards goop
gained since the morning; the morning snapshot round-trips through JSON)
and _goop_drops (1000-kill statistical drop-rate check against config,
type restriction to Aliens only, pouch-capacity-respecting credit, and
shed-theft eligibility). Updated _state()'s and test_cycle.gd's hardcoded
3-key shed dicts for the new 4th material.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 14:23:22 -04:00
Forrest
4298caf5cb updates 2026-10-04 12:07:36 -04:00