- 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>
60 lines
2.7 KiB
GDScript
60 lines
2.7 KiB
GDScript
class_name RollLintBook
|
|
extends RefCounted
|
|
## Board checks for the book-table features: threads that roll with other dice
|
|
## or roll again on some results, cards with columns (and their "roll twice and
|
|
## combine" rows), and scale values.
|
|
## Items are {table_id, entry_id, message, kind: "book", level: "error"|"hint"}.
|
|
|
|
|
|
static func lint(board: TowerBoard, t: RollTable) -> Array[Dictionary]:
|
|
var out: Array[Dictionary] = []
|
|
for e in t.thread_sources():
|
|
for p in e.pipes:
|
|
var to := board.get_table(p)
|
|
if to == null:
|
|
continue
|
|
var dice := e.dice_for(p)
|
|
if dice != "":
|
|
if not to.is_ranged() or to.kind != RollTable.KIND_ROLL:
|
|
out.append(_item(t, e.id, "The thread to %s rolls with %s, but only a card with numbered ranges can use other dice." % [_n(to), dice], "hint"))
|
|
elif Dice.roll_problem(dice) != "":
|
|
out.append(_item(t, e.id, "The thread to %s rolls with %s: %s" % [_n(to), dice, Dice.roll_problem(dice)], "error"))
|
|
var again := e.reroll_for(p)
|
|
if not again.is_empty():
|
|
var left := 0
|
|
for x in to.entries:
|
|
if again.has(x.id):
|
|
continue
|
|
left += 1
|
|
var missing := again.filter(func(id: String) -> bool: return to.find_entry(id) == null)
|
|
if left == 0:
|
|
out.append(_item(t, e.id, "The thread to %s rolls again on every result, so it can never finish." % _n(to), "error"))
|
|
if not missing.is_empty():
|
|
out.append(_item(t, e.id, "The thread to %s rolls again on results that aren't on that card any more." % _n(to), "hint"))
|
|
for e in t.entries:
|
|
if e.repeat.is_empty():
|
|
continue
|
|
if not t.has_columns():
|
|
out.append(_item(t, e.id, "%s rolls its column again, but this card has no columns, so it does nothing. Use a thread back to the card instead." % _q(e), "hint"))
|
|
elif t.entries.all(func(x: TableEntry) -> bool: return not x.repeat.is_empty() or (e.repeat.get("reroll", []) as Array).has(x.id)):
|
|
out.append(_item(t, e.id, "%s rolls its column again, but every result rolls again too, so it can never finish." % _q(e), "error"))
|
|
if t.has_columns():
|
|
for c: Dictionary in t.columns:
|
|
var w := str(c.get("when", ""))
|
|
if w != "" and Expr.check(w) != "":
|
|
out.append(_item(t, "", "Column %s, only if %s: %s" % [c.get("name", ""), w, Expr.check(w)], "error"))
|
|
if t.is_scale() and t.steps.size() < 2:
|
|
out.append(_item(t, "", "The scale %s needs at least two steps." % _n(t), "error"))
|
|
return out
|
|
|
|
|
|
static func _q(e: TableEntry) -> String:
|
|
return "“%s”" % Formatter.strip_tags(e.text).strip_edges()
|
|
|
|
|
|
static func _n(t: RollTable) -> String:
|
|
return Formatter.strip_tags(t.name).strip_edges()
|
|
|
|
|
|
static func _item(t: RollTable, entry_id: String, msg: String, level: String) -> Dictionary:
|
|
return {"table_id": t.id, "entry_id": entry_id, "message": msg, "kind": "book", "level": level}
|