2026-11-10 19:53:07 -06:00
|
|
|
|
extends TestBase
|
2026-11-08 21:24:25 -06:00
|
|
|
|
## The Build inspector (docs/PLAIN.md §6): selection, the effects and
|
|
|
|
|
|
## condition builders, Otherwise, pipe inputs, check fields and the modifier
|
|
|
|
|
|
## picker, collection members, options source, the value picker, the
|
|
|
|
|
|
## Plain/Text switch, undo, and dirty/save.
|
|
|
|
|
|
## Run: godot --headless --path . -s res://tests/test_inspector.gd -- --sample
|
|
|
|
|
|
|
|
|
|
|
|
var insp: Inspector
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
2026-11-10 19:53:07 -06:00
|
|
|
|
if not await start_main():
|
2026-11-08 21:24:25 -06:00
|
|
|
|
return
|
|
|
|
|
|
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
|
|
|
|
|
|
main.size = Vector2(1440, 900)
|
|
|
|
|
|
main.set_mode(Main.Mode.BUILD)
|
|
|
|
|
|
insp = main.inspector
|
|
|
|
|
|
await _load()
|
|
|
|
|
|
await _test_selection()
|
|
|
|
|
|
await _test_effects()
|
|
|
|
|
|
await _test_unparseable()
|
|
|
|
|
|
await _test_conditions()
|
|
|
|
|
|
await _test_otherwise()
|
|
|
|
|
|
await _test_pipe_inputs()
|
|
|
|
|
|
await _test_check()
|
|
|
|
|
|
await _test_collection()
|
|
|
|
|
|
await _test_options()
|
|
|
|
|
|
await _test_value_picker()
|
|
|
|
|
|
await _test_rules_view()
|
|
|
|
|
|
await _test_undo()
|
|
|
|
|
|
await _test_dirty_and_save()
|
|
|
|
|
|
await _test_other_cards()
|
|
|
|
|
|
await _test_add_kinds()
|
2026-11-10 19:53:07 -06:00
|
|
|
|
finish()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _board_dict() -> Dictionary:
|
|
|
|
|
|
return {"format_version": 2, "id": "insp-test", "name": "Inspector test", "tables": [
|
|
|
|
|
|
{"id": "gate", "name": "Force the gate", "kind": "check", "x": 40, "y": 40, "check_dice": "2d6",
|
|
|
|
|
|
"check_mod": "dm(@str)", "check_cmp": "ge", "check_target": "8",
|
|
|
|
|
|
"entries": [{"id": "e1", "text": "Success", "pipes": ["beyond"]}, {"id": "e2", "text": "Failure"}]},
|
|
|
|
|
|
{"id": "beyond", "name": "Beyond the gate", "x": 340, "y": 40, "entries": [
|
|
|
|
|
|
{"id": "e1", "text": "Store room"},
|
|
|
|
|
|
{"id": "e2", "text": "The warden's vault", "effects": "@luck -= 1", "pipes": [
|
|
|
|
|
|
{"table": "loot", "with": {"tier": "3"}, "when": "@luck >= 2"},
|
|
|
|
|
|
{"table": "curios", "with": {"tier": "1"}, "otherwise": true}]}]},
|
|
|
|
|
|
{"id": "loot", "name": "Loot", "x": 700, "y": 20, "inputs": [{"name": "tier", "label": "Tier", "default": "1"}],
|
|
|
|
|
|
"entries": [{"id": "e1", "text": "Silver"}]},
|
|
|
|
|
|
{"id": "curios", "name": "Curios", "x": 700, "y": 300, "inputs": [{"name": "tier", "label": "Tier", "default": "1"}],
|
|
|
|
|
|
"entries": [{"id": "e1", "text": "A curio"}]},
|
|
|
|
|
|
{"id": "learn", "name": "Learn", "kind": "choice", "choice": "pick", "x": 340, "y": 380,
|
|
|
|
|
|
"entries": [{"id": "e1", "text": "Option 1"}, {"id": "e2", "text": "Option 2"}]},
|
|
|
|
|
|
{"id": "str", "name": "Strength", "kind": "variable", "var_name": "str", "var_type": "number", "initial": "9", "x": 40, "y": 330, "entries": []},
|
|
|
|
|
|
{"id": "luck", "name": "Luck", "kind": "variable", "var_name": "luck", "var_type": "number", "initial": "2", "x": 40, "y": 470, "entries": []},
|
|
|
|
|
|
{"id": "skills", "name": "Skills", "kind": "variable", "var_name": "skill", "var_type": "collection", "x": 40, "y": 610, "entries": []},
|
2026-11-10 18:24:23 -06:00
|
|
|
|
{"id": "rt", "name": "Branch", "kind": "router", "x": 1000, "y": 40, "entries": [
|
2026-11-08 21:24:25 -06:00
|
|
|
|
{"id": "c1", "text": "Strong", "when": "@str >= 8"}, {"id": "c2", "text": "Otherwise"}]},
|
|
|
|
|
|
{"id": "lp", "name": "Repeat", "kind": "loop", "loop_mode": "times", "loop_expr": "3", "x": 1000, "y": 300,
|
|
|
|
|
|
"entries": [{"id": "e1", "text": "Each time"}, {"id": "e2", "text": "Afterwards"}]},
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _load() -> void:
|
|
|
|
|
|
main.data.load_dict(_board_dict())
|
|
|
|
|
|
main.lit_entries.clear()
|
|
|
|
|
|
main.lit_pipes.clear()
|
|
|
|
|
|
main.persistent_vars.clear()
|
|
|
|
|
|
main._rebuild_cards()
|
|
|
|
|
|
main.clear_inspector()
|
|
|
|
|
|
await _frames(4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _t(id: String) -> RollTable:
|
|
|
|
|
|
return main.data.get_table(id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _vault() -> TableEntry:
|
|
|
|
|
|
return _t("beyond").find_entry("e2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Selection ----------
|
|
|
|
|
|
|
|
|
|
|
|
func _test_selection() -> void:
|
|
|
|
|
|
print("Selection")
|
|
|
|
|
|
_check(insp.visible, "the inspector shows in Build mode")
|
|
|
|
|
|
_check(insp.selection.is_empty(), "nothing is selected at first")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(_has_text(insp, "Select a card, a result or a thread to edit it."), "the empty state says how to select")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.select_card("gate")
|
|
|
|
|
|
_eq(main.inspector_selection(), {"kind": "card", "tid": "gate"}, "select_card")
|
|
|
|
|
|
_check(insp.fields.has("check_dice"), "a check card shows its dice field")
|
|
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
_eq(insp.selection.get("kind"), "result", "select_result")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(insp.effects != null and insp.pipe_parts.has("loot") and insp.pipe_parts.has("curios"), "a result shows its effects and both threads")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.inspecting.select_pipe("beyond:e2>loot")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(insp.selection.get("to"), "loot", "select_pipe")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(insp.pipe_parts.keys(), ["loot"], "a thread shows only its own box")
|
|
|
|
|
|
_eq(main.board.pipes.select_key, "beyond:e2>loot", "the selected thread is highlighted on the spread")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.clear_inspector()
|
|
|
|
|
|
_check(insp.selection.is_empty(), "clear_inspector")
|
|
|
|
|
|
main.open_pipe_options("beyond:e2>curios", Vector2(10, 10))
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(insp.selection.get("to"), "curios", "clicking a thread in Build selects it in the inspector")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.request_table_settings("loot")
|
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
|
|
|
|
_eq(insp.selection, {"kind": "card", "tid": "loot"}, "Table settings… selects the card")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.select_result("beyond", "nope")
|
|
|
|
|
|
_eq(insp.selection.get("tid"), "loot", "a missing result isn't selected")
|
|
|
|
|
|
main.set_mode(Main.Mode.PLAY)
|
|
|
|
|
|
_check(not insp.visible and insp.selection.is_empty(), "Play hides and clears the inspector")
|
|
|
|
|
|
main.set_mode(Main.Mode.BUILD)
|
|
|
|
|
|
_check(insp.visible, "Build shows it again")
|
|
|
|
|
|
insp.set_collapsed(true)
|
|
|
|
|
|
_check(insp.custom_minimum_size.x == Inspector.STRIP, "the inspector collapses to a strip")
|
|
|
|
|
|
main.select_card("gate")
|
|
|
|
|
|
_check(not insp.collapsed, "selecting something opens it again")
|
|
|
|
|
|
# Deleting the selected card empties the inspector.
|
|
|
|
|
|
main.select_card("lp")
|
|
|
|
|
|
var keep := _t("lp").to_dict()
|
|
|
|
|
|
main.delete_table("lp")
|
|
|
|
|
|
await _frames(2)
|
|
|
|
|
|
_check(insp.selection.is_empty(), "deleting the selected card clears the inspector")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo.undo()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames(2)
|
|
|
|
|
|
_check(_t("lp") != null, "(undo brings the card back)")
|
|
|
|
|
|
_eq(_t("lp").to_dict()["name"], keep["name"], "(same card)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _has_text(n: Node, s: String) -> bool:
|
|
|
|
|
|
for c in n.get_children():
|
|
|
|
|
|
if (c is Label and (c as Label).text == s) or _has_text(c, s):
|
|
|
|
|
|
return true
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Effects ----------
|
|
|
|
|
|
|
|
|
|
|
|
func _test_effects() -> void:
|
|
|
|
|
|
print("Effects builder")
|
|
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
var fx := insp.effects
|
|
|
|
|
|
_eq(fx.rows.size(), 1, "one row per statement")
|
|
|
|
|
|
_eq([fx.rows[0]["op"], fx.rows[0]["var"], fx.rows[0]["amount"]], ["subtract", "@luck", "1"], "the row reads Subtract 1 from Luck")
|
|
|
|
|
|
fx.set_row_amount(0, "2")
|
|
|
|
|
|
_eq(_vault().effects, "@luck -= 2", "changing the amount writes the statement")
|
|
|
|
|
|
fx.set_row_op(0, "add")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2", "changing the op")
|
|
|
|
|
|
fx.add_row()
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2", "a new row isn't written until it's filled in")
|
|
|
|
|
|
fx.set_row_var(1, "@str")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@str += 1", "picking its value writes it, joined by a newline")
|
|
|
|
|
|
fx.set_row_op(1, "set")
|
|
|
|
|
|
fx.set_row_amount(1, "Millbrook")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@str = \"Millbrook\"", "a word typed as an amount becomes quoted text")
|
|
|
|
|
|
fx.set_row_amount(1, "1d6 + 2")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@str = 1d6 + 2", "an expression stays as written")
|
|
|
|
|
|
fx.set_row_op(1, "append")
|
|
|
|
|
|
fx.set_row_var(1, "@traits")
|
|
|
|
|
|
fx.set_row_amount(1, "Psionic")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@traits += \"Psionic\"", "Add to list")
|
|
|
|
|
|
fx.set_row_op(1, "remove")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@traits -= \"Psionic\"", "Remove from list")
|
|
|
|
|
|
fx.set_row_op(1, "reset")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\nreset @traits", "Clear")
|
|
|
|
|
|
fx.set_row_op(1, "multiply")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2\n@traits *= 1", "Multiply after Clear starts at 1")
|
|
|
|
|
|
fx.remove_row(1)
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 2", "× removes the row")
|
|
|
|
|
|
# Typing in the row's field.
|
|
|
|
|
|
var amt := InspectorKit.find_tagged(fx, "res.fx.0.amount") as LineEdit
|
|
|
|
|
|
amt.text = "3"
|
|
|
|
|
|
amt.text_changed.emit("3")
|
|
|
|
|
|
_eq(_vault().effects, "@luck += 3", "typing in the amount field writes the statement")
|
|
|
|
|
|
# Edit as text and back.
|
|
|
|
|
|
fx.set_text_mode(true)
|
|
|
|
|
|
_check(fx.text_mode and InspectorKit.find_tagged(fx, "res.fx.raw") != null, "Edit as text shows the whole effects text")
|
|
|
|
|
|
fx.set_raw("@luck -= 1\n@str += 2")
|
|
|
|
|
|
_eq(_vault().effects, "@luck -= 1\n@str += 2", "the text is written as typed")
|
|
|
|
|
|
fx.set_text_mode(false)
|
|
|
|
|
|
_eq(fx.rows.size(), 2, "Use the builder brings back one row per statement")
|
|
|
|
|
|
_eq(Builder.parse_effects(_vault().effects).size(), 2, "(still two statements)")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_unparseable() -> void:
|
|
|
|
|
|
print("Unparseable statements")
|
|
|
|
|
|
_vault().effects = "@luck -= 1\n@gold += 2 +\n@str += 1"
|
|
|
|
|
|
main.mark_dirty()
|
|
|
|
|
|
await _frames(2)
|
|
|
|
|
|
var fx := insp.effects
|
|
|
|
|
|
_eq(fx.rows.size(), 3, "every statement gets a row")
|
|
|
|
|
|
_check(not fx.rows[1]["ok"], "the broken statement isn't a builder row")
|
|
|
|
|
|
var le := InspectorKit.find_tagged(fx, "res.fx.1.src") as LineEdit
|
|
|
|
|
|
_check(le != null and le.text == "@gold += 2 +", "it shows as a text field with its text")
|
|
|
|
|
|
fx.set_row_amount(0, "5")
|
|
|
|
|
|
_eq(_vault().effects, "@luck -= 5\n@gold += 2 +\n@str += 1", "editing another row keeps it exactly")
|
|
|
|
|
|
fx.set_text_mode(true)
|
|
|
|
|
|
fx.set_text_mode(false)
|
|
|
|
|
|
_check(fx.text_mode, "Use the builder waits until every statement parses")
|
|
|
|
|
|
fx.set_raw("@luck -= 5\n@gold += 2\n@str += 1")
|
|
|
|
|
|
fx.set_text_mode(false)
|
|
|
|
|
|
_check(not fx.text_mode and fx.rows.size() == 3 and fx.rows[1]["ok"], "then the builder takes over")
|
|
|
|
|
|
_vault().effects = "@luck -= 1"
|
|
|
|
|
|
main.mark_dirty()
|
|
|
|
|
|
await _frames(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Conditions ----------
|
|
|
|
|
|
|
|
|
|
|
|
func _test_conditions() -> void:
|
|
|
|
|
|
print("Condition builder")
|
|
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
var cond: ConditionBuilder = insp.pipe_parts["loot"]["when"]
|
|
|
|
|
|
_eq(cond.clauses, [{"var": "@luck", "cmp": "ge", "value": "2"}], "the Only if reads as one clause")
|
|
|
|
|
|
cond.add_clause()
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2", "an empty clause isn't written")
|
|
|
|
|
|
cond.set_clause_var(1, "@str")
|
|
|
|
|
|
cond.set_clause_value(1, "8")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2 and @str >= 8", "two clauses join with and")
|
|
|
|
|
|
cond.set_join("or")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2 or @str >= 8", "the switch makes it or")
|
|
|
|
|
|
cond.set_clause_cmp(1, "eq")
|
|
|
|
|
|
cond.set_clause_value(1, "Aslan")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2 or @str = \"Aslan\"", "a word is compared as quoted text")
|
|
|
|
|
|
cond.set_clause_cmp(1, "set")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2 or @str", "is set has no amount")
|
|
|
|
|
|
cond.remove_clause(1)
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 2", "× removes a clause")
|
|
|
|
|
|
# A condition the builder can't show stays text.
|
|
|
|
|
|
_vault().set_pipe_when("loot", "@luck >= 2 and @str > 1 or @x")
|
|
|
|
|
|
main.mark_dirty()
|
|
|
|
|
|
await _frames(2)
|
|
|
|
|
|
cond = insp.pipe_parts["loot"]["when"]
|
|
|
|
|
|
_check(cond.text_mode, "mixed and/or shows as text")
|
|
|
|
|
|
cond.set_raw("@luck >= 3")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 3", "the text is written")
|
|
|
|
|
|
cond.set_raw("@luck >= = 3")
|
|
|
|
|
|
_eq(_vault().when_for("loot"), "@luck >= 3", "text that doesn't work isn't written")
|
|
|
|
|
|
cond.set_raw("@luck >= 2")
|
|
|
|
|
|
cond.set_text_mode(false)
|
|
|
|
|
|
_check(not cond.text_mode and cond.clauses.size() == 1, "Use the builder once it parses")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_otherwise() -> void:
|
|
|
|
|
|
print("Otherwise")
|
|
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
var loot_other: CheckBox = insp.pipe_parts["loot"]["otherwise"]
|
|
|
|
|
|
var cur_other: CheckBox = insp.pipe_parts["curios"]["otherwise"]
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(cur_other.button_pressed and not cur_other.disabled, "the otherwise thread is ticked")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(loot_other.disabled and not loot_other.button_pressed, "Otherwise is off while Only if is set")
|
|
|
|
|
|
insp.set_pipe_when("loot", "")
|
|
|
|
|
|
_check(not loot_other.disabled, "clearing Only if allows Otherwise")
|
|
|
|
|
|
insp.set_pipe_otherwise("loot", true)
|
|
|
|
|
|
_check(_vault().is_otherwise("loot") and loot_other.button_pressed, "ticking Otherwise writes it")
|
|
|
|
|
|
insp.set_pipe_when("loot", "@luck >= 2")
|
|
|
|
|
|
_check(not _vault().is_otherwise("loot") and loot_other.disabled, "an Only if turns Otherwise off")
|
|
|
|
|
|
insp.set_pipe_otherwise("curios", false)
|
|
|
|
|
|
_check(not _vault().is_otherwise("curios"), "unticking")
|
|
|
|
|
|
cur_other.toggled.emit(true)
|
|
|
|
|
|
_check(_vault().is_otherwise("curios"), "the checkbox writes it too")
|
|
|
|
|
|
insp.set_pipe_count("loot", "2")
|
|
|
|
|
|
_eq(_vault().count_text("loot"), "2", "count")
|
|
|
|
|
|
insp.set_pipe_count("loot", "@x +")
|
|
|
|
|
|
_eq(_vault().count_text("loot"), "2", "a bad count isn't written")
|
|
|
|
|
|
insp.set_pipe_save("loot", "@weapon")
|
|
|
|
|
|
_eq(_vault().save_for("loot"), "@weapon", "saves as")
|
|
|
|
|
|
insp.set_pipe_save("loot", "not a name")
|
|
|
|
|
|
_eq(_vault().save_for("loot"), "@weapon", "a bad name isn't saved")
|
|
|
|
|
|
insp.set_pipe_save("loot", "")
|
|
|
|
|
|
insp.set_pipe_count("loot", "1")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_pipe_inputs() -> void:
|
2026-11-10 18:24:23 -06:00
|
|
|
|
print("Thread inputs")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
var le: LineEdit = insp.pipe_parts["loot"]["inputs"]["tier"]
|
|
|
|
|
|
_eq(le.text, "3", "the target's input shows the passed value")
|
|
|
|
|
|
_eq(le.placeholder_text, "1", "its default is the placeholder")
|
|
|
|
|
|
le.text = "5"
|
|
|
|
|
|
le.text_changed.emit("5")
|
|
|
|
|
|
_eq(_vault().with_for("loot"), {"tier": "5"}, "typing writes pipe_with")
|
|
|
|
|
|
insp.set_pipe_input("loot", "tier", "@luck + 1")
|
|
|
|
|
|
_eq(_vault().with_for("loot"), {"tier": "@luck + 1"}, "an expression")
|
|
|
|
|
|
insp.set_pipe_input("loot", "tier", "@luck +")
|
|
|
|
|
|
_eq(_vault().with_for("loot"), {"tier": "@luck + 1"}, "a broken one isn't written")
|
|
|
|
|
|
insp.set_pipe_input("loot", "tier", "")
|
|
|
|
|
|
_eq(_vault().with_for("loot"), {}, "empty uses the default")
|
|
|
|
|
|
insp.set_pipe_input("loot", "tier", "3")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Cards ----------
|
|
|
|
|
|
|
|
|
|
|
|
func _test_check() -> void:
|
|
|
|
|
|
print("Check card")
|
|
|
|
|
|
main.select_card("gate")
|
|
|
|
|
|
var t := _t("gate")
|
|
|
|
|
|
var sentence: Label = insp.fields["sentence"]
|
|
|
|
|
|
_eq(sentence.text, Describe.check(t, main.data), "a live sentence")
|
|
|
|
|
|
_check(sentence.text.contains("Strength"), "it names the modifier's value: %s" % sentence.text)
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_target", "9")
|
|
|
|
|
|
_eq(t.check_target, "9", "target")
|
|
|
|
|
|
_check(sentence.text.contains("9"), "the sentence follows: %s" % sentence.text)
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_cmp", "le")
|
|
|
|
|
|
_check(t.check_cmp == "le" and sentence.text.contains("or less"), "or less")
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_dice", "3d6")
|
|
|
|
|
|
_eq(t.check_dice, "3d6", "dice")
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_dice", "")
|
|
|
|
|
|
_eq(t.check_dice, "3d6", "empty dice aren't written")
|
2026-11-09 10:01:10 -06:00
|
|
|
|
var mod: ModifierEditor = insp.fields["check_mod"]
|
|
|
|
|
|
_eq(mod.way, ModifierEditor.Way.DM, "dm(@str) opens as a value's modifier")
|
|
|
|
|
|
_eq(mod.picker.value, "@str", "the picker shows the modifier's value")
|
|
|
|
|
|
mod.picker.choose("@luck")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(t.check_mod, "dm(@luck)", "picking Luck writes dm(@luck)")
|
2026-11-09 10:01:10 -06:00
|
|
|
|
mod.set_way(ModifierEditor.Way.ADD)
|
|
|
|
|
|
_eq(t.check_mod, "@luck", "Add keeps the value: @luck")
|
|
|
|
|
|
mod.set_way(ModifierEditor.Way.NONE)
|
|
|
|
|
|
_eq(t.check_mod, "", "No modifier clears it")
|
|
|
|
|
|
mod.set_way(ModifierEditor.Way.CUSTOM)
|
|
|
|
|
|
_check(mod.field != null, "Custom shows the modifier as a field")
|
|
|
|
|
|
mod.field.text = "@str - 1"
|
|
|
|
|
|
mod.field.text_changed.emit("@str - 1")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(t.check_mod, "@str - 1", "typed text is written")
|
|
|
|
|
|
insp.rebuild()
|
2026-11-09 10:01:10 -06:00
|
|
|
|
_eq((insp.fields["check_mod"] as ModifierEditor).way, ModifierEditor.Way.CUSTOM, "a modifier the plain forms can't show stays Custom")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
InspectorCard.set_check(insp, "check_mod", "dm(@str)")
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_cmp", "ge")
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_target", "8")
|
|
|
|
|
|
InspectorCard.set_check(insp, "check_dice", "2d6")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_collection() -> void:
|
2026-11-10 18:24:23 -06:00
|
|
|
|
print("Spread members")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.select_card("skills")
|
|
|
|
|
|
var t := _t("skills")
|
|
|
|
|
|
_eq(insp.members(t), [], "no members at first")
|
|
|
|
|
|
var item := InspectorCard.add_member(insp, t)
|
|
|
|
|
|
_eq(item, "new", "+ Add member")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(main.persistent_vars.get("skill_new", {}).get("value"), 0, "it's the spread value @skill_new = 0")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
InspectorCard.set_member(insp, t, "new", "2")
|
|
|
|
|
|
InspectorCard.rename_member(insp, t, "new", "pilot")
|
|
|
|
|
|
_check(not main.persistent_vars.has("skill_new"), "renaming drops the old name")
|
|
|
|
|
|
_eq(main.persistent_vars.get("skill_pilot", {}).get("value"), 2, "and keeps the value under the new one")
|
|
|
|
|
|
InspectorCard.add_member(insp, t)
|
|
|
|
|
|
InspectorCard.rename_member(insp, t, "new", "gun_combat")
|
|
|
|
|
|
_eq(insp.members(t), [["gun_combat", "0"], ["pilot", "2"]], "members list name and value")
|
|
|
|
|
|
_check(InspectorKit.find_tagged(insp, "member.pilot.value") != null, "each member has a value field")
|
|
|
|
|
|
InspectorCard.remove_member(insp, t, "gun_combat")
|
|
|
|
|
|
_eq(insp.members(t), [["pilot", "2"]], "× removes a member")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(Describe.label("@skill_pilot", main.data), "Pilot", "(members are labelled through the spread)")
|
2026-11-14 13:36:03 -06:00
|
|
|
|
_eq(t.members, [{"name": "pilot", "start": "2"}], "the entries are saved on the card")
|
|
|
|
|
|
var copy := RollTable.from_dict(t.to_dict())
|
|
|
|
|
|
_eq(copy.members, t.members, "and survive a save and load (copies, exports)")
|
|
|
|
|
|
main.persistent_vars["skill_pilot"] = {"value": 5, "source": "roll"}
|
|
|
|
|
|
main.reset_variable("skill_pilot")
|
|
|
|
|
|
_eq(main.persistent_vars.get("skill_pilot", {}).get("value"), 2, "Reset puts an entry back to its start")
|
|
|
|
|
|
main.undo_redo.undo()
|
|
|
|
|
|
_eq(t.members, [{"name": "pilot", "start": "2"}, {"name": "gun_combat", "start": "0"}], "undo brings a removed entry back")
|
|
|
|
|
|
_eq(main.persistent_vars.get("skill_gun_combat", {}).get("value"), 0, "with its value")
|
|
|
|
|
|
main.undo_redo.redo()
|
|
|
|
|
|
var old := RollTable.create(RollTable.KIND_VARIABLE, "old_ledger", "Feats", RollTable.VAR_COLLECTION)
|
|
|
|
|
|
var made := {"feat_dodge": {"value": 3, "source": "old_ledger"}, "feat_luck": {"value": 1, "source": "a_roll"}}
|
|
|
|
|
|
var board := TowerBoard.new()
|
|
|
|
|
|
board.tables.append(old)
|
|
|
|
|
|
_check(LedgerMembers.adopt(board, made), "an older Ledger takes in the entries made on it")
|
|
|
|
|
|
_eq(old.members, [{"name": "dodge", "start": "3"}], "but not values that rolls added")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_options() -> void:
|
|
|
|
|
|
print("Options source")
|
|
|
|
|
|
main.select_card("learn")
|
|
|
|
|
|
var t := _t("learn")
|
|
|
|
|
|
_check(not t.is_dynamic(), "a fixed list at first")
|
|
|
|
|
|
var err := InspectorCard.set_options(insp, "@skill_*", "")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(err, "", "From a spread")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(t.is_dynamic() and t.options_from == "@skill_*", "options come from Skills")
|
|
|
|
|
|
var where: ConditionBuilder = insp.fields.get("options_where")
|
|
|
|
|
|
_check(where != null, "a where builder")
|
|
|
|
|
|
where.add_clause("option_value", "ge", "1")
|
|
|
|
|
|
_eq(t.options_where, "option_value >= 1", "where Its value is at least 1")
|
|
|
|
|
|
var picker: ValuePicker = insp.fields["options_from"]
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(picker.value, "@skill_*", "the source picker shows the spread")
|
|
|
|
|
|
_check(picker.items().any(func(it: Dictionary) -> bool: return it["name"] == "@skill_*"), "it offers spreads")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(not picker.items().any(func(it: Dictionary) -> bool: return it["name"] == "@luck"), "but not numbers")
|
|
|
|
|
|
_eq(insp.apply_settings({"options_mode": "fixed"}, true), "", "back to a fixed list")
|
|
|
|
|
|
_check(t.options_from == "" and not t.is_dynamic(), "options_from is cleared")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_value_picker() -> void:
|
|
|
|
|
|
print("Value picker")
|
|
|
|
|
|
var p := ValuePicker.new(main, "")
|
|
|
|
|
|
root.add_child(p)
|
|
|
|
|
|
var names := p.items().map(func(it: Dictionary) -> String: return it["name"])
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(names.has("@luck") and names.has("@str"), "it lists the spread's values")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
var luck: Dictionary = p.items().filter(func(it: Dictionary) -> bool: return it["name"] == "@luck")[0]
|
|
|
|
|
|
_eq([luck["label"], luck["kind"], luck["group"]], ["Luck", "number", "Variables"], "with label, kind and group")
|
|
|
|
|
|
_check(names.find("@luck") < names.find("@skill_pilot") or not names.has("@skill_pilot"), "variables come first")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(names.has("@skill_pilot"), "spread members with values are offered")
|
|
|
|
|
|
_check(not names.has("@skill_*"), "spread patterns only where they fit")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
p.allow_patterns = true
|
2026-11-11 08:39:07 -06:00
|
|
|
|
_check(p.items().any(func(it: Dictionary) -> bool: return it["name"] == "@skill_*" and it["group"] == "Ledgers"), "grouped under Spreads")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(p.filtered("lu").map(func(it: Dictionary) -> String: return it["name"]), ["@luck"], "search by label")
|
|
|
|
|
|
p.open_menu()
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
_check(p.shown_names().has("@luck"), "the open menu lists them")
|
|
|
|
|
|
p.close_menu()
|
|
|
|
|
|
var got: Array = []
|
|
|
|
|
|
p.value_chosen.connect(func(n: String) -> void: got.append(n))
|
|
|
|
|
|
p.choose("@str")
|
|
|
|
|
|
_eq(got, ["@str"], "choosing emits value_chosen")
|
|
|
|
|
|
_check(p.text.begins_with("Strength"), "the button shows the label: %s" % p.text)
|
|
|
|
|
|
var n := p.create_value("Fame", true)
|
|
|
|
|
|
_eq(n, "@fame", "+ New value… names it")
|
|
|
|
|
|
var card := main.variable_card("fame")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(card != null and card.name == "Fame", "Show on the spread adds a variable card")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(got.back(), "@fame", "and picks it")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
var steps := main.undo_redo.edits.undo_stack.size()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
n = p.create_value("Mood", false)
|
|
|
|
|
|
_eq(n, "@mood", "without a card")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(main.variable_card("mood") == null and main.undo_redo.edits.undo_stack.size() == steps, "no card, no spread change")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
p.queue_free()
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_rules_view() -> void:
|
|
|
|
|
|
print("Plain / Text switch")
|
|
|
|
|
|
var got: Array = []
|
|
|
|
|
|
main.rules_view_changed.connect(func(v: String) -> void: got.append(v))
|
|
|
|
|
|
_check(main.rules_plain() and main.rules_view() == "plain", "plain words by default")
|
|
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
main.set_rules_view("text")
|
|
|
|
|
|
_eq(got, ["text"], "rules_view_changed fires")
|
|
|
|
|
|
_check(not main.rules_plain(), "rules_plain() follows")
|
|
|
|
|
|
_check(insp.effects.text_mode, "the inspector shows rule text")
|
|
|
|
|
|
_check((insp.pipe_parts["loot"]["when"] as ConditionBuilder).text_mode, "conditions too")
|
|
|
|
|
|
main.set_rules_view("text")
|
|
|
|
|
|
_eq(got.size(), 1, "setting the same view again doesn't fire")
|
|
|
|
|
|
main.set_rules_view("bogus")
|
|
|
|
|
|
_eq(main.rules_view(), "text", "unknown views are ignored")
|
UI pass: striped rows, View/Help menus, zoom control, card ⋯ menu, fuller sample
- Striped result rows (parchment tint, on by default, `striped_rows` setting).
- Top bar: View ▾ (Plain words / Rule text, Collapse/Expand all, Striped rows,
Minimap) and a "− 90% ▾ +" zoom control replace the Plain|Text switch,
Collapse all, −/Fit/+ and Map. Arrange ▾ folds into Board ▾; Search is an icon.
- Help ▾ and F1 open a Help window; the 17 topics live in help/topics.txt.
- Build cards get a ⋯ menu (settings, template, collapse, delete) instead of
the gear and footer Delete, sharing Style.overflow_button with group cards.
Row × buttons show only on hover, focus or selection.
- Sample: Luck value card, Make Camp (pick card) and Search the Ruins
(1d6 + Luck, with results only a modifier reaches).
- New test suite test_top_bar; Canvas/GraphML round-trip tests compare plain
tables only, since logic keys are JSON-only.
- DESIGN.md: open items, including the Card Mode UI redesign.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:36:38 -06:00
|
|
|
|
main.top_bar.view_menu.activate(ViewMenu.ID_PLAIN)
|
|
|
|
|
|
_eq(main.rules_view(), "plain", "View ▾ → Plain words sets it")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(not insp.effects.text_mode, "builders are back")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_undo() -> void:
|
|
|
|
|
|
print("Undo")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo._commit_edits()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
main.select_result("beyond", "e2")
|
|
|
|
|
|
var before := _vault().effects
|
|
|
|
|
|
insp.effects.set_row_amount(0, "7")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo._commit_edits()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(_vault().effects, "@luck -= 7", "(the edit)")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo.undo()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames(2)
|
|
|
|
|
|
_eq(_vault().effects, before, "undo puts the effects back")
|
|
|
|
|
|
_eq(insp.effects.rows[0]["amount"], "1", "the inspector shows the old text")
|
|
|
|
|
|
_eq(insp.selection.get("eid"), "e2", "and keeps the selection")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo.redo()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames(2)
|
|
|
|
|
|
_eq(_vault().effects, "@luck -= 7", "redo")
|
|
|
|
|
|
# Typing in a field is one step once it pauses.
|
|
|
|
|
|
var le: LineEdit = insp.fields["text"]
|
|
|
|
|
|
le.grab_focus()
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
var steps := main.undo_redo.edits.undo_stack.size()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
for s in ["The vault", "The vaults", "The vaults!"]:
|
|
|
|
|
|
le.text = s
|
|
|
|
|
|
le.text_changed.emit(s)
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
_eq(main.undo_redo.edits.undo_stack.size(), steps, "typing waits for a pause")
|
|
|
|
|
|
main.undo_redo._commit_edits()
|
|
|
|
|
|
_eq(main.undo_redo.edits.undo_stack.size(), steps + 1, "then makes one step")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
le.release_focus()
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo.undo()
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames(2)
|
|
|
|
|
|
_eq(_vault().text, "The warden's vault", "one undo takes all the typing back")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_dirty_and_save() -> void:
|
|
|
|
|
|
print("Dirty and save")
|
|
|
|
|
|
main.select_card("loot")
|
|
|
|
|
|
var rev := main.edit_rev
|
|
|
|
|
|
main._saving_enabled = true
|
|
|
|
|
|
main._save_timer.stop()
|
|
|
|
|
|
insp.apply_settings({"tags": "loot, treasure"})
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(main.edit_rev > rev, "an inspector edit marks the spread dirty")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(not main._save_timer.is_stopped(), "and schedules a save")
|
|
|
|
|
|
main._save_timer.stop()
|
|
|
|
|
|
main._saving_enabled = false
|
|
|
|
|
|
_eq(_t("loot").tags, ["loot", "treasure"], "tags")
|
|
|
|
|
|
var copy := TowerBoard.new()
|
|
|
|
|
|
copy.load_dict(main.data.to_dict())
|
|
|
|
|
|
_eq(copy.get_table("loot").tags, ["loot", "treasure"], "the saved form has it")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(copy.get_table("beyond").find_entry("e2").with_for("loot"), {"tier": "3"}, "thread inputs are saved")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
main.undo_redo._commit_edits()
|
|
|
|
|
|
_check(main.undo_redo.can_undo(), "and it's an undo step")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_other_cards() -> void:
|
|
|
|
|
|
print("Other cards")
|
|
|
|
|
|
main.select_card("loot")
|
|
|
|
|
|
var t := _t("loot")
|
|
|
|
|
|
var rows: Array = insp.fields["inputs_rows"]
|
|
|
|
|
|
_eq(rows.size(), 1, "declared inputs are listed")
|
|
|
|
|
|
var le := InspectorKit.find_tagged(insp, "card.in.0.default") as LineEdit
|
|
|
|
|
|
le.text = "2"
|
|
|
|
|
|
le.text_changed.emit("2")
|
|
|
|
|
|
_eq(t.inputs, [{"name": "tier", "label": "Tier", "default": "2"}], "editing a default")
|
|
|
|
|
|
(InspectorKit.find_tagged(insp, "card.name") as LineEdit).text_changed.emit("Treasure")
|
|
|
|
|
|
_eq(t.name, "Treasure", "name")
|
|
|
|
|
|
# Router cases.
|
|
|
|
|
|
main.select_card("rt")
|
|
|
|
|
|
var rt := _t("rt")
|
|
|
|
|
|
InspectorCard.add_case(insp)
|
|
|
|
|
|
_eq(rt.entries.size(), 3, "+ Add case")
|
|
|
|
|
|
_eq(rt.entries[2].id, "c2", "it goes before the Otherwise case")
|
|
|
|
|
|
insp.set_case_when(rt.entries[1].id, "@luck >= 1")
|
|
|
|
|
|
_eq(rt.entries[1].when, "@luck >= 1", "a case's condition")
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_eq(Roller.lint_router(rt), [], "the branch is fine")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
# A router case from the result side.
|
|
|
|
|
|
main.select_result("rt", "c1")
|
|
|
|
|
|
_check(insp.case_builder != null and insp.case_builder.clauses.size() == 1, "a case result shows its condition builder")
|
|
|
|
|
|
# Loop.
|
|
|
|
|
|
main.select_card("lp")
|
|
|
|
|
|
InspectorCard.set_loop_mode(insp, "while")
|
|
|
|
|
|
_check(_t("lp").loop_mode == "while" and _t("lp").loop_expr == "i < 3", "a loop switches to while with a condition")
|
|
|
|
|
|
(insp.fields["loop_cond"] as ConditionBuilder).set_clause_value(0, "5")
|
|
|
|
|
|
_eq(_t("lp").loop_expr, "i < 5", "and the builder edits it")
|
|
|
|
|
|
InspectorCard.set_loop_mode(insp, "times")
|
|
|
|
|
|
_eq(_t("lp").loop_expr, "3", "back to times")
|
|
|
|
|
|
# Variable card.
|
|
|
|
|
|
main.select_card("luck")
|
|
|
|
|
|
_eq(insp.apply_settings({"initial": "3"}), "", "a variable's starting value")
|
|
|
|
|
|
_eq(_t("luck").initial, "3", "(written)")
|
|
|
|
|
|
_check(insp.apply_settings({"var_name": "Bad Name"}) != "", "a bad name is refused")
|
|
|
|
|
|
await _frames()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _test_add_kinds() -> void:
|
|
|
|
|
|
print("+ Card ▾")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
var labels: Array = main.editing.ADD_KINDS.map(func(k: Array) -> String: return k[0])
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(labels.any(func(s: String) -> bool: return s.begins_with("Check")), "Check card is in the menu")
|
2026-11-11 08:39:07 -06:00
|
|
|
|
_check(labels.any(func(s: String) -> bool: return s.begins_with("Ledger")), "Ledger is in the menu")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
_eq(main.editing._add_menu.text, "+ Card ▾", "the button reads + Card ▾")
|
|
|
|
|
|
var c := main.editing.add_table(RollTable.KIND_CHECK)
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_check(c.kind == RollTable.KIND_CHECK and c.name == "Check" and c.entries.size() == 2, "adding a check card")
|
|
|
|
|
|
_eq(insp.selection.get("tid"), c.id, "a new card is selected in the inspector")
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
var col := main.editing.add_table(RollTable.KIND_VARIABLE, RollTable.VAR_COLLECTION)
|
2026-11-10 18:24:23 -06:00
|
|
|
|
_check(col.is_collection() and col.name == "Skills" and col.var_name == "skill_2", "adding a spread (%s, @%s)" % [col.name, col.var_name])
|
Split ui/main.gd into area helpers (no behaviour change)
Main (3679 lines) becomes a shell: shared state, start-up, cards, input,
rules view and one-line delegators for the methods other files call. Each
area moves with its state into a RefCounted helper holding a back-reference
(m: Main):
main_cli.gd command-line and screenshot flags
main_top_bar.gd top bar, toast, endless-loop chip
main_editing.gd add/delete cards, results and pipes, selection bar
main_groups.gd groups and card drags
main_templates.gd templates
main_rolling.gd rolling, choice questions, playback, session seed, copy
main_collections.gd collections, import/export, table settings, test board
main_state.gd decks, variables, roll history (local state)
main_navigation.gd search, focus, minimap, arrange/pack
main_history.gd undo/redo and mark_dirty
main_inspector.gd inspector selection and refresh
Tests that reached moved private members now go through the helper
(main.undo_redo.edits, main.rolling.pending_choice(), ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 08:14:19 -06:00
|
|
|
|
var v := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
|
2026-11-08 21:24:25 -06:00
|
|
|
|
_eq(v.name, "New variable", "a plain variable keeps its name")
|
|
|
|
|
|
await _frames()
|