Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
class_name RollTable
|
|
|
|
|
|
extends RefCounted
|
|
|
|
|
|
## A named list of entries placed on the board.
|
|
|
|
|
|
##
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Plain tables pick by entry weight (6 equal entries = d6). If any entry has a
|
|
|
|
|
|
## range, the table becomes a ranged dice table (1d100 by default, or any dice
|
|
|
|
|
|
## expression) where the probability mass of each range sets its chance.
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
##
|
|
|
|
|
|
## Every table has a `kind` (docs/LOGIC.md §1): "roll" (the default), "choice",
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## "loop", "variable", "sheet" or "router", with the per-kind fields below
|
|
|
|
|
|
## (a router's cases are its entries, each with an entry-level `when`). Use create()
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## for a well-formed card of each kind.
|
|
|
|
|
|
##
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Ranged tables may add a modifier to the roll (`dice_mod`, e.g. "@luck"),
|
|
|
|
|
|
## and also accept a full expression in `dice` ("2d6 + dm(@end)", "@terms").
|
|
|
|
|
|
## With either, a total past the lowest or highest range counts as that end
|
|
|
|
|
|
## result. Chances are known for a modifier (given its value) but not for an
|
|
|
|
|
|
## expression (chance() is 0, has_chances() false). The numbers live in
|
|
|
|
|
|
## RollRange.
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
|
|
|
|
|
const DEFAULT_DICE := "1d100"
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
const KIND_ROLL := "roll"
|
|
|
|
|
|
const KIND_CHOICE := "choice"
|
|
|
|
|
|
const KIND_LOOP := "loop"
|
|
|
|
|
|
const KIND_VARIABLE := "variable"
|
|
|
|
|
|
const KIND_SHEET := "sheet"
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
const KIND_ROUTER := "router"
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
const KIND_CHECK := "check"
|
|
|
|
|
|
const KINDS: Array[String] = [KIND_ROLL, KIND_CHOICE, KIND_LOOP, KIND_VARIABLE, KIND_SHEET, KIND_ROUTER, KIND_CHECK]
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## A new router's first case condition (an even chance, so both cases can come up).
|
|
|
|
|
|
const ROUTER_DEFAULT_WHEN := "1d6 >= 4"
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
const CHOICES: Array[String] = ["pick", "number", "text"]
|
|
|
|
|
|
const LOOPS: Array[String] = ["times", "while", "until"]
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## A variable card with var_type "collection" declares a group of board
|
|
|
|
|
|
## values @<var_name>_<item> (docs/PLAIN.md §3); its name labels the group.
|
|
|
|
|
|
const VAR_COLLECTION := "collection"
|
|
|
|
|
|
const VAR_TYPES: Array[String] = ["number", "text", "list", VAR_COLLECTION]
|
|
|
|
|
|
## Check cards (docs/PLAIN.md §4.1): success when the total is >= ("ge") or
|
|
|
|
|
|
## <= ("le") the target.
|
|
|
|
|
|
const CHECK_CMPS: Array[String] = ["ge", "le"]
|
|
|
|
|
|
const CHECK_DEFAULT_DICE := "2d6"
|
|
|
|
|
|
const CHECK_DEFAULT_TARGET := "8"
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var id: String = ""
|
|
|
|
|
|
var name: String = ""
|
|
|
|
|
|
var position: Vector2 = Vector2.ZERO
|
|
|
|
|
|
var collapsed: bool = false
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Longer description (may contain BBCode).
|
|
|
|
|
|
var details: String = ""
|
|
|
|
|
|
var tags: Array[String] = []
|
2026-11-10 18:20:46 -06:00
|
|
|
|
## The card's own colour ("#hex") for its frame and header; "" = the theme's.
|
|
|
|
|
|
var color: String = ""
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Dice expression for ranged tables, e.g. "1d100", "2d6", "1d8+2", or any
|
|
|
|
|
|
## expression such as "2d6 + dm(@end)".
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var dice: String = DEFAULT_DICE
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Ranged tables: the modifier added to the dice, an expression ("@luck",
|
|
|
|
|
|
## "-@fatigue", "dm(@str)", "2"), or "" for none.
|
|
|
|
|
|
var dice_mod: String = ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Card mode: entries are drawn without replacement until the deck is empty.
|
|
|
|
|
|
var card_mode: bool = false
|
|
|
|
|
|
## What happens when the deck runs out: "reshuffle" or "stop".
|
|
|
|
|
|
var deck_empty: String = "reshuffle"
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
var entries: Array[TableEntry] = []
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## One of KINDS.
|
|
|
|
|
|
var kind: String = KIND_ROLL
|
|
|
|
|
|
## Choice cards: "pick", "number" or "text".
|
|
|
|
|
|
var choice: String = "pick"
|
|
|
|
|
|
## Choice cards: the question, BBCode with {@var} expansion.
|
|
|
|
|
|
var prompt: String = ""
|
|
|
|
|
|
## Choice cards: variable the answer is saved under ("@name" or a chain name).
|
|
|
|
|
|
var save_as: String = ""
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
## Pick choices: options from variables (docs/LOGIC.md §2a). "@prefix_*"
|
|
|
|
|
|
## gives one option per set variable with that prefix, "@list" one option per
|
|
|
|
|
|
## item of a list variable. "" for a fixed list. When it's set, entries[0] is
|
|
|
|
|
|
## the Chosen entry (it happens for whichever dynamic option is picked) and
|
|
|
|
|
|
## any other entries are fixed extras.
|
|
|
|
|
|
var options_from: String = ""
|
|
|
|
|
|
## Pick choices with options_from: an expression each candidate must pass,
|
|
|
|
|
|
## with the chain variables option, option_label and option_value bound.
|
|
|
|
|
|
var options_where: String = ""
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## Number choices: bounds, as expressions.
|
|
|
|
|
|
var min_expr: String = "0"
|
|
|
|
|
|
var max_expr: String = "99"
|
|
|
|
|
|
## Loop cards: "times", "while" or "until", and the count or condition.
|
|
|
|
|
|
var loop_mode: String = "times"
|
|
|
|
|
|
var loop_expr: String = ""
|
|
|
|
|
|
## Variable cards: the variable's name (no "@"), its type and starting value
|
|
|
|
|
|
## (an expression).
|
|
|
|
|
|
var var_name: String = ""
|
|
|
|
|
|
var var_type: String = "number"
|
|
|
|
|
|
var initial: String = ""
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## Check cards: the dice, the modifier and the target (expressions) and the
|
|
|
|
|
|
## comparison ("ge" or "le"). entries[0] is Success, entries[1] Failure.
|
|
|
|
|
|
var check_dice: String = CHECK_DEFAULT_DICE
|
|
|
|
|
|
var check_mod: String = ""
|
|
|
|
|
|
var check_cmp: String = "ge"
|
|
|
|
|
|
var check_target: String = CHECK_DEFAULT_TARGET
|
|
|
|
|
|
## Card inputs (any kind but variable): Array of {"name": String, "label":
|
|
|
|
|
|
## String, "default": String (an expression; "" reads as 0)}. While a pipe's
|
|
|
|
|
|
## subtree runs, each input is a chain value (the pipe's "with" value, or the
|
|
|
|
|
|
## default).
|
|
|
|
|
|
var inputs: Array = []
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var _dice_cache: Dice = null
|
|
|
|
|
|
var _dice_cache_text: String = ""
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
var _dice_plain: bool = true
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
func _init(p_id: String = "", p_name: String = "") -> void:
|
|
|
|
|
|
id = p_id
|
|
|
|
|
|
name = p_name
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## A well-formed card of any kind. `sub` picks the variant: the choice
|
|
|
|
|
|
## ("pick", "number", "text"), the loop mode ("times", "while", "until") or
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## the variable type ("number", "text", "list", "collection").
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## roll: four "Result N" entries · choice pick: three options ·
|
|
|
|
|
|
## choice number/text: one "Answer" entry · loop: "Each time" and
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## "Afterwards" · variable: no entries · sheet: one template entry ·
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## router: an "if …" case (when ROUTER_DEFAULT_WHEN) and an "Otherwise" case ·
|
|
|
|
|
|
## check: "Success" and "Failure" (2d6 vs 8) · variable "collection": the
|
|
|
|
|
|
## stem is the name's slug without a final "s" ("Skills" -> "skill").
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
static func create(p_kind: String, p_id: String, p_name: String, sub: String = "") -> RollTable:
|
|
|
|
|
|
var t := RollTable.new(p_id, p_name)
|
|
|
|
|
|
t.kind = p_kind if KINDS.has(p_kind) else KIND_ROLL
|
|
|
|
|
|
match t.kind:
|
|
|
|
|
|
KIND_ROLL:
|
|
|
|
|
|
for n in range(1, 5):
|
|
|
|
|
|
t.entries.append(TableEntry.new("e%d" % n, "Result %d" % n))
|
|
|
|
|
|
KIND_CHOICE:
|
|
|
|
|
|
t.choice = sub if CHOICES.has(sub) else "pick"
|
|
|
|
|
|
match t.choice:
|
|
|
|
|
|
"pick":
|
|
|
|
|
|
t.prompt = "Which one?"
|
|
|
|
|
|
for n in range(1, 4):
|
|
|
|
|
|
t.entries.append(TableEntry.new("e%d" % n, "Option %d" % n))
|
|
|
|
|
|
"number":
|
|
|
|
|
|
t.prompt = "How many?"
|
|
|
|
|
|
t.entries.append(TableEntry.new("e1", "Answer"))
|
|
|
|
|
|
"text":
|
|
|
|
|
|
t.prompt = "What is it?"
|
|
|
|
|
|
t.entries.append(TableEntry.new("e1", "Answer"))
|
|
|
|
|
|
KIND_LOOP:
|
|
|
|
|
|
t.loop_mode = sub if LOOPS.has(sub) else "times"
|
|
|
|
|
|
t.loop_expr = "3" if t.loop_mode == "times" else "i < 3"
|
|
|
|
|
|
t.entries.append(TableEntry.new("e1", "Each time"))
|
|
|
|
|
|
t.entries.append(TableEntry.new("e2", "Afterwards"))
|
|
|
|
|
|
KIND_VARIABLE:
|
|
|
|
|
|
t.var_type = sub if VAR_TYPES.has(sub) else "number"
|
|
|
|
|
|
t.var_name = JsonIO.slug(Formatter.strip_tags(p_name), "var") if p_name != "" else "var"
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
if t.var_type == VAR_COLLECTION and t.var_name.length() > 3 and t.var_name.ends_with("s") and not t.var_name.ends_with("ss"):
|
|
|
|
|
|
t.var_name = t.var_name.substr(0, t.var_name.length() - 1)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
t.initial = "0" if t.var_type == "number" else ""
|
|
|
|
|
|
KIND_SHEET:
|
|
|
|
|
|
t.entries.append(TableEntry.new("e1", "[b]%s[/b]" % p_name))
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
KIND_ROUTER:
|
|
|
|
|
|
var first := TableEntry.new("e1", "if …")
|
|
|
|
|
|
first.when = ROUTER_DEFAULT_WHEN
|
|
|
|
|
|
t.entries.append(first)
|
|
|
|
|
|
t.entries.append(TableEntry.new("e2", "Otherwise"))
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
KIND_CHECK:
|
|
|
|
|
|
t.entries.append(TableEntry.new("e1", "Success"))
|
|
|
|
|
|
t.entries.append(TableEntry.new("e2", "Failure"))
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
return t
|
|
|
|
|
|
|
|
|
|
|
|
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
## True for a collection variable card.
|
|
|
|
|
|
func is_collection() -> bool:
|
|
|
|
|
|
return kind == KIND_VARIABLE and var_type == VAR_COLLECTION
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Names of the declared inputs, in order.
|
|
|
|
|
|
func input_names() -> Array[String]:
|
|
|
|
|
|
var out: Array[String] = []
|
|
|
|
|
|
for inp: Dictionary in inputs:
|
|
|
|
|
|
out.append(str(inp.get("name", "")))
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The declared input called `name`, or {}.
|
|
|
|
|
|
func find_input(input_name: String) -> Dictionary:
|
|
|
|
|
|
for inp: Dictionary in inputs:
|
|
|
|
|
|
if str(inp.get("name", "")) == input_name:
|
|
|
|
|
|
return inp
|
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Cleans an "inputs" value from JSON or the UI: Array of {name, label,
|
|
|
|
|
|
## default} with names trimmed (a leading "@" dropped) and empty names left
|
|
|
|
|
|
## out. Numbers become expression text.
|
|
|
|
|
|
static func clean_inputs(v: Variant) -> Array:
|
|
|
|
|
|
var out: Array = []
|
|
|
|
|
|
if not (v is Array):
|
|
|
|
|
|
return out
|
|
|
|
|
|
for item: Variant in v:
|
|
|
|
|
|
var nm := ""
|
|
|
|
|
|
var label := ""
|
|
|
|
|
|
var def := ""
|
|
|
|
|
|
if item is Dictionary:
|
|
|
|
|
|
nm = str(item.get("name", "")) if item.get("name") != null else ""
|
|
|
|
|
|
label = str(item.get("label", "")) if item.get("label") != null else ""
|
|
|
|
|
|
def = expr_text(item.get("default", ""), "")
|
|
|
|
|
|
elif item is String:
|
|
|
|
|
|
nm = item
|
|
|
|
|
|
nm = nm.strip_edges().trim_prefix("@")
|
|
|
|
|
|
if nm == "":
|
|
|
|
|
|
continue
|
|
|
|
|
|
out.append({"name": nm, "label": label.strip_edges(), "default": def.strip_edges()})
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
## True for a pick choice whose options come from variables (options_from).
|
|
|
|
|
|
func is_dynamic() -> bool:
|
|
|
|
|
|
return kind == KIND_CHOICE and choice == "pick" and options_from.strip_edges() != ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Index of the first fixed option on a pick choice: 1 when entries[0] is the
|
|
|
|
|
|
## Chosen entry of a dynamic card, else 0.
|
|
|
|
|
|
func fixed_start() -> int:
|
|
|
|
|
|
return 1 if is_dynamic() else 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Parses an options_from pattern: {"kind": "prefix" | "list" | "", "name":
|
|
|
|
|
|
## the prefix or list variable name without "@" and "*", "error": String}.
|
|
|
|
|
|
## "@skill_*" is a prefix, "@contacts" a list variable.
|
|
|
|
|
|
static func parse_options_from(src: String) -> Dictionary:
|
|
|
|
|
|
var s := src.strip_edges()
|
|
|
|
|
|
if s == "":
|
|
|
|
|
|
return {"kind": "", "name": "", "error": ""}
|
|
|
|
|
|
if not s.begins_with("@"):
|
|
|
|
|
|
return {"kind": "", "name": "", "error": "Write @prefix_* (each set variable with that prefix) or @list (each item of a list variable)"}
|
|
|
|
|
|
var prefix := s.ends_with("*")
|
|
|
|
|
|
var name := s.substr(1, s.length() - (2 if prefix else 1)).to_lower()
|
|
|
|
|
|
if name == "":
|
|
|
|
|
|
return {"kind": "", "name": "", "error": "Give a name after @, e.g. @skill_* or @contacts"}
|
|
|
|
|
|
if RegEx.create_from_string("^[a-z_][a-z0-9_]*$").search(name) == null:
|
|
|
|
|
|
return {"kind": "", "name": "", "error": "\"%s\" isn't a variable name (lowercase letters, digits and _)" % s}
|
|
|
|
|
|
return {"kind": "prefix" if prefix else "list", "name": name, "error": ""}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## "each @skill_* that's set, where option_value >= 1" (for previews and cards).
|
|
|
|
|
|
func options_description() -> String:
|
|
|
|
|
|
var p := parse_options_from(options_from)
|
|
|
|
|
|
var s := ""
|
|
|
|
|
|
match str(p["kind"]):
|
|
|
|
|
|
"prefix":
|
|
|
|
|
|
s = "each @%s* that's set" % p["name"]
|
|
|
|
|
|
"list":
|
|
|
|
|
|
s = "each item of @%s" % p["name"]
|
|
|
|
|
|
_:
|
|
|
|
|
|
s = options_from.strip_edges()
|
|
|
|
|
|
if options_where.strip_edges() != "":
|
|
|
|
|
|
s += ", where " + options_where.strip_edges()
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
|
Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.
New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.
UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00
|
|
|
|
## Router cards: index of the first case that is an Otherwise case (empty
|
|
|
|
|
|
## `when`), or -1.
|
|
|
|
|
|
func otherwise_index() -> int:
|
|
|
|
|
|
for i in entries.size():
|
|
|
|
|
|
if entries[i].when.strip_edges() == "":
|
|
|
|
|
|
return i
|
|
|
|
|
|
return -1
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
func is_kind(k: String) -> bool:
|
|
|
|
|
|
return kind == k
|
|
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func is_ranged() -> bool:
|
|
|
|
|
|
for e in entries:
|
|
|
|
|
|
if e.has_range:
|
|
|
|
|
|
return true
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## True when `dice` is a full expression rather than plain dice (ranged tables).
|
|
|
|
|
|
func is_expr_dice() -> bool:
|
|
|
|
|
|
dice_obj()
|
|
|
|
|
|
return is_ranged() and not _dice_plain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The parsed dice expression (falls back to 1d100 if `dice` is invalid or an
|
|
|
|
|
|
## expression; see is_expr_dice()).
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func dice_obj() -> Dice:
|
|
|
|
|
|
if _dice_cache == null or _dice_cache_text != dice:
|
|
|
|
|
|
var d := Dice.parse(dice)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
_dice_plain = d.valid or dice.strip_edges() == ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
_dice_cache = d if d.valid else Dice.make(1, 100)
|
|
|
|
|
|
_dice_cache_text = dice
|
|
|
|
|
|
return _dice_cache
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## The roll modifier, if any (see RollRange): true when dice_mod is set.
|
|
|
|
|
|
func has_mod() -> bool:
|
|
|
|
|
|
return dice_mod.strip_edges() != ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The whole roll as text: "1d20 + @luck", or the dice alone.
|
|
|
|
|
|
func roll_text() -> String:
|
|
|
|
|
|
return RollRange.join(dice, dice_mod)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True when totals past the ends count as the end results (RollRange.clamps).
|
|
|
|
|
|
func clamps() -> bool:
|
|
|
|
|
|
return RollRange.clamps(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Rolls the dice and adds the modifier. Returns {"value": int, "error": String}.
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
func roll_value(ctx: RollContext) -> Dictionary:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.roll_value(self, ctx)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Label for the dice: "d100", "2d6", "1d8+2". Plain tables label by entry
|
|
|
|
|
|
## count; expression dice show the expression.
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func dice_label() -> String:
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
if kind == KIND_CHECK:
|
|
|
|
|
|
return check_dice.strip_edges()
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if is_ranged():
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
return dice.strip_edges() if is_expr_dice() else dice_obj().label()
|
2026-11-08 12:11:43 -06:00
|
|
|
|
return "d%d" % die_size()
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Lowest value that can be shown or rolled (RollRange.min_value).
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func min_value() -> int:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.min_value(self)
|
2026-11-08 12:11:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Highest value (RollRange.max_value). Plain tables: the entry count.
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func die_size() -> int:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.max_value(self)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
func total_weight() -> int:
|
|
|
|
|
|
var w := 0
|
|
|
|
|
|
for e in entries:
|
|
|
|
|
|
w += maxi(0, e.weight)
|
|
|
|
|
|
return w
|
|
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func fmt(value: int) -> String:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.fmt(self, value)
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func num_label(e: TableEntry, index: int) -> String:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.num_label(self, e, index)
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## False when chances can't be known (expression dice).
|
|
|
|
|
|
func has_chances() -> bool:
|
|
|
|
|
|
return not is_expr_dice()
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Chance (0–1) that a roll lands on this entry, with the modifier at `mod`.
|
|
|
|
|
|
func chance(e: TableEntry, mod: int = 0) -> float:
|
|
|
|
|
|
return RollRange.chance(self, e, mod)
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
|
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## True when the entry can come up at all.
|
|
|
|
|
|
func can_come_up(e: TableEntry) -> bool:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.can_come_up(self, e)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## The entry whose range holds `value` exactly, or -1.
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func entry_index_for(value: int) -> int:
|
|
|
|
|
|
for i in entries.size():
|
|
|
|
|
|
var e := entries[i]
|
|
|
|
|
|
if e.has_range and value >= e.range_lo and value <= e.range_hi:
|
|
|
|
|
|
return i
|
|
|
|
|
|
return -1
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## The entry a rolled total picks: past the ends counts as the end result on
|
|
|
|
|
|
## a table that clamps (RollRange.index_for).
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
func entry_index_clamped(value: int) -> int:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.index_for(self, value)
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func find_entry(eid: String) -> TableEntry:
|
|
|
|
|
|
for e in entries:
|
|
|
|
|
|
if e.id == eid:
|
|
|
|
|
|
return e
|
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## Gaps, overlaps and out-of-reach ranges, or "" when clean (RollRange.problems).
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func range_problems() -> String:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
return RollRange.problems(self)
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
## A variable card's starting value: {"value", "error"}. An empty `initial`
|
|
|
|
|
|
## gives 0 for numbers and "" otherwise. For text and list variables, plain
|
|
|
|
|
|
## words that aren't an expression ("Aslan") are taken as they are.
|
|
|
|
|
|
func initial_value(ctx: RollContext) -> Dictionary:
|
|
|
|
|
|
var src := initial.strip_edges()
|
|
|
|
|
|
if src == "":
|
|
|
|
|
|
return {"value": 0 if var_type == "number" else "", "error": ""}
|
|
|
|
|
|
if var_type != "number" and _looks_literal(src):
|
|
|
|
|
|
return {"value": src, "error": ""}
|
|
|
|
|
|
var r := Expr.evaluate(src, ctx)
|
|
|
|
|
|
if r["error"] != "":
|
|
|
|
|
|
return {"value": 0 if var_type == "number" else "", "error": r["error"]}
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _looks_literal(src: String) -> bool:
|
|
|
|
|
|
if src.begins_with("\"") or src.begins_with("'") or src.contains("@") or src.contains("("):
|
|
|
|
|
|
return false
|
|
|
|
|
|
return RegEx.create_from_string("^[^+\\-*/%=<>!&|]*$").search(src) != null and not src.is_valid_float()
|
|
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func to_dict() -> Dictionary:
|
|
|
|
|
|
var list: Array = []
|
|
|
|
|
|
for e in entries:
|
|
|
|
|
|
list.append(e.to_dict())
|
|
|
|
|
|
var d := {"id": id, "name": name, "x": roundi(position.x), "y": roundi(position.y), "entries": list}
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
if kind != KIND_ROLL:
|
|
|
|
|
|
d["kind"] = kind
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if collapsed:
|
|
|
|
|
|
d["collapsed"] = true
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if details != "":
|
|
|
|
|
|
d["details"] = details
|
|
|
|
|
|
if not tags.is_empty():
|
|
|
|
|
|
d["tags"] = tags.duplicate()
|
2026-11-10 18:20:46 -06:00
|
|
|
|
if color != "":
|
|
|
|
|
|
d["color"] = color
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if is_ranged():
|
|
|
|
|
|
d["dice"] = dice
|
2026-11-09 10:01:10 -06:00
|
|
|
|
if has_mod():
|
|
|
|
|
|
d["dice_mod"] = dice_mod.strip_edges()
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if card_mode:
|
|
|
|
|
|
d["card_mode"] = true
|
|
|
|
|
|
if deck_empty != "reshuffle":
|
|
|
|
|
|
d["deck_empty"] = deck_empty
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
if kind == KIND_CHOICE:
|
|
|
|
|
|
if choice != "pick":
|
|
|
|
|
|
d["choice"] = choice
|
|
|
|
|
|
if prompt != "":
|
|
|
|
|
|
d["prompt"] = prompt
|
|
|
|
|
|
if save_as != "":
|
|
|
|
|
|
d["save_as"] = save_as
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
if options_from.strip_edges() != "":
|
|
|
|
|
|
d["options_from"] = options_from.strip_edges()
|
|
|
|
|
|
if options_where.strip_edges() != "":
|
|
|
|
|
|
d["options_where"] = options_where.strip_edges()
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
if min_expr != "0":
|
|
|
|
|
|
d["min"] = min_expr
|
|
|
|
|
|
if max_expr != "99":
|
|
|
|
|
|
d["max"] = max_expr
|
|
|
|
|
|
elif kind == KIND_LOOP:
|
|
|
|
|
|
if loop_mode != "times":
|
|
|
|
|
|
d["loop"] = loop_mode
|
|
|
|
|
|
if loop_expr != "":
|
|
|
|
|
|
d["loop_expr"] = loop_expr
|
|
|
|
|
|
elif kind == KIND_VARIABLE:
|
|
|
|
|
|
if var_name != "":
|
|
|
|
|
|
d["var_name"] = var_name
|
|
|
|
|
|
if var_type != "number":
|
|
|
|
|
|
d["var_type"] = var_type
|
|
|
|
|
|
if initial != "":
|
|
|
|
|
|
d["initial"] = initial
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
elif kind == KIND_CHECK:
|
|
|
|
|
|
if check_dice != CHECK_DEFAULT_DICE:
|
|
|
|
|
|
d["check_dice"] = check_dice
|
|
|
|
|
|
if check_mod != "":
|
|
|
|
|
|
d["check_mod"] = check_mod
|
|
|
|
|
|
if check_cmp != "ge":
|
|
|
|
|
|
d["check_cmp"] = check_cmp
|
|
|
|
|
|
if check_target != CHECK_DEFAULT_TARGET:
|
|
|
|
|
|
d["check_target"] = check_target
|
|
|
|
|
|
if not inputs.is_empty():
|
|
|
|
|
|
var list2: Array = []
|
|
|
|
|
|
for inp: Dictionary in inputs:
|
|
|
|
|
|
var o := {"name": str(inp.get("name", ""))}
|
|
|
|
|
|
if str(inp.get("label", "")) != "":
|
|
|
|
|
|
o["label"] = str(inp["label"])
|
|
|
|
|
|
if str(inp.get("default", "")) != "":
|
|
|
|
|
|
o["default"] = str(inp["default"])
|
|
|
|
|
|
list2.append(o)
|
|
|
|
|
|
d["inputs"] = list2
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func from_dict(d: Dictionary) -> RollTable:
|
|
|
|
|
|
var t := RollTable.new(str(d.get("id", "")), str(d.get("name", "")))
|
|
|
|
|
|
t.position = Vector2(float(d.get("x", 0)), float(d.get("y", 0)))
|
|
|
|
|
|
t.collapsed = bool(d.get("collapsed", false))
|
2026-11-08 12:11:43 -06:00
|
|
|
|
t.details = str(d.get("details", ""))
|
|
|
|
|
|
for tag: Variant in d.get("tags", []):
|
|
|
|
|
|
t.tags.append(str(tag))
|
2026-11-10 18:20:46 -06:00
|
|
|
|
t.color = str(d.get("color", ""))
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if d.has("dice"):
|
|
|
|
|
|
t.dice = str(d["dice"])
|
|
|
|
|
|
elif int(d.get("die", 0)) > 1:
|
|
|
|
|
|
t.dice = "1d%d" % int(d["die"])
|
2026-11-09 10:01:10 -06:00
|
|
|
|
t.dice_mod = expr_text(d.get("dice_mod", ""), "").strip_edges()
|
2026-11-08 12:11:43 -06:00
|
|
|
|
t.card_mode = bool(d.get("card_mode", false))
|
|
|
|
|
|
t.deck_empty = "stop" if str(d.get("deck_empty", "reshuffle")) == "stop" else "reshuffle"
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
var k := str(d.get("kind", KIND_ROLL))
|
|
|
|
|
|
t.kind = k if KINDS.has(k) else KIND_ROLL
|
|
|
|
|
|
var c := str(d.get("choice", "pick"))
|
|
|
|
|
|
t.choice = c if CHOICES.has(c) else "pick"
|
|
|
|
|
|
t.prompt = str(d.get("prompt", ""))
|
|
|
|
|
|
t.save_as = str(d.get("save_as", ""))
|
Dynamic pick options, show_if and indirect @[expr] names
Pick choice cards can take their options from variables (options_from:
@prefix_* or a @list, filtered by options_where with option, option_label
and option_value bound). A Chosen entry runs for whichever dynamic option
is picked; fixed entries stay as extras, listed first. Random weighs each
dynamic option as the Chosen entry and fixed ones by weight. Any pick
option can have show_if, which hides it from the pop-up and from Random;
with nothing offered the node stops with "No options available".
@[expr] reads or writes the variable named by expr in expressions,
effects (including reset) and text ({@[expr]}); bad computed names are
effect errors. JSON round trip, lint_options in lint_pipes, choice
pop-up value badges and previews, card and settings UI, docs, demo board
(Spend a find) and tests/test_options.gd.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 18:55:38 -06:00
|
|
|
|
t.options_from = str(d.get("options_from", "")).strip_edges() if d.get("options_from") != null else ""
|
|
|
|
|
|
t.options_where = expr_text(d.get("options_where", ""), "").strip_edges()
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
t.min_expr = expr_text(d.get("min", "0"), "0")
|
|
|
|
|
|
t.max_expr = expr_text(d.get("max", "99"), "99")
|
|
|
|
|
|
var lm := str(d.get("loop", "times"))
|
|
|
|
|
|
t.loop_mode = lm if LOOPS.has(lm) else "times"
|
|
|
|
|
|
t.loop_expr = expr_text(d.get("loop_expr", ""), "")
|
|
|
|
|
|
t.var_name = str(d.get("var_name", "")).strip_edges().trim_prefix("@")
|
|
|
|
|
|
var vt := str(d.get("var_type", "number"))
|
|
|
|
|
|
t.var_type = vt if VAR_TYPES.has(vt) else "number"
|
|
|
|
|
|
t.initial = expr_text(d.get("initial", ""), "")
|
Plain Build engine: Describe, Builder, checks, inputs, collections, why trace
Implements docs/PLAIN.md sections 1-5 (the engine half of the usability pass):
- core/describe.gd (Describe): rules in plain words, labelled from variable
cards, collections and card inputs, falling back to the original text.
- core/builder.gd (Builder): effect and condition models that round-trip
with the rule text, a rule tokenizer, and known_values(board).
- Collections: variable cards with var_type "collection" label their
members and don't declare their stem.
- Check cards (kind "check"): dice + modifier vs target, Success/Failure,
chain values nat/total/effect, node "check" info, lint and static checks.
- Card inputs and pipe "with" values, scoped over the pipe's subtree on the
explicit work stack (OP_RESTORE frames), with defaults and snapshot
evaluation.
- nat on every roll-table roll; dice faces recorded through ctx.faces.
- Why trace: facts on nodes and steps (input, roll, check, case, show_if,
options_where, effect, when, otherwise).
- StateStore rules_view setting; JSON for the new keys; LOGIC.md and
PLAIN.md updated (deviations in PLAIN.md 5a).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:01:24 -06:00
|
|
|
|
t.check_dice = expr_text(d.get("check_dice", CHECK_DEFAULT_DICE), CHECK_DEFAULT_DICE).strip_edges()
|
|
|
|
|
|
if t.check_dice == "":
|
|
|
|
|
|
t.check_dice = CHECK_DEFAULT_DICE
|
|
|
|
|
|
t.check_mod = expr_text(d.get("check_mod", ""), "").strip_edges()
|
|
|
|
|
|
var cc := str(d.get("check_cmp", "ge"))
|
|
|
|
|
|
t.check_cmp = cc if CHECK_CMPS.has(cc) else "ge"
|
|
|
|
|
|
t.check_target = expr_text(d.get("check_target", CHECK_DEFAULT_TARGET), CHECK_DEFAULT_TARGET).strip_edges()
|
|
|
|
|
|
if t.check_target == "":
|
|
|
|
|
|
t.check_target = CHECK_DEFAULT_TARGET
|
|
|
|
|
|
t.inputs = clean_inputs(d.get("inputs", []))
|
2026-11-08 12:11:43 -06:00
|
|
|
|
for ed: Variant in d.get("entries", []):
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if ed is Dictionary:
|
|
|
|
|
|
t.entries.append(TableEntry.from_dict(ed))
|
|
|
|
|
|
return t
|
Logic cards engine: expressions, effects, choice/loop/variable/sheet cards, coroutine roller
- Expr: @vars, chain vars, dice tokens, dm/has/count, lone = as ==, errors as values, parse cache
- Effects: = += -= *= /= and reset (with prefix), number vs list semantics, logs, validation
- RollTable kinds and per-kind fields with factories; expression dice with end clamping
- TableEntry effects and expression pipe counts; JSON round trip through JsonIO
- TextExpander: {@prefix_*}, {= expr}, number display, expand_async and live render()
- Roller: coroutine with an explicit work stack, prompts for choice cards, loops,
10,000-action limit, partial tree on ctx.root, iterative flatten/collect_lit
- Variables keep numbers as numbers through StateStore
- Main: awaits the roll with a default (headless) prompt hook, iterative playback,
long chains show at once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:38:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Expression fields may arrive as JSON numbers: 3.0 -> "3".
|
|
|
|
|
|
static func expr_text(v: Variant, fallback: String) -> String:
|
|
|
|
|
|
if v == null:
|
|
|
|
|
|
return fallback
|
|
|
|
|
|
if v is float or v is int:
|
|
|
|
|
|
return Expr.format_value(v)
|
|
|
|
|
|
return str(v)
|