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"
|
2026-11-10 21:12:47 -06:00
|
|
|
|
## A variable card with var_type "scale" lists ordered steps (Scales).
|
|
|
|
|
|
const VAR_SCALE := "scale"
|
|
|
|
|
|
const VAR_TYPES: Array[String] = ["number", "text", "list", VAR_COLLECTION, VAR_SCALE]
|
|
|
|
|
|
## Cards with columns: one roll picks the row for every column ("row"), or
|
|
|
|
|
|
## each column is rolled on its own ("each"; RollColumns).
|
|
|
|
|
|
const COLUMNS_ROW := "row"
|
|
|
|
|
|
const COLUMNS_EACH := "each"
|
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 (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 = ""
|
2026-11-10 18:32:09 -06:00
|
|
|
|
## The size the user dragged the card to: its width in Play (Build adds a
|
|
|
|
|
|
## little), and the height of its results list, which then scrolls. 0 = automatic.
|
|
|
|
|
|
var width: float = 0.0
|
|
|
|
|
|
var list_height: float = 0.0
|
2026-11-10 19:15:09 -06:00
|
|
|
|
## Ranged tables: the total never goes below / above these (numbers or
|
|
|
|
|
|
## expressions such as @atmo_min, often set by an earlier result). "" = none.
|
|
|
|
|
|
var roll_floor: String = ""
|
|
|
|
|
|
var roll_ceiling: 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"
|
2026-11-10 18:43:16 -06:00
|
|
|
|
## What a Deck-mode card that waits for Shuffle gives once it's empty ("" = "Empty").
|
|
|
|
|
|
var deck_empty_text: String = ""
|
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] = []
|
2026-11-10 21:12:47 -06:00
|
|
|
|
## Roll cards with columns (a multi-column table): Array of {"name": String,
|
|
|
|
|
|
## "save_as": value name (optional), "when": condition (optional)}. Column 0
|
|
|
|
|
|
## is each result's own text; the others are TableEntry.cells. Empty = a
|
|
|
|
|
|
## plain one-column card.
|
|
|
|
|
|
var columns: Array = []
|
|
|
|
|
|
## COLUMNS_ROW or COLUMNS_EACH.
|
|
|
|
|
|
var column_rolls: String = COLUMNS_ROW
|
2026-11-11 09:06:55 -06:00
|
|
|
|
## Cards with columns: when not "", the result reads as the column texts joined
|
|
|
|
|
|
## with this ("Ash" + " " + "Canyons" = "Ash Canyons") instead of "1st Part:
|
|
|
|
|
|
## Ash · 2nd Part: Canyons", and that phrase is what a thread saves.
|
|
|
|
|
|
var column_join: String = ""
|
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
|
|
|
|
## 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 = ""
|
2026-11-10 21:12:47 -06:00
|
|
|
|
## Scale variables: the ordered steps, lowest first.
|
|
|
|
|
|
var steps: Array[String] = []
|
2026-11-14 14:23:07 -06:00
|
|
|
|
## A cost to roll this card (RollCosts): the value ("@luck") and the amount
|
|
|
|
|
|
## taken away each time. Empty = free.
|
|
|
|
|
|
var cost_value: String = ""
|
|
|
|
|
|
var cost_amount: String = ""
|
2026-11-14 13:40:20 -06:00
|
|
|
|
## List cards: true when the list keeps repeats (an item added every time, in
|
|
|
|
|
|
## order); false adds an item only if it isn't there yet.
|
|
|
|
|
|
var list_repeats := false
|
2026-11-14 13:36:03 -06:00
|
|
|
|
## Ledger cards: the entries, [{name, start}] (LedgerMembers).
|
|
|
|
|
|
var members: Array = []
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
## A well-formed card of any kind; `sub` picks the variant (RollTableFactory).
|
|
|
|
|
|
static func create(p_kind: String, p_id: String, p_name: String, sub: String = "") -> RollTable: return RollTableFactory.create(p_kind, p_id, p_name, sub)
|
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-10 21:12:47 -06:00
|
|
|
|
## True for a roll card with columns.
|
|
|
|
|
|
func has_columns() -> bool:
|
|
|
|
|
|
return kind == KIND_ROLL and not columns.is_empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The column names, in order.
|
|
|
|
|
|
func column_names() -> Array[String]:
|
|
|
|
|
|
var out: Array[String] = []
|
|
|
|
|
|
for c: Dictionary in columns:
|
|
|
|
|
|
out.append(str(c.get("name", "")))
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Column `k`'s text on a result: its own text for column 0, else its cell.
|
|
|
|
|
|
static func cell_text(e: TableEntry, k: int) -> String:
|
|
|
|
|
|
if k == 0:
|
|
|
|
|
|
return e.text
|
|
|
|
|
|
return e.cells[k - 1] if k - 1 < e.cells.size() else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True for a scale variable card.
|
|
|
|
|
|
func is_scale() -> bool:
|
|
|
|
|
|
return kind == KIND_VARIABLE and var_type == VAR_SCALE
|
|
|
|
|
|
|
|
|
|
|
|
|
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 {}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
## Cleans an "inputs" value from JSON or the UI (RollTableIO.clean_inputs).
|
|
|
|
|
|
static func clean_inputs(v: Variant) -> Array: return RollTableIO.clean_inputs(v)
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
## Parses an options_from pattern: {"kind", "name", "error"} (RollChoice).
|
|
|
|
|
|
static func parse_options_from(src: String) -> Dictionary: return RollChoice.parse_options_from(src)
|
|
|
|
|
|
## "each @skill_* that's set, where option_value >= 1" (RollChoice).
|
|
|
|
|
|
func options_description() -> String: return RollChoice.options_description(self)
|
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
|
|
|
|
|
|
|
|
|
|
|
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.
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func roll_text() -> String: return RollRange.join(dice, dice_mod)
|
2026-11-09 10:01:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## True when totals past the ends count as the end results (RollRange.clamps).
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func clamps() -> bool: return RollRange.clamps(self)
|
2026-11-09 10:01:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Rolls the dice and adds the modifier. Returns {"value": int, "error": String}.
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func roll_value(ctx: RollContext) -> Dictionary: 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-14 13:19:54 -06:00
|
|
|
|
func min_value() -> int: 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.
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func die_size() -> int: 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
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func fmt(value: int) -> String: 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
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func num_label(e: TableEntry, index: int) -> String: 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`.
|
2026-11-14 13:19:54 -06:00
|
|
|
|
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.
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func can_come_up(e: TableEntry) -> bool: 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).
|
2026-11-14 13:19:54 -06:00
|
|
|
|
func entry_index_clamped(value: int) -> int: 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-10 18:43:16 -06:00
|
|
|
|
## The result an empty Deck-mode card gives when it waits for Shuffle.
|
|
|
|
|
|
func empty_text() -> String:
|
|
|
|
|
|
return deck_empty_text if deck_empty_text.strip_edges() != "" else "Empty"
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
## Gaps, overlaps and out-of-reach ranges, or "" when clean (RollRange.problems).
|
|
|
|
|
|
func range_problems() -> String: return RollRange.problems(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-14 13:19:54 -06:00
|
|
|
|
## A variable card's starting value: {"value", "error"} (RollLive).
|
|
|
|
|
|
func initial_value(ctx: RollContext) -> Dictionary: return RollLive.initial_value(self, ctx)
|
|
|
|
|
|
## True for plain words that aren't an expression (RollLive.looks_literal).
|
|
|
|
|
|
static func _looks_literal(src: String) -> bool: return RollLive.looks_literal(src)
|
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-14 13:19:54 -06:00
|
|
|
|
func to_dict() -> Dictionary: return RollTableIO.to_dict(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
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 13:19:54 -06:00
|
|
|
|
static func from_dict(d: Dictionary) -> RollTable: return RollTableIO.from_dict(d)
|
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-14 13:19:54 -06:00
|
|
|
|
## Expression fields may arrive as JSON numbers: 3.0 -> "3" (RollTableIO).
|
|
|
|
|
|
static func expr_text(v: Variant, fallback: String) -> String: return RollTableIO.expr_text(v, fallback)
|