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>
This commit is contained in:
Forrest 2026-10-06 13:06:25 -04:00
parent 26b735d3e6
commit fa7f67fe04
23 changed files with 535 additions and 138 deletions

View file

@ -57,8 +57,18 @@ a knock alone doesn't open it) and stays open for 0.4 s after you stop. Talking
- your microphone's state.
- **Edge arrow:** when your friend is off screen, an arrow at the edge points to them, with the
distance.
- **Everything is shared:** the shed, the pouch, upgrades, structures, and the vacation itself.
Either player can gather, build, repair, buy upgrades, and start the day.
- **Shared:** the shed, upgrades, structures, and the vacation itself. Either player can gather,
build, repair, buy upgrades, and start the day.
- **Your pouch is your own.** The materials HUD shows yours.
- What you gather goes into your pouch.
- Only you walking into the Supply Shed banks it: your friend standing there doesn't.
- You pay for building, repairs, patching, and upgrades from your own pouch first, then the
shed, never from your friend's pouch.
- An Alien's goop goes into the pouch of the player who killed it. A pumpkin bomb's or a
turret's kill goes to the nearest scarecrow.
- Both pouches hold the same amount: one Bigger pouch makes both bigger.
- When your friend leaves, what they carried goes into the shed. So does player 2's pouch in
a co-op save that the host continues alone.
- **Health is your own.** Upgrades to max health apply to both scarecrows.
- **A scarecrow at 0 HP is out until the morning.** It lies there and the camera follows the
other one. It comes back each morning at half health. **Game Over only when both are down at
@ -128,7 +138,8 @@ message on both sides.
- **`game/tests/test_coop.gd`** (in the main suite) runs host and partner in one process: the
partner's farm sits in its own world, over the loopback link. It covers the join, requests,
the partner moving, gathering, and shooting (and its pick of weapon), the host's stabs and
the partner moving, gathering, and shooting (and its pick of weapon), each player's own pouch
(gathering, the shed, paying, the shared capacity, goop to the killer, leaving), the host's stabs and
pumpkin bombs drawn on the partner's farm (harmless there), enemies, loot, and shots arriving, the fall rule
and Retry, a crowd with dropped packets, message sizes, and either side leaving.
- **`game/tools/coop_smoke.gd`** plays a real GD-Sync LAN game between two processes on one