TableTower/docs/PLAIN.md
RobinFiredrake 8ca50acd4b Add the Plain Build spec (usability pass)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:31:58 -06:00

7.3 KiB
Raw Blame History

TableTower: Plain Build (usability pass)

Status: Spec · Branch: plain-build · Mockup: https://claude.ai/code/artifact/caad5536-59a0-4b74-9c0d-b3024a9767c1

Goal: a person can build logic boards without learning the rule language, and anyone can read a board and see why a roll went the way it did.

Constraint: the stored format stays the rule text from docs/LOGIC.md, so old boards open unchanged and power users can always edit as text. Everything here is a layer in front of it. New keys are additive.

1. Describe: rules in plain words (core/describe.gd, class Describe)

Pure functions that turn stored rules into short phrases. They use value labels (§3) and fall back to the original text for anything they can't parse.

Function Input Example output
effect(stmt, board) -> String one effect statement @luck -= 1 → "Luck −1"; @skill_pilot += 1 → "Pilot +1"; @town = "Millbrook" → "Town = Millbrook"; reset @skill_* → "Clear all Skills"; @[option] += 1 → "Chosen skill +1" (or "Chosen value +1" outside a skills collection)
effects(text, board) -> Array[String] effects field one phrase per statement
condition(expr, board) -> String a when / show_if / options_where / loop rule @str >= 8 → "Strength is 8 or more"; @x = 0 and @soc >= 9 → "X is 0 and Social Standing is 9 or more"; has(@traits, "Psionic") → "Traits include Psionic"
dice(expr, board) -> String dice / count expression 2d6 + dm(@str) → "2D + Strength modifier"; 1d6 + tier → "1D + Tier"
options(table, board) -> String dynamic pick source "your Skills, level 1 or more"
pipe(entry, target_id, board) -> String a pipe's label "Tier 3 · only if Luck is 2 or more", "otherwise", "×2 · saves Weapon"
check(table, board) -> String a Check card "Roll 2D + Strength modifier, need 8 or more"
why(fact, board, plain := true) -> String one trace fact (§5) "Skipped Tier 3 because Luck was 1 (needs 2 or more)"

Comparisons read as "is", "is not", "is at least", "is at most", "is more than" and "is less than". >= N reads "is N or more" when it sits after a value name.

2. Builders: structured models that round-trip with text (core/builder.gd, class Builder)

  • parse_effect(stmt) -> {ok, op, var, amount}
    • op is one of set, add, subtract, multiply, divide, reset, append or remove.
    • var may be @name, @prefix_* (reset only) or @[option].
    • ok: false means the statement doesn't fit the builder, so the UI shows it as text.
  • effect_text(model) -> String is the inverse. parse_effect(effect_text(m)) must equal m.
  • parse_condition(expr) -> {ok, join: "and"|"or", clauses: [{var, cmp, value}]}
    • cmp is one of eq, ne, ge, le, gt, lt, has (list contains), set or unset.
    • value is a number, quoted text, or another @name.
    • Mixed and/or, function calls other than has, and dice give ok: false.
  • condition_text(model) -> String is the inverse.
  • known_values(board) -> Array[{name, label, kind, source}]: every value the board uses.
    • kind is number, text, list or collection.
    • Sources: variable cards, collections, effect targets, save_as, card inputs, and chain names (answer, option, i, total, nat, effect).
    • It's used by value pickers, with variable-card labels first.

3. Value labels and collections

  • Labels. A value's label comes from its variable card's name, then from the collection it belongs to (skill_gun_combat in the Skills collection reads "Gun Combat"), and otherwise from a pretty form of its name (soc → "Soc"). A label table for common short names (str → "Strength") isn't built in; variable cards are how boards name things.
  • Collection is a variable card with var_type: "collection". Its var_name is the stem (e.g. skill), its name is the label ("Skills"), and its members are the board values @<stem>_<item>.
    • On the board it shows a list editor: members with their values, plus "+ Add".
    • options_from: "@skill_*" reads "your Skills".
    • count("skill_") and {@skill_*} work as before.
    • Describe uses the collection to label its members.

4. New engine features

  1. Check card (kind: "check").

    • Fields: check_dice (default "2d6"), check_mod (an expression, default "", e.g. dm(@str)), check_cmp (ge, the default, or le) and check_target (an expression, default "8").
    • Two fixed entries: Success (index 0) and Failure (index 1), each with effects and pipes.
    • Rolling sets the chain variables nat (the dice alone), total (dice plus modifier) and effect (total minus target).
    • The node gets check: {nat, mod, total, target, success}. It counts as one action.
  2. Card inputs (pipe parameters).

    • A table may declare inputs: [{name, label, default}].
    • A pipe object may carry with: {name: "<expr>"}. The expressions are evaluated in the entry's snapshot (LOGIC §3a), with the other pipe values.
    • While that pipe's subtree runs, each input is a chain value (tier, {tier} in text). When the subtree ends, the previous values come back. Two pipes to the same card can pass different values.
    • Missing inputs use their default. A roll that starts on the card uses the defaults.
    • JSON: inputs on tables and with on pipe objects.
  3. nat is also set on every dice roll of a roll table (the dice part only), so "natural 2" rules can test nat = 2.

  4. Why trace. Every node gets why: Array[Dictionary] facts, recorded by the roller:

    • roll: dice faces, modifier and total.
    • check.
    • when: the pipe, the expression, the values it read, and the result.
    • otherwise.
    • case (router): the case tried, its values and its result.
    • show_if / options_where (summarized).
    • effect: before and after.
    • input: name and value.

    Describe.why turns each fact into a sentence. Steps from Roller.flatten carry the facts. Facts are plain data and survive JSON (history).

5. Display preference

state setting rules_view: "plain" (default) or "text". Everywhere a rule is shown, the UI uses Describe in plain mode and the stored text in text mode.

6. UI (phase 2)

  • Inspector (Build mode): a panel docked right that edits the selected card, result or pipe.
    • Results: text, details, and a When this comes up effects builder (rows of [op] [amount] [to/from] [value ▾]).
    • Then go to: one box per pipe with inputs, Only if (condition builder rows of [value ▾] [comparison ▾] [amount], plus and/or), Otherwise, count and save as.
    • Cards: kind-specific fields (check dice, modifier picker and target; collection members; declared inputs; options source as "from [collection ▾] where [condition]"; and so on).
    • A value picker lists known_values with search and "+ New value…".
    • "Edit as text" on any builder switches it to the text field, and back when it parses.
  • Display:
    • Plain chips for effects, plain pipe labels, router cases, choice option sources and loop rules.
    • Check, collection and input visuals on the cards.
    • "Why this?" on tray chips and in step hover.
    • Plain previews in the choice pop-up.
    • A Plain words / Text switch.