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

@ -1,9 +1,11 @@
class_name ResourceHud
extends Control
## Top-right materials readout: what the supply shed holds, and what the scarecrow carries in
## its pouch (with its capacity). A line flashes when its numbers change.
## Top-right materials readout: what the supply shed holds, and what this machine's scarecrow
## carries in its own pouch (with its capacity). A line flashes when its numbers change.
var campaign: CampaignController
## The avatar slot whose pouch is shown (FarmSim.set_local: the partner's machine shows P2's).
var slot: int = 0
## Set by FarmSim: shows how many structures stand.
var structures: StructureSystem
@ -34,7 +36,8 @@ func _process(delta: float) -> void:
return
var r := campaign.state.resources
var shed := "Shed %s" % _amounts(r.shed)
var pouch := "Pouch %d/%d %s" % [r.pouch_total(), r.pouch_capacity, _amounts(r.pouch) if r.pouch_total() > 0 else "empty"]
var total := r.pouch_total(slot)
var pouch := "Pouch %d/%d %s" % [total, r.pouch_capacity, _amounts(r.pouch_of(slot)) if total > 0 else "empty"]
if shed != _last_shed:
_last_shed = shed
_shed.text = shed