2026-11-08 16:39:56 -06:00
|
|
|
|
class_name TablePreview
|
|
|
|
|
|
extends RefCounted
|
|
|
|
|
|
## A compact, read-only summary of a table, as a Control that can be dropped
|
|
|
|
|
|
## into any panel: name, kind and dice, details, then the entries with their
|
|
|
|
|
|
## number or range labels and chances (capped), and a "→ Next table" hint on
|
|
|
|
|
|
## entries that lead further. Used by the choice pop-up's preview panel; the
|
|
|
|
|
|
## board's hover pop-ups can use it too.
|
|
|
|
|
|
##
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
## Rules (conditions, effects, option sources, loop rules, a check's rule)
|
|
|
|
|
|
## read in plain words unless opts "plain" is false (docs/PLAIN.md §6).
|
|
|
|
|
|
##
|
2026-11-08 16:39:56 -06:00
|
|
|
|
## Usage: TablePreview.build(board, table_id, {"count": "2"}) -> Control.
|
|
|
|
|
|
## Nothing in it takes the mouse, so it never gets in the way of what is
|
|
|
|
|
|
## underneath.
|
|
|
|
|
|
|
|
|
|
|
|
## Rows shown before "+N more".
|
|
|
|
|
|
const MAX_ROWS := 12
|
|
|
|
|
|
const NEXT_HINT := "→ Next table"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## `opts`: count (String, e.g. "2" or "@terms": shown as "×2" when not "1"),
|
|
|
|
|
|
## max_rows (int), width (float, minimum width of the block),
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
## heading (String shown in place of the kind line, optional), plain (bool,
|
|
|
|
|
|
## default RulesView.plain(null): plain words unless the text view is on).
|
2026-11-08 16:39:56 -06:00
|
|
|
|
static func build(board: TowerBoard, table_id: String, opts: Dictionary = {}) -> Control:
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
var plain := bool(opts.get("plain", RulesView.plain(null)))
|
2026-11-08 16:39:56 -06:00
|
|
|
|
var box := VBoxContainer.new()
|
|
|
|
|
|
box.add_theme_constant_override("separation", 4)
|
|
|
|
|
|
box.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
box.custom_minimum_size.x = float(opts.get("width", 0.0))
|
|
|
|
|
|
var t: RollTable = board.get_table(table_id) if board != null else null
|
|
|
|
|
|
if t == null:
|
|
|
|
|
|
box.add_child(_label("Missing table", 14, Style.DANGER_INK, true))
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
|
|
|
|
# Head: name, then "Roll table · d100" and the pipe count.
|
|
|
|
|
|
var head := HBoxContainer.new()
|
|
|
|
|
|
head.add_theme_constant_override("separation", 8)
|
|
|
|
|
|
head.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
var name := Style.make_label(Formatter.strip_tags(t.name), Style.display(), 17, Style.INK)
|
|
|
|
|
|
name.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
|
|
|
|
name.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
|
|
|
|
name.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
head.add_child(name)
|
|
|
|
|
|
var count := str(opts.get("count", "1")).strip_edges()
|
|
|
|
|
|
if count != "" and count != "1":
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
head.add_child(_label("×" + (RulesView.cut(Describe.dice(count, board), 18) if plain else count), 15, Style.TRIM, true))
|
2026-11-08 16:39:56 -06:00
|
|
|
|
box.add_child(head)
|
|
|
|
|
|
box.add_child(_label(str(opts["heading"]) if opts.has("heading") else kind_line(t), 12, Style.MUTED, false))
|
|
|
|
|
|
|
|
|
|
|
|
var det := t.details.strip_edges()
|
|
|
|
|
|
if det != "":
|
|
|
|
|
|
var d := RichText.label(RichText.decorate(det), 13, Style.INK, false)
|
|
|
|
|
|
d.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
box.add_child(d)
|
|
|
|
|
|
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
var extra := summary_line(t, board, plain)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if extra != "":
|
|
|
|
|
|
box.add_child(_label(extra, 13, Style.INK, false, true))
|
|
|
|
|
|
|
|
|
|
|
|
var shown := 0
|
|
|
|
|
|
var cap := int(opts.get("max_rows", MAX_ROWS))
|
|
|
|
|
|
var list := VBoxContainer.new()
|
|
|
|
|
|
list.add_theme_constant_override("separation", 2)
|
|
|
|
|
|
list.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
2026-11-08 17:11:19 -06:00
|
|
|
|
if t.kind == RollTable.KIND_SHEET:
|
|
|
|
|
|
# A sheet's "entry" is its template: show it filled in, not as a result row.
|
|
|
|
|
|
var vars: Dictionary = opts.get("vars", {})
|
|
|
|
|
|
var sheet := RichText.label(RichText.decorate(Roller.render_sheet(board, vars, t)), 13, Style.INK, false)
|
|
|
|
|
|
sheet.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
box.add_child(sheet)
|
|
|
|
|
|
return box
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if t.kind != RollTable.KIND_VARIABLE:
|
|
|
|
|
|
for i in t.entries.size():
|
|
|
|
|
|
if shown >= cap:
|
|
|
|
|
|
break
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
list.add_child(_row(t, t.entries[i], i, board, plain))
|
2026-11-08 16:39:56 -06:00
|
|
|
|
shown += 1
|
|
|
|
|
|
if list.get_child_count() > 0:
|
|
|
|
|
|
box.add_child(list)
|
|
|
|
|
|
if t.kind != RollTable.KIND_VARIABLE and t.entries.size() > shown:
|
|
|
|
|
|
box.add_child(_label("+%d more" % (t.entries.size() - shown), 12, Style.MUTED, false))
|
|
|
|
|
|
return box
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## "Roll table · d100", "Choice card · pick", ...
|
|
|
|
|
|
static func kind_line(t: RollTable) -> String:
|
|
|
|
|
|
match t.kind:
|
|
|
|
|
|
RollTable.KIND_CHOICE:
|
Terminology pass: one set of kind and choice names, 2d6, result/change wording
- Describe.kind_label / choice_label / choice_labels replace six drifting
label tables. Search no longer calls Check and Router cards "Table", and
a Check card's dialog is titled "Check settings".
- Choice types read "Which option / How many / Open ended" everywhere
(menu, settings, inspector, card, preview, details).
- Plain dice read "2d6" / "d6" instead of the 2D-game "2D" / "1D".
- The built-in "2D skill check" template becomes "Skill check (2d6 vs
target)" (builtin:skill-check), a real Check card with Success and Failure.
- User text says "result" and "change" instead of "entry", "row" and "effect"
(Test board, settings dialog, lint, variables panel, pipe options).
- Pipes are deleted (link, toast, undo label), like cards and results; the
reset statement reads "Reset" in the builder and "Reset all X" for
prefixes. "Clear" stays for a value that really was erased.
- The template-saved toast points at "+ Card ▾".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 09:14:30 -06:00
|
|
|
|
return "Choice card · " + Describe.choice_label(t.choice).to_lower()
|
2026-11-08 16:39:56 -06:00
|
|
|
|
RollTable.KIND_LOOP:
|
2026-11-10 18:24:23 -06:00
|
|
|
|
return "Repeat card"
|
2026-11-08 16:39:56 -06:00
|
|
|
|
RollTable.KIND_VARIABLE:
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
return "Collection card" if t.is_collection() else "Variable card"
|
2026-11-08 16:39:56 -06:00
|
|
|
|
RollTable.KIND_SHEET:
|
|
|
|
|
|
return "Sheet card"
|
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
|
|
|
|
RollTable.KIND_ROUTER:
|
2026-11-10 18:24:23 -06:00
|
|
|
|
return "Branch · if / else if / otherwise"
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
RollTable.KIND_CHECK:
|
|
|
|
|
|
return "Check card · " + t.check_dice.strip_edges()
|
2026-11-08 16:39:56 -06:00
|
|
|
|
var s := "Roll table · " + t.dice_label()
|
|
|
|
|
|
return s + " · deck" if t.card_mode else s
|
|
|
|
|
|
|
|
|
|
|
|
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
## The kind-specific line: a choice card's question, a loop's rule, ... With
|
|
|
|
|
|
## `plain`, rules read in plain words (labelled from `board`).
|
|
|
|
|
|
static func summary_line(t: RollTable, board: TowerBoard = null, plain: bool = false) -> String:
|
|
|
|
|
|
if plain:
|
|
|
|
|
|
var s := _plain_summary(t, board)
|
|
|
|
|
|
if s != "":
|
|
|
|
|
|
return s
|
2026-11-08 16:39:56 -06:00
|
|
|
|
match t.kind:
|
|
|
|
|
|
RollTable.KIND_CHOICE:
|
|
|
|
|
|
var q := Formatter.strip_tags(t.prompt).strip_edges()
|
|
|
|
|
|
var ask := "Asks: " + q if q != "" else "Asks the player"
|
|
|
|
|
|
match t.choice:
|
|
|
|
|
|
"number":
|
|
|
|
|
|
return "%s (a whole number from %s to %s)" % [ask, t.min_expr, t.max_expr]
|
|
|
|
|
|
"text":
|
|
|
|
|
|
return ask + " (free text)"
|
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 t.is_dynamic():
|
|
|
|
|
|
return "%s\nOptions: %s" % [ask, t.options_description()]
|
2026-11-08 16:39:56 -06:00
|
|
|
|
return ask
|
|
|
|
|
|
RollTable.KIND_LOOP:
|
|
|
|
|
|
var e := t.loop_expr.strip_edges()
|
|
|
|
|
|
match t.loop_mode:
|
|
|
|
|
|
"while":
|
|
|
|
|
|
return "Repeats while %s" % e
|
|
|
|
|
|
"until":
|
|
|
|
|
|
return "Repeats until %s" % e
|
|
|
|
|
|
return "Repeats %s times" % (e if e != "" else "?")
|
|
|
|
|
|
RollTable.KIND_VARIABLE:
|
|
|
|
|
|
return "Holds @%s (%s)" % [t.var_name, t.var_type]
|
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
|
|
|
|
RollTable.KIND_ROUTER:
|
|
|
|
|
|
return "Goes on with the first case that's true"
|
2026-11-08 16:39:56 -06:00
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
static func _plain_summary(t: RollTable, board: TowerBoard) -> String:
|
|
|
|
|
|
match t.kind:
|
|
|
|
|
|
RollTable.KIND_CHOICE:
|
|
|
|
|
|
var q := Formatter.strip_tags(t.prompt).strip_edges()
|
|
|
|
|
|
var ask := "Asks: " + q if q != "" else "Asks the player"
|
|
|
|
|
|
match t.choice:
|
|
|
|
|
|
"number":
|
|
|
|
|
|
return "%s (a whole number from %s to %s)" % [ask, Describe.dice(t.min_expr, board), Describe.dice(t.max_expr, board)]
|
|
|
|
|
|
"text":
|
|
|
|
|
|
return ask + " (free text)"
|
|
|
|
|
|
if t.is_dynamic():
|
|
|
|
|
|
return "%s\n%s" % [ask, RulesView.options_line(t, board, true)]
|
|
|
|
|
|
return ask
|
|
|
|
|
|
RollTable.KIND_LOOP:
|
|
|
|
|
|
return _cap(RulesView.loop_rule(t, board, true))
|
|
|
|
|
|
RollTable.KIND_VARIABLE:
|
|
|
|
|
|
if t.is_collection():
|
|
|
|
|
|
return "Holds your %s" % Formatter.strip_tags(t.name).strip_edges()
|
|
|
|
|
|
return "Holds %s (%s), kept between rolls" % [Describe.label("@" + t.var_name, board), t.var_type]
|
|
|
|
|
|
RollTable.KIND_CHECK:
|
|
|
|
|
|
return Describe.check(t, board)
|
|
|
|
|
|
RollTable.KIND_ROLL:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
if t.clamps():
|
|
|
|
|
|
return Describe.roll(t, board)
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _cap(s: String) -> String:
|
|
|
|
|
|
if s.begins_with("×"):
|
|
|
|
|
|
return "Repeats " + s
|
|
|
|
|
|
return s.substr(0, 1).to_upper() + s.substr(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _row(t: RollTable, e: TableEntry, index: int, board: TowerBoard = null, plain: bool = false) -> Control:
|
2026-11-08 16:39:56 -06:00
|
|
|
|
var row := HBoxContainer.new()
|
|
|
|
|
|
row.add_theme_constant_override("separation", 8)
|
|
|
|
|
|
row.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
var num := _label(row_label(t, e, index), 12, Style.TRIM, false)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
num.custom_minimum_size.x = 40
|
|
|
|
|
|
num.size_flags_vertical = Control.SIZE_SHRINK_BEGIN
|
|
|
|
|
|
row.add_child(num)
|
|
|
|
|
|
var col := VBoxContainer.new()
|
|
|
|
|
|
col.add_theme_constant_override("separation", 0)
|
|
|
|
|
|
col.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
|
|
|
|
col.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
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
|
|
|
|
if t.kind == RollTable.KIND_ROUTER:
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
var cond := _label(RulesView.case_label(e, board, plain), 12, Style.TRIM_DARK, true, true)
|
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
|
|
|
|
cond.max_lines_visible = 2
|
|
|
|
|
|
cond.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
|
|
|
|
col.add_child(cond)
|
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 t.kind == RollTable.KIND_CHOICE and t.choice == "pick" and e.show_if.strip_edges() != "":
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
var si := _label(RulesView.show_if_line(e, board, plain), 12, Style.TRIM_DARK, true, true)
|
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
|
|
|
|
si.max_lines_visible = 2
|
|
|
|
|
|
si.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
|
|
|
|
col.add_child(si)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
var tx := Formatter.strip_tags(e.text).strip_edges()
|
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 t.is_dynamic() and index == 0 and (tx == "" or tx == Roller.CHOSEN):
|
|
|
|
|
|
tx = "The picked option"
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
if t.kind == RollTable.KIND_CHECK and (tx == "" or tx == TableCard.check_outlet_name(index)):
|
|
|
|
|
|
tx = TableCard.check_outlet_name(index)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
var text := _label(tx if tx != "" else "(empty)", 13, Style.INK, false, true)
|
|
|
|
|
|
text.max_lines_visible = 2
|
|
|
|
|
|
text.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
|
|
|
|
col.add_child(text)
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
if e.effects.strip_edges() != "":
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
var fx := _label(RulesView.effects_line(e.effects, board, t, plain), 11, Style.TRIM_DARK, true, true)
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
fx.max_lines_visible = 1
|
|
|
|
|
|
fx.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
|
|
|
|
col.add_child(fx)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if not e.pipes.is_empty():
|
Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.
ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
|
|
|
|
col.add_child(_label(NEXT_HINT, 11, Style.TRIM, false))
|
2026-11-08 16:39:56 -06:00
|
|
|
|
row.add_child(col)
|
|
|
|
|
|
if t.kind == RollTable.KIND_ROLL:
|
2026-11-09 10:01:10 -06:00
|
|
|
|
# The preview doesn't know the modifier's value, so it shows no chances.
|
|
|
|
|
|
var ch := "" if t.has_mod() else chance_text(t, e)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if ch != "":
|
|
|
|
|
|
var c := _label(ch, 12, Style.MUTED, false)
|
|
|
|
|
|
c.size_flags_vertical = Control.SIZE_SHRINK_BEGIN
|
|
|
|
|
|
row.add_child(c)
|
|
|
|
|
|
return row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## The number or range an entry covers; choice options and loop steps are
|
|
|
|
|
|
## numbered or named instead.
|
|
|
|
|
|
static func row_label(t: RollTable, e: TableEntry, index: int) -> String:
|
|
|
|
|
|
match t.kind:
|
|
|
|
|
|
RollTable.KIND_CHOICE:
|
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 t.choice != "pick":
|
|
|
|
|
|
return "Answer"
|
|
|
|
|
|
if t.is_dynamic():
|
|
|
|
|
|
return "Chosen" if index == 0 else str(index)
|
|
|
|
|
|
return str(index + 1)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
RollTable.KIND_LOOP:
|
|
|
|
|
|
return "Each" if index == 0 else "After"
|
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
|
|
|
|
RollTable.KIND_ROUTER:
|
|
|
|
|
|
return str(index + 1)
|
Plain Build display: plain rules on cards, pipes and tray, Why this?, check/collection/inputs visuals
- RulesView (ui/rules_view.gd): plain-or-text helpers over Describe, reading
Main.rules_plain() when present (else StateStore, else plain; --rules=text
for screenshots) and refreshing on Main.rules_view_changed.
- Cards: effect chips, router cases, option sources, show_if, loop rules,
expression dice and variable kinds read in plain words. Build cards drop the
inline effects / show_if / condition / details editors for plain chips;
result text and names stay inline. Row clicks call main.select_result();
the selected row gets a copper bar (set_selected_entry / inspector_selection).
- Check cards: 2D badge, the rule as a sentence, Success / Failure outlets.
Collection cards: live members and "+ Add" (main.select_card). Inputs:
a dashed "Input Tier · starts at 1" box.
- Pipe labels via Describe.pipe, nudged apart and cut to the gap.
- Tray: plain captions (inputs, checks, cases), effect lines from why facts,
and a "Why this?" button opening a WhyPopover; hovers show the same reasons.
- Previews and the choice pop-up read conditions, effects and option sources
in plain words. Style.rules_switch() for the Plain words / Text switch.
- Describe: empty text reads "empty" ("Loot is not empty").
- tests/test_plain_display.gd; option and choice tests pin the Text view
where they check stored text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 21:30:55 -06:00
|
|
|
|
RollTable.KIND_CHECK:
|
|
|
|
|
|
var outs := RulesView.check_outlets(t)
|
|
|
|
|
|
return outs[index] if index < 2 else str(index + 1)
|
2026-11-08 16:39:56 -06:00
|
|
|
|
return t.num_label(e, index)
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-09 10:01:10 -06:00
|
|
|
|
## "25%", "<1%" or "" when the chances can't be known. `mod` is the roll
|
|
|
|
|
|
## modifier's value (RollRange.live_mod), for a table that has one.
|
|
|
|
|
|
static func chance_text(t: RollTable, e: TableEntry, mod: int = 0) -> String:
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if not t.has_chances():
|
|
|
|
|
|
return ""
|
2026-11-09 10:01:10 -06:00
|
|
|
|
var p := t.chance(e, mod) * 100.0
|
2026-11-08 16:39:56 -06:00
|
|
|
|
if p <= 0.0:
|
|
|
|
|
|
return "0%"
|
|
|
|
|
|
if p < 1.0:
|
|
|
|
|
|
return "<1%"
|
|
|
|
|
|
if p < 10.0 and absf(p - roundf(p)) > 0.05:
|
|
|
|
|
|
return "%.1f%%" % p
|
|
|
|
|
|
return "%d%%" % roundi(p)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func _label(text: String, size: int, color: Color, bold: bool, wrap: bool = false) -> Label:
|
|
|
|
|
|
var l := Style.make_label(text, Style.body_bold() if bold else Style.body(), size, color)
|
|
|
|
|
|
l.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
|
if wrap:
|
|
|
|
|
|
l.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
|
|
|
|
l.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
|
|
|
|
return l
|