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 TableEntry
|
|
|
|
|
|
extends RefCounted
|
|
|
|
|
|
## One possible result on a table. An entry may pipe into other tables, and on a
|
|
|
|
|
|
## ranged (dice) table it covers a span of die values such as 01–30.
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
const MAX_PIPE_COUNT := 99
|
|
|
|
|
|
|
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 text: String = ""
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## Optional longer description (may contain BBCode).
|
|
|
|
|
|
var details: String = ""
|
|
|
|
|
|
## Relative chance on a plain table; also the number of copies in card mode.
|
|
|
|
|
|
## 0 means it never comes up. Ignored on ranged tables.
|
|
|
|
|
|
var weight: int = 1
|
|
|
|
|
|
## IDs of the tables this entry rolls on next (unique; one pipe per target).
|
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 pipes: Array[String] = []
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## target table id -> how many times to roll it (missing = 1).
|
|
|
|
|
|
var pipe_count: Dictionary = {}
|
|
|
|
|
|
## target table id -> variable name to save the result under (missing = none).
|
|
|
|
|
|
var pipe_save: Dictionary = {}
|
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 has_range: bool = false
|
|
|
|
|
|
var range_lo: int = 1
|
|
|
|
|
|
var range_hi: int = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init(p_id: String = "", p_text: String = "") -> void:
|
|
|
|
|
|
id = p_id
|
|
|
|
|
|
text = p_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## How many die faces this entry covers. Plain entries cover exactly one.
|
|
|
|
|
|
func span() -> int:
|
|
|
|
|
|
return range_hi - range_lo + 1 if has_range else 1
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-08 12:11:43 -06:00
|
|
|
|
## How many times the pipe to `target` rolls.
|
|
|
|
|
|
func count_for(target: String) -> int:
|
|
|
|
|
|
return clampi(int(pipe_count.get(target, 1)), 1, MAX_PIPE_COUNT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Variable name the pipe to `target` saves into, or "".
|
|
|
|
|
|
func save_for(target: String) -> String:
|
|
|
|
|
|
return str(pipe_save.get(target, ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func set_pipe_count(target: String, n: int) -> void:
|
|
|
|
|
|
n = clampi(n, 1, MAX_PIPE_COUNT)
|
|
|
|
|
|
if n == 1:
|
|
|
|
|
|
pipe_count.erase(target)
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_count[target] = n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func set_pipe_save(target: String, name: String) -> void:
|
|
|
|
|
|
name = name.strip_edges()
|
|
|
|
|
|
if name == "":
|
|
|
|
|
|
pipe_save.erase(target)
|
|
|
|
|
|
else:
|
|
|
|
|
|
pipe_save[target] = name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Adds a pipe if it isn't there already.
|
|
|
|
|
|
func add_pipe(target: String, count: int = 1, save_as: String = "") -> void:
|
|
|
|
|
|
if not pipes.has(target):
|
|
|
|
|
|
pipes.append(target)
|
|
|
|
|
|
set_pipe_count(target, count)
|
|
|
|
|
|
set_pipe_save(target, save_as)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Removes a pipe along with its options.
|
|
|
|
|
|
func remove_pipe(target: String) -> void:
|
|
|
|
|
|
pipes.erase(target)
|
|
|
|
|
|
pipe_count.erase(target)
|
|
|
|
|
|
pipe_save.erase(target)
|
|
|
|
|
|
|
|
|
|
|
|
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
func to_dict() -> Dictionary:
|
|
|
|
|
|
var d := {"id": id, "text": text}
|
2026-11-08 12:11:43 -06:00
|
|
|
|
if details != "":
|
|
|
|
|
|
d["details"] = details
|
|
|
|
|
|
if weight != 1:
|
|
|
|
|
|
d["weight"] = weight
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if not pipes.is_empty():
|
2026-11-08 12:11:43 -06:00
|
|
|
|
var list: Array = []
|
|
|
|
|
|
for p in pipes:
|
|
|
|
|
|
var n := count_for(p)
|
|
|
|
|
|
var s := save_for(p)
|
|
|
|
|
|
if n == 1 and s == "":
|
|
|
|
|
|
list.append(p)
|
|
|
|
|
|
else:
|
|
|
|
|
|
var po := {"table": p}
|
|
|
|
|
|
if n != 1:
|
|
|
|
|
|
po["count"] = n
|
|
|
|
|
|
if s != "":
|
|
|
|
|
|
po["save_as"] = s
|
|
|
|
|
|
list.append(po)
|
|
|
|
|
|
d["pipes"] = list
|
Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.
- core/: data model (RollTable, TableEntry, TowerBoard), sample board
with a d100 table of 100 trinkets and a weighted d100 range table,
and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
cards, result tray with earlier rolls, undo toasts, and a Collapse all
/ Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00
|
|
|
|
if has_range:
|
|
|
|
|
|
d["range"] = [range_lo, range_hi]
|
|
|
|
|
|
return d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static func from_dict(d: Dictionary) -> TableEntry:
|
|
|
|
|
|
var e := TableEntry.new(str(d.get("id", "")), str(d.get("text", "")))
|
2026-11-08 12:11:43 -06:00
|
|
|
|
e.details = str(d.get("details", ""))
|
|
|
|
|
|
e.weight = maxi(0, int(d.get("weight", 1)))
|
|
|
|
|
|
for p: Variant in d.get("pipes", []):
|
|
|
|
|
|
if p is Dictionary:
|
|
|
|
|
|
var target := str(p.get("table", ""))
|
|
|
|
|
|
if target != "":
|
|
|
|
|
|
e.add_pipe(target, int(p.get("count", 1)), str(p.get("save_as", "")))
|
|
|
|
|
|
elif str(p) != "":
|
|
|
|
|
|
e.add_pipe(str(p))
|
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 r: Variant = d.get("range")
|
|
|
|
|
|
if r is Array and r.size() == 2:
|
|
|
|
|
|
e.has_range = true
|
|
|
|
|
|
e.range_lo = int(r[0])
|
|
|
|
|
|
e.range_hi = int(r[1])
|
|
|
|
|
|
return e
|