From 0c9ab1aa7178aae532de669c2cc3cb50fb8cc737 Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Tue, 10 Nov 2026 18:03:10 -0600 Subject: [PATCH] Slim DESIGN.md to a status page; add parallel test runner DESIGN.md (read every session) keeps status, names and the agreed plan; architecture and history move to ARCHITECTURE.md and HISTORY.md, read on demand. tools/run_tests.sh runs the suites in parallel and fails on SCRIPT ERROR as well as on a missing PASS line. Co-Authored-By: Claude Opus 5.5 --- docs/ARCHITECTURE.md | 175 +++++++++++++++ docs/DESIGN.md | 521 ++++++++----------------------------------- docs/HISTORY.md | 154 +++++++++++++ tools/run_tests.sh | 32 +++ 4 files changed, 454 insertions(+), 428 deletions(-) create mode 100644 docs/ARCHITECTURE.md create mode 100644 docs/HISTORY.md create mode 100755 tools/run_tests.sh diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md new file mode 100644 index 0000000..85d592f --- /dev/null +++ b/docs/ARCHITECTURE.md @@ -0,0 +1,175 @@ +# TableTower — Architecture and Features + +Read on demand (not every session). Status and plan: `docs/DESIGN.md`. + +## 2. Feature summary (all on `main`) + +**Board and rolling** +- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a + result's ● onto another card to lay a pipe. A result can pipe into several cards (fan-out), + on ranged and weighted tables alike; one roll runs them all. +- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation. +- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the + **− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M). +- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand + all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo, + Card ▾ + and Board ▾ (Test board, Reset sample, Pack collapsed groups, import, export). +- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and + selection paint over it. On by default; the `striped_rows` local setting. +- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup, + see `HelpDialog`), included in exports via the preset's include filter. +- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any + expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle). +- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to + its dice. Ranges may run past the dice (−3 to 24 on a d20); totals past the ends use the end + result. The card shows chances for the modifier's value now, and Why says "+3 for Luck". +- **Pipe options.** A count (a number or an expression), "save as", **Only if** conditions, + and **Otherwise**. A result's conditions and counts are evaluated once, as a snapshot, + before any pipe runs. +- **Text in results.** `[[Table]]` inline references, `{@var}` / `{hero}` values, and BBCode formatting. +- **The result tray** shows the chain as chips with effect lines, a sheet headline, + Earlier rolls, a Variables tab, Copy (text, BBCode, with details) and **Why this?** on each step. +- **Resizable panels.** Drag the tray's top edge or the inspector's left edge (double-click for the + default). The sizes are kept in local settings (`tray_height`, `inspector_width`). Every part of + the tray scrolls inside it. + +**Logic cards** (`docs/LOGIC.md`) +- **Choice:** "Which option" (pick, with Random), "How many" (a number) or "Open + ended" (text). The pop-up can be minimized, and its options preview where they lead. +- **Loop:** repeat N times, while a condition holds, or until it does. Then "Afterwards". +- **Router:** if / else if / otherwise cases; the first true case runs. +- **Check:** roll + modifier against a target, with Success and Failure outlets. Sets `nat`, `total` and `effect`. +- **Variable** cards (with a starting value) and **Collection** cards (e.g. Skills, whose members are `@skill_*`). +- **Sheet:** a live template, e.g. a character sheet. +- **Changes** (stored as `effects`) on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names. +- **Dynamic pick options** from a collection or list (`options_from`, `options_where`), plus `show_if` on any option. +- **Card inputs:** a card declares inputs, and pipes pass values (`with`), scoped to that pipe's part of the roll. +- **A 10,000-action limit** per roll. The roller uses an explicit stack, so long loops don't overflow. + +**Building** (Build mode) +- **The inspector,** docked right. It edits the selected card, result or pipe: + - effects as rows ("[Subtract] [1] from [Luck]") + - a roll or check modifier as "[Add ▾] [Luck ▾]" (ModifierEditor) + - conditions as rows ("[Luck] [is at least] [2]", with and/or) + - pipe inputs, Otherwise, count and saves-as + - kind-specific card fields + - a value picker with "+ New value…" + - "Edit as text" everywhere +- **Plain / Text** in View ▾ → Rules. +- **Card ⋯ menu** (Build): Table settings…, Save as template…, Collapse, Delete table. A row's × + shows only on hover, keyboard focus or when the row is selected. +- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step. + - Collapse/expand isn't undoable. + - Rolls, variables and decks aren't undoable. + - Collection members aren't undoable either. +- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to + select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → Pack collapsed groups. +- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from + "+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`: + skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter + and simple sheet. +- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card. +- **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports + errors, dead ends, unreached cards and lint, and clicking an item jumps to the card. +- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower + JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only). + +## 3. Architecture + +``` +core/ engine, no UI, testable headless + tower_board.gd a collection (tables, groups), JSON, format v2 + migration + roll_table.gd a card: kind, dice, entries, logic fields, factories (RollTable.create) + roll_range.gd a ranged card's numbers: span, natural range, labels, chances, the roll + modifier (shared with check cards), range problems + table_entry.gd a result: text, weight, range, effects, pipes (+count/save/when/otherwise/with), show_if, when + roller.gd coroutine roller with an explicit stack (_chain loop, roll/pipe steps, + apply_starting_values) plus delegators to its parts: + roll_pipes.gd pipe_plan snapshot, card inputs (`with`) + roll_cards.gd weighted picks, router, check, loops + roll_choice.gd choice requests, dynamic options, show_if, asking + roll_tree.gd flatten, step lookups, lit keys, pipe/entry keys + roll_lint.gd lint_*, endless_cycles + roll_context.gd per-roll state: chain and board variables, prompt hook, actions, depth + expr.gd / effects.gd expression evaluation (Godot Expression + rewrites), effect statements + text_expander.gd [[refs]], {vars}, {@prefix_*}, {= expr}; formatter.gd: BBCode safety and stripping + dice.gd / deck_state.gd dice parsing and distributions, card-mode decks + describe.gd rules → plain words, labels, why sentences; kind_label / choice_label + (the only place card-kind and choice-type names are defined) + builder.gd effect/condition models ↔ text, known_values + board_tester.gd simulation and static checks (used by the Test board UI and the CLI) + library_store.gd / state_store.gd collections on disk / local state (decks, variables, history, settings) + table_group.gd, template_kit.gd, template_library.gd, sample_board.gd +io/ json_io (canonical + import), canvas_io, graphml_io, mermaid_exporter, dot_exporter +ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, input) with one-line + delegators to RefCounted helpers that hold `m: Main`: + main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups, + main_history (undo), main_navigation (search/focus/minimap/arrange), + main_top_bar (bar, toast, endless-loop chip), main_state (decks, variables), + main_collections, main_templates, main_inspector + top bar parts: view_menu (View ▾), zoom_control, help_menu + help_dialog + table_card.gd + table_card_{header,rows,editing,value,text}.gd + result_tray.gd + tray_chips, tray_text, earlier_rolls + table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields + inspector_card (card fields) + inspector_roll (roll dice and modifier); + modifier_editor (the plain modifier builder); panel_splitter (drag handles) + and: board_view, card_layer, pipe_layer, port_layer, group_layer, group_card, minimap, + why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker, + rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog, + template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style +help/ topics.txt: the Help window's text (# Title per topic) +tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows) +tests/ test_*.gd: 27 headless suites +templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL) +``` + +**Key implementation facts** +- **Lazy cards.** Cards hidden inside collapsed groups aren't built, so + `main.card_for(id)` can return null. Pipe, port and card layers redraw only when something changes. +- **Undo** (`ui/edit_history.gd`) snapshots each table and group separately, sharing unchanged ones. +- **Prompts.** The roller awaits `ctx.prompt` for choices, and the UI shows progress before each pop-up. +- **Rules display.** The UI reads plain or text mode through `RulesView` and `main.rules_plain()`, + and `main.rules_view_changed` signals a switch. +- **Shared builders, use them rather than copying:** `Style.menu_button`, `Style.font_colors`, + `Style.field_colors`, `TableCard.vbox/hbox`, `InspectorKit.*` (fields, `focused_tag`/`refocus`, + `as_text_link`), `Main.file_dialog`/`export_dialog`, `JsonIO.entry_line`/`finish_import`. +- **Keep files small.** Aim for under ~400 lines; split by area into helper objects as above. + Next candidates, all 530–730 lines: + - core: describe (731, the largest now), roll_table, expr + - ui: choice_dialog, inspector_card, inspector, main, edit_history + - io: json_io + +## 4. Data and storage +- **Collections:** `user://collections/.json`, format_version 2 (`{format_version, id, + name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`. +- **Local state** (never exported): `user://state/state.json` holds decks, board + variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed, + `rules_view`, `striped_rows`). Templates live in `user://templates/`. +- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed + up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are + `traveller-chargen.before-*.json.bak` in the app data folder. + + +## 7. Known gaps and bugs +- **Only one pipe per target per result.** Pipes are keyed by target id, so the mockup's + two pipes into Loot (Tier 3 "only if", Tier 1 "otherwise") can't be built. Lifting this + needs pipe ids in the model, the file format, the UI keys (`tid:eid>to`) and undo. +- Long pipe labels are cut with "…" in narrow gaps, and labels draw behind cards. +- The Why pop-over opens above the tray and can cover the bottom of the board. +- Not tried by hand yet: all of this was verified with headless tests and screenshots + only. A hands-on playtest with a checklist is overdue. +- The Linux export preset exists, but the 4.7.2 export templates aren't installed. They're a + large download and the user hasn't approved it. There are no Windows or Mac presets. +- Loading a big board with every group expanded takes about 5 s (building `TableCard` nodes). +- Group frames are rectangles, so a non-member card lying inside one looks like a member. + Pipes into a collapsed group can't be clicked. +- Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON. +- `{= }` dice in live sheet and variable displays re-roll when the display refreshes. +- The simulator and Test board list results that only a modifier reaches as "never chosen" when + the modifier stays small in the runs (the demo's luck-only vault, for example). +- **Not yet looked into: Coderstanding warnings.** + - Signals emitted but never connected: `ModalCard.closed`, `SearchPanel.closed`. + - A possible wrong handler in `ModalCard.segmented` (`pressed` → `on_change`; probably a + false positive from a bound callable). + - Large class cycles in ui/ (expected from the `main` back-references). + diff --git a/docs/DESIGN.md b/docs/DESIGN.md index c2fe009..d78dba5 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1,436 +1,101 @@ -# TableTower — Design and Status +# Table Tarot (repo: TableTower) — Status and Plan -**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (UI pass: striped rows, View/Help menus, card ⋯ menu, a fuller sample; see §10) +**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-10 -This is the starting point for anyone picking the project up, including a new Claude -session. It records what TableTower is, how it's built, how to work on it, where things -stand, and what's next. +The short page to read at the start of every session. Everything else is read only when needed: +- `docs/ARCHITECTURE.md`: feature summary, file map, key implementation facts, data/storage, known gaps. +- `docs/HISTORY.md`: decisions on record, the private Traveller board, the old ideas list, history. +- `docs/LOGIC.md` (rule language), `docs/PLAIN.md` (plain-language layer), `README.md` (CLI flags). -**Detailed references:** -- `docs/LOGIC.md`: the rule language and every logic feature: card kinds, expressions, - effects, variables, conditional pipes, routers, dynamic options and the file keys. -- `docs/PLAIN.md`: the Plain Build usability layer: plain-language display, fill-in - builders, Check cards, card inputs, collections and the "why" trace. -- `README.md`: user-facing usage notes and command-line/screenshot flags. +## 1. What it is +A desktop (soon Android) app for building **random roll tables** as cards on a board, joined by +threads (code: pipes). A roll flows card to card; a logic layer adds choices, values, repeats, +branches and sheets. -**Open items for the next session (as of 2026-11-09)** -- **Repo privacy (waiting on the user).** The Forgejo instance is internet-facing. The user - wants every one of their repos private, with `digit` and Niles/sock as collaborators. - - Today only `RobinFiredrake/TableTower` is public. - - Niles/sock's username wasn't found: logged-out user search for "niles" or "sock" returns nothing. - - **Needed from the user:** that exact username, plus an API token (repository read/write - and user read, passed as `FORGEJO_TOKEN`), or they do it in the web UI themselves. - - Don't go looking for stored credentials. -- **Card Mode needs a UI redesign (user request, 2026-11-09).** Card mode works, but its - controls need rethinking when we get to it: - - It's switched on deep in Table settings… (an Off/On switch plus "When the deck runs out"). - - The deck state is a small "4 / 6 left · ↻ Reshuffle" line under the card's name. - Start with a mockup, as for the UI pass, before changing code. The sample's Party Roles is - the card-mode example. Undecided: where the switch lives, how a dealt result looks on the card, - and how "deck empty" shows. -- **Hands-on playtest, then fix what feels wrong.** On `main`: - - The UI pass had a first look from the user ("looks fine for now"), but not every part was - tried: striped rows, View ▾ (Plain/Text moved here), the zoom control, Help ▾ / F1, the card - ⋯ menu and the row × that shows on hover. In the sample, pray at Make Camp's shrine and search - the ruins until the vault turns up. An existing Fantasy Loot collection only gets the new - cards after Board ▾ → Reset sample. - - Not yet tried by hand: - - Roll modifiers: build a 1d20 + Luck table from −3 to 24 in the inspector, check that the - chances move as Luck changes, roll it, and read Why this?. - - The resizable tray and inspector: drag both edges, double-click to reset, restart the app to - check the sizes are kept, and fill Earlier with long rolls to check it scrolls. - - The terminology pass (the file splits had a first look: "looking fine so far"). -- **Suggested test audit: script errors can still pass.** A suite whose test function crashes - (SCRIPT ERROR) skips the rest of that function but can still print `PASS: 0 failure(s)`. - test_groups and test_navigation did this during the UI pass. Fix: treat any SCRIPT ERROR in - a suite's output as a failure, for example in a small `tools/run_tests.sh` that runs the suites - in parallel (about 15 s) and checks both. -- **Suggested next: a size audit of `core/describe.gd`** (731 lines, now the largest file). Split - it by area (labels, effects/conditions, cards, why) with one-line delegators, as for main.gd. - The other files over ~530 lines are listed in §3 under "Keep files small". -- **Stale worktree.** `.claude/worktrees/agent-aa27e470dd86ce971` (branch `split-table-card`) - stayed locked by a finished agent. Its work is merged, so run - `git worktree remove -f -f` on it, then delete the branch. +**Product principles (from the user)** +- **General-purpose.** The Traveller board is only a capability test. No game-specific features. +- **Intuitive for non-technical people.** Flag anything programmer-y. Play mode stays simple. +- **Plain words by default**; rule text stays stored and reachable ("Edit as text"). +- **Themed names are welcome** as long as they stay easy to understand. ---- +## 2. Names (decided 2026-11-10; UI text only; code and JSON keys keep old names) +| UI word | Was (UI) | Code / JSON | +|---|---|---| +| Table Tarot (app) | TableTower | project, classes, `user://` folder unchanged | +| Spread (a saved set of cards) | Board / Collection | `TowerBoard`, `LibraryStore`, `collections/` | +| Thread | Pipe | `pipes`, `PipeLayer` | +| Deck mode | Card mode | `card_mode` | +| Book / Page (reusable results) | — | new | +| Branch (if… / otherwise) | Router | `router` | +| Repeat | Loop | `loop` | +The Collection *card kind* needs a new UI name (not "List", not "Collection"); undecided. +Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology". -## 1. What TableTower is +## 3. Plan (agreed 2026-11-10, in order) +1. **Theme system first.** `Style` constants become a runtime theme (tokens + gradients), so + per-card/per-thread colours are overrides of the same tokens. Options menu theme editor: + colours (cards, threads, background, panels, text…), gradients for large areas, font, logo, + background pattern; save themes as sets. Ship two: **Tarot** (default: dark jewel-tone purple + cloth with a faint gradient shine, colours from `assets/art/fortune_teller.svg` and + `assets/ui/frame_*.svg`) and **Felt** (inspired by the current green/copper look). +2. **Rename and reskin.** Table Tarot text, mascot/logo/icon `assets/art/fortune_teller.svg`, + scaling card borders from `assets/ui/frame_border.svg` + `frame_corner.svg`. Magical particles + on the thread glow and the selected-result glow (CPUParticles2D for mobile). Thread string art + comes later (user hasn't drawn it). +3. **Board interaction.** Remove the drag walls. Empty-space drag = selection box (groups can be + box-selected and moved together even if not groupable). Pan = middle-drag, Space+drag + fallback, two fingers on touch. Cards resizable in width and height (results scroll inside). +4. **One menu system.** Right-click menus for cards, threads and background (create card/group, + search, shuffle all, list view, Book…), shared with the card ⋯ menu, mobile long-press, and a + top-bar menu button (keep a visible button: more intuitive than right-click for some). + Zoomed-out Build: names become tooltips, only drag + right-click; Play: click rolls. +5. **Small UI items.** Tray chips show the source card name clearly (bold/contrast). Inspector + lists threads in (from where) and out (to where). Range low > high: warning + disabled roll, + no auto-fix. Template "Update template" (edit existing). Export menu: odd formats under + "Other formats…". Test board explains "lint". +6. **Deck mode.** Rename; show drawn-out options on the card; surface Reshuffle-vs-Stop (exists: + RollTable "When the deck runs out"); Stop gives a custom result (default + "Empty"); Shuffle all (menu + right-click). +7. **Nested groups**, then **List view** (folders = groups; reorder; own search; thread icons with + tooltips), then the **mobile layout** (List view default; Android export template download OK'd). +8. **Book and Pages.** Library of reusable results (name, BBCode text, details, tags, image), + searchable, with an editor; drag a Page onto a table slot. Pages are **linked** (edit once, + updates everywhere; "unlink"). Same linking mechanism as linked templates. Stored in the spread + file so exports keep them. Closable; open from top bar or background right-click. +9. **Roll features.** "Roll N times, then: keep all / add / highest / lowest / let me choose" + (one feature; "keep all" from a card = batches). **Pause**: a thread can wait; the paused roll + is set aside as a "Continue ▸" chip in the tray. **Costs** on choice options (greyed out with + a reason when unaffordable). **Adjust later rolls**: plain builder over values/modifiers for + "next roll on X gets +3 / at least Medium / results below X become Y" (engine already can). +10. **Sheets**: easier building, export as Text / Markdown / HTML (no PDF). +11. **Images** in details/tables, embedded in the spread file (downscaled, size-capped); imported + BBCode may only use embedded images. +12. **Help**: document major features, hotkey cheat sheet, per-topic "Try a demo" spreads that open + unsaved and don't appear in the spread list. -A desktop app for building **random roll tables** and rolling on them, for tabletop GMs, -players and anyone using random prompts. Tables are **cards on a felt board**, joined by -**copper pipes**. A roll flows down the pipes from card to card, and the path lights up. +**Still open from before:** repo privacy on Forgejo (waiting on the user: Niles/sock's username + +token); hands-on playtest; size audit of `core/describe.gd` (731 lines) and the other files over +~530 lines (list in ARCHITECTURE.md §3); known gaps in ARCHITECTURE.md §7. -On top of plain tables, a **logic layer** lets a board ask the player questions, remember -values, repeat steps, branch, and print a sheet. A whole procedure, such as generating a -character, can run as one chain. - -### Product principles (from the user) -- **General-purpose.** Not built for any one game. The Traveller board (§8) is only a - capability test, used to find missing general features. Don't build game-specific features. -- **Play mode stays simple** for use at the game table. Advanced controls belong in Build mode. -- **Readable by normal people.** Rules show in plain words by default. The rule text is - still stored, and visible through the Plain/Text switch and "Edit as text". -- **The visual design is settled:** felt green, copper pipes, brass for lit and selected - things, Rokkitt (display) and Atkinson Hyperlegible (body). See `ui/style.gd`. Match it - and don't restyle. - -## 2. Feature summary (all on `main`) - -**Board and rolling** -- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a - result's ● onto another card to lay a pipe. A result can pipe into several cards (fan-out), - on ranged and weighted tables alike; one roll runs them all. -- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation. -- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the - **− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M). -- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand - all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo, + Card ▾ - and Board ▾ (Test board, Reset sample, Pack collapsed groups, import, export). -- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and - selection paint over it. On by default; the `striped_rows` local setting. -- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup, - see `HelpDialog`), included in exports via the preset's include filter. -- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any - expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle). -- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to - its dice. Ranges may run past the dice (−3 to 24 on a d20); totals past the ends use the end - result. The card shows chances for the modifier's value now, and Why says "+3 for Luck". -- **Pipe options.** A count (a number or an expression), "save as", **Only if** conditions, - and **Otherwise**. A result's conditions and counts are evaluated once, as a snapshot, - before any pipe runs. -- **Text in results.** `[[Table]]` inline references, `{@var}` / `{hero}` values, and BBCode formatting. -- **The result tray** shows the chain as chips with effect lines, a sheet headline, - Earlier rolls, a Variables tab, Copy (text, BBCode, with details) and **Why this?** on each step. -- **Resizable panels.** Drag the tray's top edge or the inspector's left edge (double-click for the - default). The sizes are kept in local settings (`tray_height`, `inspector_width`). Every part of - the tray scrolls inside it. - -**Logic cards** (`docs/LOGIC.md`) -- **Choice:** "Which option" (pick, with Random), "How many" (a number) or "Open - ended" (text). The pop-up can be minimized, and its options preview where they lead. -- **Loop:** repeat N times, while a condition holds, or until it does. Then "Afterwards". -- **Router:** if / else if / otherwise cases; the first true case runs. -- **Check:** roll + modifier against a target, with Success and Failure outlets. Sets `nat`, `total` and `effect`. -- **Variable** cards (with a starting value) and **Collection** cards (e.g. Skills, whose members are `@skill_*`). -- **Sheet:** a live template, e.g. a character sheet. -- **Changes** (stored as `effects`) on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names. -- **Dynamic pick options** from a collection or list (`options_from`, `options_where`), plus `show_if` on any option. -- **Card inputs:** a card declares inputs, and pipes pass values (`with`), scoped to that pipe's part of the roll. -- **A 10,000-action limit** per roll. The roller uses an explicit stack, so long loops don't overflow. - -**Building** (Build mode) -- **The inspector,** docked right. It edits the selected card, result or pipe: - - effects as rows ("[Subtract] [1] from [Luck]") - - a roll or check modifier as "[Add ▾] [Luck ▾]" (ModifierEditor) - - conditions as rows ("[Luck] [is at least] [2]", with and/or) - - pipe inputs, Otherwise, count and saves-as - - kind-specific card fields - - a value picker with "+ New value…" - - "Edit as text" everywhere -- **Plain / Text** in View ▾ → Rules. -- **Card ⋯ menu** (Build): Table settings…, Save as template…, Collapse, Delete table. A row's × - shows only on hover, keyboard focus or when the row is selected. -- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step. - - Collapse/expand isn't undoable. - - Rolls, variables and decks aren't undoable. - - Collection members aren't undoable either. -- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to - select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → Pack collapsed groups. -- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from - "+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`: - skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter - and simple sheet. -- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card. -- **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports - errors, dead ends, unreached cards and lint, and clicking an item jumps to the card. -- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower - JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only). - -## 3. Architecture - -``` -core/ engine, no UI, testable headless - tower_board.gd a collection (tables, groups), JSON, format v2 + migration - roll_table.gd a card: kind, dice, entries, logic fields, factories (RollTable.create) - roll_range.gd a ranged card's numbers: span, natural range, labels, chances, the roll - modifier (shared with check cards), range problems - table_entry.gd a result: text, weight, range, effects, pipes (+count/save/when/otherwise/with), show_if, when - roller.gd coroutine roller with an explicit stack (_chain loop, roll/pipe steps, - apply_starting_values) plus delegators to its parts: - roll_pipes.gd pipe_plan snapshot, card inputs (`with`) - roll_cards.gd weighted picks, router, check, loops - roll_choice.gd choice requests, dynamic options, show_if, asking - roll_tree.gd flatten, step lookups, lit keys, pipe/entry keys - roll_lint.gd lint_*, endless_cycles - roll_context.gd per-roll state: chain and board variables, prompt hook, actions, depth - expr.gd / effects.gd expression evaluation (Godot Expression + rewrites), effect statements - text_expander.gd [[refs]], {vars}, {@prefix_*}, {= expr}; formatter.gd: BBCode safety and stripping - dice.gd / deck_state.gd dice parsing and distributions, card-mode decks - describe.gd rules → plain words, labels, why sentences; kind_label / choice_label - (the only place card-kind and choice-type names are defined) - builder.gd effect/condition models ↔ text, known_values - board_tester.gd simulation and static checks (used by the Test board UI and the CLI) - library_store.gd / state_store.gd collections on disk / local state (decks, variables, history, settings) - table_group.gd, template_kit.gd, template_library.gd, sample_board.gd -io/ json_io (canonical + import), canvas_io, graphml_io, mermaid_exporter, dot_exporter -ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, input) with one-line - delegators to RefCounted helpers that hold `m: Main`: - main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups, - main_history (undo), main_navigation (search/focus/minimap/arrange), - main_top_bar (bar, toast, endless-loop chip), main_state (decks, variables), - main_collections, main_templates, main_inspector - top bar parts: view_menu (View ▾), zoom_control, help_menu + help_dialog - table_card.gd + table_card_{header,rows,editing,value,text}.gd - result_tray.gd + tray_chips, tray_text, earlier_rolls - table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields - inspector_card (card fields) + inspector_roll (roll dice and modifier); - modifier_editor (the plain modifier builder); panel_splitter (drag handles) - and: board_view, card_layer, pipe_layer, port_layer, group_layer, group_card, minimap, - why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker, - rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog, - template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style -help/ topics.txt: the Help window's text (# Title per topic) -tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows) -tests/ test_*.gd: 27 headless suites -templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL) -``` - -**Key implementation facts** -- **Lazy cards.** Cards hidden inside collapsed groups aren't built, so - `main.card_for(id)` can return null. Pipe, port and card layers redraw only when something changes. -- **Undo** (`ui/edit_history.gd`) snapshots each table and group separately, sharing unchanged ones. -- **Prompts.** The roller awaits `ctx.prompt` for choices, and the UI shows progress before each pop-up. -- **Rules display.** The UI reads plain or text mode through `RulesView` and `main.rules_plain()`, - and `main.rules_view_changed` signals a switch. -- **Shared builders, use them rather than copying:** `Style.menu_button`, `Style.font_colors`, - `Style.field_colors`, `TableCard.vbox/hbox`, `InspectorKit.*` (fields, `focused_tag`/`refocus`, - `as_text_link`), `Main.file_dialog`/`export_dialog`, `JsonIO.entry_line`/`finish_import`. -- **Keep files small.** Aim for under ~400 lines; split by area into helper objects as above. - Next candidates, all 530–730 lines: - - core: describe (731, the largest now), roll_table, expr - - ui: choice_dialog, inspector_card, inspector, main, edit_history - - io: json_io - -## 4. Data and storage -- **Collections:** `user://collections/.json`, format_version 2 (`{format_version, id, - name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`. -- **Local state** (never exported): `user://state/state.json` holds decks, board - variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed, - `rules_view`, `striped_rows`). Templates live in `user://templates/`. -- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed - up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are - `traveller-chargen.before-*.json.bak` in the app data folder. - -## 5. Working on it - -**Basics** -- **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. A desktop launcher "TableTower (Godot)" opens the editor on the project. -- **Tests:** `for t in tests/test_*.gd; do godot --headless --path . -s "res://$t" -- --sample; done`. - All must print `PASS: 0 failure(s)`. After adding `class_name` files, run `godot --headless --path . --import` first. -- **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample`, which must print no SCRIPT ERROR. -- **Simulator:** `godot --headless --path . -s res://tools/simulate_board.gd -- --board= --start= --runs=N [--check] [--prefer=regex] [--quiet]`. -- **Windowed runs and screenshots: always go through `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`.** - - It runs the game as window class "TableTower Test", and a KWin rule (KDE Plasma 6, - Wayland, in `~/.config/kwinrulesrc`) keeps that class unfocused and behind other windows. - - Never open a test window with plain `godot --path .`. - - Don't minimize test windows; Godot stops rendering when minimized. -- **Screenshot and state flags**, read in `ui/main_cli.gd` and in some UI files; README lists the main ones: - - Setup and roll: `--board`, `--roll`, `--fast`, `--answers`, `--build`, `--rules=text`, `--why`. - - Inspector and focus: `--inspect=tid[:eid][>to]`, `--search`, `--focus`, `--minimap`. - - Tools and layout: `--test-board`, `--pack`, `--perf`, `--window=WxH`. - -- **Coderstanding** (the user's structure scanner, https://forgejo.smhub.duckdns.org/digit/coderstanding) - saves tokens on audits and big reads. - - **Not installed permanently.** Clone it into the scratchpad, make a venv, `pip install `. - - **Keep its config and data out of the repo.** Set `XDG_CONFIG_HOME=/xdgconf`, then - `coderstanding add tabletower --data /cs_data` and `coderstanding rescan tabletower`. - - **Commands:** `outline ` (functions with line ranges), `hotspots`, `dupes` - (string literals only), `warnings`, `find`, `uses`, `brief`. - - **Copied code:** `dupes` doesn't find copied code blocks; use a sliding-window line hash for that. -- **Launching for the user to look at** (not a test): plain `godot --path .` in the - background is fine, so the window comes to the front. - -**Git and agent workflow** -- **Git:** remote `origin` = `git@forgejo.smhub.duckdns.org:RobinFiredrake/TableTower.git`. - Work on a feature branch and merge to `main` when the user asks (fast-forward). - End commit messages with the Co-Authored-By line. -- **Agents.** Large features have been split across parallel agents in git worktrees, each owning specific files: - - Worktrees start from an old commit, so each brief says `git reset --hard ` first. - - Merge one by one, run every suite and the simulator, take screenshots, then fix the seams. - - Brief each agent to keep the public API of the file it owns (one-line delegators), so - parallel splits don't conflict. Only tests may change in several branches at once. - - Merged feature branches still exist locally and on the server (`pipe-board`, `fast-roll`, - `logic-cards`, `groups-templates`, `boards-v2`, `undo-options`, `plain-build`); they can be deleted. - -## 6. Decisions on record -- The three-pane UI from the first design was replaced by the pipe board (a user request: simpler at the table). -- Variables are kept between rolls until changed or reset, so a character sheet survives other rolls. -- A variable card's starting value is applied, if the variable isn't set, when a top-level roll starts. -- Expression dice clamp beyond the end ranges. Plain dice tables report gaps instead. -- Pipe conditions and counts are a snapshot taken when the result is chosen. Two true Only-if pipes both run; routers give exactly one. -- `a if c else b` is refused (Godot's Expression returns the wrong branch); use `if(c, a, b)`. -- Collapse/expand isn't undoable. Collection members aren't undoable. -- Rules are stored as text, and the plain layer sits on top of it, so old boards open unchanged. -- Traveller-derived content stays out of the repo (§8). -- **Roll modifiers (2026-11-09).** A separate `dice_mod` field, not just an expression in `dice`, - so the card knows its dice: it can show chances, the natural range and plain words. Totals past - the ends always use the end result; there's no separate "nothing happens" setting, because an end - result that says so does the same job. The Check card's modifier picker became the shared - ModifierEditor, which also adds a value as it is (`@luck`) and doesn't only use `dm()`. -- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's - `SplitContainer`. The tray used to size itself to its content and the inspector collapses to a - strip, and a handle that sets the panel's size fits both without changing the layout. -- **UI pass (2026-11-09).** View preferences (rules view, collapse all, stripes, minimap) live in - View ▾ rather than on the bar; Plain/Text is one click further away, which the user accepted. - The card ⋯ menu shares `Style.overflow_button` with the group card's ⋯. Stripes use the - "parchment" tint picked from a mockup (felt tint and hairline were the other options). The - sample's Search the Ruins uses `[[refs]]` rather than pipes, because Loot and the trinkets are - far across the board. Card mode already existed (Party Roles) and needed no new work. -- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names. - - **Card:** anything on the felt. "Roll table" means only the `roll` kind. - - **Result**, never "entry" or "row" (code: `TableEntry`, `entries`). - - **Change** in plain text, "effect" only in Text mode (code and JSON: `effects`). - - **Pipe.** Pipes are *deleted*, like cards and results. "Remove" is for taking an item out - of something. - - **Reset** = back to the starting value, or erased if the value has no card. "Clear" only - when a value really is erased. - - **Dice** always read `2d6` / `d6`. `2D` is accepted as input only. - - **Choice types:** "Which option / How many / Open ended", from `Describe.choice_label`. - - **JSON keys aren't renamed.** A rename needs a format bump plus migration. -- **Fan-out on ranged tables (2026-11-09).** Dropping a pipe from a range used to replace that - range's pipe, a rule left over from the first build. It was a user-reported bug (a "Rocky" range - could not feed Resources, Atmosphere and Water), so ranges now add pipes like weighted results. - `MainEditing.finish_link` uses `TableEntry.add_pipe`. The drop itself has no automated test. - -## 7. Known gaps and bugs -- **Only one pipe per target per result.** Pipes are keyed by target id, so the mockup's - two pipes into Loot (Tier 3 "only if", Tier 1 "otherwise") can't be built. Lifting this - needs pipe ids in the model, the file format, the UI keys (`tid:eid>to`) and undo. -- Long pipe labels are cut with "…" in narrow gaps, and labels draw behind cards. -- The Why pop-over opens above the tray and can cover the bottom of the board. -- Not tried by hand yet: all of this was verified with headless tests and screenshots - only. A hands-on playtest with a checklist is overdue. -- The Linux export preset exists, but the 4.7.2 export templates aren't installed. They're a - large download and the user hasn't approved it. There are no Windows or Mac presets. -- Loading a big board with every group expanded takes about 5 s (building `TableCard` nodes). -- Group frames are rectangles, so a non-member card lying inside one looks like a member. - Pipes into a collapsed group can't be clicked. -- Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON. -- `{= }` dice in live sheet and variable displays re-roll when the display refreshes. -- The simulator and Test board list results that only a modifier reaches as "never chosen" when - the modifier stays small in the runs (the demo's luck-only vault, for example). -- **Not yet looked into: Coderstanding warnings.** - - Signals emitted but never connected: `ModalCard.closed`, `SearchPanel.closed`. - - A possible wrong handler in `ModalCard.segmented` (`pressed` → `on_change`; probably a - false positive from a bound callable). - - Large class cycles in ui/ (expected from the `main` back-references). - -## 8. The Traveller test board (private) -- **Location.** Private content derived from the user's Mongoose Traveller 2e rulebook lives in - `~/Repos/Godot/TableTower-private/` (outside git; see its README). That covers the rules digest - (`traveller/chargen.json`), the board generator (`traveller/board/build_board.py`, - `python3 -I`) and the generated board. -- **The board itself.** It's installed as collection `traveller-chargen`: 662 cards, 23 groups, - routers, dynamic options and `show_if`. It runs clean in the simulator (start card `new_traveller`). -- **Still worked around:** - - global "argument" variables (`@x_offer`, `@x_lvl`) feeding shared skill cards - - natural-roll pre-rolls (`rs`, `ra`, `rc`) - - `.replace()` chains for names - - counters instead of `len()` - - about 70 reset statements - - a guard before empty dynamic picks -- **Not automated:** group steps (Connections, skill packages, shared ships), contact - naming, gear choice, medical bills, anagathics, the Psion career, Noble titles, and the - total skill cap. -- **Open question for the user:** "Raise a skill you already have" counts level-0 skills as held (the rules reading); the user's earlier example was level 1+. - -## 9. Improvement ideas, roughly by value -1. **Hands-on playtest** with a checklist, then fix what feels wrong. Highest value now that Build mode has changed a lot. -2. **Several pipes to the same card** (pipe ids). It unlocks Tier 3 "only if" plus Tier 1 "otherwise" into one card. -3. **Port the Traveller board to the new features:** - - card inputs instead of the `@x_*` argument variables - - Check cards - - `nat` - - collections - This also tests them end to end. -4. **Small engine additions:** - - `len(list)` - - `sum` / `max` over a prefix (enables "best of these skills" and skill caps) - - a fallback path when a dynamic pick has no options, instead of stopping the roll - - telling unset from 0 - - lists that keep duplicates - - effects that run after pipes - - nicer display names ("Jack-of-all-Trades") -5. **Onboarding:** a guided tutorial board, a cheat-sheet panel, and templates surfaced as "starter blocks". -6. **Sheet output:** save a finished sheet as text or Markdown; keep finished characters as a list. -7. **Comfort:** a UI scale setting, colour-blind-friendly lit pipes, optional seeded rolls. -8. **Groups:** nested groups, only true members inside frames, clickable pipes into collapsed - groups, and groups in the Canvas and GraphML exports. -9. **Linked templates:** a plan exists. Copies record template uid, revision and role, and - offer "Update available" with a per-field merge. -10. **Faster expanded-board loads.** -11. **Builds:** install the export templates (needs the user's OK), add Windows and Mac presets. -12. **From the original design:** a big-button quick-roll view, cross-collection references - (`[[Collection/Table]]`), touch support. -13. **Naming suggestions not yet applied** (from the 2026-11-09 audit): - - Rename the Collection card kind (e.g. "List"), so "collection" means only the saved set. - - Label the check margin "Margin" instead of "Effect". - - Keep raw `@name` / `{@x}` / "BBCode" out of Play mode. - - "Endless loop" → "Never finishes". - - Drop the `_` on helpers used across files. - - `EffectsBuilder`/`ConditionBuilder` → `*Editor`, `LibraryStore` → `CollectionStore`. - - Keep JSON keys as they are; document the key ↔ UI mapping in LOGIC.md. -14. **Housekeeping:** delete merged branches (also `split-table-card`, see Open items). Keep LOGIC.md and PLAIN.md in step with features. - -## 10. History - -**2026-11-08 (one long session): board and core features** -1. Initial Godot project and the original design doc. An HTML mockup became the pipe board, built in Godot. -2. First feature wave (parallel agents): weights, dice expressions, card mode, text references and BBCode, - collections and local state, import/export, a Linux preset, the play-side UI, and the app shell (settings, - collection switcher, import/export menu). -3. Fast roll (Shift-click). - -**Logic cards** -4. Logic cards: choice, loop, variable and sheet cards, effects, expressions, the 10,000-action limit and a coroutine roller. -5. The Traveller board was generated and simulated from the rulebook digest. - -**Building tools** -6. Group cards and templates. Choice pop-up minimize and option previews. -7. Conditional pipes and routers, search, minimap, packing, lazy cards (the board opens in 0.38 s, was 5 s), and Test board. -8. Undo/redo, and dynamic options with `show_if` and `@[expr]`. The Traveller board was regenerated with them (792 → 662 cards). - -**Plain Build** -9. The usability mockup, then Plain Build: plain words, the inspector with builders, Check - cards, card inputs, collections, Why this?, the Plain/Text switch, and starting values applied. - -**2026-11-09: token diet** -10. Split the oversized files (main.gd 3679 → 617 lines plus 11 helpers; table_card, roller, - table_settings_dialog and result_tray likewise) with no behaviour change, then a duplicate-code - pass guided by the Coderstanding scanner (shared Style/InspectorKit/JsonIO/Main helpers, dead - flags and fields removed). A terminology pass followed: - - One `Describe.kind_label` / `choice_label` for every kind and choice name. - - Choice types are "Which option / How many / Open ended". - - Dice read "2d6", never "2D". - - The built-in skill check is now a real Check card (`builtin:skill-check`). - - "result" and "change" replace "entry", "row" and "effect" in UI text. - - Pipes are deleted, not removed; `reset` reads "Reset". - -**2026-11-09: roll modifiers and resizable panels** (merged to `main` as 3391388) -11. Roll modifiers: `dice_mod` on ranged roll tables, results past the dice, the end results - taking totals past the ends, live chances, plain wording and Why lines. The range and chance - code moved from roll_table.gd into `RollRange`. The shared ModifierEditor serves roll and check - cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches. -12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no - longer grows with long Earlier rolls, sheets or chains. - -**2026-11-09: UI pass** (merged to `main` as 8f16d33) -13. From an HTML mockup: striped result rows; View ▾ (Plain/Text, Collapse all, Striped rows, - Minimap) and the zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map; - Arrange ▾ folded into Board ▾; Search is an icon. Help ▾ and F1 open a Help window with - 17 topics. Build cards get a ⋯ menu instead of the gear and footer Delete, and row × buttons - show on hover. The sample gained Luck, Make Camp (a pick card) and Search the Ruins (1d6 + Luck, - with a cave-in and a vault only a modifier reaches). New suite: test_top_bar. - -**2026-11-09: fan-out fix** -14. A range on a ranged table can pipe into several cards; a new pipe no longer replaces the old one. +## 4. Working on it +- **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. After adding `class_name` files run + `godot --headless --path . --import` first. +- **Tests:** `tools/run_tests.sh [filter]`: parallel, ~20 s, one line per suite, fails on SCRIPT + ERROR too. Prints details only for failures. Use it instead of the old for-loop. +- **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample` (no SCRIPT ERROR). +- **Simulator:** `godot --headless --path . -s res://tools/simulate_board.gd -- --board= --start= --runs=N [--check] [--quiet]`. +- **Windowed runs/screenshots: always `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`** + (KWin rule keeps it in the background; never plain `godot --path .`; don't minimize). Flags are in + `ui/main_cli.gd`. Launching for the user to look at: plain `godot --path .` in the background. +- **Keep files under ~400 lines**; split by area into RefCounted helpers holding `m: Main` with + one-line delegators. Reuse shared builders (list in ARCHITECTURE.md §3). +- **Coderstanding** (structure scanner) for audits: + clone https://forgejo.smhub.duckdns.org/digit/coderstanding into the scratchpad, venv, + `pip install`, `XDG_CONFIG_HOME=/xdgconf`, `coderstanding add tabletower --data + /cs_data`. Commands: `outline`, `hotspots`, `dupes`, `warnings`, `find`, `uses`, `brief`. +- **Git:** origin `git@forgejo.smhub.duckdns.org:RobinFiredrake/TableTower.git`. Feature branch, + fast-forward merge to `main` when the user asks. Co-Authored-By line on commits. +- **Agents:** only for large, separate features (each rereads context). Worktree briefs start with + `git reset --hard `, own specific files, keep public APIs as delegators. Remove worktrees + after merging. +- **Keep this page short.** Update §3 as items land; put history in HISTORY.md, not here. diff --git a/docs/HISTORY.md b/docs/HISTORY.md new file mode 100644 index 0000000..7f1b7ee --- /dev/null +++ b/docs/HISTORY.md @@ -0,0 +1,154 @@ +# TableTower — Decisions, Ideas and History + +Read on demand. Status and plan: `docs/DESIGN.md`. + +## 6. Decisions on record +- The three-pane UI from the first design was replaced by the pipe board (a user request: simpler at the table). +- Variables are kept between rolls until changed or reset, so a character sheet survives other rolls. +- A variable card's starting value is applied, if the variable isn't set, when a top-level roll starts. +- Expression dice clamp beyond the end ranges. Plain dice tables report gaps instead. +- Pipe conditions and counts are a snapshot taken when the result is chosen. Two true Only-if pipes both run; routers give exactly one. +- `a if c else b` is refused (Godot's Expression returns the wrong branch); use `if(c, a, b)`. +- Collapse/expand isn't undoable. Collection members aren't undoable. +- Rules are stored as text, and the plain layer sits on top of it, so old boards open unchanged. +- Traveller-derived content stays out of the repo (§8). +- **Roll modifiers (2026-11-09).** A separate `dice_mod` field, not just an expression in `dice`, + so the card knows its dice: it can show chances, the natural range and plain words. Totals past + the ends always use the end result; there's no separate "nothing happens" setting, because an end + result that says so does the same job. The Check card's modifier picker became the shared + ModifierEditor, which also adds a value as it is (`@luck`) and doesn't only use `dm()`. +- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's + `SplitContainer`. The tray used to size itself to its content and the inspector collapses to a + strip, and a handle that sets the panel's size fits both without changing the layout. +- **UI pass (2026-11-09).** View preferences (rules view, collapse all, stripes, minimap) live in + View ▾ rather than on the bar; Plain/Text is one click further away, which the user accepted. + The card ⋯ menu shares `Style.overflow_button` with the group card's ⋯. Stripes use the + "parchment" tint picked from a mockup (felt tint and hairline were the other options). The + sample's Search the Ruins uses `[[refs]]` rather than pipes, because Loot and the trinkets are + far across the board. Card mode already existed (Party Roles) and needed no new work. +- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names. + - **Card:** anything on the felt. "Roll table" means only the `roll` kind. + - **Result**, never "entry" or "row" (code: `TableEntry`, `entries`). + - **Change** in plain text, "effect" only in Text mode (code and JSON: `effects`). + - **Pipe.** Pipes are *deleted*, like cards and results. "Remove" is for taking an item out + of something. + - **Reset** = back to the starting value, or erased if the value has no card. "Clear" only + when a value really is erased. + - **Dice** always read `2d6` / `d6`. `2D` is accepted as input only. + - **Choice types:** "Which option / How many / Open ended", from `Describe.choice_label`. + - **JSON keys aren't renamed.** A rename needs a format bump plus migration. +- **Fan-out on ranged tables (2026-11-09).** Dropping a pipe from a range used to replace that + range's pipe, a rule left over from the first build. It was a user-reported bug (a "Rocky" range + could not feed Resources, Atmosphere and Water), so ranges now add pipes like weighted results. + `MainEditing.finish_link` uses `TableEntry.add_pipe`. The drop itself has no automated test. + + +## 8. The Traveller test board (private) +- **Location.** Private content derived from the user's Mongoose Traveller 2e rulebook lives in + `~/Repos/Godot/TableTower-private/` (outside git; see its README). That covers the rules digest + (`traveller/chargen.json`), the board generator (`traveller/board/build_board.py`, + `python3 -I`) and the generated board. +- **The board itself.** It's installed as collection `traveller-chargen`: 662 cards, 23 groups, + routers, dynamic options and `show_if`. It runs clean in the simulator (start card `new_traveller`). +- **Still worked around:** + - global "argument" variables (`@x_offer`, `@x_lvl`) feeding shared skill cards + - natural-roll pre-rolls (`rs`, `ra`, `rc`) + - `.replace()` chains for names + - counters instead of `len()` + - about 70 reset statements + - a guard before empty dynamic picks +- **Not automated:** group steps (Connections, skill packages, shared ships), contact + naming, gear choice, medical bills, anagathics, the Psion career, Noble titles, and the + total skill cap. +- **Open question for the user:** "Raise a skill you already have" counts level-0 skills as held (the rules reading); the user's earlier example was level 1+. + +## 9. Improvement ideas, roughly by value +1. **Hands-on playtest** with a checklist, then fix what feels wrong. Highest value now that Build mode has changed a lot. +2. **Several pipes to the same card** (pipe ids). It unlocks Tier 3 "only if" plus Tier 1 "otherwise" into one card. +3. **Port the Traveller board to the new features:** + - card inputs instead of the `@x_*` argument variables + - Check cards + - `nat` + - collections + This also tests them end to end. +4. **Small engine additions:** + - `len(list)` + - `sum` / `max` over a prefix (enables "best of these skills" and skill caps) + - a fallback path when a dynamic pick has no options, instead of stopping the roll + - telling unset from 0 + - lists that keep duplicates + - effects that run after pipes + - nicer display names ("Jack-of-all-Trades") +5. **Onboarding:** a guided tutorial board, a cheat-sheet panel, and templates surfaced as "starter blocks". +6. **Sheet output:** save a finished sheet as text or Markdown; keep finished characters as a list. +7. **Comfort:** a UI scale setting, colour-blind-friendly lit pipes, optional seeded rolls. +8. **Groups:** nested groups, only true members inside frames, clickable pipes into collapsed + groups, and groups in the Canvas and GraphML exports. +9. **Linked templates:** a plan exists. Copies record template uid, revision and role, and + offer "Update available" with a per-field merge. +10. **Faster expanded-board loads.** +11. **Builds:** install the export templates (needs the user's OK), add Windows and Mac presets. +12. **From the original design:** a big-button quick-roll view, cross-collection references + (`[[Collection/Table]]`), touch support. +13. **Naming suggestions not yet applied** (from the 2026-11-09 audit): + - Rename the Collection card kind (e.g. "List"), so "collection" means only the saved set. + - Label the check margin "Margin" instead of "Effect". + - Keep raw `@name` / `{@x}` / "BBCode" out of Play mode. + - "Endless loop" → "Never finishes". + - Drop the `_` on helpers used across files. + - `EffectsBuilder`/`ConditionBuilder` → `*Editor`, `LibraryStore` → `CollectionStore`. + - Keep JSON keys as they are; document the key ↔ UI mapping in LOGIC.md. +14. **Housekeeping:** delete merged branches (also `split-table-card`, see Open items). Keep LOGIC.md and PLAIN.md in step with features. + +## 10. History + +**2026-11-08 (one long session): board and core features** +1. Initial Godot project and the original design doc. An HTML mockup became the pipe board, built in Godot. +2. First feature wave (parallel agents): weights, dice expressions, card mode, text references and BBCode, + collections and local state, import/export, a Linux preset, the play-side UI, and the app shell (settings, + collection switcher, import/export menu). +3. Fast roll (Shift-click). + +**Logic cards** +4. Logic cards: choice, loop, variable and sheet cards, effects, expressions, the 10,000-action limit and a coroutine roller. +5. The Traveller board was generated and simulated from the rulebook digest. + +**Building tools** +6. Group cards and templates. Choice pop-up minimize and option previews. +7. Conditional pipes and routers, search, minimap, packing, lazy cards (the board opens in 0.38 s, was 5 s), and Test board. +8. Undo/redo, and dynamic options with `show_if` and `@[expr]`. The Traveller board was regenerated with them (792 → 662 cards). + +**Plain Build** +9. The usability mockup, then Plain Build: plain words, the inspector with builders, Check + cards, card inputs, collections, Why this?, the Plain/Text switch, and starting values applied. + +**2026-11-09: token diet** +10. Split the oversized files (main.gd 3679 → 617 lines plus 11 helpers; table_card, roller, + table_settings_dialog and result_tray likewise) with no behaviour change, then a duplicate-code + pass guided by the Coderstanding scanner (shared Style/InspectorKit/JsonIO/Main helpers, dead + flags and fields removed). A terminology pass followed: + - One `Describe.kind_label` / `choice_label` for every kind and choice name. + - Choice types are "Which option / How many / Open ended". + - Dice read "2d6", never "2D". + - The built-in skill check is now a real Check card (`builtin:skill-check`). + - "result" and "change" replace "entry", "row" and "effect" in UI text. + - Pipes are deleted, not removed; `reset` reads "Reset". + +**2026-11-09: roll modifiers and resizable panels** (merged to `main` as 3391388) +11. Roll modifiers: `dice_mod` on ranged roll tables, results past the dice, the end results + taking totals past the ends, live chances, plain wording and Why lines. The range and chance + code moved from roll_table.gd into `RollRange`. The shared ModifierEditor serves roll and check + cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches. +12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no + longer grows with long Earlier rolls, sheets or chains. + +**2026-11-09: UI pass** (merged to `main` as 8f16d33) +13. From an HTML mockup: striped result rows; View ▾ (Plain/Text, Collapse all, Striped rows, + Minimap) and the zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map; + Arrange ▾ folded into Board ▾; Search is an icon. Help ▾ and F1 open a Help window with + 17 topics. Build cards get a ⋯ menu instead of the gear and footer Delete, and row × buttons + show on hover. The sample gained Luck, Make Camp (a pick card) and Search the Ruins (1d6 + Luck, + with a cave-in and a vault only a modifier reaches). New suite: test_top_bar. + +**2026-11-09: fan-out fix** +14. A range on a ranged table can pipe into several cards; a new pipe no longer replaces the old one. diff --git a/tools/run_tests.sh b/tools/run_tests.sh new file mode 100755 index 0000000..3ec987c --- /dev/null +++ b/tools/run_tests.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Runs every headless suite in parallel and prints one line per suite. +# A suite fails if it doesn't print "PASS: 0 failure(s)" or if its output has +# a SCRIPT ERROR (a crashed test function can still print PASS). +# Usage: tools/run_tests.sh [name-filter] e.g. tools/run_tests.sh inspector +# Full output of failing suites is printed; passing output is discarded. +set -u +cd "$(dirname "$0")/.." +GODOT="${GODOT:-$HOME/apps/Godot_v4.7.2-stable_linux.x86_64}" +OUT="$(mktemp -d)" +trap 'rm -rf "$OUT"' EXIT +suites=(tests/test_*${1:-}*.gd) +for t in "${suites[@]}"; do + n="$(basename "$t" .gd)" + ( timeout 300 "$GODOT" --headless --path . -s "res://$t" -- --sample >"$OUT/$n.log" 2>&1 ) & + while (( $(jobs -rp | wc -l) >= ${JOBS:-8} )); do wait -n; done +done +wait +fail=0 +for t in "${suites[@]}"; do + n="$(basename "$t" .gd)" + log="$OUT/$n.log" + if grep -q "PASS: 0 failure(s)" "$log" && ! grep -q "SCRIPT ERROR" "$log"; then + echo "ok $n" + else + echo "FAIL $n" + grep -E "FAIL|SCRIPT ERROR|ERROR|at: " "$log" | head -40 + fail=1 + fi +done +(( fail )) && echo "SOME SUITES FAILED" || echo "ALL ${#suites[@]} SUITES PASSED" +exit $fail