Files
de-praxis/docs/campaign-format.md
T
juli 3bdf2d70a0 Fix relay discovery for long non-ASCII names, alerts while incapacitated and crew case
The LAN beacon only answers with a reply no larger than the probe, but
cut names by characters, so a relay named in Cyrillic, CJK or emoji
could need more than 160 bytes and never answered scans. Names are now
shortened by whole characters until the reply fits.

Frozen or fainted operators got a 'your move' alert every cycle although
they can't act. {crew|upper} and {crew|lower} used the filter as a
separator instead of changing case.
2026-10-25 14:21:44 +01:00

15 KiB
Raw Permalink Blame History

Writing a campaign: format reference (de-praxis/campaign@1)

A campaign is one JSON file. The relay reads it, checks it, and runs it. Campaigns contain only data, with no scripts, so a relay can safely load one written by a stranger.

Start by copying one of the built-in campaigns:

  • dead-channel.json: one room, flags, clue decks and checks.
  • hollow-point.json: also uses locations, items, a dread stat that can freeze operators, private memories and a hidden role goal. Check your work as you go:
./server/build/install/server/bin/server campaign validate my-campaign.json

The validator lists every problem with its location, such as $.actions[2].success[0].set: Unknown flag 'powr'.. Errors must be fixed before the campaign can load. Warnings point at things that are probably mistakes, like a flag nothing uses. Add --strict to fail on warnings too (useful in CI), or --json for a machine-readable report.

For autocomplete and inline errors in VS Code or another editor, keep this line at the top of your file. The schema is in campaign-v1.schema.json and ships next to the server in campaigns/:

"$schema": "campaign-v1.schema.json",

How a game runs

  1. Players join, each with a role. The host starts; the intro lines are posted.
  2. Every round, each player picks an action and may describe it. Actions they can't take right now are refused with the action's message, and their turn isn't spent.
  3. When everyone has submitted, actions resolve: first actions, then normal ones in crew order, then last ones. An action either applies its effects directly, or rolls a check and applies its success or failure effects.
  4. After the round, if every operator is incapacitated, the campaign ends with rules.allDown. Otherwise the clock goes down by one. At zero the campaign ends with the clock's ending. Otherwise any beat for that clock value is posted, then the new scene if it changed, or else an ambient line.
  5. An end effect finishes the campaign immediately for everyone.

A check succeeds when roll + bonus ≥ DC. The bonus is:

  • the role's bonus for that action (or rules.offRole if it has none),
  • plus rules.prepare if the player is prepared (preparation is then used up),
  • plus the action's learned approach: each setback adds rules.setback.step to that action's future checks, up to rules.setback.cap;
  • plus any of the check's modifiers whose condition holds.

Top-level fields

Field Required What it is
format yes Always "de-praxis/campaign@1".
meta yes id (lowercase, digits, hyphens), version (semver like 1.2.0), title, authors, license (SPDX id, e.g. CC-BY-SA-4.0). Optional: tagline, description, language (en), players {min, max}, minutes, warnings (content warnings).
rules yes clock {start, onZero, label} is required. Optional with defaults: dice 20, dc 10, offRole 1, prepare 3, setback {step: 2, cap: 4}. allDown names the ending for when every operator is incapacitated.
roles yes id, name, optional blurb and bonus ({ "action-id": 4 }).
state no flags (true/false facts, all start false) and counters ({ "name": { "start": 0, "max": 3 } }, values 0–99).
objectives no Shown to players as a checklist: id, label, flag (done when set), optional, and role for a hidden goal only that role sees until the end.
actions yes What players can do each round; see below.
scenes yes chapter, title, prompt, optional when. The first scene whose condition holds is shown; the last must have no condition.
decks no Ordered clue cards; see draw.
beats no { "clock": 4, "text": "…" }: said when the clock reaches that value.
ambient no Lines said at the end of a round when nothing else did; first matching when wins.
endings yes id, title, text, grade (best, mixed or bad), optional debrief. The reported ending is the title in capitals.
intro no Lines posted when the host starts.
narrator no brief and style for the optional LLM narrator, which only adds atmosphere.
text no Wording of the engine's own lines (round header, player action, roll line, PASS/FAIL, moving, incapacitated).
items no Things operators carry; see below.
stats, statuses no Per-operator values and conditions; see below.
locations, start no Places to move between; see below.

Log lines have a kind that the app styles: DM (story, the default), SYSTEM (rules) or SCENE (where you are).

Actions

{
  "id": "restore", "label": "Restore", "hint": "Bring the emergency power online. DC 10.",
  "allowed": [{ "when": { "not": "power" }, "otherwise": "That objective is already complete." }],
  "redundant": { "when": "power", "effects": [{ "prepare": "self" }, { "say": "{player} backs up the crew." }] },
  "check": {},
  "success": [{ "set": "power" }, { "say": "Emergency power restored." }],
  "failure": [{ "setback": true }, { "say": "The breaker trips." }]
}
  • allowed: rules checked in order when a player submits. If a when is false, the action is refused with otherwise. The app also hides actions that would be refused.
  • redundant: checked when the action resolves. If true, these effects replace the action. Use it for "a crewmate finished this earlier in the same round".
  • An action has either effects (no roll) or check with success/failure. check may override the DC: { "dc": 14 }.
  • order: first, normal (default) or last.
  • at: locations where the action is offered, e.g. ["shed"]. Empty means anywhere.
  • roles: roles that have this action, e.g. ["keeper"]. Other roles never see it, which keeps role secrets secret. Empty means everyone.
  • check.modifiers: conditional bonuses, e.g. [{ "when": { "has": "multimeter" }, "value": 2 }, { "when": { "stat": "dread", "atLeast": 2 }, "value": -2 }].

If an operator who isn't incapacitated has nothing they can do (every action refused and every exit closed), the relay offers a built-in Wait (id wait), so the round still resolves and the clock keeps running. The validator warns about situations where this can happen. A campaign that defines its own wait action gets no built-in one.

Conditions

Condition True when
"power" the flag is set
true / false always / never
{ "not": C }, { "all": [C, …] }, { "any": [C, …] } logic
{ "counter": "discoveries", "atLeast": 2 } counter comparison (atLeast, atMost, equals)
{ "clock": { "atMost": 3 } } rounds remaining
{ "round": { "even": true } } round number (atLeast, atMost, equals, even)
{ "role": "engineer" } the acting player has this role
{ "has": "fuse" } the acting player carries it, or it's in the crew pool
{ "crewHas": "key" } anyone carries it, or it's in the crew pool
{ "stat": "dread", "atLeast": 2 } the acting player's stat (atLeast, atMost, equals)
{ "status": "frozen" } the acting player has the status
{ "at": "shed" }, { "crewAt": "lamp" } the acting player is there / everyone who isn't incapacitated is there

Conditions nest at most 8 levels.

Effects

Effects run in order. After an end effect, nothing more runs.

Effect Does
{ "set": "flag" }, { "clear": "flag" } change a flag
{ "add": "counter", "by": 1 } change a counter, kept within 0..max
{ "prepare": "self" } or "crew" grant preparation
{ "setback": true } raise this action's learned approach (checked actions only)
{ "say": "text", "kind": "SYSTEM", "to": "self" } post a log line. kind defaults to DM. to is crew (default), self, here (operators at the same location) or role:<id>.
{ "draw": "deck" } post the deck's next card. Once the cards run out, post its first matching fallback line. If the deck has a counter, that counter is the draw position and goes up by one.
{ "end": "ending-id" } end the campaign
{ "if": C, "then": [ … ], "else": [ … ] } choose by a condition
{ "give": "fuse" }, { "give": "fuse", "to": "crew" } personal items go to the acting operator (or to every operator); crew items go to the shared pool
{ "take": "fuse" } remove it from the acting operator, or else from the pool
{ "use": "fuse" } spend one use; the item is gone after its last use
{ "adjust": "dread", "by": 1, "to": "crew" } change a stat for the acting operator (default) or everyone, within its min and max
{ "status": "frozen" }, { "recover": "frozen" } apply or clear a status (to: self or crew)

Placeholders

Text can include {player}, {role}, {action}, {text} (what the player typed), {round}, {clock}, {scene} (current scene prompt) and {approach} (this action's learned bonus). {crew} lists the crew joined by commas; {crew|. } uses another separator. Add |upper or |lower to change case, e.g. {action|upper} or {crew|upper}. The roll line can also use {dice}, {dc}, {roll}, {bonus}, {total} and {result}.

{location} is the acting operator's location and {status} names the status that stops them (in text.incapacitated).

Placeholders are filled in once, so a player named {crew} is shown literally. Scene prompts are plain text.

Items

"items": [
  { "id": "key", "name": "Shed key", "scope": "crew" },
  { "id": "fuse", "name": "Ceramic fuse", "scope": "personal", "uses": 1 }
]

personal items are carried by one operator; crew items sit in a shared pool. uses makes an item consumable. Gate actions with has in allowed, give bonuses with check modifiers, and lock exits with crewHas.

Stats and statuses

"stats": [{ "id": "dread", "name": "Dread", "start": 0, "min": 0, "max": 3,
            "atMax": { "status": "frozen", "say": "{player} cannot make their legs move." } }],
"statuses": [{ "id": "frozen", "name": "Frozen", "incapacitated": true }]

Every operator has their own value for each stat. When an adjust brings a stat to its min or max, that threshold's status and line apply. An incapacitated operator can't submit actions. The round resolves without them, and an action they submitted earlier in the round is skipped. When every operator is incapacitated, the campaign ends with rules.allDown, which is required whenever a status can incapacitate.

Private information

  • say with to: "self", "here" or "role:<id>" posts a line only those operators see.
  • A deck with "personal": true keeps a separate position for each operator, and only the drawer sees the card.
  • An objective with a role is a hidden goal. Only that role sees it until the campaign ends, when everyone does.
  • The optional narrator only ever receives lines everyone can see.

Locations

"locations": [
  { "id": "cottage", "name": "the keeper's cottage",
    "exits": [{ "to": "lamp" }, { "to": "shed", "when": { "crewHas": "key" }, "otherwise": "The shed is padlocked." }] },
  { "id": "shed", "name": "the generator shed", "exits": [{ "to": "cottage" }],
    "onEnter": [{ "adjust": "dread", "by": 1 }] }
],
"start": "cottage"

With locations, every operator has a position, starting at start. A built-in move action (id move, reserved) takes the operator through an open exit; a closed exit is refused with its otherwise text. onEnter effects run for the operator who arrives. Scenes are worked out for each operator, so tie them to places with { "at": "shed" }. Each operator gets their own scene line, privately.

Operators can hand a personal item to a crewmate in the same place with the built-in pass action (id pass, reserved when the campaign has personal items). The item keeps its remaining uses, and they add to the recipient's if they already carry one. Its log line is text.handOver, with {item} and {recipient}.

What the validator checks

  • Structure and types; unknown fields are errors, which catches typos.
  • References: every flag, counter, action, deck, ending and role you mention must exist.
  • Limits:
    • document size: 512 KiB;
    • counts: 32 flags, 16 counters, 8 roles, 60 actions, 16 endings, 24 items, 4 stats, 8 statuses, 24 locations, 500 effects;
    • text lengths: labels 24, titles 60, hints 160, log text 1,000 characters.
  • Reachability: it plays out everything a single operator could reach (flags, counters, items held, stats, statuses and location, including moves), and reports:
    • objectives that can never be completed (error);
    • campaigns where only the clock can end the game, or the fastest ending takes more rounds than the clock allows (error);
    • actions that are never offered, or endings that are never reached (warning);
    • situations where an operator of some role has nothing to do but wait (warning).
  • Housekeeping: flags that are never used, set but never checked, or checked but never set; unused counters and decks; no best ending.

Sharing: packages and catalogs

A package (.dpc) is a zip with manifest.json (format de-praxis/package@1, the campaign's id and version, and a SHA-256 for each file), campaign.json, and optionally cover.png (at most 1 MiB and 1600 px a side) and README.md. Packages are limited to 4 MiB unpacked and are fully validated on import.

server campaign pack my-campaign.json --cover cover.png --readme README.md   # writes my-campaign-1.0.0.dpc
server campaign simulate my-campaign-1.0.0.dpc --runs 2000 --strategy explore

simulate plays many games and reports how often each ending occurs and how long games last. expert (the default) plays the shortest route to the best ending, explore tries untried actions first like newcomers, and random picks any legal action.

A catalog is a static index.json next to its packages, so any web server, Git forge or file host can serve one:

server campaign catalog --name "Friends' shelf" --description "Campaigns we play on Fridays." ./shelf --out ./shelf/index.json
{
  "format": "de-praxis/catalog@1",
  "name": "Friends' shelf",
  "description": "Campaigns we play on Fridays.",
  "campaigns": [
    { "id": "tidewater", "version": "1.1.0", "title": "Tidewater", "tagline": "…", "authors": ["juli"], "license": "CC-BY-SA-4.0",
      "minPlayers": 1, "maxPlayers": 2, "minutes": 25, "url": "tidewater-1.1.0.dpc", "sha256": "7a52…", "size": 3656 }
  ]
}

url is relative to the index unless --base-url is given. Each id may appear once, so list only the newest version. Relays follow the index URL in the control panel and verify every download against sha256 before importing it. Unknown fields are errors.