From ad39f6d320a97e5609d4cc82cb12f4fcac0f685f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 23:28:18 +0000 Subject: [PATCH] Call characters by name only once the player knows it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The format gave every object one static name, so the engine showed a character's real name on chips, in command labels, conversation headings and {id} references before the player could know it (»Sprich mit Anni« while the text said »die Frau«; Lene never named at all). ADR 0013: an object's name is a Text with variants (additive within lexvm-pack/1). Every place that shows a name resolves it against the state; the parser accepts the words of every variant. lexvm check warns (text.name-before-reveal) when a walkthrough step prints a present character's name before its name variant holds. Guide, checklist and the world, logic and review prompts state the rule; spec, JSON Schema and prompt kit are updated. Die letzte Nacht der Reichsmark 1.2.0: Anni, Kröger, Lene and Tadeusz go by appearance or role until their name falls in conversation; texts before that get variants without the name. Lotte is named as a logical consequence (Anni now says »unsere Tochter«). 0 warnings, exploration complete, 25/25. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01R5RB4cK9E5cLMxHzTdGHXf --- CHANGELOG.md | 8 ++ apps/web/src/screens/game.ts | 5 +- docs/adr/0013-names-the-player-knows.md | 98 ++++++++++++++++ docs/adr/README.md | 1 + docs/authoring/guide.md | 5 + docs/spec/content-pack.md | 29 ++++- packages/cli/src/generate/verify.ts | 1 + packages/engine/src/analyze-text.ts | 6 +- packages/engine/src/analyze-walk.ts | 6 +- packages/engine/src/commands.ts | 23 ++-- packages/engine/src/context.ts | 2 +- packages/engine/src/defaults.ts | 20 ++-- packages/engine/src/describe.ts | 16 +-- packages/engine/src/effects.ts | 2 +- packages/engine/src/index.ts | 2 +- packages/engine/src/parser.ts | 13 ++- packages/engine/src/playtime.ts | 2 +- packages/engine/src/runtime.ts | 13 ++- packages/engine/src/schema.ts | 8 +- packages/engine/src/text.ts | 49 +++++--- packages/engine/src/walkthrough.ts | 62 +++++++++- packages/engine/test/text.test.ts | 36 ++++-- packages/engine/test/walkthrough.test.ts | 39 +++++++ .../design/CHANGES.md | 34 ++++++ .../dialogues.yaml | 20 +++- .../letzte-nacht-der-reichsmark/objects.yaml | 66 ++++++++--- packs/letzte-nacht-der-reichsmark/pack.yaml | 17 ++- packs/letzte-nacht-der-reichsmark/rooms.yaml | 12 +- packs/letzte-nacht-der-reichsmark/rules.yaml | 107 ++++++++++++++---- prompts/oneshot.md | 31 ++++- prompts/templates/logic.md | 2 + prompts/templates/review.md | 9 +- prompts/templates/world.md | 2 +- schema/lexvm-pack-1.schema.json | 38 ++++++- 34 files changed, 647 insertions(+), 137 deletions(-) create mode 100644 docs/adr/0013-names-the-player-knows.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 86ef3fb..72be606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,14 @@ First release in preparation: v0.1 "Playable". prompts state the rule. *Die letzte Nacht der Reichsmark* 1.1.1 learns six entries no earlier than their facts are told (»Der Fall Brodersen« named Tadeusz before Anni did). +- Characters are called by name only once the player knows it + ([ADR 0013](docs/adr/0013-names-the-player-knows.md)): an object's `name` + may be a text with variants (additive in `lexvm-pack/1`), resolved against + the state wherever a name is shown; the parser accepts every variant. + `lexvm check` warns (`text.name-before-reveal`) when the walkthrough calls a + present character by a name not yet revealed. *Die letzte Nacht der + Reichsmark* 1.2.0 introduces Anni, Kröger, Lene and Tadeusz by appearance + first. ### Added diff --git a/apps/web/src/screens/game.ts b/apps/web/src/screens/game.ts index 9fba306..5a8b524 100644 --- a/apps/web/src/screens/game.ts +++ b/apps/web/src/screens/game.ts @@ -8,6 +8,7 @@ import { type MetaCommand, type OutputBlock, objectDescription, + objectName, PackError, parseCommand, type SaveGame, @@ -397,7 +398,7 @@ export function createGameScreen(key: string, fresh: boolean): Screen { function safeLabel(command: Command): string { if (!game) return command.verb; try { - return commandLabel(game.session.pack, command); + return commandLabel(game.session.pack, command, game.session.state); } catch { return [command.verb, command.object, command.with].filter(Boolean).join(" "); } @@ -506,7 +507,7 @@ export function createGameScreen(key: string, fresh: boolean): Screen { lang: lang(), stepText: (step) => stripMarkup(step, (id) => - Object.hasOwn(session.pack.objects, id) ? session.pack.objects[id]?.name : undefined, + Object.hasOwn(session.pack.objects, id) ? objectName(session.pack, session.state, id) : undefined, ), onReveal: (id, count) => { session.setRevealed(id, count); diff --git a/docs/adr/0013-names-the-player-knows.md b/docs/adr/0013-names-the-player-knows.md new file mode 100644 index 0000000..b867f0d --- /dev/null +++ b/docs/adr/0013-names-the-player-knows.md @@ -0,0 +1,98 @@ +# 0013. Names the player knows: object names are text with variants + +- Status: Accepted +- Date: 2026-10-24 + +## Context + +A playtest of *Die letzte Nacht der Reichsmark* found that characters carry +their names before the player can know them. The watchman at the Zollkanal is +"Tadeusz" on his chip, in the room text and in the command "Sprich mit +Tadeusz" before he has said a word; the very first command of the game reads +"Sprich mit Anni" while the text still calls her "die Frau"; and the dealer in +the backyard is "Lene" although nobody ever tells Voss her name. + +The cause is in the format, not only in the text: + +1. **An object had exactly one, static `name`.** The engine shows it on + chips, in command labels and echoes, in the conversation heading, in + default messages and wherever a text says `{id}`. What the player knows + about a character was not part of the model, so the only name available + was the omniscient one. Descriptions could vary with the state; names + could not. +2. **Authors and prompts wrote the name into the prose as well** ("Auf einem + Poller sitzt Tadeusz"), because the format suggested that the id's name is + the character. No rule in the guide, the checklist or the review asked + when the player learns a name, and no check could tell, because the moment + a name is revealed was nowhere in the pack. + +The same pattern let notebook entries run ahead of the story (fixed earlier +by showing them in the transcript): what the player knows at a given moment +was implicit, and nothing checked it. + +## Decision + +1. **`name` is a `Text`.** Like `description`, it is a string or a list of + variants; the first variant whose `when` holds is shown. By convention the + first variant is the name the character ends up with and the last one, + without `when`, the description the player starts with: + + ```yaml + name: + - when: { flag: kennt_tadeusz } + text: Tadeusz + - text: Wächter + ``` + + A plain string keeps working, so the change is additive within + `lexvm-pack/1`. +2. **Every place that shows a name resolves it against the current state:** + chips and the inventory, command labels and echoes, the conversation + heading, default messages, `{id}` markup, parser candidate lists and hint + texts. Code that renders names takes the state explicitly (`null` where + there is none, which shows the first variant). +3. **The parser recognises every variant.** A player who types "Tadeusz" + before the watchman has introduced himself still means the watchman; this + follows the forgiving policy ([ADR 0005](0005-forgiving-policy-verified-by-exploration.md)) + and reveals nothing the player did not type. +4. **A walkthrough check.** `lexvm check` warns (`text.name-before-reveal`) + when a walkthrough step prints an earlier variant's text (the real name, + also as a genitive) while that character is present and still unrevealed + after the step. Mentions in their absence ("Fragen Sie Tadeusz am + Zollkanal") are fine; the step that reveals the name is not checked, + because the reveal usually comes with it. `lexvm generate` ranks the + warning with the walkthrough findings. +5. **The rule for authors:** a character is called by name only once the + player knows the name *and* that this person has it: it falls in + conversation, or it follows compellingly from what the player knows. + Before that, the character is described by appearance or role. The guide, + its checklist and the world, logic and review prompts state it. + +## Consequences + +- Packs can introduce characters the way stories do. The reveal is an + explicit, checkable condition in the pack, usually a flag set where the + name falls. +- Prose before the reveal needs text variants where it mentions a present + character; a `{id}` reference resolves by itself, but German inflection + often needs written-out variants. +- The check only covers the walkthrough, and only the literal name while the + character is present. Paths off the walkthrough and paraphrases still need + the transcript review. +- Saves are unaffected (names are not state); the content hash of a changed + pack changes as with any edit. + +## Alternatives considered + +- **Generic names forever** ("Wächter", "Händlerin"). No format change, but + the game could never call a character by the name the player has learned. +- **Two objects per character**, swapped when the name is revealed. Every + rule, dialogue and condition about the character would exist twice, and + the swap would have to carry location and state across. +- **A dedicated `known` flag per object with an `introduce` effect.** Less + general than conditions and a second mechanism next to text variants; the + variants already express "this name once that holds", and a flag set in + the right dialogue node is just as explicit. +- **Rejecting the real name in the parser before the reveal.** Stricter, but + it punishes players for a guess the story invites and contradicts the + forgiving policy. diff --git a/docs/adr/README.md b/docs/adr/README.md index 1193ffe..ddf0012 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -22,6 +22,7 @@ instead of by accident ([ADR 0001](0001-record-architecture-decisions.md)). | [0010](0010-content-licensing.md) | Content licensing | Proposed | | [0011](0011-text-first-optional-svg-vignettes.md) | Text first, optional SVG vignettes later | Accepted | | [0012](0012-narrative-pacing.md) | Narrative pacing: calibrate play time by reading share, write story before data | Accepted | +| [0013](0013-names-the-player-knows.md) | Names the player knows: object names are text with variants | Accepted | ## When to write an ADR diff --git a/docs/authoring/guide.md b/docs/authoring/guide.md index 9ba5311..9cd701a 100644 --- a/docs/authoring/guide.md +++ b/docs/authoring/guide.md @@ -202,6 +202,7 @@ options that appear when the player holds a clue. - Interrogations progress by knowledge: options with `when: { has: clue_x }` appear once the player knows something. `once: true` hides an option after use. - Confrontations: let the player show evidence — a rule `on: { verb: show, object: clue_x, with: npc_id }` — or offer a dialogue option gated by `has: clue_x`. Give characters a reaction to every clue that plausibly concerns them, and one generic reaction (`on: { verb: show, with: npc_id }`) placed after the specific rules. - Characters remember: change greetings and descriptions with flags after key events. +- Names the player knows: call a character by name only once the player knows the name and that this person has it — it falls in conversation, or it follows compellingly from what the player knows (the missing man found where the confession said he lies). Before that, describe the character by appearance or role. Give such a character a `name` with variants, the real name first: `name: [{ when: { flag: knows_graves }, text: Graves }, { text: porter }]`; `set` the flag in the node or rule where the name falls, and give every text that mentions the present character before that a variant without the name. Hearing a name ("ask Graves at the gate") is not meeting its owner. - Node `say` ≤ 300 characters, option text ≤ 80. Options are the player's words; narration belongs in `say` or `do`. @@ -319,6 +320,7 @@ anyway. The LLM prompts ask the model to go through the same list. 13. **One key per condition and effect.** `{ set: a, score: 1 }` is two effects; two conditions go in a list or `all: […]`. 14. **Score.** Each point is awarded once; `maxScore` equals the walkthrough's total. 15. **Notebook entries ahead of the story.** Every clue description states only what the player has read when its `learn` runs. A dialogue that `learn`s a summary in an early node and says the rest later gives the game away; move the `learn` to the node that says the last fact. +16. **Names before introductions.** A character the player meets as a stranger has a `name` with variants (real name first, the description last) and a flag set where the name falls; no text calls the present character by name before that. ## 15. Reviewing a pack (human or generated) @@ -335,6 +337,9 @@ you. Before you publish, play it on a phone and ask: they went? Is there a moment where something happens without a reason? - Does any notebook entry run ahead of the story? The transcript shows each entry where it is learned; it may only say what the text above it has said. +- Is any character called by name before the player could know it? Read the + commands in the transcript too: "Talk to Graves" before Graves has said who + he is gives the name away. - Does the text read well on a small screen, in the chosen narrative voice, with consistent quotes? Does the rhythm vary, or is it a chain of fragments? - Are there plausible actions that get a bland default answer where a custom diff --git a/docs/spec/content-pack.md b/docs/spec/content-pack.md index 9bcb454..650d094 100644 --- a/docs/spec/content-pack.md +++ b/docs/spec/content-pack.md @@ -95,7 +95,7 @@ holds and should come last. Inside strings: -- `{object_id}` renders the object's `name` as a tappable reference. +- `{object_id}` renders the object's current `name` as a tappable reference. - `{object_id|display text}` renders custom text (for inflected forms such as German cases: `{logbook|des Logbuchs}`) as a reference to `object_id`. - A blank line separates paragraphs; a single newline is a line break. @@ -146,8 +146,8 @@ Everything the player can refer to is an object. | Key | Meaning | |---|---| -| `name` | Display name without article, e.g. `Logbuch`, `brass key`. | -| `synonyms` | Extra parser words. The words of `name` always work. | +| `name` | Display name without article, e.g. `Logbuch`, `brass key`. A `Text` (section 4): variants let a character go by a description until the player learns the name (see below). | +| `synonyms` | Extra parser words. The words of every `name` variant always work. | | `description` | Text printed on *look*. | | `roomText` | Sentence appended to the room description while the object lies directly in the current room (or the current room is listed in its `alsoIn`). Objects without `roomText` that are portable are listed automatically ("You see here: …"). Scenery without `roomText` must be mentioned in the room description. | | `location` | **Required.** Room id, container object id, `inventory` or `nowhere` (not in play yet). | @@ -162,6 +162,28 @@ Everything the player can refer to is an object. | `hidden` | Absent until revealed with `reveal`. | | `verbs` | Extra verbs offered in the action sheet (e.g. `read`, `push`). | +**Names the player knows.** A character is called by name only once the +player knows the name and that this person has it ([ADR 0013](../adr/0013-names-the-player-knows.md)). +Write the name the character ends up with as the first variant and the +description the player starts with last: + +```yaml +tadeusz: + name: + - when: { flag: kennt_tadeusz } + text: Tadeusz + - text: Wächter + synonyms: [Wachmann] +``` + +Every place that shows the name uses the current variant: chips, command +labels and echoes, the conversation heading, default messages, `{id}` markup +and hints. The parser accepts the words of every variant. Set the condition +where the name falls (a `set` in the dialogue node), and give texts that +mention the present character before that a variant without the name; +`lexvm check` warns (`text.name-before-reveal`) when the walkthrough does +otherwise. + **Presence.** An object is *present* when it is not hidden and either its location chain leads to the current room or to `inventory` (through containers that are open or not openable), or the current room is listed in `alsoIn`. @@ -707,6 +729,7 @@ walkthrough, play time and exploration results. | `walkthrough.ended-early` | error | The game ended before the last step. | | `walkthrough.not-won` | error | The walkthrough does not end in a winning ending. | | `walkthrough.not-offered` | warning | A step works only as a typed command: no action sheet offers it. | +| `text.name-before-reveal` | warning | A step prints a character's name while the character is present and still shown by an earlier description (its name variant does not hold yet, also not after the step). | | `walkthrough.score-mismatch` | warning | The walkthrough's final score differs from `maxScore` (not reported again when `score.maxScore-unreachable` already explains it). | **Exploration** (`lexvm check`) diff --git a/packages/cli/src/generate/verify.ts b/packages/cli/src/generate/verify.ts index 5917bab..fa938d4 100644 --- a/packages/cli/src/generate/verify.ts +++ b/packages/cli/src/generate/verify.ts @@ -163,6 +163,7 @@ function warningRank(code: string): number { if (/^playtime\./.test(code)) return -1; // the pack misses its target length if (/^explore\./.test(code)) return 0; // exploration findings (incomplete with --allow-incomplete) if (/^walkthrough\./.test(code)) return 1; + if (code === "text.name-before-reveal") return 1; // the story calls a character by a name not yet learned if (/shadow|unreach|unused|unreferenced|score/i.test(code)) return 2; if (/^(ref|semantic|dialogue|rule|exit|hint)/.test(code)) return 3; if (/text|length|budget|style/i.test(code)) return 5; diff --git a/packages/engine/src/analyze-text.ts b/packages/engine/src/analyze-text.ts index 162a915..c47b1ac 100644 --- a/packages/engine/src/analyze-text.ts +++ b/packages/engine/src/analyze-text.ts @@ -112,12 +112,14 @@ function checkUnmentioned(ix: PackIndex, out: DiagnosticList): void { // Portable objects without roomText are listed automatically; clues live in the notebook. if (object.portable || object.clue || object.roomText !== undefined) continue; const rooms = [...(pack.rooms[object.location] ? [object.location] : []), ...(object.alsoIn ?? [])]; - const name = object.name.toLowerCase(); + const names = (typeof object.name === "string" ? [object.name] : object.name.map((v) => v.text)).map((n) => + n.toLowerCase(), + ); for (const roomId of rooms) { const room = pack.rooms[roomId]; if (room === undefined) continue; const mentioned = textStrings(room.description).some( - (s) => markupRefs(s).some((r) => r.id === id) || s.toLowerCase().includes(name), + (s) => markupRefs(s).some((r) => r.id === id) || names.some((name) => s.toLowerCase().includes(name)), ); if (!mentioned) { out.info( diff --git a/packages/engine/src/analyze-walk.ts b/packages/engine/src/analyze-walk.ts index a8c5ccb..00f2d07 100644 --- a/packages/engine/src/analyze-walk.ts +++ b/packages/engine/src/analyze-walk.ts @@ -14,7 +14,7 @@ import { type Pack, type Text, } from "./schema.ts"; -import { objectDef } from "./text.ts"; +import { objectDef, objectName } from "./text.ts"; /** Where a piece of logic lives; lets checks treat e.g. turn rules specially. */ export type Site = @@ -108,6 +108,7 @@ export function walkPack(pack: Pack, v: Visitor): void { } for (const [id, object] of Object.entries(pack.objects)) { const site: Site = { kind: "object", object: id }; + visitText(object.name, `objects.${id}.name`, site, v); visitText(object.description, `objects.${id}.description`, site, v); visitText(object.roomText, `objects.${id}.roomText`, site, v); } @@ -196,7 +197,8 @@ export function markupRefs(text: string): Array<{ id: string; display?: string; export function renderedText(text: string, pack: Pack): string { return text.replace( /\{([^{}|]*)(?:\|([^{}]*))?\}/g, - (_, id: string, display?: string) => display ?? objectDef(pack, id.trim())?.name ?? id, + (_, id: string, display?: string) => + display ?? (objectDef(pack, id.trim()) ? objectName(pack, null, id.trim()) : id), ); } diff --git a/packages/engine/src/commands.ts b/packages/engine/src/commands.ts index 903bc0e..2e65f3d 100644 --- a/packages/engine/src/commands.ts +++ b/packages/engine/src/commands.ts @@ -3,8 +3,8 @@ import { exitLabelAnywhere } from "./affordances.ts"; import { fill, type StandardExit } from "./messages/index.ts"; import { indexPack, isCoreVerb } from "./pack-index.ts"; import type { Pack } from "./schema.ts"; -import { objectDef, plainText } from "./text.ts"; -import type { Command } from "./types.ts"; +import { objectName, plainText } from "./text.ts"; +import type { Command, GameState } from "./types.ts"; /** Canonical string form: "verb [object [with]]". */ export function formatCommand(command: Command): string { @@ -52,20 +52,25 @@ const COMPASS: ReadonlySet = new Set([ * "