TableTower/README.md

85 lines
4.2 KiB
Markdown
Raw Normal View History

# TableTower
Random roll tables for tabletop games, built as a board of table cards joined by pipes.
Click the die on any table and the result flows down its pipes into the next table.
Made with Godot 4.7 (GDScript).
## Running
Open `project.godot` in Godot 4.7.x and press Play, or from a terminal:
```sh
godot --path .
```
## Using it
- **Play mode** is for the game table. Click a die to roll. The results flicker, one lands,
and a bead runs down any pipe into the next table. Hold **Shift** while clicking to fast
roll: no animation, just the result. The tray at the bottom shows the whole chain and the
last few rolls.
- **Build mode** is for setting up tables. Edit names, results, weights and details in place,
add or delete results and tables, and drag a card by its header. Drag from a result's ●
onto another table to lay a pipe. Click a pipe to set how many times it rolls, save its
result as a variable, or remove it. The ⚙ on a card opens its settings: details, tags,
plain or dice table (e.g. 2d6), and Card mode. Deletions can be undone from the toast.
- **Text in results** can roll on other tables inline with `[[Table]]`, `[[3x Gems]]` or
`[[Names -> hero]]` (saves the result as `{hero}` for the rest of the roll). `{@town|Towns}`
keeps a value across rolls until you clear it in the tray's Variables tab. BBCode such as
`[b]bold[/b]` works anywhere you type.
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray - ChoiceDialog: card-styled pop-up for pick (option rows with details, Random, 1-9 / R keys), number (spin box with min/max/default, Enter) and text. Cancel, Esc, freeing the dialog, a new roll or a collection switch all answer null through a separate Reply object, so a roll never hangs. - Main: real prompt hook; the steps so far light on the board and in the tray before each question; a roll with questions shows the rest at once; a new roll cancels an open question cleanly; refresh_live() re-renders variable, sheet and question text only after rolls and edits. - TableCard: "?" badge and question for choice cards, loop icon, rule chip and Each time / Afterwards rows, compact live variable cards (reset in Build), live sheet cards with one outlet, expression-dice subtitles, effect chips in Play and a validated effects editor in Build. - Build: "+ Table" menu for every kind; kind-specific settings (choice type, question, save as, min/max; loop mode and rule; variable name, type, starting value; sheet template) checked with Expr.check; expression pipe counts in the pipe popover and on pipe labels. - Tray: effect lines under chips, last 12 steps behind "+N earlier steps", sheet headline, Cancelled / action-limit pill, capped indents and Earlier rows; Variables tab lists every board variable with Reset all. - RichText: error markers in red; previews show {@x_*} and {= expr}. - examples/logic_demo.json and tests/test_logic_ui.gd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
- **Logic cards** (see `docs/LOGIC.md`): Build mode's **+ Table ▾** also adds choice cards
(which option, how many, open ended), loops, variables and sheets. A choice card pauses the
roll with a pop-up (1–9 pick, R for Random, Enter confirms, Esc cancels); the steps so far
light up behind it. Loops show their rule (`× @rooms`, `while @hp > 0`); variable cards show
their live value; sheet cards show their template filled in, and become the tray's
headline when a chain reaches them. Results can carry effects (`@hp -= 2`), edited with
the **ƒ** button in Build mode. The tray's Variables tab lists every variable, with
**Reset all…**. Try `examples/logic_demo.json` (Board ▾ → Import).
- **Collections:** the switcher in the top bar holds separate sets of tables. Build mode's
**Board ▾** menu imports and exports TableTower JSON, JSON Canvas, Mermaid, DOT and GraphML.
- **Ranged tables** (like *Wilderness Travel*) roll a d100 where each range's size sets its
chance. Each range takes one pipe; laying a new one replaces the old.
- **Collapsing:** the arrow beside a table's name collapses it. A collapsed table still shows
its last result. **Collapse all / Expand all** in the top bar does every table at once.
- **Moving around:** drag the felt to pan, use the mouse wheel to scroll (Shift for sideways),
Ctrl+wheel or pinch to zoom, and **Fit** to see every table.
Collections save automatically to `user://collections/<id>.json`, and card draws, saved
variables and roll history to `user://state/state.json` (on Linux, under
`~/.local/share/godot/app_userdata/TableTower/`). Local state is never exported.
**Board ▾ → Reset sample** restores the example tables.
## Layout
```
core/ data model, roller, dice, decks, text references, storage (no UI; testable headless)
io/ import and export converters
ui/ main scene, board view, cards, pipes, ports, result tray, styles
assets/ fonts (Rokkitt and Atkinson Hyperlegible, both SIL OFL)
tests/ headless checks
docs/ design document
```
## Tests
```sh
for t in tests/test_*.gd; do godot --headless --path . -s "res://$t" -- --sample; done
```
## Screenshots from the command line
```sh
tools/test_window.sh -- --screenshot=/tmp/board.png [--build] [--expand-all] [--collapse-all] \
[--roll=wilderness] [--fast] [--shot-delay=0.75]
```
Logic cards UI: choice pop-up, card kinds, Build creation and settings, tray - ChoiceDialog: card-styled pop-up for pick (option rows with details, Random, 1-9 / R keys), number (spin box with min/max/default, Enter) and text. Cancel, Esc, freeing the dialog, a new roll or a collection switch all answer null through a separate Reply object, so a roll never hangs. - Main: real prompt hook; the steps so far light on the board and in the tray before each question; a roll with questions shows the rest at once; a new roll cancels an open question cleanly; refresh_live() re-renders variable, sheet and question text only after rolls and edits. - TableCard: "?" badge and question for choice cards, loop icon, rule chip and Each time / Afterwards rows, compact live variable cards (reset in Build), live sheet cards with one outlet, expression-dice subtitles, effect chips in Play and a validated effects editor in Build. - Build: "+ Table" menu for every kind; kind-specific settings (choice type, question, save as, min/max; loop mode and rule; variable name, type, starting value; sheet template) checked with Expr.check; expression pipe counts in the pipe popover and on pipe labels. - Tray: effect lines under chips, last 12 steps behind "+N earlier steps", sheet headline, Cancelled / action-limit pill, capped indents and Earlier rows; Variables tab lists every board variable with Reset all. - RichText: error markers in red; previews show {@x_*} and {= expr}. - examples/logic_demo.json and tests/test_logic_ui.gd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:07:57 -06:00
Logic-card views: `--board=examples/logic_demo.json --roll=start "--answers=Brin|3"` answers
the first questions and leaves the next pop-up open; `--menu=add`, `--open-settings=<id>`,
`--edit-effects=<id>`, `--demo-long=<n>` (a chain of n steps) and `--confirm-reset` show the
rest.
This uses the sample board and doesn't save anything. `tools/test_window.sh` runs the game
under the window class "TableTower Test" (via a temporary `override.cfg`), which a KWin
window rule keeps in the background without focus.