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:
parent
26b735d3e6
commit
fa7f67fe04
23 changed files with 535 additions and 138 deletions
|
|
@ -16,8 +16,8 @@ extends Node3D
|
|||
## into Game Over on the same tick (in co-op only once both have fallen: until then it's out
|
||||
## until the morning). Every new morning, also after a retry, revives it with fear ready.
|
||||
## In co-op there are two kits: slot 0 (player 1) uses FarmState.scarecrow_hp, slot 1 (player 2)
|
||||
## partner_hp. A kit whose remote is set (the partner's, on the host) reads RemoteControls
|
||||
## instead of the local input.
|
||||
## partner_hp, and each patches with straw from its own pouch (and the shed). A kit whose remote
|
||||
## is set (the partner's, on the host) reads RemoteControls instead of the local input.
|
||||
|
||||
signal damaged(hp: int)
|
||||
signal fear_used(position: Vector3, scared: int)
|
||||
|
|
@ -145,10 +145,10 @@ func step_patch(dt: float, held: bool) -> void:
|
|||
if not patching:
|
||||
if hp() >= max_hp() or (interactions != null and interactions.channeling()):
|
||||
return
|
||||
if not s.resources.can_afford(cost):
|
||||
if not s.resources.can_afford(cost, slot):
|
||||
if not _patch_denied: # once per press
|
||||
_patch_denied = true
|
||||
patch_denied.emit(s.resources.missing(cost))
|
||||
patch_denied.emit(s.resources.missing(cost, slot))
|
||||
return
|
||||
patching = true
|
||||
patch_elapsed = 0.0
|
||||
|
|
@ -156,7 +156,7 @@ func step_patch(dt: float, held: bool) -> void:
|
|||
patch_elapsed += dt
|
||||
if patch_elapsed >= config.patch_time:
|
||||
_end_patch()
|
||||
if s.pay(cost):
|
||||
if s.pay(cost, slot):
|
||||
_set_hp(hp() + config.patch_heal)
|
||||
s.record_event("patches")
|
||||
patched.emit(hp())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue