Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/screens/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
type MetaCommand,
type OutputBlock,
objectDescription,
objectName,
PackError,
parseCommand,
type SaveGame,
Expand Down Expand Up @@ -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(" ");
}
Expand Down Expand Up @@ -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);
Expand Down
98 changes: 98 additions & 0 deletions docs/adr/0013-names-the-player-knows.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions docs/authoring/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
<!-- prompt:end guide -->

Expand Down Expand Up @@ -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.
<!-- prompt:end checklist -->

## 15. Reviewing a pack (human or generated)
Expand All @@ -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
Expand Down
29 changes: 26 additions & 3 deletions docs/spec/content-pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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). |
Expand All @@ -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`.
Expand Down Expand Up @@ -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`)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/generate/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions packages/engine/src/analyze-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions packages/engine/src/analyze-walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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),
);
}

Expand Down
23 changes: 14 additions & 9 deletions packages/engine/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -52,20 +52,25 @@ const COMPASS: ReadonlySet<string> = new Set([
* "<Label> <object> [<prep> <object>]". For `choose` the option text is
* returned.
*/
export function commandLabel(pack: Pack, command: Command): string {
return commandLabelIn(pack, command, undefined);
export function commandLabel(pack: Pack, command: Command, state?: GameState): string {
return commandLabelIn(pack, command, undefined, state ?? null);
}

/** commandLabel with the current room known, so `go` uses that room's exit label. */
export function commandLabelIn(pack: Pack, command: Command, room: string | undefined): string {
export function commandLabelIn(
pack: Pack,
command: Command,
room: string | undefined,
state: GameState | null,
): string {
const ix = indexPack(pack);
const m = ix.m;
const { verb } = command;
const name = (id: string | undefined) => (id === undefined ? "" : (objectDef(pack, id)?.name ?? id));
const name = (id: string | undefined) => (id === undefined ? "" : objectName(pack, state, id));
const obj = name(command.object);
const withName = name(command.with);

if (verb === "choose") return optionText(pack, command.object) ?? command.object ?? verb;
if (verb === "choose") return optionText(pack, state, command.object) ?? command.object ?? verb;
if (verb === "go") {
const id = command.object ?? "";
const roomLabel = room !== undefined ? pack.rooms[room]?.exits?.[id]?.label : undefined;
Expand Down Expand Up @@ -111,12 +116,12 @@ export function commandLabelIn(pack: Pack, command: Command, room: string | unde
}

/** Text of a dialogue option by id (first dialogue in pack order that defines it). */
function optionText(pack: Pack, optionId: string | undefined): string | undefined {
function optionText(pack: Pack, state: GameState | null, optionId: string | undefined): string | undefined {
if (optionId === undefined) return undefined;
for (const d of Object.values(pack.dialogues)) {
for (const node of Object.values(d.nodes)) {
const o = node.options?.find((x) => x.id === optionId);
if (o) return plainText(pack, o.text);
if (o) return plainText(pack, state, o.text);
}
}
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function emitMsg(ctx: Ctx, kind: OutputKind, template: string, args?: Rec
export function emitText(ctx: Ctx, kind: OutputKind, text: Text | undefined): void {
if (ctx.quiet || text === undefined) return;
const str = resolveText(ctx.pack, ctx.state, text);
if (str !== null) ctx.out.push(...textBlocks(ctx.pack, kind, str));
if (str !== null) ctx.out.push(...textBlocks(ctx.pack, ctx.state, kind, str));
}

export function emitBlocks(ctx: Ctx, blocks: OutputBlock[]): void {
Expand Down
Loading
Loading