harvest/docs/plan.md
Forrest 6a9575dfe4 plan: thirty nights + no pop-up lines (#23-#28)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 15:52:02 -04:00

380 lines
19 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Harvest Season — thirty nights (2026-10-06)
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
- **Godot binary:** `godot` is not on PATH here. Use `~/Downloads/Godot_v4.7.2-stable_linux.x86_64`
everywhere these docs say `godot`. Exit code 127 means the binary wasn't found, not a pass.
- **Tests:** `godot --headless --path . --script res://game/tests/run_tests.gd`. The exit code is
the failure count and is never 0 here: about 25 checks fail because of tuning, and the
test_roster "All three" check is flaky. Run the suite before editing, diff the FAIL lines
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` 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: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 (the user's, 2026-10-06)
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)
**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
### #23 [pop-ups] Remove the zone banner and the message feed
**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`.
**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.
**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`.
**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).
**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.
**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.
### #24 [30] Nights by count, per-night enemy speed and HP
Code only. `campaign_nights` stays 5 here; #27 flips it to 30 together with the plans.
**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`.
**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.
**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.
**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.
**Docs:** RULES.md, The enemies: add a line about the per-night scales.
### #25 [30] Arrivals wait for a free character
**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.
**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.
**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.
### #26 [30] Upgrade tiers and timed shed stock
**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.
**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.
**`game_config.tres` values.** Level 1 keeps the user's current numbers.
| 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] |
- 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.
**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.
**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.
**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.
**`soak_night.gd`:** the scripted buyer's `UPGRADE_ORDER` keeps buying affordable next levels.
**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.
**Docs:** RULES.md, Upgrades. Replace the table with levels and per-level costs, add the stock
schedule, and fix "Bought once each".
### #27 [30] The thirty nights
Depends on #24.
**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`.
**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.
**`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.
**Recipe for night n:**
| 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. |
**Flip to 30.** Set `campaign_nights = 30` in `game_config.gd` and fix its comment.
**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.
**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.
### #28 [30] Thirty-night soak, pool sizes, and a balance report
Depends on #23–#27. A report, not a retune: change numbers only to fix outright breakage.
**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 |
|---|---|
| `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):** #23, #24, #26. They touch separate regions of shared files; merge
carefully.
- **Wave 2 (parallel):** #25 and #27, after #24.
- **Wave 3:** #28.