- Card threads: a port on each card's bottom edge. Plain runs after any result (once the result's own threads finish); Otherwise runs only when no thread of the result ran. Saved as card_threads (LOGIC.md 3g). - Typing on long cards no longer rebuilds the inspector or the card per key (~175 ms -> ~7 ms). Timing tool: tests/perf_typing.gd. - "+ Add result" scrolls to the new row and focuses it. - Mouse wheel zooms; Shift+wheel pans sideways; scrolling lists keep it. - "SPREAD" caption over the switcher; Morgan's first-run welcome. - docs/MECHANICS.md: checklist of table mechanics for planning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.8 KiB
GDScript
41 lines
1.8 KiB
GDScript
class_name CardThreads
|
|
extends RefCounted
|
|
## Card threads: threads that leave a card from its bottom edge rather than
|
|
## from one result (LOGIC.md §3g). They live on the card's outlet
|
|
## (RollTable.outlet), a TableEntry that is never rolled, so every thread
|
|
## option (count, Only if, save as, dice, rerolls, inputs, pause) works the
|
|
## same way as on a result's thread.
|
|
##
|
|
## When the card has given its result and that result's own threads have run
|
|
## (their whole chains), the card threads run, in order:
|
|
## - a plain card thread always runs ("Always");
|
|
## - an "Otherwise" card thread runs only if no thread of the result ran and
|
|
## no conditional card thread was true;
|
|
## - a card thread with Only if runs when its condition is true, worked out
|
|
## at that moment (after the result's chains).
|
|
## A loop card's threads run once, after its Afterwards row.
|
|
|
|
|
|
## True when card `t` has card threads to follow after `node` (a chosen row).
|
|
static func follows(t: RollTable, node: Dictionary) -> bool:
|
|
return t != null and not t.outlet.pipes.is_empty() and not node.has("pass")
|
|
|
|
|
|
## True when the pipe key belongs to a card thread.
|
|
static func is_card_key(key: String) -> bool:
|
|
return key.contains(":" + RollTable.OUTLET_ID + ">")
|
|
|
|
|
|
## Runs the card threads of frame["node"]'s card (a Roller.OP_CARD frame,
|
|
## popped once the result's own threads are done).
|
|
static func run(frame: Dictionary, ctx: RollContext, stack: Array) -> void:
|
|
var node: Dictionary = frame["node"]
|
|
var t: RollTable = node["table"]
|
|
var log: Array = []
|
|
var why: Array = []
|
|
var plan := RollPipes.pipe_plan(t.outlet, ctx, log, why, bool(frame.get("ran", false)))
|
|
for fact: Dictionary in why:
|
|
fact["card"] = true
|
|
Roller._log(node, log)
|
|
Roller._why(node, why)
|
|
RollPipes.push_plan(node, t.outlet, plan, stack, int(frame["depth"]), true)
|