[PR #7474] [MERGED] feat(game): generated worlds 5/5: story scripts, a library of worlds, hand-made battlefields and towns by hand #7751

Closed
opened 2026-10-24 04:07:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7474
Author: @kolacheee
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @kolacheee

Base: staging ← Head: feat/generated-worlds-5


📝 Commits (10+)

  • adead92 fix(world): the world's ledger carries across sessions
  • 26ce2ac feat(world): story scripts travel with their world
  • 4ebecc6 fix(world): story script review fixes
  • 07d50dd fix(world): check a story against the world as it is written
  • 6b9defb feat(world): play a world's story
  • 3298c31 fix(world): story play review fixes
  • 2cd3280 test(world): story play proofs for the review fixes
  • 7b54eb5 test(world): a party in a place the Game Master added is in its town
  • 34b72fe fix(world): read a reply's scenes once, before the rewrite agents run
  • 29148d0 feat(world): a library of worlds

📊 Changes

71 files changed (+6238 additions, -196 deletions)

View changed files

📝 docs/development/game-combat-roadmap.md (+1 -1)
📝 docs/development/optional-agent-packages.md (+4 -2)
➕ docs/extending/writing-story-scripts.md (+182 -0)
📝 docs/game/combat.md (+6 -2)
📝 docs/game/getting-started.md (+7 -3)
📝 docs/game/map-time-weather.md (+2 -0)
📝 docs/game/sessions-and-saves.md (+2 -0)
📝 e2e/game-hybrid-terrain.e2e.ts (+4 -2)
➕ e2e/game-world-battlefields.e2e.ts (+185 -0)
📝 e2e/game-world-files.e2e.ts (+63 -3)
📝 e2e/game-world-map-packs.e2e.ts (+10 -2)
➕ e2e/game-world-story.e2e.ts (+159 -0)
➕ e2e/game-world-town-layouts.e2e.ts (+127 -0)
📝 packages/client/src/components/game/DirectedCombatUI.tsx (+1 -1)
📝 packages/client/src/components/game/GameJournal.tsx (+22 -0)
📝 packages/client/src/components/game/GameSetupWizard.tsx (+8 -4)
📝 packages/client/src/components/game/GameSetupWorldChooser.tsx (+42 -15)
📝 packages/client/src/components/game/GameSetupWorldKitChooser.tsx (+47 -2)
📝 packages/client/src/components/game/GameSurface.tsx (+1 -1)
📝 packages/client/src/components/game/TacticalCombatUI.tsx (+14 -5)

...and 51 more files

📄 Description

Linked issue

Part of #7468

Follows #7473 (generated worlds 4/5), now merged; this PR is up to date with staging. This is the last of the five worlds PRs; the issue stays open for later world work. New Overworld games stay behind the MARINARA_OVERWORLD_GAMES switch from #7470, and the library's Your worlds picker sits inside the World step it greys out.

Why this change

  • A creator wants a world to come with a story: events, cutscenes and flags that trip on what the game records and steer the Game Master, without code.
  • A world made once should be reusable across games, and what the party did to a world should survive a new session; each session is its own chat, so deeds, days and standing silently started over.
  • A text-rewrite agent must not change what the Engine wrote into a reply.
  • Fights are on generated boards and towns are generated. A creator wants the fight at the bridge on a board they painted, and a building moved to another lot or a street painted.

What changed

  • The ledger across sessions: a game's next session carries the world's ledger (gameLedgerCarry): deeds, days, holds and standing go on, and a party's own turn is never read as the Game Master's word.
  • Story scripts: a world can carry a story script (features/world/story.ts): flags, standing directions for the Game Master, events and cutscenes, checked against the places, people and groups they name. Once a turn, before the reply, events trip on the start, a turn or day, arriving somewhere, meeting someone, a deed, a fight's end or flags, and on the Game Master's own [story:] tags for what the script makes its own. Scenes play in the narration exactly as written or are narrated by the Game Master, and objectives appear under Story on the World tab. A swipe or regeneration takes back what its reply did. Stories travel in world files, map packs and setup files; GET, PUT and DELETE /api/game/:chatId/story. A new guide, docs/extending/writing-story-scripts.md, says how to write one.
  • Library of worlds: worlds can be kept outside any game, made from a kit and a seed or imported from a world file, edited by hand and given a story. Your worlds in setup, beside Import a world file, starts a game from one; the game takes a copy. New file table game_worlds (in FILE_BACKED_TABLES and the launcher's list), routes under /api/game-worlds with the same editor routes a game's world has, and privileged writes.
  • Rewrite guard: a text-rewrite agent can no longer change a world, place or story tag or a scene shown as written, in a turn or a retry. It works with staging's per-part rewrite of a reply split at scene breaks (#7507, #7510): each part keeps the tags and scenes it holds.
  • Hand-made battlefields: a world's hand edits can carry tactical boards painted for its places (features/world/battlefield-maps.ts). A tactical or directed fight that starts at such a place, or a place inside it, is fought on one of them exactly as painted, in its own scene, and the battlefield line and the Game Master name it; elsewhere boards are generated as before. A board is checked as one (a standard size, plains deployment strips, every open tile connected), a board that cannot be fought on is dropped on its own, and a failed lookup generates the board.
  • Towns laid out by hand: hand edits can lay a town out: buildings moved between lots (swapping with the one there) and the ground painted with streets, paving, open ground, trees and wells, sparing the square's middle and the market's stalls. A layout is checked when saved and applied as far as it fits when read; the town view and walks follow it. GET /api/game/:chatId/world/town?settlement= gives a maker the town with its lots.
  • Battlefields and town layouts travel with the world in world files, map packs and the library, and are saved with the other hand edits through PUT /api/game/:chatId/world/edits (or the library's).
  • One-pass tag reading: story tags and the Engine tags the rewrite guard keeps are read with a body that never holds [, like the world and place tags on staging, so a reply full of unclosed openers cannot make each start scan to the end. world-story-play times 40,000 unclosed openers for each reader.
  • Lanes: world-ledger-sessions, world-story-scripts, world-story-play, world-library, world-map-packs, world-battlefield-maps, world-towns-by-hand, capability-gm-verbs. E2E: game-world-story, game-world-files, game-world-map-packs, game-world-battlefields, game-hybrid-terrain, game-world-town-layouts.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md
  • On this branch after merging staging 983e44f7e (which includes #7473, #7507 and #7510): pnpm check green; every world-*, story, capability-package, agent-activation and advanced-memory lane passes; the six e2e specs above plus game-world-towns and game-world-journal pass on desktop Chromium (17 tests).
  • Full regression run on a88f57cd4: 616 of 619 passed. The three that did not (memory-recall-revectorize, regeneration-context, native-export-memory) need memory embeddings, which the test container cannot run because its native ONNX runtime install is skipped; this PR changes no memory or embedding code. The later commit 5a7215a29 only adds rate limits to the library routes, a word boundary in the story attribute reader and docs wording; route-rate-limits and world-story-play pass on it.
  • Earlier, on the separate branches: each part's lanes and e2e specs on desktop and mobile Chromium, with planted defects caught for every part; an adversarial placement probe of 37,500 fight starts never changed a painted tile, and one of 16,362 random town layouts found no overlap, every door on a street and no painted roof.

Manual verification notes

  • Story scripts: checked with real models from two providers on an isolated instance: start pages and tells, a Game Master event with beats, an arrival with a world person speaking, hidden and shown objectives, and refused tags. One defect was found and fixed (a Game Master event's beats now go in the story block with the event); a re-run narrated the beats in the marking reply on both.
  • Battlefields and town layouts: the e2e draws a painted board in a tactical fight at its place, and a painted tree and a moved building in the town view.
  • Not checked by a person yet: writing a story with the guide (authoring is by JSON for now; no story maker is part of this PR), and painting boards or laying out towns, which need a maker that is not part of this PR.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)
  • No CHANGELOG.md edit, per #7483; "What changed" above is for the release notes. docs/extending/writing-story-scripts.md is new; docs/development/game-combat-roadmap.md, docs/development/optional-agent-packages.md, docs/game/combat.md, docs/game/getting-started.md, docs/game/map-time-weather.md and docs/game/sessions-and-saves.md changed. The translations, including the new guide, are tracked on #7512.

UI evidence (if applicable)

No screenshots attached; the e2e specs above drive these screens (the Your worlds picker, the Story section on the World tab, a fight on a painted board and a town with a moved building and painted ground).

Summary by CodeRabbit

  • New Features
    • Save and manage worlds in your library, then select them during game setup.
    • Customize town layouts and tactical battlefields; battles at matching world locations can use your authored maps.
    • Add story scripts to worlds and map packs, with scenes in game narration and objectives in the World journal.
    • World stories, progress, and other world changes carry into new sessions.
    • Share world files with their stories and edits, and retain these when the seed and brief remain unchanged.
  • Documentation
    • Added guides for writing story scripts, editing towns, and using hand-made battlefields.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7474 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/generated-worlds-5` --- ### 📝 Commits (10+) - [`adead92`](https://github.com/Pasta-Devs/Marinara-Engine/commit/adead92959b35cbec52ef2aa992f42c2caa9c696) fix(world): the world's ledger carries across sessions - [`26ce2ac`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26ce2ac3273d0d9518cff642926fd022797cca88) feat(world): story scripts travel with their world - [`4ebecc6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ebecc608b50bfef331eb171e0212a6d221acdf6) fix(world): story script review fixes - [`07d50dd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/07d50dd203c408717b39601150173abbcd964a0d) fix(world): check a story against the world as it is written - [`6b9defb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6b9defb70b7d37f0c87f4ad1af65616e046015c1) feat(world): play a world's story - [`3298c31`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3298c31e13fd8a93a22f374bf67860b53e999c47) fix(world): story play review fixes - [`2cd3280`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2cd32801d0017547ac8b7be1f1ae8bde72147d9e) test(world): story play proofs for the review fixes - [`7b54eb5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7b54eb52d2da418009c90a4937bb859e3e304b59) test(world): a party in a place the Game Master added is in its town - [`34b72fe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/34b72fe5e7a77ba066bdd88fd9d51003c285bd97) fix(world): read a reply's scenes once, before the rewrite agents run - [`29148d0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29148d0a625b5826c9a4a25312d7d772d5b25e46) feat(world): a library of worlds ### 📊 Changes **71 files changed** (+6238 additions, -196 deletions) <details> <summary>View changed files</summary> 📝 `docs/development/game-combat-roadmap.md` (+1 -1) 📝 `docs/development/optional-agent-packages.md` (+4 -2) ➕ `docs/extending/writing-story-scripts.md` (+182 -0) 📝 `docs/game/combat.md` (+6 -2) 📝 `docs/game/getting-started.md` (+7 -3) 📝 `docs/game/map-time-weather.md` (+2 -0) 📝 `docs/game/sessions-and-saves.md` (+2 -0) 📝 `e2e/game-hybrid-terrain.e2e.ts` (+4 -2) ➕ `e2e/game-world-battlefields.e2e.ts` (+185 -0) 📝 `e2e/game-world-files.e2e.ts` (+63 -3) 📝 `e2e/game-world-map-packs.e2e.ts` (+10 -2) ➕ `e2e/game-world-story.e2e.ts` (+159 -0) ➕ `e2e/game-world-town-layouts.e2e.ts` (+127 -0) 📝 `packages/client/src/components/game/DirectedCombatUI.tsx` (+1 -1) 📝 `packages/client/src/components/game/GameJournal.tsx` (+22 -0) 📝 `packages/client/src/components/game/GameSetupWizard.tsx` (+8 -4) 📝 `packages/client/src/components/game/GameSetupWorldChooser.tsx` (+42 -15) 📝 `packages/client/src/components/game/GameSetupWorldKitChooser.tsx` (+47 -2) 📝 `packages/client/src/components/game/GameSurface.tsx` (+1 -1) 📝 `packages/client/src/components/game/TacticalCombatUI.tsx` (+14 -5) _...and 51 more files_ </details> ### 📄 Description ## Linked issue Part of #7468 Follows #7473 (generated worlds 4/5), now merged; this PR is up to date with `staging`. This is the last of the five worlds PRs; the issue stays open for later world work. New Overworld games stay behind the `MARINARA_OVERWORLD_GAMES` switch from #7470, and the library's **Your worlds** picker sits inside the World step it greys out. ## Why this change - A creator wants a world to come with a story: events, cutscenes and flags that trip on what the game records and steer the Game Master, without code. - A world made once should be reusable across games, and what the party did to a world should survive a new session; each session is its own chat, so deeds, days and standing silently started over. - A text-rewrite agent must not change what the Engine wrote into a reply. - Fights are on generated boards and towns are generated. A creator wants the fight at the bridge on a board they painted, and a building moved to another lot or a street painted. ## What changed - **The ledger across sessions:** a game's next session carries the world's ledger (`gameLedgerCarry`): deeds, days, holds and standing go on, and a party's own turn is never read as the Game Master's word. - **Story scripts:** a world can carry a story script (`features/world/story.ts`): flags, standing directions for the Game Master, events and cutscenes, checked against the places, people and groups they name. Once a turn, before the reply, events trip on the start, a turn or day, arriving somewhere, meeting someone, a deed, a fight's end or flags, and on the Game Master's own `[story:]` tags for what the script makes its own. Scenes play in the narration exactly as written or are narrated by the Game Master, and objectives appear under **Story** on the World tab. A swipe or regeneration takes back what its reply did. Stories travel in world files, map packs and setup files; `GET`, `PUT` and `DELETE /api/game/:chatId/story`. A new guide, `docs/extending/writing-story-scripts.md`, says how to write one. - **Library of worlds:** worlds can be kept outside any game, made from a kit and a seed or imported from a world file, edited by hand and given a story. **Your worlds** in setup, beside **Import a world file**, starts a game from one; the game takes a copy. New file table `game_worlds` (in `FILE_BACKED_TABLES` and the launcher's list), routes under `/api/game-worlds` with the same editor routes a game's world has, and privileged writes. - **Rewrite guard:** a text-rewrite agent can no longer change a world, place or story tag or a scene shown as written, in a turn or a retry. It works with staging's per-part rewrite of a reply split at scene breaks (#7507, #7510): each part keeps the tags and scenes it holds. - **Hand-made battlefields:** a world's hand edits can carry tactical boards painted for its places (`features/world/battlefield-maps.ts`). A tactical or directed fight that starts at such a place, or a place inside it, is fought on one of them exactly as painted, in its own scene, and the battlefield line and the Game Master name it; elsewhere boards are generated as before. A board is checked as one (a standard size, plains deployment strips, every open tile connected), a board that cannot be fought on is dropped on its own, and a failed lookup generates the board. - **Towns laid out by hand:** hand edits can lay a town out: buildings moved between lots (swapping with the one there) and the ground painted with streets, paving, open ground, trees and wells, sparing the square's middle and the market's stalls. A layout is checked when saved and applied as far as it fits when read; the town view and walks follow it. `GET /api/game/:chatId/world/town?settlement=` gives a maker the town with its lots. - Battlefields and town layouts travel with the world in world files, map packs and the library, and are saved with the other hand edits through `PUT /api/game/:chatId/world/edits` (or the library's). - **One-pass tag reading:** story tags and the Engine tags the rewrite guard keeps are read with a body that never holds `[`, like the world and place tags on `staging`, so a reply full of unclosed openers cannot make each start scan to the end. `world-story-play` times 40,000 unclosed openers for each reader. - Lanes: `world-ledger-sessions`, `world-story-scripts`, `world-story-play`, `world-library`, `world-map-packs`, `world-battlefield-maps`, `world-towns-by-hand`, `capability-gm-verbs`. E2E: `game-world-story`, `game-world-files`, `game-world-map-packs`, `game-world-battlefields`, `game-hybrid-terrain`, `game-world-town-layouts`. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` - On this branch after merging staging 983e44f7e (which includes #7473, #7507 and #7510): `pnpm check` green; every `world-*`, `story`, `capability-package`, `agent-activation` and `advanced-memory` lane passes; the six e2e specs above plus `game-world-towns` and `game-world-journal` pass on desktop Chromium (17 tests). - Full regression run on a88f57cd4: 616 of 619 passed. The three that did not (`memory-recall-revectorize`, `regeneration-context`, `native-export-memory`) need memory embeddings, which the test container cannot run because its native ONNX runtime install is skipped; this PR changes no memory or embedding code. The later commit 5a7215a29 only adds rate limits to the library routes, a word boundary in the story attribute reader and docs wording; `route-rate-limits` and `world-story-play` pass on it. - Earlier, on the separate branches: each part's lanes and e2e specs on desktop and mobile Chromium, with planted defects caught for every part; an adversarial placement probe of 37,500 fight starts never changed a painted tile, and one of 16,362 random town layouts found no overlap, every door on a street and no painted roof. ### Manual verification notes - Story scripts: checked with real models from two providers on an isolated instance: start pages and tells, a Game Master event with beats, an arrival with a world person speaking, hidden and shown objectives, and refused tags. One defect was found and fixed (a Game Master event's beats now go in the story block with the event); a re-run narrated the beats in the marking reply on both. - Battlefields and town layouts: the e2e draws a painted board in a tactical fight at its place, and a painted tree and a moved building in the town view. - Not checked by a person yet: writing a story with the guide (authoring is by JSON for now; no story maker is part of this PR), and painting boards or laying out towns, which need a maker that is not part of this PR. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README) as needed - [x] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) - No `CHANGELOG.md` edit, per #7483; "What changed" above is for the release notes. `docs/extending/writing-story-scripts.md` is new; `docs/development/game-combat-roadmap.md`, `docs/development/optional-agent-packages.md`, `docs/game/combat.md`, `docs/game/getting-started.md`, `docs/game/map-time-weather.md` and `docs/game/sessions-and-saves.md` changed. The translations, including the new guide, are tracked on #7512. ## UI evidence (if applicable) No screenshots attached; the e2e specs above drive these screens (the Your worlds picker, the Story section on the World tab, a fight on a painted board and a town with a moved building and painted ground). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Save and manage worlds in your library, then select them during game setup. * Customize town layouts and tactical battlefields; battles at matching world locations can use your authored maps. * Add story scripts to worlds and map packs, with scenes in game narration and objectives in the World journal. * World stories, progress, and other world changes carry into new sessions. * Share world files with their stories and edits, and retain these when the seed and brief remain unchanged. * **Documentation** * Added guides for writing story scripts, editing towns, and using hand-made battlefields. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:08 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7751
No description provided.