diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 863b870..4b14dd6 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1,6 +1,6 @@ # TableTower — Design and Status -**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-08 (`main` at `adb93c5`) +**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (big files split; see §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 @@ -94,8 +94,13 @@ 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) 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; pipe_plan snapshot, route, choices, - checks, inputs, why facts, lint_*, endless_cycles, flatten, apply_starting_values + 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 @@ -106,12 +111,19 @@ core/ engine, no UI, testable headless 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: top bar, modes, rolling, editing actions, undo, CLI flags) and its parts: - board_view, card_layer, pipe_layer, port_layer, group_layer, group_card, minimap, - table_card, result_tray, 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_*, table_settings_dialog, io_menu, - collection_switcher, variables_panel, modal_card, rich_text, style +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, rules switch), main_state (decks, variables), + main_collections, main_templates, main_inspector + 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 + 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 tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows) tests/ test_*.gd: 25 headless suites templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL) @@ -124,6 +136,10 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) - **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. ## 4. Data and storage - **Collections:** `user://collections/.json`, format_version 2 (`{format_version, id, @@ -148,7 +164,7 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) 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 `_run_cli*` in `ui/main.gd` and in some UI files; README lists the main ones: +- **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`. @@ -260,3 +276,9 @@ templates/ built-in templates · examples/logic_demo.json (original demo board) **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 audit produced suggestions only (not yet applied). diff --git a/docs/LOGIC.md b/docs/LOGIC.md index 93349e4..7d5ffe1 100644 --- a/docs/LOGIC.md +++ b/docs/LOGIC.md @@ -212,7 +212,7 @@ more, with `le` (roll-under) when it is the target or less. It has two fixed ent - A dice, modifier or target expression that fails, or gives text, stops the node with "Can't roll the check: …" (a dead end in the board test). A check with no Failure entry stops with "This check has no Failure result" when it fails. -- `Roller.check_roll(table, ctx)` does the roll alone; `Roller.lint_check(table)` reports +- `RollCards.check_roll(table, ctx)` does the roll alone; `Roller.lint_check(table)` reports expressions that don't parse, an empty dice or target, and a missing Success or Failure entry. ### `nat` on roll tables