diff --git a/docs/engines.md b/docs/engines.md index c923e0efc2..6002895d46 100644 --- a/docs/engines.md +++ b/docs/engines.md @@ -80,6 +80,7 @@ and clamped by code. - **Overworld and region map generation** - seeded value-noise terrain on a 96x72 grid with genre reskins, reconciling locations to anchors lazily as the party travels. A room or street the GM files under a bigger place (move_party's partOf, or a name that opens with the place's own) shares that place's dot; a new place lands at the direction and distance the GM gave; names on the map make way for each other (src/lib/overworld/places.ts, label-layout.ts). - **Battle map generation** - seeded tactical maps (terrain, lighting, spawns, line of sight and cover, movement budgets, pathfinding), regenerable from the encounter. - **Location persistence** - structured per-area layout, exits, and connections so narration stays spatially consistent, plus an illustrated top-down map image. +- **A party that splits up** - the server keeps who is where once some of the party goes and the rest stay. The story follows one group at a time and cuts to the others when they act, one reply for each group, so two rooms are never told as one. A call reaches only who is in the scene, a fight, a rest and a group check belong to it, and going where the others wait brings the party back together. A small narrator rarely says who goes, so the players' own words are read as the turn opens, by the utility model, for who stays behind: the narrator is told, and the server records the parting itself when the narrator does not. - **Living-world tick engine** - a zero-model-call heartbeat that advances world state on dice and computes encounter pressure after each narration. - **World arcs** - one or two escalating off-screen storylines that advance whether or not the party engages them. - **NPC agency** - once-per-chapter goal advancement for every tracked NPC with no model call, surfacing outcomes as rumors and world facts. diff --git a/scripts/browser/scenarios/100-party-split.mjs b/scripts/browser/scenarios/100-party-split.mjs index d0f8a52f82..9cbb203b93 100644 --- a/scripts/browser/scenarios/100-party-split.mjs +++ b/scripts/browser/scenarios/100-party-split.mjs @@ -55,6 +55,36 @@ export default { await untilStill(page); await t.shot("split"); + // ---- The split is kept (issue 951): the table says who is where ---- + // The scene line under the title names who the story is with, and the + // party panel marks whoever is not there. Seren may have slipped away + // in the split, so the mark is read off Ilse, who stayed. + const sceneLine = page.locator(`${root}.session-heading p`).first(); + await eventually(async () => /The Old Mill · .*Kael Ashvale/.test((await sceneLine.textContent()) ?? ""), { label: "the scene line naming who the story is with" }); + check(!/Ilse Marrow/.test((await sceneLine.textContent()) ?? ""), "the scene line leaves out who stayed behind"); + await openPanelTab(t, "party"); + const ilse = page.locator(`${root}[data-party-card]`).filter({ hasText: "Ilse Marrow" }).locator("visible=true").first(); + await eventually(() => ilse.count(), { label: "Ilse's card in the party panel" }); + const mark = ilse.locator("[data-elsewhere]").first(); + await eventually(() => mark.count(), { label: "the mark on a character who is elsewhere" }); + check((await mark.textContent())?.trim().startsWith("At "), `the mark says where: ${await mark.textContent()}`); + const kaelCard = page.locator(`${root}[data-party-card]`).filter({ hasText: "Kael Ashvale" }).locator("visible=true").first(); + check((await kaelCard.locator("[data-elsewhere]").count()) === 0, "nobody the story is with is marked"); + // The mark comes in, as a combatant's side does (globals.css .side-badge). + check((await mark.evaluate((node) => getComputedStyle(node).animationName)) === "side-badge-in", "the mark animates in"); + await mark.scrollIntoViewIfNeeded(); + await untilStill(page); + await t.shot("elsewhere"); + // The same in the day theme, where the mark must still read. + const theme = await page.evaluate(() => document.documentElement.dataset.theme ?? ""); + await page.evaluate(() => (document.documentElement.dataset.theme = "light")); + await untilStill(page); + const ink = await mark.evaluate((node) => ({ color: getComputedStyle(node).color, background: getComputedStyle(node).backgroundColor })); + check(ink.color !== ink.background, `the mark has ink on its ground in the day theme (${ink.color} on ${ink.background})`); + await t.shot("elsewhere-day"); + await page.evaluate((mode) => (document.documentElement.dataset.theme = mode), theme); + await openPanelTab(t, "dm"); + // ---- A deed's form: who spoke against it ---- await tab("social"); await open("Relationship beat"); diff --git a/scripts/lib/enforce-narrator.mjs b/scripts/lib/enforce-narrator.mjs index 029650c731..e6b0cfa3ef 100644 --- a/scripts/lib/enforce-narrator.mjs +++ b/scripts/lib/enforce-narrator.mjs @@ -31,6 +31,11 @@ import http from "node:http"; import { answerReader, isReaderRequest } from "./claims-reader.mjs"; +// The first words of the read that asks the players' words whether the party +// parts (party-split-logic.ts PARTING_PROMPT_START), spelled here so this +// helper loads before src/. +const PARTING_PROMPT_START = "You read what the players at a tabletop RPG table just said, and tell whether the party parts ways"; + // The AI's door into the engine: an AI turn and actor kind "ai", the way a // delegated turn or an AI share of an assisted session reaches it. export async function aiEngine(world) { @@ -103,6 +108,8 @@ export async function fakeModel({ slots = 0 } = {}) { const requests = []; let readerScript = []; const readerRequests = []; + let partingScript = []; + const partingRequests = []; const fallback = reply({ text: "The moment settles, and the table waits on the next move." }); function sse(res, entry) { @@ -224,6 +231,16 @@ export async function fakeModel({ slots = 0 } = {}) { answerReader(res, readerScript.shift() ?? []); return; } + // The read of the players' words for whether the party parts, as a + // turn opens (src/lib/dm/party-split.ts readParting): nobody parts, + // unless the test says who with model.parting([...]), so a scripted + // turn's replies are never spent on it. + if (String(body.messages?.[0]?.content ?? "").startsWith(PARTING_PROMPT_START)) { + partingRequests.push(body); + res.writeHead(200, { "Content-Type": "application/json" }); + res.end(JSON.stringify({ choices: [{ index: 0, finish_reason: "stop", message: { role: "assistant", content: JSON.stringify(partingScript.shift() ?? { stays: [], to: "" }) } }] })); + return; + } requests.push(body); slotState.restarted = false; const entry = script[served] ?? fallback; @@ -259,6 +276,13 @@ export async function fakeModel({ slots = 0 } = {}) { return { requests, readerRequests, + // What the parting read answers, one per read: + // { stays: [{ name, quote }], to }. + partingRequests, + parting: (entries) => { + partingScript = [...entries]; + partingRequests.length = 0; + }, slotLog, slots: { restart: () => { diff --git a/scripts/name-lookups.json b/scripts/name-lookups.json index 1695517972..613905c6ef 100644 --- a/scripts/name-lookups.json +++ b/scripts/name-lookups.json @@ -513,7 +513,7 @@ "app/campaigns/[campaignId]/MessageParts.tsx#partial": [ [ "pattern", - 7, + 13, "a fixed pattern over text that reads no record's name: its English words are scripts/text-comparisons.json's to classify" ], [ @@ -2117,8 +2117,14 @@ "lib/dm/party-conduct.ts#whole": [["identity",1,"a companion's standing with one character, by its whole name (textKey)"]], "lib/dm/party-logic.ts#bypass": [["identity",1,"a stash line by its whole own name and facts"]], "lib/dm/party-logic.ts#whole": [["identity",1,"a stash line by its whole own name and facts"]], - "lib/dm/party-split.ts#first": [["key",1,"the one name of a list of one, for a sentence"]], - "lib/dm/party-split.ts#whole": [["identity",4,"who goes when the party splits, by characterId or whole name (textKey), and whether move_party names only some of them"]], + "lib/dm/party-split-logic.ts#whole-single": [["identity",1,"two place names compared whole through textKey, for whether a move goes where a group of a split party is (issue 951)"]], + "lib/dm/party-split-logic.ts#partial": [["key",5,"a character id in a group's or a move's list of ids, compared as stored (issue 951)"],["search",1,"a reader's quote held to the words the players wrote, both through textKey: the words being found there is the point, and a miss leaves nobody behind"]], + "lib/dm/party-split-logic.ts#keyed": [["key",1,"a character id as the key of the cut's own record of who came into the scene"]], + "lib/dm/party-split-logic.ts#whole": [["identity",3,"a character a call or a reader's reply names, by id or whole name through textKey, against those elsewhere or the party (issue 951); a name that fits nobody is nobody"]], + "lib/db/locations.ts#partial": [["identity",1,"a follower's recorded place among the places the party left, whole names through textKey (issue 951)"]], + "lib/dm/party-split.ts#partial": [["key",2,"a character id in a group's or a read's list of ids, compared as stored (issue 951)"]], + "lib/dm/party-split.ts#whole-single": [["identity",1,"the place a move goes to against the place the scene is at, whole names through textKey (issue 951)"]], + "lib/dm/party-split.ts#whole": [["identity",2,"who goes when the party splits, by characterId or whole name (textKey)"]], "lib/dm/party-story.ts#partial": [["parse",6,"a model draft's quotes and its last sentence end"]], "lib/dm/party-tools.ts#bypass": [["identity",2,"the taken line's own name, granted as it was and named in the carrying refusal"]], "lib/dm/party-tools.ts#whole": [["identity",1,"a sheet by whole name"]], diff --git a/scripts/smoke-local.mjs b/scripts/smoke-local.mjs index cfdec52808..dda97adbe1 100644 --- a/scripts/smoke-local.mjs +++ b/scripts/smoke-local.mjs @@ -18,9 +18,11 @@ // node scripts/smoke-local.mjs --provider local --model gemma4:31b-it-qat [--runs 6] // (Ollama native API at OLLAMA_BASE_URL; LOCAL_TEXT_CONTEXT caps num_ctx) // options: --turns N (how many of the scenario's turns to play, default all) -// --scenario ford|town|skirmish (the ford's five turns, the town's -// eight: arrival, an NPC, persuasion, a purchase, stealth, a fight, -// attacks; or the skirmish's nine, a fight over several rounds) +// --scenario ford|town|skirmish|split (the ford's five turns, the +// town's eight: arrival, an NPC, persuasion, a purchase, stealth, a +// fight, attacks; the skirmish's nine, a fight over several rounds; +// or the split's five, a party that splits up, acts in two places +// at once and comes back together) // --label NAME --out DIR (writes