Game systems

A game system is the data of one game: fields, sheet, formulas, pages and rules text. The engine knows no game; each campaign plays one system. Examples come from the 5e and from systems/free, the one system the engine ships. src/systems/read.ts reads a system.yaml against schema.ts.

1. The folder

systems/<name>/
  system.yaml           what the system declares (section 2)
  LICENSE.md            license and attribution
  world/                its pages (section 4)
  rules/*.md            its rules, one chapter a file
  images/               pictures its pages link in `image`
  instructions/*.md     additions to the master's instructions (section 4)
  words/<code>.yaml     its words in other languages (section 4)
  translations/<code>/  its pages and rules in another language (section 4)
  versions/<name>/      a version of its rules (section 2)
  theme/                its dashboard theme (section 2)
  package.json          npm name, version, API, code (section 6)
  build/, test/         not shipped
  • package install 5e installs from npm, package install ./my-system from a folder; package new "<title>" --kind system makes a TypeScript package with passing tests.
  • A campaign names its system in campaign.yaml (system: 5e).
  • An unknown key, an unreadable formula, or a key naming a missing or wrong-kind field, group, condition, table or occasion refuses the system.
  • The schema is part of the package API: a new key comes with a new API number, which a system using it declares. A folder without package.json is data alone.

2. system.yaml

Only title and language are required. Field names ignore case.

Key Does
title the system’s name
language the language its pages are named in, as en
attribution the credit its source requires; the dashboard shows it

Theme

theme: theme names the folder holding theme.yaml, data the engine checks and turns into CSS custom properties. dashboard-style.md says what each value changes.

Key Shape
name text
version, engine its version; the lowest rpg-engine that reads it, quoted ("0.22")
fonts [{family, file, weight, license}]: woff2, woff, ttf or otf, each with its license file
text-font, title-font, story-font a family of fonts
story-size 0.85 to 1.4 of the page’s letters
number-font text or title
corners px, 0 to 16
titles {case: as-written, capitals or small-capitals, spacing}
cards {inner-line, ornament, corner, texture}
buttons, tabs, bars, pips {shape}: rounded, square, pill, cut, underline, slanted, round as each allows
shadows soft, sharp, none or glow
papers {documents, maps} colours
portraits {shape, frame}
style a CSS file, added in layer theme-style over the page’s rules
icons SVGs for party, scene, combat, journal, world, saves, help, settings, about, packages, menu
light, dark each mode’s colours, both required
variants [{name, light, dark}]: colour variants offered in Settings
  • Mode colours: required paper, panel, rule, ink, muted, accent, gold, on-gold, ally, low. Optional, else derived: panel-2, float, gold-ink, warn, on-low, action, on-action, dice, on-dice, card-edge, title-glow, bar-edge, card-grain, shadow, portrait-frame, bar.
  • Mode pictures: page-texture, bar-texture, head-picture as {picture, fit: tile or cover}; page-ink, bar-ink, head-ink, head-ink-2 colour an SVG picture’s currentColor.
  • Maps: maps: {paper, ink, floor, things, water, land, roads} in a mode; paper and ink required, the rest derived.
  • Variants change colours only, never pictures, faces, shapes or papers.
  • Files stay in the theme folder, at most 1000 KB each, named with their case on disk; icons are SVG paths on a 24 grid. The cards’ texture SVG paints only in currentColor, with no style, picture, filter or animation. The style sheet’s url() names only theme files, with no @import or font faces.
  • Checks: the engine measures contrast (text 4.5:1, focus ring 3:1) in each mode and variant; a failing theme is not used and validate names the colour to change.
  • A theme is also a package of its own, for any system: a repo with the topic rpg-engine-theme, a .zip or a folder with theme.yaml at its top; see the theme guide.

fields

fields: {hp: counter, str: number, str-mod: modifier}. An undeclared field written as a number or current/max counts as a counter.

Kind Meaning
counter 12 or current/max, changed with change
number a number, never counted
at-least raised by pages of bonus-lists, never lowered
modifier shown with its sign
bonus effects add it up; missing reads 0
factor effects multiply it (2, 1/2); missing reads 1
length, weight worked out, shown in the game’s unit and in metric for a metric player
duration minutes, shown as 1h 30m
text text, or true/false
list a list
rolls dice kept for later

Measures, money and travel

Key Does
coins gp 100, pp 1000 rare, sp 10, cp 1: each coin’s value in the smallest; rare never given as change
coin-metals {gp: gold}, as the dashboard draws coins
round 6 seconds
dawn "06:00"; passing it, the output lists counters to restore
imperial {mile, foot, pound} in metric, for imperial campaigns
length-unit the unit of computed lengths, as ft
load {field, limit, coins, weightless, bundle, stages}: carried weight against a limit; formulas read load and load-limit
travel {paces, pace, hours, rule, beyond, terrain, vehicles, kinds}: paces per hour, day length, terrain factors, vehicles and kinds of route
grid {square, diagonal, difficult, speed, walking, size, footprints, leaving}: how a place’s map counts movement

settings, engine-settings, versions

settings:
  outcomes:
    about: how what happens is decided
    rolled: {means: "for the master", player: "for the player", asks: [die], suggested: true}
engine-settings: {rigor: [smooth]}
  • settings: what the setup asks. Each value has means; optional player, without, asks, suggested and engine-settings.
  • engine-settings: the values offered of an engine setting such as rigor or lethality; one value alone is enforced, never asked.
  • versions: written as a setting, picked with the engine setting ruleset; the first listed is the default, so list the oldest first. Each has versions/<name>/ in the system’s shape, with a system.yaml of only the keys it changes; maps merge by name, lists and values replace, a same-named page, chapter or word replaces.

The sheet

sheet:
  Abilities: [str (str-mod), dex (dex-mod), proficiency]
status-line: [level, hp, temp-hp?]
Key Does
sheet groups of fields in order; field? only when it applies, field (beside) beside it, inventory lists what is carried
sheet-notes what write says of a group when a character joins
sheet-icons a group’s icon, an SVG path on a 24 grid
token-icons {field, icons}: a token’s mark by a field’s value
sheet-headline the line under a name, as "Level {level} {classes}"
sheet-cards {rail, order, at-hand}: where the dashboard puts groups
sheet-actions list fields to verbs (attack, use, equip, unequip or the system’s) the player acts with
sheet-verbs the system’s verbs: {label, title, says, says-on, says-at, says-self}
sheet-dice the free roll’s dice by field, as 1d20 or 2d20kh1
sheet-odds {better, worse, when}: dice of better and worse free rolls
sheet-knowledge fields whose checks recall knowledge
status-line the line in status; ? hides a field at zero
values, sheet-values closed lists in the system’s language; sheet-values only on pages with a sheet
marks lists that mark the numbers reading them (stealth +7 ●●)
roll-names what the game calls a roll, by language
oracle {yes: low or high}: where the oracle’s d100 says yes

Play

Key Does
rewards {xp: {from, overcome}}: what overcome creatures give, proposed at scene close
thresholds {hp 0: Rule}: the rule a counter touches at a value or formula
recipes rests: set, regain, lower, spend, needs, once-per, lasts, ends, rules
upkeep {daily, short, grace, worsens, water, lifestyle, rules}: food and lodging under rigor rules or simulation
expenses {name: {costs, every, rules}}: costs paid each day or month
burning {Torch: {lasts, spends}}: what an effect burns
bonds {attuned: {most, needs, while, rules}}: lists a character binds items in
at-most the most a sheet field holds, number or formula
turn-uses per-turn uses scene use counts: most, any-turn, needs, within, resets, note, note-when
damage {counter, halves, ignores, doubles, rules}: resistance lists change reads
conditions, condition-icons effects that show their rule; SVG icons for effects
keeping {counter, conditions, rules}: what breaks what someone keeps alive, as concentration
combat {track, in-words, in-words-for, inactive}: the counter Combat follows and how it is said
down {at: hp 0}: when one of the party is down
immune the list whose conditions effect add refuses
checks [{when, needs, say}]: what cannot be true together, reported, never changed

An effect named with the system’s word in the campaign’s language counts as its English name.

Numbers

tables: {proficiency-by-level: {1: 2, 5: 3, 9: 4}}
computed: {level: sum(classes), proficiency: table(proficiency-by-level, level)}
counters: {temp-hp: {shields: hp}, hit-dice-d10: {max: "sum(classes, hit-die = d10)", refill: long rest}}
Key Does
tables a number key reads the highest row not above it; a name key reads its row
computed a formula, or a list whose first with a value wins; never written by hand
counters {min, max, refill, shields, look} per counter; refill names occasions a recipe ends; look is marks or bar
progression {list, level, features, skip, parts, experience}: items as [[Barbarian]] 3 read their page’s level table
item-formulas fields each listed item’s page gives a formula for, as "1d8 + str-mod slashing"
item-columns fields of each item’s page its sheet row shows
entry-formulas formulas for entries without pages, as languages: int + languages
always-in pages every sheet has in a list
bonus-lists lists whose pages add bonus fields and raise at-least fields
icons, widgets, figures as in an extension.yaml

3. Formulas

Form Gives
numbers, fields, + - * /, ( ) arithmetic
floor, ceil, min, max as usual
best(a, b, …) the highest with a value
table(name, key) the table’s row
has(list, Name) 1 if the list holds Name, else 0
count(list), count(list, field = value) how many items
item(list, Name) the number after Name
sum(list), sum(list, field = value) the total of the items’ numbers
highest(list, field), lowest(list, field) extremes of a field on the items’ pages
dice(1d6, field) in an item formula, the largest die
  • Names are ASCII letters, digits and single hyphens: write level - 1, not level-1.
  • A list item is a name with an optional number: "[[Fighter]] 3".
  • Formulas also read effects, rigor, load and load-limit.
  • A missing field, division by zero or missing row gives no value; the page’s own is read.
  • A page is read in layers: its bases, the page, its effects, then the system’s computations.

4. Pages, rules, words and instructions

  • Pages: world/<folder>/<Name>.md, the folder giving the type: characters, places, factions, quests, items, events, topics, creatures. Names are unique; quote signed numbers and links. A system’s pages hold no secrets. An item is a kind, counted in stacks, unless it has a counter.
  • Rules: rules/*.md, each chapter opening with a heading; sections are headings, bold titles and table captions. Titles hold no ›, > or /.
  • Words: words/<code>.yaml with groups, fields, words, names (full names of short fields) and headline.
  • Translations: translations/<code>/world/... (frontmatter only name) and translations/<code>/rules/..., by English file name; read in place of English, while the sheet is worked out from English.
  • Instructions: instructions/<part>.md adds to a core part, or replaces it with replace: true. Parts: setup, session-zero, session, play, combat or any scene type, new-day, quest-ends, level-up, adventure, dashboard-guide, mentor-hints, mentor-tutorial, import, and <setting>-<value>, which follows play while that value plays.

5. What a campaign adds

  • A campaign’s pages work as a system’s; a campaign page cannot take a system page’s name.
  • A layer changes a system page for the whole campaign: write Goblin, layer, set hp=12/12 writes layers/<system>/world/creatures/Goblin.md with only what differs; reset removes it.
  • campaign.yaml adds fields, tables, computed, counters, recipes, status-line, travel, values and condition-icons with config. Same names replace, but recipes and travel merge, and values and status-line join.
config counters "bulwark-dice: {max: 'has(subclasses, Shield Oath) * 4', refill: short rest}"

An extension adds the same keys but status-line and travel: see extensions.md.

6. Code

Where data is not enough, a system brings code, with the contract of an extension, PackageEntry (extensions.md): commands, timePassed, widget hooks and a page module. Its package.json declares it:

{ "name": "@rpgengine/system-5e", "version": "0.16.2", "type": "module", "main": "dist/index.js", "rpg-engine": { "kind": "system", "api": 9, "page": "dist/page.js" } }
Hook Runs
counterChanged after a counter is written
turnStarted as a turn starts
rolled after a roll that is not hidden
effectAdded after an effect is added
asking before ask shows its buttons; may change how the roll is asked
  • Hooks return lines for the output; the system’s run before the extensions’.
  • Commands are named as the system or start with its name and a hyphen: 5e-spells.
  • The page module may give groups: components that draw a sheet group’s card.
  • Code reaches the game only through game: never Math.random, Date, process, globalThis, import() or Node’s modules.
  • Code loads once at start; a failing hook becomes a line for the master and the command’s change stands.

7. Checks

The test kit’s systemChecks(folder) checks a system’s pages, names, fields, rules, dice, coins, pictures and theme, and returns its attribution. A system keeps its own tests on the kit (extensions.md).


© 2026 Stefano Caronia · code under the MIT license