[PR] Game systems overhaul: survival stakes, seasons, mood, XP & fair raids #49

Open
agent-claude wants to merge 0 commits from claude/48-systems-overhaul into main
Collaborator

Fixes #48

Why

A headless 30-day probe of a fresh colony showed the systems had no stakes:

  • The first raid wiped the colony by day 4. Colonists never fought back and raiders executed the downed.
  • Without raids nothing could go wrong. Mood sat at 85% forever, and a tundra colony reported "Pleasant Weather" because the biome temperature was overwritten on tick 1.
  • Skills, crafted weapons, tables, heaters, traps and healroot did little or nothing.

What changed (all in sim-core, deterministic, suspended while protectedOffline)

System Now
Seasons & climate Biome base temperature, 60-day year, day/night swing, cold snaps and heat waves. Crops stop growing in the cold, and a killing frost withers them.
Rooms Enclosed-room detection. Heaters, coolers (walk-in freezers) and campfires set room temperature, which drives spoilage, comfort and greenhouse growth.
Survival Hypothermia and heatstroke, starvation, and exhaustion collapse. Each one is telegraphed by alerts and can kill.
Mood 50% baseline. Timed memories for meals, tables, beds, deaths and raids. Mood scales work speed and can trigger mental breaks (daze, binge, tantrum) followed by catharsis.
Skills XP-based levels and new Medicine and Combat skills. Skill scales work speed and yields.
Medicine Healroot sets tend quality. Wounds heal over time and clot naturally. Bleeding or downed colonists are an emergency that outranks normal work, and doctors carry downed colonists to bed.
Raids Grace period and scout warnings. Raid strength scales with wealth, day and population, and raiders arrive from a random edge. Colonists defend themselves and equip the best weapon in stock. Raiders spare the downed, loot and leave, and drop weapons and silver when killed. Spike traps work.
Storyteller Wanderers join (gated on mood and food), cargo pods, blight on fields only, weather events.
Production All recipe inputs are consumed. Recipe tech gating is enforced. Each recipe has a stock target. Alloy and components are scarce veins, which gives trade a purpose.

Full spec: docs/GAME_DESIGN.md §6.

Bugs fixed along the way

  • raidCooldownTicks wasn't persisted in snapshots, so any colony reloaded after a server restart was never raided again. Older snapshots now get a fresh grace period.
  • Both starter research-bench spawners wrote the building type id into structureId instead of the entity id, so tile lookups could resolve to the wrong building.
  • Multi-input recipes consumed only their first input. Bolt rifles cost no components or timber.

Balance evidence (headless 60-day probes, scripted "competent player")

  • Temperate: survives with 3–5 colonists and repels 2–6 escalating raids (2 → 6 raiders). Later undefended raids rob the colony instead of killing it.
  • Arid shrubland: survives with 5 colonists and repels 5 raids.
  • Tundra: survives spring and summer, then starves in a −30°C winter unless the player trades for food or builds heated indoor farms.
  • Idle colony (no input): repels early raids, runs out of food around day 31, and dies by day 38–52.

Testing

  • npm test: 65 sim-core (23 new in systems-overhaul.test.ts) and 5 server, all passing. This includes the 300-tick replay determinism test and the binary snapshot + delta replica hash parity test.
  • npm run typecheck: clean across all workspaces.
  • Ran the worktree server and client locally:
    • Season/weather HUD and the six skills render correctly.
    • The full loop played out live: scout warning → raid → colonists self-defend → raiders flee → doctor treats a wounded wanderer with healroot.
    • New log badges show for each event.

Reviewer notes

  • The 3 existing tests that asserted old balance (one skill level per action, sub-day crops, a cooler freezing open ground) were updated to the new model. Freezers now need an enclosed room.
  • client/vite.config.ts now reads SERVER_PORT (default 4000) so parallel worktrees can run their own server.
  • colony-sim.ts grew considerably (about 5.7k lines). Splitting it into modules (combat, storyteller, health) would be a worthwhile follow-up.

🤖 Generated with Claude Code

Fixes #48 ## Why A headless 30-day probe of a fresh colony showed the systems had no stakes: - **The first raid wiped the colony by day 4.** Colonists never fought back and raiders executed the downed. - **Without raids nothing could go wrong.** Mood sat at 85% forever, and a tundra colony reported "Pleasant Weather" because the biome temperature was overwritten on tick 1. - **Skills, crafted weapons, tables, heaters, traps and healroot did little or nothing.** ## What changed (all in `sim-core`, deterministic, suspended while `protectedOffline`) | System | Now | | :-- | :-- | | **Seasons & climate** | Biome base temperature, 60-day year, day/night swing, cold snaps and heat waves. Crops stop growing in the cold, and a killing frost withers them. | | **Rooms** | Enclosed-room detection. Heaters, coolers (walk-in freezers) and campfires set room temperature, which drives spoilage, comfort and greenhouse growth. | | **Survival** | Hypothermia and heatstroke, starvation, and exhaustion collapse. Each one is telegraphed by alerts and can kill. | | **Mood** | 50% baseline. Timed memories for meals, tables, beds, deaths and raids. Mood scales work speed and can trigger mental breaks (daze, binge, tantrum) followed by catharsis. | | **Skills** | XP-based levels and new Medicine and Combat skills. Skill scales work speed and yields. | | **Medicine** | Healroot sets tend quality. Wounds heal over time and clot naturally. Bleeding or downed colonists are an emergency that outranks normal work, and doctors carry downed colonists to bed. | | **Raids** | Grace period and scout warnings. Raid strength scales with wealth, day and population, and raiders arrive from a random edge. Colonists defend themselves and equip the best weapon in stock. Raiders spare the downed, loot and leave, and drop weapons and silver when killed. Spike traps work. | | **Storyteller** | Wanderers join (gated on mood and food), cargo pods, blight on fields only, weather events. | | **Production** | All recipe inputs are consumed. Recipe tech gating is enforced. Each recipe has a stock target. Alloy and components are scarce veins, which gives trade a purpose. | Full spec: `docs/GAME_DESIGN.md` §6. ## Bugs fixed along the way - **`raidCooldownTicks` wasn't persisted in snapshots**, so any colony reloaded after a server restart was never raided again. Older snapshots now get a fresh grace period. - **Both starter research-bench spawners wrote the building *type* id into `structureId`** instead of the entity id, so tile lookups could resolve to the wrong building. - **Multi-input recipes consumed only their first input.** Bolt rifles cost no components or timber. ## Balance evidence (headless 60-day probes, scripted "competent player") - **Temperate:** survives with 3–5 colonists and repels 2–6 escalating raids (2 → 6 raiders). Later undefended raids rob the colony instead of killing it. - **Arid shrubland:** survives with 5 colonists and repels 5 raids. - **Tundra:** survives spring and summer, then starves in a −30°C winter unless the player trades for food or builds heated indoor farms. - **Idle colony (no input):** repels early raids, runs out of food around day 31, and dies by day 38–52. ## Testing - `npm test`: 65 sim-core (23 new in `systems-overhaul.test.ts`) and 5 server, all passing. This includes the 300-tick replay determinism test and the binary snapshot + delta replica hash parity test. - `npm run typecheck`: clean across all workspaces. - Ran the worktree server and client locally: - Season/weather HUD and the six skills render correctly. - The full loop played out live: scout warning → raid → colonists self-defend → raiders flee → doctor treats a wounded wanderer with healroot. - New log badges show for each event. ## Reviewer notes - The 3 existing tests that asserted old balance (one skill level per action, sub-day crops, a cooler freezing open ground) were updated to the new model. Freezers now need an enclosed room. - `client/vite.config.ts` now reads `SERVER_PORT` (default 4000) so parallel worktrees can run their own server. - `colony-sim.ts` grew considerably (about 5.7k lines). Splitting it into modules (combat, storyteller, health) would be a worthwhile follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Gives every colony system purpose and real consequences while keeping
the sim deterministic and offline-protected.

- Seasons & climate: biome base temperature, 60-day year, day/night
  swing, cold snaps & heat waves; crops stop in the cold, killing frost.
- Rooms: enclosed-room detection; heaters, coolers (freezers) and
  campfires drive room temperature and food spoilage.
- Survival: hypothermia/heatstroke, starvation and exhaustion collapse,
  each telegraphed by alerts and able to kill.
- Mood: 50% baseline, timed memories (tables, beds, meals, deaths,
  raids), mood-scaled work speed, mental breaks (daze/binge/tantrum).
- Skills: XP-based leveling, new medicine & combat skills, skill-scaled
  work speed and yields.
- Medicine: healroot-based tend quality, healing over time, clotting,
  emergency doctoring, rescue to bed.
- Raids: grace period, scout warnings, wealth/day-scaled strength from
  random edges; colonists self-defend and equip the best weapon;
  raiders spare the downed, loot and leave; weapon & silver drops.
- Storyteller: wanderers join, cargo pods, blight, weather events.
- Production: all recipe inputs consumed, recipe tech gating,
  per-recipe stock targets, scarce alloy/component veins.
- Fixes: raid timer now persisted in snapshots; starter research bench
  wrote a building type id into structureId instead of its entity id.
- Client: season/weather HUD, six skills with XP, exposure and
  malnutrition meters, log badges for the new events.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Collaborator

Merge approved by @johnw via Claude Code chat on 2026-10-20: "approve/merge and deploy all"

Merge approved by @johnw via Claude Code chat on 2026-10-20: "approve/merge and deploy all"
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin claude/48-systems-overhaul:claude/48-systems-overhaul
git switch claude/48-systems-overhaul

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff claude/48-systems-overhaul
git switch claude/48-systems-overhaul
git rebase main
git switch main
git merge --ff-only claude/48-systems-overhaul
git switch claude/48-systems-overhaul
git rebase main
git switch main
git merge --no-ff claude/48-systems-overhaul
git switch main
git merge --squash claude/48-systems-overhaul
git switch main
git merge --ff-only claude/48-systems-overhaul
git switch main
git merge claude/48-systems-overhaul
git push origin main
Sign in to join this conversation.
No description provided.