plan: thirty nights + no pop-up lines (#23-#28)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 15:52:02 -04:00
parent dcfc8544b9
commit 6a9575dfe4
2 changed files with 358 additions and 361 deletions

View file

@ -1,9 +1,9 @@
# Harvest Season — post-overhaul fix batch (2026-10-06)
# Harvest Season — thirty nights (2026-10-06)
Status: planned, not started. Seven issues the user found playtesting the alien overhaul
(`docs/tasks.md` #1–#15, all merged by 3e85104). Tasks are numbered **#16–#22** to continue that
list; the user's original item number is in brackets. Root causes were traced in code on
2026-10-06. Line numbers point at decf96b, so re-check them before editing.
Status: planned, not started. The user asked to expand the vacation from 5 nights to 30 and
"scale things accordingly". They also asked to drop the pop-up status lines. Tasks continue the
numbering at **#23–#28** (#1–#22 are merged; the last was dcfc854). Line numbers point at
dcfc854, so re-check them before editing.
## Ground rules for workers
@ -15,419 +15,366 @@ list; the user's original item number is in brackets. Root causes were traced in
afterwards, and judge your task by new FAIL lines only. One suite: `-- --suite=test_x`.
- **Parallel worktrees:** give each headless run its own `XDG_DATA_HOME` so `user://` saves don't
collide.
- **`farm.tscn`:** edit it as text. A headless `ResourceSaver.save()` drops the `uid=` lines; if
you must re-save from a script, restore them the way `game/tools/build_prop_collision.gd` does.
- **`farm.tscn` and `.tres` files:** edit them as text. A headless `ResourceSaver.save()` drops
the `uid=` lines; if you must save from a script, restore them the way
`game/tools/build_prop_collision.gd` does.
- **Co-op:** changing the shape of `state.to_dict()` or the snapshot/event wire format means
bumping `CoopSession.PROTOCOL` (`coop_session.gd:48`, currently 3). Changing the save format
means bumping `FarmState.VERSION` (`farm_state.gd:11`, currently 6) and adding a `migrate` step
bumping `CoopSession.PROTOCOL` (`coop_session.gd:54`, currently 5). Changing the save format
means bumping `FarmState.VERSION` (`farm_state.gd:12`, currently 7) and adding a `migrate` step
in `save_game.gd`. For the two-process check, run `game/tools/coop_smoke.gd` (see
`game/COOP.md`).
- **User tuning:** `game_config.tres` overrides only `costs` and `upgrades`. Its values are the
user's (e.g. Rapid fire's 3.0x), so keep them unless the task says otherwise.
- **No new HUD text:** don't add toast or banner lines for anything (task #23 removes them).
Feedback goes through the menus' own reason text, sound, or world visuals.
- **Graph:** after modifying code, run `graphify update .`.
## Decisions (resolved 2026-10-06)
## Decisions (the user's, 2026-10-06)
1. **Crop fields move onto the south brown soil.** The user chose this over laying soil under
the current spot. The playable map extends south to include them (#20).
2. **Animals roam the whole farm and are never lost on their own.** An animal that leaves an open
pen becomes loose again. An animal is lost only when an Alien carries it off the map. A closed
pen still protects the animals inside it (#21).
1. **30 nights.** `GameConfig.campaign_nights` goes from 5 to 30.
2. **Phase lengths stay as they are:** 180 s day, 30 s dusk, 150 s night, 20 s dawn. A full
vacation is about 3¼ hours. The user turned down shorter days.
3. **Losses stay permanent** (RULES "Losses carry over"). Stolen crops don't regrow and lost
animals don't come back. The user turned down crop regrowth and animal replacement.
4. **Progression stretches with upgrade tiers and timed stock.**
- Workbench upgrades get levels with rising costs and stacking effects.
- Shed items arrive on set days.
5. **No pop-up status lines.** Remove the zone-name banner (`ZoneBanner`) and the whole message
feed (`ToastFeed`), including replies to the player's own actions. The menus already show
their own reasons, such as the upgrade rows' "Need 2 more scrap".
## Defaults (assumed; flip any of these on request)
- **Pouch:** `pouch_capacity` stays shared, so one `pouch_upgrade` purchase grows both pouches.
- Goop from a kill goes to the killer's pouch. Bomb and turret kills credit the nearest avatar.
- When the partner leaves, their pouch is deposited in the shed.
- **Torch band:** about 4.5 m long (measured from the muzzle) and 1.6 m wide. Config-tunable.
- **Alien Ray beam:** about 20 m long. It stops at walls and pierces enemies, hitting each one
along it (capped by config). Damage is applied per tick while fire is held.
- **UFO model:** a flattened saucer built in code from a disc, a dome, a rim ring and small
lights. No imported asset.
- **Crop models:** existing ithappy prefabs from `assets/farm/ithappy/farm/prefabs/assets/plant/`.
- Lettuce/cabbage: `plant_004` / `plant_005` (≈0.45 m heads).
- Corn: `plant_001` (≈2.66 m stalk).
- These were picked by size and palette only. Confirm them in the editor and fall back to
primitives if they don't read right.
**The arc.**
- Nights 1–5 stay the introduction: crows, aliens, robots, both sides, then UFOs.
- Today's night 5 ("The last night") moves to **night 30**. It keeps the user's title, hint, and
180 s length, and its groups grow to the finale's size.
- A new night 5, "Lights in the sky", introduces UFOs.
- Nights 6–29 escalate. Every fifth one (10, 15, 20, 25) is a **siege night**: about 30% heavier,
at the normal 150 s length.
**The nights are generated as editable files.**
- `game/tools/make_nights.gd` writes nights 6–29 as ordinary `NightPlan` .tres files, so each
night stays editable in the inspector.
- It never overwrites a file unless given `--force`.
- Their titles and dusk hints are placeholder drafts for the user to rewrite.
**Pressure.**
- The global `wave_count_scale` of 7 and `wave_spacing_scale` of 0.3 stay.
- The ramp lives in each plan's group counts. Base totals grow from 24 on night 5 to about 61 on
night 29, about 427 arrivals as played. Night 30 is about 72 base, about 500 arrivals.
**Faster, tougher enemies.**
- Each plan gets `enemy_speed_scale` and `enemy_hp_scale` (default 1).
- The generated values start after night 5. Speed rises 1% a night, to 1.25 at night 30. HP rises
2.5% a night, to 1.625 at night 30.
- HP is floored, so a crow stays one hit. Thieves go 3→4, breakers 6→9, and UFOs 2→3.
**Arrivals wait instead of vanishing.** Today a ground arrival is silently skipped when its
type's character pool is full. Now it waits for a free character. Pool sizes move into
`GameConfig`, and #28 decides whether to raise them.
**Tiers.**
- Workbench stat upgrades get 3 levels. Level 1 keeps today's effect and cost.
- Each further level costs `upgrade_cost_growth` (1.8) times the previous one.
- Levels 2 and 3 open on days 8 and 16 (`upgrade_level_days`).
- One-off unlocks stay single: Sprint, the weapons, and Radar.
**Shed stock days.** Corn shooter 1, Shurikens 2, Pumpkin bombs 3, Potato cannon 6, Radar 8,
Propane torch 10, Alien ray 14. Hidden items still need their goop reveal as well.
**Unchanged:**
- Crop fields still sprout after nights 2 and 4.
- The edge-arrow alerts stay (they're not pop-up lines), and so do the first-day tips.
## Tasks
### #16 [1] Per-player pouch in co-op
### #23 [pop-ups] Remove the zone banner and the message feed
**Root cause:** this is by design, not a sync bug: there is exactly one pouch.
- `ResourceStore` keeps a single `pouch` and `pouch_capacity` (`resource_store.gd:13-15`) in the
shared `FarmState.resources` (`farm_state.gd:102`).
- That state is replicated whole to the client (`coop_session.gd:321-328`, applied at `621-638`).
- `game/COOP.md` says "Everything is shared: the shed, the pouch…", and `test_coop.gd:181-182`
asserts the shared pouch.
**What shows them now:**
- `ZoneBanner` (`zone_banner.gd`, node `ZoneBanner` at `farm.tscn:3677`) prints the zone's name at
the top whenever the local scarecrow walks into one.
- `ToastFeed` (`toast_feed.gd`, node `Hud/ToastFeed` at `farm.tscn:3694`, exported to `FarmSim` as
`toasts` at `farm.tscn:3794`) stacks up to 5 lines. They're fed by:
- `farm_sim.gd:328-342`: interactions, upgrade/shed panels, build mode, arrivals, breaches, open
pen, patch;
- `farm_sim.gd:772-777`: outside the fence, sunrise;
- loot events (`toast_feed.gd` `MESSAGES`, wired through `LootSystem.loot_event`);
- `main.gd:102`, `main.gd:370`, `campaign_debug.gd:88`;
- co-op, in `coop_session.gd`:
- `:187`, `:259`, `:509`, `:630`;
- the client's `"toast"` and `"arrived"` event handling at `:700-707`;
- the host's `"toast"` events at `:173`, `:179`, `:549-567`.
Every pouch path goes through `campaign.state.resources`:
- **Gathering:** `interactions.gd:296` (room check) and `:339` (`add_to_pouch`).
- **Deposit:** `interactions.gd:182-185`. A partner idling in the shed instantly banks whatever
the other player gathers.
- **Pouch-first paying:** `resource_store.gd:85-93`, via `FarmState.pay` (`farm_state.gd:222`).
Callers:
- repair, `interactions.gd:226`
- patch, `scarecrow.gd:148`
- structures, `structure_system.gd:243,371,428`
- upgrades, `upgrades.gd:91,105`
- **Goop drop:** `farm_sim.gd:636`.
- **`pouch_upgrade`:** `upgrades.gd:120-121`.
**Change:**
- Delete both nodes from `farm.tscn` (as text) and their `ext_resource` lines.
- Delete `zone_banner.gd` and `toast_feed.gd` with their `.uid` files.
- Remove every `toasts.push` call and the `FarmSim.toasts` export.
- `FarmSim.arrival_message` goes if nothing else uses it.
- `main.gd:350` `_set_hud` lists `"ZoneBanner"`; drop it.
**Approach:**
- **Storage:** the shed stays shared. The pouch becomes one per slot (`pouches[slot]`, where slot
0 is the host or solo player), with one shared `pouch_capacity`.
- **Slot parameter:** `add_to_pouch`, `deposit`, `available`, `missing`, `can_afford` and `pay`
take a `slot` that defaults to 0, so solo callers don't change.
- **Callers pass the acting avatar's slot:**
- `Interactions` uses `kit.slot`.
- The Scarecrow patch uses its own slot.
- The host's `_do_request` uses the requester's slot for "place" and "buy".
- `Upgrades.buy` and `StructureSystem.place` take a slot.
- **Goop:** credit the killer's slot (see Defaults).
- **HUD:** `resource_hud.gd:36-37` shows the local avatar's pouch. Retarget it in
`FarmSim.set_local` (`farm_sim.gd:522`). Also update `review_panel.gd:131` and
`tutorial.gd:122`.
- **Partner leaves:** `remove_partner` (`farm_sim.gd:500`) deposits the partner's pouch into the
shed.
- **Versions:** bump `FarmState.VERSION` 6→7, with a `save_game.gd` `migrate` step that adds an
empty partner pouch. Bump `CoopSession.PROTOCOL` 3→4.
- **Docs:** `game/COOP.md`, `game/RULES.md`.
**Co-op:** stop sending `"toast"` events, and drop the `"arrived"` client handler if it only
toasted. If either changes the event wire format, bump `CoopSession.PROTOCOL`.
**Files:**
- Code: `resource_store.gd`, `farm_state.gd`, `save_game.gd`, `interactions.gd`, `scarecrow.gd`,
`structure_system.gd`, `upgrades.gd`, `farm_sim.gd`, `coop_session.gd`, `resource_hud.gd`,
`review_panel.gd`, `tutorial.gd`
- Docs: `COOP.md`, `RULES.md`
- Tests: `test_coop.gd`, `test_save.gd`, `test_economy.gd`, `test_cycle.gd`, `test_flow.gd`,
`game/tools/soak_night.gd`
**Signals stay:** keep the `message` signals on `Interactions`, `BuildMode`, and `UpgradePanel`
if tests listen to them; otherwise remove them too. `WaveDirector.arrived` stays (audio and
tests use it).
**Acceptance:**
- In `test_coop`:
- P2's gathering fills only P2's pouch.
- P1 standing in the shed doesn't bank P2's pouch.
- Each player pays from their own pouch plus the shed.
- One `pouch_upgrade` raises both capacities.
- In `test_save`, a v6 save migrates.
- Solo behaviour is unchanged, and there are no new FAIL lines.
**Docs:** update the RULES.md sentences that mention the banner or messages (Tutorial / alerts /
co-op sections). Also update `README.md` and `game/COOP.md` where they describe the feed.
### #17 [2] Propane Torch sprays a band of fire
**Verify:**
- The full suite shows no new FAIL lines. `test_farm_layout.gd` references the banner or feed, so
update it.
- `rg -n "toasts|ToastFeed|ZoneBanner" game` finds nothing but history notes.
- `coop_smoke.gd` passes.
**Root cause:** damage works, but there's nothing to see and the hit area is small.
- **Path:** `step()` → `_held(&"fire")` → `attack()` → `_use()` → `_torch_tick()`
(`scarecrow_combat.gd:267,288,383-385,474-479`).
- **Hit test:** `_cone_hit` (`:484-511`) measures `torch_range` 3.5 from the scarecrow's centre.
That reaches only about 2.45 m past the 1.05 m muzzle. It uses a 55° arc, hits at most 5
targets, and deals 1 damage every 0.2 s.
- **Feedback the player gets:**
- A 0.09 s kick on an orange-tinted corn-shooter mesh, replayed on every tick
(`weapon_models.gd:28-29,68,143-150`).
- The pitchfork "stab" sound (`farm_audio.gd:300`).
- The enemy's hurt flash.
- **Test gap:** `test_weapons.gd:357-369` calls `attack_toward()` once. It checks no held fire and
no visual.
### #24 [30] Nights by count, per-night enemy speed and HP
**Approach:**
- **Band hit test:** add `_band_hit` beside `_cone_hit`.
- It projects each enemy onto the aim direction from the muzzle.
- A hit requires `0 ≤ along ≤ torch_range` and `|across| ≤ torch_width/2 + hit radius`.
- Keep the `_clear_line` check.
- **Config:** drop `torch_arc`, add `torch_width`, and lengthen `torch_range` (see Defaults).
- **Flame visual:** a `CPUParticles3D` on the torch pivot, sized to the band (pattern:
`structure_system.gd:809-830`).
- `_use` / `_show_attack` light it, and a short timeout (about 1.5 × `torch_tick_interval`) keeps
it lit. It stays lit while fire is held and goes out on release.
- Stop replaying the kick on every tick.
- **Co-op:** the existing `["attack", slot, w]` events (`coop_session.gd:163`, applied at
`687-693`) light the flame on the partner's screen. No protocol change is needed. For a remote
avatar, take the direction from the model's yaw.
- **Sound:** give the torch its own `burned` signal and sound in `farm_audio.gd`, instead of
`stabbed`.
Code only. `campaign_nights` stays 5 here; #27 flips it to 30 together with the plans.
**Files:** `scarecrow_combat.gd`, `weapon_models.gd` (or a new `torch_flame.gd`),
`game_config.gd` / `game_config.tres`, `farm_audio.gd`, `test_weapons.gd`.
**Plans by count.**
- `FarmSim.NIGHT_PLANS` (`farm_sim.gd:32-36`, loaded at `:244-246`) becomes
`night_plan_path(n)` → `"res://game/resources/nights/night_%d.tres"`, for n in
1..`config.campaign_nights`.
- A missing file is a `push_error`, and the last loaded plan is used, as
`WaveDirector.plan_for` already clamps.
- Update `game/PLAYTEST.md:308`, which names `NIGHT_PLANS`.
**Acceptance (`test_weapons`):**
- An enemy in the band ahead is hit.
- An enemy beside it, outside the width, is not hit.
- An enemy behind is not hit.
- Holding fire over N steps ticks repeatedly and stops on release (use `Input.action_press` as
`test_theft.gd:191-201` does).
- The flame is visible while fire is held and hidden after release.
**Enemy scales.**
- `NightPlan` gets `@export var enemy_speed_scale: float = 1.0` and
`@export var enemy_hp_scale: float = 1.0`. Fix the header comment's "night_1..5".
- At nightfall, `WaveDirector._on_phase_changed` sets tonight's scales on `EnemySystem` (e.g.
`night_speed_scale`, `night_hp_scale`). Debug plans (F2) carry their own (default 1).
- `EnemySystem.spawn` (`enemy_system.gd:261`): `health = maxi(t_hp[t], floori(t_hp[t] * hp_scale))`.
- Steering reads `t_speed[t] * speed_scale` (`:384`, and anywhere else `t_speed` drives
movement). Fleeing and carrying speeds derive from it as now.
- **Check the HP bar.** It must use each enemy's own full HP rather than `t_hp`, on the host and on
a co-op replica. If the replica can't know, store each enemy's max HP or send tonight's scale,
and bump `PROTOCOL` if the wire format changes.
### #18 [3] Alien Ray fires a beam
**Debug night jump** (`campaign_debug.gd`, debug builds, morning review only):
- **F3** moves to the next day's morning and **Shift+F3** to the previous one.
- The farm stays as it is; `nights_survived` follows as `night − 1`.
- Reuse the real "new morning" path, so the following all happen as on a real morning: dormant
crop fields sprout by `nights_survived`, the Workbench grant runs at ≥1, the retry snapshot is
retaken, and the review panel refreshes.
- Don't autosave on a jump.
- Add the keys to the header list. If this needs more than a small change to the morning path,
stop and report rather than restructure it.
**Root cause:** `_shoot_alien_ray` (`scarecrow_combat.gd:448-456`) is a copy of `_shoot_potato`.
It fires one non-piercing projectile through `_shots.fire`, using the shared kernel mesh
(`farm_projectiles.gd:58-62`), every 0.9 s.
- Its description text (`game_config.gd:156`) already says "beam".
- The root `plan.md` "no hitscan" rule was for the original prototype; no code or test enforces
it.
**Tests:**
- Speed and HP scaling on spawn: a crow stays at 1 HP at scale 1.6, a thief goes 3→4, a breaker
6→9.
- A plan with default scales behaves exactly as before.
- Plan paths for n in 1..campaign_nights all load.
- F3 moves the morning and keeps the farm.
**Approach:**
- **Held weapon:** like the torch, it ticks every `alien_ray_tick_interval` while fire is held.
- **Each tick:**
1. Cast a world ray (WORLD_LAYER) from the origin through the muzzle, out to
`alien_ray_range`. This gives the beam segment, clipped at the first wall.
2. Damage every enemy within `alien_ray_width/2 + hit radius` of that segment, up to
`alien_ray_pierce` enemies.
3. This needs a new EnemySystem query that returns all hits; `sweep_hit`
(`enemy_system.gd:501`) returns only the nearest.
- **Visual:** a top-level `MeshInstance3D`: an unshaded, emissive green cylinder or box, oriented
and scaled from the muzzle to the hit point each frame while firing.
- **Co-op:** the visual uses the same hold-timeout and attack-event path as the torch. The
partner recomputes the wall clip locally, which is deterministic because the world geometry is
static.
- **Config:**
- Remove `alien_ray_speed` and `alien_ray_lifetime`.
- Add `alien_ray_range` (≈20), `alien_ray_tick_interval`, `alien_ray_width` and
`alien_ray_pierce`.
- `alien_ray_damage` becomes damage per tick.
- **Counters:** add a `beam_ticks` counter to `attacks()` (`scarecrow_combat.gd:316-317`) and stop
incrementing `shots_fired`.
- **Comments:** update the headers at `scarecrow_combat.gd:38-42` and `weapon_models.gd:14-17`.
**Docs:** RULES.md, The enemies: add a line about the per-night scales.
**Files:** `scarecrow_combat.gd`, `enemy_system.gd`, `weapon_models.gd`, `game_config.gd` /
`game_config.tres`, `test_weapons.gd`.
### #25 [30] Arrivals wait for a free character
**Acceptance (`test_weapons`):** replace `_buy_equip_hit(... alien_ray ...)` at `:356` and keep
the buy/equip checks. Then check:
- A far target is hit on the same step.
- A target behind a wall is not hit.
- Two enemies in line are both hit.
- The beam mesh is visible while fire is held and hidden after release.
**Root cause:** `EnemySystem.spawn` (`enemy_system.gd:229-240`) returns -1, counted in
`spawn_skipped`, when a ground type has no free character (`EnemyCharacters.POOL`: 48 thieves,
20 breakers). The plan's enemy is lost for good. Late nights would quietly play far fewer enemies
than planned.
**Order:** #17 and #18 share files. Run #18 after #17, which sets the held-visual pattern.
**Change:**
- Add `EnemySystem.can_spawn(type)`: capacity and a free character, without side effects.
- In `WaveDirector.step`, a due arrival whose type can't spawn now waits. It stays queued without
holding back the other types behind it, and comes in as soon as a character frees.
- At sunrise, arrivals still waiting are dropped and counted: add `waited` and `dropped` counters
next to `spawned` for the soak report.
- Move `EnemyCharacters.POOL` into `GameConfig` as `character_pool := {"thief": 48, "breaker": 20}`,
same sizes for now (#28 decides). `EnemyCharacters` builds its pools from it at setup.
- RULES.md, Night plans: replace the "Up to 160 enemies…" paragraph with the real limits
(`enemy_capacity` 800 in all; on foot, the character pools) and the waiting rule.
### #19 [4] UFO model built from primitives
**Tests** (test_roster or test_nights):
- With the thief pool full, a due thief waits rather than vanishing, and arrives once one leaves.
- Crows behind it still arrive on time.
- Waiting arrivals are dropped at sunrise and counted.
**Root cause:** all flyers are drawn by one MultiMesh (`HordeRenderer`) using one mesh.
- `farm_sim.gd:177-179` passes `EnemySystem.build_bird_mesh(0.0055)` as the only flyer mesh.
- `commit_render` (`enemy_system.gd:565-582`) writes every flyer into that one buffer.
- `horde_renderer.gd:21-41` overrides the material with `game/resources/thief.gdshader`. That
shader flaps vertices by `abs(VERTEX.x)` and has a single `base_color` uniform.
### #26 [30] Upgrade tiers and timed shed stock
**Approach:**
- **Mesh:** add `static func build_ufo_mesh()` to `enemy_system.gd`.
- It merges the `get_mesh_arrays()` of a CylinderMesh disc, a SphereMesh dome, a TorusMesh rim
and small sphere lights into one `ArrayMesh`, transformed into place, with an
`ARRAY_COLOR` per part. `build_bird_mesh` (`:608-625`) is the template.
- Centre it on its origin, with nothing more than about 1.5 m below. UFOs dive to
`land_altitude` 1.55 (`thief_behavior.gd:197-209`).
- Forward is −Z, with yaw only.
- **Renderer:** create a second `HordeRenderer` for UFOs in `EnemySystem.setup` (`:145-149`).
- **Shader:** a new `game/resources/ufo.gdshader`. It takes albedo from `COLOR`, has no flap and
an optional slow spin from `TIME`, and keeps the hit flash (`INSTANCE_CUSTOM.g`) and
`night_glow`.
- **Buffers:** `commit_render` fills one buffer per type. Mirror `write_new` (`:257`),
`move_slot` (`:599`) and `clear` (`:206-208`) on both renderers.
- **DayNight:** register the new material with DayNight (`day_night.gd:38-42,111-112`;
`farm_sim.gd:254`).
- **Sound (optional):** give UFOs their own arrival sound; today they reuse the crow's.
**Today:**
- `Upgrades` (`upgrades.gd`) treats every upgrade as bought once. `FarmState.upgrades` already
stores `id -> level` (`farm_state.gd:107-108`), so saves don't change shape.
- Definitions are in `GameConfig.upgrades`, and the live ones in `game_config.tres:102+`. Costs
are in `costs`.
- The rows are drawn by `UpgradePanel` (`upgrade_panel.gd`, two instances: workbench and shed).
- Turret and tar-patch per-instance levels (#10, `StructureSystem.MAX_LEVEL`) are a separate
system; leave them alone.
**Files:** `enemy_system.gd`, `horde_renderer.gd`, new `game/resources/ufo.gdshader`,
`farm_sim.gd`, `day_night.gd`, `test_roster.gd`.
**Definitions** (document every key in the `upgrades` comment, `game_config.gd:143-150`):
- `"levels": int` (default 1).
- `"mult"` and `"add"` may be a number (the same every level) or an Array with one entry per
level.
- `"texts": Array` (optional), one description per level.
- Shed items: `"from_day": int` (default 1).
- New `GameConfig` fields:
- `upgrade_cost_growth := 1.8`: level L costs `costs[id]` × growth^(L−1), each material
rounded up;
- `upgrade_level_days: Array[int] = [1, 8, 16]`: level L can be bought from day
`upgrade_level_days[L−1]`, overridable per upgrade with `"level_days"`.
- "Day N" is `campaign.state.night`, the day before night N.
**Acceptance:**
- In `test_roster`, a spawned UFO is in the UFO renderer's visible instances and not in the bird
renderer's. Crows are unchanged.
- Eyeball the saucer in a screenshot of night 5 or of the `ufos.tres` scenario.
**`game_config.tres` values.** Level 1 keeps the user's current numbers.
### #20 [5] New crop fields on the south brown soil, with their own plant models
| Upgrade | Per level |
|---|---|
| rapid_fire | mult [3.0, 1.25, 1.25] |
| heavy_seeds | add [1, 1, 1] (kernels 2/3/4) |
| wide_fear | mult [1.3, 1.15, 1.15] |
| quick_fear | mult [0.8, 0.9, 0.9] |
| straw_stuffing | add [2, 2, 2] |
| pouch_upgrade | add [8, 4, 4] |
| reinforced_fences | mult [1.5, 1.25, 1.25] |
| long_range | mult [1.3, 1.15, 1.15] |
| sticky_tar | mult [1.5, 1.25, 1.25] |
**Root cause (placement):**
- LettuceField (`farm.tscn:2244-2249`) sits at (−6, 0, 7) and CornField (`:2635-2640`) at
(7, 0, 7), each 10×10, on the green grass plane (`farm.tscn:127-132`).
- The brown soil is the ithappy `ground_008` / `ground_011` tiles (`farm.tscn:166-173`):
- `ground_011_004` lies under the sunflower Crop Field.
- `ground_008_004` (SW, x ≈ −25…7.5, z ≈ 14.6…45) and `ground_011_003` (SE, x ≈ 13.4…46,
z ≈ 14.2…45) are bare. Both are outside the playable map (z ≤ 15, `farm_zones.gd:11`) and
inside the "South Fields (outside the fence)" straw zone (`farm.tscn:3453`).
- The plant y offsets (0.288 / 0.535) were copied from CropField, which sits at y −0.36
(`farm.tscn:1005`). So the new plants float about 0.36 m up.
- All of these get `"levels": 3` and a `"texts"` list.
- Sprint, every shed weapon, and Radar stay at 1 level.
- `from_day`: corn_shooter 1, shurikens 2, pumpkin_bomb 3, potato_cannon 6, radar 8,
propane_torch 10, alien_ray 14.
**Root cause (models):**
- `crop_unit.gd:11-13`: the `crop` field is cosmetic only, and nothing reads it.
- Every lettuce and corn unit's children are the sunflower prefabs `plant_007` / `plant_008`
(`farm.tscn:30-31`; e.g. `:2261-2264`, `:2652-2655`).
- The carried/dropped crop token is always `plant_007` (`loot_system.gd:60,159-161`).
**Upgrades API:**
- `level(state, id)`. `owned()` stays "level ≥ 1", so `requires` and the weapon unlocks don't
change.
- `max_level(cfg, id)`.
- `cost(cfg, id, level)`: the cost of buying that level; the default is the next one.
- `value()` applies each owned level's entry.
- `blocker()` adds these reasons:
- "Done" at max level;
- "Arrives on day N" before `from_day`;
- "Level N opens on day D".
- `buy()` raises the level by 1 and applies that level's side effect. The side effects are
`scarecrow_max_hp` and `pouch_capacity` with that level's `add`, and `barrier_hp`, whose ratio
logic already handles any step.
- `upgrades_bought` counts every level.
**Approach:**
- **Placement:** defaults below; confirm them with `game/tools/render_overview.gd --zones`.
- Lettuce/cabbage field: x −6…4, z 20…30, on the SW soil.
- Corn field: x 24…34, z 20…30, on the SE soil.
- Match the zone y to the soil surface; CropField uses −0.36.
- **Map bounds:** extend `FarmZones.playable` south to cover the fields with margin:
`Rect2(-13, -45, 60, 80)`, i.e. z −45…35.
- The south side has no perimeter fence, so no fence work is needed.
- `roam` already reaches z ≈ 47.
- **Knock-on effects:**
- The nav grid (`farm_sim.gd:132`, built over `playable.grow(5)`) grows about 33%. Measure the
flow-field rebuild time before and after.
- The spawn edge (`zones.edge(spawn_margin)`) moves south. The enemy and projectile bounds
(`farm_sim.gd:179,195`) follow automatically.
- The SouthFields zone's hay points at (−10, 25) and (24, 27) fall inside the new map; (24, 27)
is inside the corn field. Move the zone and those points south of z ≈ 37. Outside zones must
stay outside the playable map.
- **Thief targeting:** `ThiefBehavior.field_rect` is the bounding box of all three crop fields
(see `docs/followups.md`). With the fields this far apart it would cover most of the south map,
so switch to per-field rects.
- **Models:**
- Replace the new units' plant children: lettuce/cabbage get `plant_004` / `plant_005`, corn
gets `plant_001` (see Defaults).
- Pick the crop token per crop in `loot_system.gd`, from `_units[id].crop`.
- **Docs:** update `game/LAYOUT.md` (map size, zone table, crop units, SouthFields).
**UpgradePanel:**
- Show the level with roman numerals (e.g. "Rapid fire II"), the next level's text and cost,
"Max" when done, and the blockers above.
- A shed item before its day shows its name greyed with "Arrives on day N".
- A hidden item that hasn't arrived still shows "?" plus the arrival day.
**Files:**
- Code and scenes: `farm.tscn`, `farm_zones.gd`, `crop_unit.gd` (only if model choice moves into
code), `loot_system.gd`, `thief_behavior.gd`
- Docs: `game/LAYOUT.md`
- Tests:
- `test_farm_layout.gd`: 60×60 check (`:29`), inside-playable and overlap checks (`:56-59`),
side names (`:112-113`), open south (`:139`), and `MAX_TRAVEL` (`:13`), which will have to
rise.
- `test_theft.gd`: its edge-cell list (`:35`) includes (20, 18), which is now inside the map.
**Co-op:** a client's purchase request carries the id, and the host buys the next level. Check
`coop_session.gd`'s buy path from #22. The state dict already carries levels.
**Acceptance:**
- In `test_farm_layout`:
- Both new fields lie on the soil tiles' footprints and inside the playable map.
- No zones overlap, and outside zones are outside the map.
- Lettuce and corn units don't use the sunflower prefabs.
- The staged-field cases in `test_theft` (`:300-366`) still pass.
**`soak_night.gd`:** the scripted buyer's `UPGRADE_ORDER` keeps buying affordable next levels.
**Risk:** the new fields are about 35–40 m from the scarecrow's start at (3, −13), so night defence
spreads out further. Playtest the balance.
**Tests** (wherever upgrades are tested now: `test_economy.gd` / `test_scarecrow.gd`):
- level costs grow;
- day gates hold (L2 not before day 8);
- effects stack (heavy seeds L3 = 4 damage; rapid fire L2 = 3.0 × 1.25);
- `from_day` hides stock;
- levels survive save, retry, and co-op;
- an old save with `{"rapid_fire": 1}` loads as level 1.
### #21 [6] Animals roam the whole farm and are never lost on their own
**Docs:** RULES.md, Upgrades. Replace the table with levels and per-level costs, add the stock
schedule, and fix "Bought once each".
**Root causes:**
1. **An open pen leaks at night.** During NIGHT and DAWN, while `pen_open` is true, `_wander_out()`
(`animal_system.gd:406-425`) turns one calm HOME animal into DROPPED every
`animal_wander_interval` (10 s; the first after about 3 s). Since #11 removed the scene fence and
the starting gate, `pen_open` stays true until the whole ring is built.
2. **DROPPED animals always run for the edge and are deleted.** `_stray()` (`:322-336`) follows
`escape_field`, then `loot.animal_escaped()` → `_lose` (`loot_system.gd:693-703`) marks the
animal LOST and hides it (`animal_system.gd:457`).
- The escape goal is the outline of `zones.edge(3)` (`farm_sim.gd:151`). The pen's west wall
is at x = −10, only about 5 m from the west exit band, which is the user's "a few steps".
- This runs in any phase.
- Animals also become DROPPED when `FOLLOW_LEASH` breaks (more than 20 m from their scarecrow;
`animal_system.gd:33,346-351`) or when a carrier is killed (`loot_system.gd:394-403`).
3. **Loose animals are tethered.** `LOOSE_WANDER_RADIUS` is 0.8 (`animal_system.gd:35`), and
`_wander_goal` (`:397-403`) stays around `_loose_spot`. The spots (`game_config.gd:92-95`) hug
the pen; the x = −12 spots are about 3 m from the exit band.
### #27 [30] The thirty nights
**Approach (Decision 2):**
- **No self-escape:** remove `_stray`'s edge path and `animal_escaped`.
- A DROPPED animal (an Alien dropped it, its carrier was killed, or its leash broke) becomes
LOOSE where it stands.
- Keep the two real loss paths: a thief carrying an animal off the map (`thief_behavior.gd:508-512`
→ `loot.escape`), and `on_enemy_removed` with reason LEFT (`loot_system.gd:493-498`).
- **Open pen:** `_wander_out` turns HOME into LOOSE (no escape) and calls `FarmState.unpen_animal`
(`farm_state.gd:192`). Keep `pen_open` and its messaging.
- **Roaming, day and night:** `_wander_goal` picks a goal 4–8 m from the animal's current
position. The goal must be:
- inside the playable rect shrunk by a margin (pass the rect in `setup`, wired at
`farm_sim.gd:185`; `behavior.farm_rect` already exists),
- walkable (`nav.is_walkable`),
- reachable in a clear line (`nav.line_clear`, `farm_navigation.gd:187`).
- **Mornings:** `sync_from_state` (`animal_system.gd:153`) puts loose animals back at their loose
spots, so no new save fields are needed. Move the x = −12 spots inward.
- **Dawn:** `return_dropped` (`loot_system.gd:479-490`) auto-pens DROPPED animals at dawn. Remove
it, since no DROPPED animals remain by then.
- **Text:** fix every place that promises animals "wander out" or "run for the edge":
- header comments in `animal_system.gd:3-22` and `loot_system.gd:15-26`
- `RULES.md:179-195`
- the toast at `farm_sim.gd:335-337`
- `review_panel.gd:128-129`
- **`animals_strayed` event:** keep it (it now counts animals that left the pen). This avoids
churn in save data and tests (`test_save.gd:125`, `test_farm_state.gd:30`, `test_cycle.gd:155`,
`soak_night.gd:234`, `review_panel.gd:155`).
- **Leave as is:** followers become HOME as soon as they cross the unfenced pen rect
(`animal_system.gd:340`).
Depends on #24.
**Files:** `animal_system.gd`, `loot_system.gd`, `farm_sim.gd`, `game_config.gd` /
`game_config.tres`, `review_panel.gd`, `game/RULES.md`, `test_targets.gd`.
**Move the finale.**
- `git mv game/resources/nights/night_5.tres night_30.tres`, which keeps its uid.
- Keep the user's title, dusk hint, and `night_length = 180`.
- Grow its groups to about 72 base, keeping the three-wave shape and adding UFO groups.
- Set `enemy_speed_scale = 1.25` and `enemy_hp_scale = 1.625`.
**Acceptance (`test_targets`):**
- Over a long day and night, loose animals roam more than 4 m but stay inside the playable map.
This replaces the "none wandered off" check in `_loose_start` (`:85-95`).
- An Alien-dropped animal becomes LOOSE, not LOST (`:105-107`, `:221-226`).
- At night an open pen lets animals out as LOOSE, and none become LOST (rework `_breach`,
`:286-340`).
- Carrying an animal off the map still loses it.
- `_make_loose` (`:507`) and `_leading` (`:279-281`) are updated to the new route into HOME.
- The `pen_open` checks in `test_structures` still pass.
**New night 5, hand-authored:** "Lights in the sky".
- Night 4's shape plus the first UFOs: two single-UFO groups, 14 as played.
- About 24 base in total, scales 1.
- Its hint introduces the UFOs.
### #22 [7] The joining player can open the store
**`game/tools/make_nights.gd`** (new, `extends SceneTree`):
- Writes nights `--from=6 --to=29` with a fixed `--seed` (default 30), skipping existing files
unless `--force`.
- Writes the .tres text directly, in the existing files' layout, with a fresh uid from
`ResourceUID.create_id()`.
- Checks every plan with `NightPlan.problems()` at the played scales (7, 0.3, its length) and
exits non-zero on any problem.
**Status:** the cause is not confirmed; reading the code didn't show a blocker. The open path is
wired:
1. The host handles P2's press through `RemoteControls.take` (`interactions.gd:160`).
2. The partner's `Interactions` finds the ShedCounter in `setup` (`:93-101`) and focuses it in
`_nearest` (`:361-365`).
3. Having no panel, it emits `shed_requested` (`:271-277`), which becomes a `["shed"]` event
(`coop_session.gd:167`).
4. The client opens `sim.shed_panel` if it's daytime (`:701-703`).
**Recipe for night n:**
Purchases are already routed to the host: `buy_request` → `["buy", id]` (`:212-213`) →
`_do_request` (`:549-555`).
| What | Rule |
|---|---|
| Base total | `round(24 × (1 + 0.065 × (n − 5)))`; siege nights (n % 5 == 0) × 1.3 |
| Mix | Interpolated linearly from n=6 to n=29: crows 0.45→0.30, thieves 0.35→0.35, breakers 0.12→0.20, UFOs 0.08→0.15. At least one group of each type. |
| Targets | Crows go for crops; breakers and UFOs for any; thieves rotate animals → supplies → any |
| Waves | 3 for n < 12, 4 for 12–21, 5 for 22+, evenly spaced from about 5 s to `length − 30` s |
| Groups per wave | 2–4 from different types, arriving within 0–6 s of each other (the "from both sides" moments) |
| Group size | count 1–5 base, every 1.5–3.0 s base |
| Scales | `enemy_speed_scale = 1 + 0.01 × (n − 5)`, `enemy_hp_scale = 1 + 0.025 × (n − 5)`, written into each file |
| Title and hint | Short drafts from small lists. Sieges are titled "Siege: …". Don't invent lore beyond what nights 1–5 say. |
**Co-op defects found on the way:**
- **No shop prompt on the client.** `_gather_node` (`coop_session.gd:804-813`) resolves only the
workbench and the gather nodes. So the client's replicated focus is null at the counter, and
its label never shows "[E / X] Shop" (`interactions.gd:399-401`, `shed_counter.gd:41`).
- **Presses can be silently dropped.** The host consumes P2's press on every tick
(`interactions.gd:160`), even when its lagging copy of P2 isn't within reach yet.
- **Pressing interact again doesn't close the shop on the client.** `_close_menu`
(`coop_session.gd:929-935`) ignores presses.
- **A partner's purchase doesn't equip the new weapon.** `bought` fires only on the local path
(`upgrade_panel.gd:136-138`, `farm_sim.gd:272-275`).
**Flip to 30.** Set `campaign_nights = 30` in `game_config.gd` and fix its comment.
**Approach:**
1. **Test first.** Add a failing test to `test_coop.gd`:
- Put `client.player` at `counter.global_position + (0, 0, 1.2)` and pump about 20 ticks.
- Press and release `interact`, then pump again.
- Assert `client.shed_panel.is_open`, `not host.shed_panel.is_open`, and `remote.ui_open`.
- Repeat for the Workbench after `host.structures.grant_workbench()`.
**Tests:**
- `test_nights.gd`:
- 30 plans;
- every plan passes `problems()` at the played scales;
- no breaker before night 3 and no UFO before night 5;
- played totals never drop by more than 15% from one non-siege night to the next;
- night 30 is the longest.
- `_five_nights` (`test_nights.gd:202-251`) plays every night back to back. At 30 nights that's
too slow, so make it play nights 1–5, a siege night, and 30 with arrivals as planned. Skip the
rest with the same morning path as #24's F3, and keep the check that the farmers return after
the last.
- `test_campaign.gd:48-58` "exactly five nights" reads `campaign_nights`.
- `test_flow.gd` and `test_outcome.gd` already read `campaign_nights`; check that their runtime
stays sane.
Also try a two-process `coop_smoke.gd` run, since the loopback pair may not reproduce a timing
cause. Fix whatever the test pins down.
2. **Fix all four defects above:**
- Add the ShedCounter to `_gather_node`.
- On the host, keep a partner's press pending for a short window (about 0.3 s) until its focus
is valid, instead of dropping it.
- On the client, treat interact while a menu is open as "close".
- When the host handles a partner's "buy", emit an equip event for the buyer's slot.
- With #16 in place, "buy" pays from the requester's pouch.
**Docs:**
- RULES.md: The vacation ("thirty nights"), the Night row (180 s is now night 30), and the nights
table. Keep rows 1–5, add a summary row per week with the generated ranges, plus row 30.
- `README.md` (lines ~104, 174, 312, 496, 536-540).
- `game/PLAYTEST.md`: add a dated section rather than rewriting history.
**Files:** `coop_session.gd`, `interactions.gd`, `upgrade_panel.gd`, `farm_sim.gd`,
`test_coop.gd` (and possibly `shed_counter.gd`).
### #28 [30] Thirty-night soak, pool sizes, and a balance report
**Depends on #16:** they share files and the PROTOCOL bump, and "buy" needs per-player paying.
Depends on #23–#27. A report, not a retune: change numbers only to fix outright breakage.
**Acceptance:**
- The new `test_coop` cases pass for both shops.
- The client can buy a weapon: it pays from P2's pouch plus the shed, and the weapon lands in
P2's hand.
- In a two-process smoke run, the client opens the shed.
**Soak.**
- Run `soak_night.gd --mode=cycle --cycles=30` for 3 seeds.
- Per night, record:
- arrivals planned, arrived, waited, and dropped;
- the peak alive per type;
- losses per category;
- the scarecrow's HP;
- levels bought;
- materials banked;
- the sim tick's average and max.
**Pools.**
- Measure the headless sim tick with `character_pool` at 48/20 vs 64/28 on nights 20 and 30.
- Recommend sizes, but leave the render cost to a visible-window check by the user (headless
can't measure it).
**Output.**
- Write `docs/thirty-night-soak.md` with the table and three things to tune next.
- Fix anything outright broken: plan problems, a stuck queue, a crash, or a night that can't end.
Report everything else.
## File overlap and order
| File | Tasks |
|---|---|
| `coop_session.gd`, `interactions.gd` | #16, #22 |
| `scarecrow_combat.gd`, `weapon_models.gd`, `test_weapons.gd` | #17, #18 |
| `enemy_system.gd` | #18 (beam query), #19 (renderer) |
| `loot_system.gd` | #20 (crop token), #21 (escape/drop) |
| `farm_sim.gd` | #16, #19, #21, #22 (separate regions) |
| `game_config.gd` / `game_config.tres` | #17, #18, #21 |
| `farm.tscn` | #20 only |
| `farm_sim.gd` | #23 (toasts, ~328-342, 756-777), #24 (plan paths, ~32-36, 244-246) |
| `coop_session.gd` | #23 (toast events), #24 (HP bar on the replica, if needed), #26 (buy path, if needed) |
| `wave_director.gd` | #24 (nightfall scales), #25 (queue in `step`) |
| `enemy_system.gd` | #24 (spawn HP, steering speed), #25 (`can_spawn`) |
| `game_config.gd` | #24 (comment), #25 (`character_pool`), #26 (upgrades group), #27 (`campaign_nights`) |
| `game_config.tres` | #26 only |
| `campaign_debug.gd` | #23 (one toast), #24 (F3) |
| `test_nights.gd` | #24, #27 |
| `soak_night.gd` | #26 (`UPGRADE_ORDER`), #28 |
| `RULES.md` | #23–#27, separate sections |
- **Wave 1 (parallel):** #16, #17, #19, #20, #21. Their overlaps in `farm_sim.gd`,
`loot_system.gd` and `game_config.gd` are in separate regions; merge carefully.
- **Wave 2:** #18 after #17, and #22 after #16.
This batch supersedes these entries in `docs/followups.md`:
- UFOs use the crow mesh (#19).
- The torch's kick placeholder (#17).
- `ThiefBehavior.field_rect` spans all crop fields (#20).
- `LAYOUT.md` doesn't list the new fields (#20).
- **Wave 1 (parallel):** #23, #24, #26. They touch separate regions of shared files; merge
carefully.
- **Wave 2 (parallel):** #25 and #27, after #24.
- **Wave 3:** #28.

View file

@ -232,3 +232,53 @@ parallel; wave 2 waits on the task named.
host keeps a partner's press pending until focus is valid, interact closes the client menu,
partner purchases equip on the buyer's slot and pay from the buyer's pouch.
*Acceptance:* new test_coop cases pass for shed and Workbench; two-process smoke opens the shed.
# Thirty nights — task list (2026-10-06)
Narrative, decisions, defaults, and file pointers are in `docs/plan.md` ("Harvest Season — thirty
nights"). The user's calls: 30 nights, phase lengths unchanged, permanent losses, upgrade tiers +
timed shed stock, and no pop-up status lines.
## Wave 1
- [ ] **#23 Remove the zone banner and the message feed.** [user: pop-ups]
Delete `ZoneBanner` and `ToastFeed` (nodes, scripts, `.uid` files), every `toasts.push`, the
`FarmSim.toasts` export, and the co-op `"toast"`/`"arrived"` events (PROTOCOL bump if the wire
format changes). Docs follow.
*Acceptance:* no new FAIL lines; `rg "toasts|ToastFeed|ZoneBanner" game` finds no code;
coop_smoke passes.
- [ ] **#24 Nights by count, per-night enemy speed and HP.** Blocks #25, #27.
`night_plan_path(n)` for 1..`campaign_nights` (stays 5 here); `NightPlan.enemy_speed_scale` /
`enemy_hp_scale` applied at nightfall (HP floored, never below the type's own); HP bars use each
enemy's own full HP (host and replica); debug F3 / Shift+F3 jump the morning by a day.
*Acceptance:* scaling-on-spawn checks (crow 1→1, thief 3→4, breaker 6→9 at 1.6); default plans
unchanged; F3 keeps the farm; no new FAIL lines.
- [ ] **#26 Upgrade tiers and timed shed stock.**
`"levels"`, per-level `"mult"`/`"add"`/`"texts"`, `upgrade_cost_growth` 1.8,
`upgrade_level_days` [1, 8, 16], shed `"from_day"`; nine stat upgrades get 3 levels (level 1 =
the user's current values); panel shows levels and arrival days; soak buyer buys levels.
*Acceptance:* tests for cost growth, day gates, stacked effects, hidden stock, save/retry/co-op
levels, old saves as level 1; no new FAIL lines.
## Wave 2
- [ ] **#25 Arrivals wait for a free character.** Blocked by #24.
`EnemySystem.can_spawn`; due ground arrivals wait for a free character without holding back
other types; dropped and counted at sunrise; `GameConfig.character_pool` (48/20 for now).
*Acceptance:* full-pool wait, crows unaffected, sunrise drop counted; no new FAIL lines.
- [ ] **#27 The thirty nights.** Blocked by #24.
Old night 5 → `night_30.tres` (enlarged finale, user's title/hint kept); new night 5 "Lights in
the sky"; `game/tools/make_nights.gd` writes nights 6–29 from the plan's recipe;
`campaign_nights = 30`; RULES/README/PLAYTEST updated.
*Acceptance:* 30 valid plans at played scales; roster intro order; night 30 longest; the
back-to-back test samples nights and still reaches the farmers' return; no new FAIL lines.
## Wave 3
- [ ] **#28 Thirty-night soak, pool sizes, and a balance report.** Blocked by #23–#27.
`soak_night.gd --mode=cycle --cycles=30` × 3 seeds; headless tick cost at pools 48/20 vs 64/28;
`docs/thirty-night-soak.md`.
*Acceptance:* the report exists with per-night numbers; no crash, stuck queue, or invalid plan.