Terminology pass: one set of kind and choice names, 2d6, result/change wording
- Describe.kind_label / choice_label / choice_labels replace six drifting label tables. Search no longer calls Check and Router cards "Table", and a Check card's dialog is titled "Check settings". - Choice types read "Which option / How many / Open ended" everywhere (menu, settings, inspector, card, preview, details). - Plain dice read "2d6" / "d6" instead of the 2D-game "2D" / "1D". - The built-in "2D skill check" template becomes "Skill check (2d6 vs target)" (builtin:skill-check), a real Check card with Success and Failure. - User text says "result" and "change" instead of "entry", "row" and "effect" (Test board, settings dialog, lint, variables panel, pipe options). - Pipes are deleted (link, toast, undo label), like cards and results; the reset statement reads "Reset" in the builder and "Reset all X" for prefixes. "Clear" stays for a value that really was erased. - The template-saved toast points at "+ Card ▾". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6208e42f75
commit
5e34592fec
32 changed files with 156 additions and 135 deletions
|
|
@ -82,7 +82,7 @@ godot --path .
|
||||||
- **Templates:** save a card (⚙ → Save as template…), a group (⋯ → Save as template…) or a
|
- **Templates:** save a card (⚙ → Save as template…), a group (⋯ → Save as template…) or a
|
||||||
selection as a reusable template. Write `{$name}` in any text to make a parameter; the
|
selection as a reusable template. Write `{$name}` in any text to make a parameter; the
|
||||||
save dialog finds them and asks for a label and default. **+ Card ▾ → From template…**
|
save dialog finds them and asks for a label and default. **+ Card ▾ → From template…**
|
||||||
lists your templates and the built-in ones (2D skill check, ask-and-repeat, pick menu,
|
lists your templates and the built-in ones (skill check, ask-and-repeat, pick menu,
|
||||||
counter, simple sheet), asks for the parameters and drops fresh copies at the view
|
counter, simple sheet), asks for the parameters and drops fresh copies at the view
|
||||||
centre. Pipes to cards outside the template relink by name, or are listed if they can't.
|
centre. Pipes to cards outside the template relink by name, or are listed if they can't.
|
||||||
Templates live in `user://templates/` and are shared by every collection; the list can
|
Templates live in `user://templates/` and are shared by every collection; the list can
|
||||||
|
|
@ -162,7 +162,7 @@ Test board: `--test-board` opens the dialog, `--test-board-run=<runs>` also star
|
||||||
|
|
||||||
Groups and templates: `--select=<id>,<id>`, `--group-selected[=<name>]`, `--collapse-groups`,
|
Groups and templates: `--select=<id>,<id>`, `--group-selected[=<name>]`, `--collapse-groups`,
|
||||||
`--expand-groups`, `--toggle-group=<id>`, `--group-menu`, `--drag-demo`, `--templates[=<search>]`,
|
`--expand-groups`, `--toggle-group=<id>`, `--group-menu`, `--drag-demo`, `--templates[=<search>]`,
|
||||||
`--insert-form=builtin:2d-check`, `--insert-template=<id> --template-values=skill=pilot|target=8`,
|
`--insert-form=builtin:skill-check`, `--insert-template=<id> --template-values=skill=pilot|target=8`,
|
||||||
`--save-template=<table>`, `--save-group-template=first`, `--view=<x>,<y>[,<zoom>]`, `--fit` and
|
`--save-template=<table>`, `--save-group-template=first`, `--view=<x>,<y>[,<zoom>]`, `--fit` and
|
||||||
`--clear-result`.
|
`--clear-result`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ static func static_checks(b: TowerBoard) -> Array[Dictionary]:
|
||||||
for e in t.entries:
|
for e in t.entries:
|
||||||
_check_braces(e.text, func(src: String) -> void: expr.call("Text", src, e.id))
|
_check_braces(e.text, func(src: String) -> void: expr.call("Text", src, e.id))
|
||||||
for p in Effects.validate(e.effects):
|
for p in Effects.validate(e.effects):
|
||||||
add.call("effect", t, e.id, "Effect \"%s\": %s" % [p["src"], p["error"]])
|
add.call("effect", t, e.id, "Change \"%s\": %s" % [p["src"], p["error"]])
|
||||||
for target in e.pipes:
|
for target in e.pipes:
|
||||||
if b.get_table(target) == null:
|
if b.get_table(target) == null:
|
||||||
add.call("missing_pipe", t, e.id, "Pipe to a table that doesn't exist (%s)." % target)
|
add.call("missing_pipe", t, e.id, "Pipe to a table that doesn't exist (%s)." % target)
|
||||||
|
|
@ -402,7 +402,7 @@ static func format_problems(problems: Array, list: int = 40) -> PackedStringArra
|
||||||
var p: Dictionary = problems[k]
|
var p: Dictionary = problems[k]
|
||||||
var where: String = "%s (%s)" % [p["table"], p["table_id"]]
|
var where: String = "%s (%s)" % [p["table"], p["table_id"]]
|
||||||
if str(p["entry_id"]) != "":
|
if str(p["entry_id"]) != "":
|
||||||
where += ", entry " + str(p["entry_id"])
|
where += ", result " + str(p["entry_id"])
|
||||||
out.append(" %s: %s" % [where, p["text"]])
|
out.append(" %s: %s" % [where, p["text"]])
|
||||||
if problems.size() > list:
|
if problems.size() > list:
|
||||||
out.append(" ... and %d more" % (problems.size() - list))
|
out.append(" ... and %d more" % (problems.size() - list))
|
||||||
|
|
@ -431,12 +431,12 @@ static func format_report(r: Dictionary, list: int = 40, show_sheet: bool = true
|
||||||
out.append("@%s: never a number" % name)
|
out.append("@%s: never a number" % name)
|
||||||
else:
|
else:
|
||||||
out.append("@%s: min %s, mean %.1f, max %s (%d runs)" % [name, Expr.format_value(t["min"]), t["sum"] / t["n"], Expr.format_value(t["max"]), t["n"]])
|
out.append("@%s: min %s, mean %.1f, max %s (%d runs)" % [name, Expr.format_value(t["min"]), t["sum"] / t["n"], Expr.format_value(t["max"]), t["n"]])
|
||||||
_section(out, "Effect / expression errors", r["errors"], list, func(e: Dictionary) -> String:
|
_section(out, "Change / expression errors", r["errors"], list, func(e: Dictionary) -> String:
|
||||||
return "%dx %s, entry \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]])
|
return "%dx %s, result \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]])
|
||||||
_section(out, "Dead ends (rolls that stopped)", r["dead_ends"], list, func(e: Dictionary) -> String:
|
_section(out, "Dead ends (rolls that stopped)", r["dead_ends"], list, func(e: Dictionary) -> String:
|
||||||
return "%dx %s: %s" % [e["count"], e["table"], e["text"]])
|
return "%dx %s: %s" % [e["count"], e["table"], e["text"]])
|
||||||
_section(out, "Unset variables, missing tables and {= } errors in text", r["unset_markers"], list, func(e: Dictionary) -> String:
|
_section(out, "Unset variables, missing tables and {= } errors in text", r["unset_markers"], list, func(e: Dictionary) -> String:
|
||||||
return "%dx %s, entry \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]])
|
return "%dx %s, result \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]])
|
||||||
var un: Array = r["unreached"]
|
var un: Array = r["unreached"]
|
||||||
out.append("Tables never reached: %d" % un.size())
|
out.append("Tables never reached: %d" % un.size())
|
||||||
for k in mini(list, un.size()):
|
for k in mini(list, un.size()):
|
||||||
|
|
@ -447,7 +447,7 @@ static func format_report(r: Dictionary, list: int = 40, show_sheet: bool = true
|
||||||
var n_entries := 0
|
var n_entries := 0
|
||||||
for k: String in uc:
|
for k: String in uc:
|
||||||
n_entries += (uc[k] as Array).size()
|
n_entries += (uc[k] as Array).size()
|
||||||
out.append("Entries never chosen: %d in %d reached tables" % [n_entries, uc.size()])
|
out.append("Results never chosen: %d in %d reached cards" % [n_entries, uc.size()])
|
||||||
var shown := 0
|
var shown := 0
|
||||||
for k: String in uc:
|
for k: String in uc:
|
||||||
if shown >= list:
|
if shown >= list:
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,31 @@ const _OPS := {"*": "×", "/": "÷", "-": MINUS, "==": "=", "!=": "≠", ">=": "
|
||||||
|
|
||||||
# ---------------------------------------------------------------- labels
|
# ---------------------------------------------------------------- labels
|
||||||
|
|
||||||
|
## What each kind of card is called in the UI (search, inspector, settings, previews).
|
||||||
|
const KIND_LABELS := {
|
||||||
|
RollTable.KIND_ROLL: "Roll table", RollTable.KIND_CHOICE: "Choice", RollTable.KIND_LOOP: "Loop",
|
||||||
|
RollTable.KIND_ROUTER: "Router", RollTable.KIND_CHECK: "Check", RollTable.KIND_VARIABLE: "Variable",
|
||||||
|
RollTable.KIND_SHEET: "Sheet",
|
||||||
|
}
|
||||||
|
## What each kind of choice is called (the + Card menu, settings, card, previews).
|
||||||
|
const CHOICE_LABELS := {"pick": "Which option", "number": "How many", "text": "Open ended"}
|
||||||
|
|
||||||
|
|
||||||
|
## "Roll table", "Check", "Collection", ...
|
||||||
|
static func kind_label(t: RollTable) -> String:
|
||||||
|
return "Collection" if t.is_collection() else str(KIND_LABELS.get(t.kind, "Card"))
|
||||||
|
|
||||||
|
|
||||||
|
## "Which option", "How many" or "Open ended".
|
||||||
|
static func choice_label(choice: String) -> String:
|
||||||
|
return str(CHOICE_LABELS.get(choice, choice))
|
||||||
|
|
||||||
|
|
||||||
|
## The choice kinds' labels in RollTable.CHOICES order (for segmented pickers).
|
||||||
|
static func choice_labels() -> Array:
|
||||||
|
return RollTable.CHOICES.map(choice_label)
|
||||||
|
|
||||||
|
|
||||||
## The label of a value: "@luck", "@skill_pilot", "@skill_*" (a collection
|
## The label of a value: "@luck", "@skill_pilot", "@skill_*" (a collection
|
||||||
## or prefix: "Skills", or "Skill values" without a collection card), "@[…]"
|
## or prefix: "Skills", or "Skill values" without a collection card), "@[…]"
|
||||||
## ("Chosen value"), or a chain name ("answer" -> "Answer", an input's label).
|
## ("Chosen value"), or a chain name ("answer" -> "Answer", an input's label).
|
||||||
|
|
@ -90,7 +115,7 @@ static func _collection_of(name: String, L: Dictionary) -> Dictionary:
|
||||||
# ---------------------------------------------------------------- effects
|
# ---------------------------------------------------------------- effects
|
||||||
|
|
||||||
## One effect statement in plain words: "@luck -= 1" -> "Luck −1",
|
## One effect statement in plain words: "@luck -= 1" -> "Luck −1",
|
||||||
## "@town = \"Millbrook\"" -> "Town = Millbrook", "reset @skill_*" -> "Clear
|
## "@town = \"Millbrook\"" -> "Town = Millbrook", "reset @skill_*" -> "Reset
|
||||||
## all Skills", "@traits += \"Psionic\"" -> "Add Psionic to Traits",
|
## all Skills", "@traits += \"Psionic\"" -> "Add Psionic to Traits",
|
||||||
## "@[option] += 1" -> "Chosen skill +1" when `table` is a pick card taking
|
## "@[option] += 1" -> "Chosen skill +1" when `table` is a pick card taking
|
||||||
## options from a collection (else "Chosen value +1").
|
## options from a collection (else "Chosen value +1").
|
||||||
|
|
@ -119,7 +144,7 @@ static func _effect(stmt: String, L: Dictionary, table: RollTable) -> String:
|
||||||
match str(m["op"]):
|
match str(m["op"]):
|
||||||
"reset":
|
"reset":
|
||||||
if v.ends_with("*"):
|
if v.ends_with("*"):
|
||||||
out = "Clear all " + _label(v, L)
|
out = "Reset all " + _label(v, L)
|
||||||
elif L["vars"].has(v.trim_prefix("@")):
|
elif L["vars"].has(v.trim_prefix("@")):
|
||||||
out = "Reset " + subj
|
out = "Reset " + subj
|
||||||
else:
|
else:
|
||||||
|
|
@ -256,8 +281,8 @@ static func _value(tok: String, L: Dictionary) -> String:
|
||||||
|
|
||||||
# ---------------------------------------------------------------- dice
|
# ---------------------------------------------------------------- dice
|
||||||
|
|
||||||
## A dice or count expression in plain words: "2d6 + dm(@str)" -> "2D +
|
## A dice or count expression in plain words: "2d6 + dm(@str)" -> "2d6 +
|
||||||
## Strength modifier", "1d6 + tier" -> "1D + Tier", "@terms" -> "Terms".
|
## Strength modifier", "1d6 + tier" -> "d6 + Tier", "@terms" -> "Terms".
|
||||||
## d6 dice read as "ND"; other dice as "dN" / "NdM". Text that can't be read
|
## d6 dice read as "ND"; other dice as "dN" / "NdM". Text that can't be read
|
||||||
## comes back as it is.
|
## comes back as it is.
|
||||||
static func dice(expr: String, board: TowerBoard) -> String:
|
static func dice(expr: String, board: TowerBoard) -> String:
|
||||||
|
|
@ -288,9 +313,7 @@ static func _expr(expr: String, L: Dictionary) -> String:
|
||||||
match t:
|
match t:
|
||||||
"dice":
|
"dice":
|
||||||
var dp := Builder.dice_parts(s)
|
var dp := Builder.dice_parts(s)
|
||||||
if int(dp[1]) == 6:
|
if int(dp[0]) == 1:
|
||||||
pieces.append(["val", "%dD" % int(dp[0])])
|
|
||||||
elif int(dp[0]) == 1:
|
|
||||||
pieces.append(["val", "d%d" % int(dp[1])])
|
pieces.append(["val", "d%d" % int(dp[1])])
|
||||||
else:
|
else:
|
||||||
pieces.append(["val", "%dd%d" % [int(dp[0]), int(dp[1])]])
|
pieces.append(["val", "%dd%d" % [int(dp[0]), int(dp[1])]])
|
||||||
|
|
@ -399,7 +422,7 @@ static func pipe(entry: TableEntry, target_id: String, board: TowerBoard) -> Str
|
||||||
return " · ".join(parts)
|
return " · ".join(parts)
|
||||||
|
|
||||||
|
|
||||||
## A check card: "Roll 2D + Strength modifier, need 8 or more" ("need 5 or
|
## A check card: "Roll 2d6 + Strength modifier, need 8 or more" ("need 5 or
|
||||||
## less" for a roll-under check). "" for other kinds.
|
## less" for a roll-under check). "" for other kinds.
|
||||||
static func check(table: RollTable, board: TowerBoard) -> String:
|
static func check(table: RollTable, board: TowerBoard) -> String:
|
||||||
if table == null or table.kind != RollTable.KIND_CHECK:
|
if table == null or table.kind != RollTable.KIND_CHECK:
|
||||||
|
|
@ -460,7 +483,7 @@ static func why(fact: Dictionary, board: TowerBoard, plain: bool = true) -> Stri
|
||||||
if s != "":
|
if s != "":
|
||||||
s = s.substr(0, 1).to_upper() + s.substr(1)
|
s = s.substr(0, 1).to_upper() + s.substr(1)
|
||||||
if not plain:
|
if not plain:
|
||||||
s = "show_if hid %d option(s)%s" % [h, ", and the Chosen entry" if bool(fact.get("chosen_hidden", false)) else ""]
|
s = "show_if hid %d option(s)%s" % [h, ", and the Chosen result" if bool(fact.get("chosen_hidden", false)) else ""]
|
||||||
"options_where":
|
"options_where":
|
||||||
var kept := int(fact.get("kept", 0))
|
var kept := int(fact.get("kept", 0))
|
||||||
var total := int(fact.get("total", 0))
|
var total := int(fact.get("total", 0))
|
||||||
|
|
@ -650,7 +673,7 @@ static func _why_effect(f: Dictionary, L: Dictionary, plain: bool) -> String:
|
||||||
return "%s %s: %s → %s" % [v, op, _raw(f.get("before")), _raw(f.get("after"))]
|
return "%s %s: %s → %s" % [v, op, _raw(f.get("before")), _raw(f.get("after"))]
|
||||||
var lab := _label(v, L)
|
var lab := _label(v, L)
|
||||||
if f.has("count"):
|
if f.has("count"):
|
||||||
return "Cleared all %s (%s)" % [lab, Expr.format_value(f["count"])]
|
return "Reset all %s (%s)" % [lab, Expr.format_value(f["count"])]
|
||||||
var before: Variant = f.get("before")
|
var before: Variant = f.get("before")
|
||||||
var after: Variant = f.get("after")
|
var after: Variant = f.get("after")
|
||||||
if op == "reset" and after == null:
|
if op == "reset" and after == null:
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ static func lint_pipes(board: TowerBoard) -> Array[Dictionary]:
|
||||||
first_other = p
|
first_other = p
|
||||||
if first_other != "" and not has_when:
|
if first_other != "" and not has_when:
|
||||||
out.append({"table_id": t.id, "entry_id": e.id,
|
out.append({"table_id": t.id, "entry_id": e.id,
|
||||||
"message": "The otherwise pipe to %s always runs: no pipe on this entry has a condition" % _table_name(board, first_other)})
|
"message": "The otherwise pipe to %s always runs: no pipe on this result has a condition" % _table_name(board, first_other)})
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ static func lint_options(t: RollTable) -> Array[Dictionary]:
|
||||||
if str(p["error"]) != "":
|
if str(p["error"]) != "":
|
||||||
out.append({"table_id": t.id, "entry_id": "", "message": "Options from %s: %s" % [from, p["error"]]})
|
out.append({"table_id": t.id, "entry_id": "", "message": "Options from %s: %s" % [from, p["error"]]})
|
||||||
if t.entries.is_empty():
|
if t.entries.is_empty():
|
||||||
out.append({"table_id": t.id, "entry_id": "", "message": "This card takes options from %s but has no Chosen entry" % from})
|
out.append({"table_id": t.id, "entry_id": "", "message": "This card takes options from %s but has no Chosen result" % from})
|
||||||
if where != "":
|
if where != "":
|
||||||
if from == "":
|
if from == "":
|
||||||
out.append({"table_id": t.id, "entry_id": "", "message": "Only where %s does nothing without Options from" % where})
|
out.append({"table_id": t.id, "entry_id": "", "message": "Only where %s does nothing without Options from" % where})
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,15 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
11. **Builds:** install the export templates (needs the user's OK), add Windows and Mac presets.
|
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
|
12. **From the original design:** a big-button quick-roll view, cross-collection references
|
||||||
(`[[Collection/Table]]`), touch support.
|
(`[[Collection/Table]]`), touch support.
|
||||||
13. **Housekeeping:** delete merged branches. Keep LOGIC.md and PLAIN.md in step with features.
|
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. Keep LOGIC.md and PLAIN.md in step with features.
|
||||||
|
|
||||||
## 10. History (2026-11-08, one long session)
|
## 10. History (2026-11-08, one long session)
|
||||||
|
|
||||||
|
|
@ -281,4 +289,10 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
||||||
10. Split the oversized files (main.gd 3679 → 617 lines plus 11 helpers; table_card, roller,
|
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
|
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
|
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).
|
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".
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ Pure functions that turn stored rules into short phrases. They use value labels
|
||||||
|
|
||||||
| Function | Input | Example output |
|
| Function | Input | Example output |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `effect(stmt, board) -> String` | one effect statement | `@luck -= 1` → "Luck −1"; `@skill_pilot += 1` → "Pilot +1"; `@town = "Millbrook"` → "Town = Millbrook"; `reset @skill_*` → "Clear all Skills"; `@[option] += 1` → "Chosen skill +1" (or "Chosen value +1" outside a skills collection) |
|
| `effect(stmt, board) -> String` | one effect statement | `@luck -= 1` → "Luck −1"; `@skill_pilot += 1` → "Pilot +1"; `@town = "Millbrook"` → "Town = Millbrook"; `reset @skill_*` → "Reset all Skills"; `@[option] += 1` → "Chosen skill +1" (or "Chosen value +1" outside a skills collection) |
|
||||||
| `effects(text, board) -> Array[String]` | effects field | one phrase per statement |
|
| `effects(text, board) -> Array[String]` | effects field | one phrase per statement |
|
||||||
| `condition(expr, board) -> String` | a `when` / `show_if` / `options_where` / loop rule | `@str >= 8` → "Strength is 8 or more"; `@x = 0 and @soc >= 9` → "X is 0 and Social Standing is 9 or more"; `has(@traits, "Psionic")` → "Traits include Psionic" |
|
| `condition(expr, board) -> String` | a `when` / `show_if` / `options_where` / loop rule | `@str >= 8` → "Strength is 8 or more"; `@x = 0 and @soc >= 9` → "X is 0 and Social Standing is 9 or more"; `has(@traits, "Psionic")` → "Traits include Psionic" |
|
||||||
| `dice(expr, board) -> String` | dice / count expression | `2d6 + dm(@str)` → "2D + Strength modifier"; `1d6 + tier` → "1D + Tier" |
|
| `dice(expr, board) -> String` | dice / count expression | `2d6 + dm(@str)` → "2d6 + Strength modifier"; `1d6 + tier` → "d6 + Tier" |
|
||||||
| `options(table, board) -> String` | dynamic pick source | "your Skills, level 1 or more" |
|
| `options(table, board) -> String` | dynamic pick source | "your Skills, level 1 or more" |
|
||||||
| `pipe(entry, target_id, board) -> String` | a pipe's label | "Tier 3 · only if Luck is 2 or more", "otherwise", "×2 · saves Weapon" |
|
| `pipe(entry, target_id, board) -> String` | a pipe's label | "Tier 3 · only if Luck is 2 or more", "otherwise", "×2 · saves Weapon" |
|
||||||
| `check(table, board) -> String` | a Check card | "Roll 2D + Strength modifier, need 8 or more" |
|
| `check(table, board) -> String` | a Check card | "Roll 2d6 + Strength modifier, need 8 or more" |
|
||||||
| `why(fact, board, plain := true) -> String` | one trace fact (§5) | "Skipped Tier 3 because Luck was 1 (needs 2 or more)" |
|
| `why(fact, board, plain := true) -> String` | one trace fact (§5) | "Skipped Tier 3 because Luck was 1 (needs 2 or more)" |
|
||||||
|
|
||||||
Comparisons read as "is", "is not", "is at least", "is at most", "is more than" and "is less
|
Comparisons read as "is", "is not", "is at least", "is at most", "is more than" and "is less
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"format_version": 1,
|
|
||||||
"name": "2D skill check",
|
|
||||||
"description": "Pass or fail on 2d6 plus a skill's DM against a target number, as in most 2D games. The DM is read from a board variable, so effects elsewhere can raise it.",
|
|
||||||
"kind": "card",
|
|
||||||
"params": [
|
|
||||||
{"name": "skill", "label": "Variable holding the DM (no @)", "default": "skill"},
|
|
||||||
{"name": "target", "label": "Target number", "default": "8"}
|
|
||||||
],
|
|
||||||
"tables": [
|
|
||||||
{
|
|
||||||
"id": "check",
|
|
||||||
"name": "{$skill} check, {$target}+",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"details": "Rolls 2d6 + @{$skill} − {$target}, the check's Effect. An Effect of 0 or more passes.",
|
|
||||||
"dice": "2d6 + @{$skill} - {$target}",
|
|
||||||
"entries": [
|
|
||||||
{"id": "e1", "text": "Fail", "range": [-1, -1]},
|
|
||||||
{"id": "e2", "text": "Pass", "range": [0, 0]}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"groups": []
|
|
||||||
}
|
|
||||||
27
templates/skill-check.json
Normal file
27
templates/skill-check.json
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"format_version": 1,
|
||||||
|
"name": "Skill check (2d6 vs target)",
|
||||||
|
"description": "A Check card: rolls 2d6 plus a skill's modifier against a target number, with a Success and a Failure result to pipe from. The modifier is read from a board variable, so changes elsewhere can raise it.",
|
||||||
|
"kind": "card",
|
||||||
|
"params": [
|
||||||
|
{"name": "skill", "label": "Variable holding the modifier (no @)", "default": "skill"},
|
||||||
|
{"name": "target", "label": "Target number", "default": "8"}
|
||||||
|
],
|
||||||
|
"tables": [
|
||||||
|
{
|
||||||
|
"id": "check",
|
||||||
|
"kind": "check",
|
||||||
|
"name": "{$skill} check, {$target}+",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"details": "Rolls 2d6 + @{$skill} against {$target}. Meeting or beating it is a Success.",
|
||||||
|
"check_mod": "@{$skill}",
|
||||||
|
"check_target": "{$target}",
|
||||||
|
"entries": [
|
||||||
|
{"id": "e1", "text": "Success"},
|
||||||
|
{"id": "e2", "text": "Failure"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"groups": []
|
||||||
|
}
|
||||||
|
|
@ -105,15 +105,15 @@ func _test_effects() -> void:
|
||||||
_eq(Describe.effect("@luck += -2", b), "Luck −2", "add a negative")
|
_eq(Describe.effect("@luck += -2", b), "Luck −2", "add a negative")
|
||||||
_eq(Describe.effect("@luck -= -2", b), "Luck +2", "subtract a negative")
|
_eq(Describe.effect("@luck -= -2", b), "Luck +2", "subtract a negative")
|
||||||
_eq(Describe.effect("@town = \"Millbrook\"", b), "Town = Millbrook", "set text")
|
_eq(Describe.effect("@town = \"Millbrook\"", b), "Town = Millbrook", "set text")
|
||||||
_eq(Describe.effect("@str = 2d6", b), "Strength = 2D", "set dice")
|
_eq(Describe.effect("@str = 2d6", b), "Strength = 2d6", "set dice")
|
||||||
_eq(Describe.effect("@str = 2d6 + dm(@soc)", b), "Strength = 2D + Social Standing modifier", "set expression")
|
_eq(Describe.effect("@str = 2d6 + dm(@soc)", b), "Strength = 2d6 + Social Standing modifier", "set expression")
|
||||||
_eq(Describe.effect("@credits += 1d6 * 1000", b), "Credits + 1D × 1000", "add expression")
|
_eq(Describe.effect("@credits += 1d6 * 1000", b), "Credits + d6 × 1000", "add expression")
|
||||||
_eq(Describe.effect("@age *= 2", b), "Age ×2", "multiply")
|
_eq(Describe.effect("@age *= 2", b), "Age ×2", "multiply")
|
||||||
_eq(Describe.effect("@age /= 2", b), "Age ÷2", "divide")
|
_eq(Describe.effect("@age /= 2", b), "Age ÷2", "divide")
|
||||||
_eq(Describe.effect("@traits += \"Psionic\"", b), "Add Psionic to Traits", "append")
|
_eq(Describe.effect("@traits += \"Psionic\"", b), "Add Psionic to Traits", "append")
|
||||||
_eq(Describe.effect("@traits -= \"Psionic\"", b), "Remove Psionic from Traits", "remove")
|
_eq(Describe.effect("@traits -= \"Psionic\"", b), "Remove Psionic from Traits", "remove")
|
||||||
_eq(Describe.effect("reset @skill_*", b), "Clear all Skills", "reset a collection")
|
_eq(Describe.effect("reset @skill_*", b), "Reset all Skills", "reset a collection")
|
||||||
_eq(Describe.effect("reset @contact_*", b), "Clear all Contact values", "reset a prefix")
|
_eq(Describe.effect("reset @contact_*", b), "Reset all Contact values", "reset a prefix")
|
||||||
_eq(Describe.effect("reset @luck", b), "Reset Luck", "reset a declared value")
|
_eq(Describe.effect("reset @luck", b), "Reset Luck", "reset a declared value")
|
||||||
_eq(Describe.effect("reset @dex", b), "Clear Dex", "reset an undeclared value")
|
_eq(Describe.effect("reset @dex", b), "Clear Dex", "reset an undeclared value")
|
||||||
_eq(Describe.effect("@[option] += 1", b), "Chosen value +1", "indirect, no card")
|
_eq(Describe.effect("@[option] += 1", b), "Chosen value +1", "indirect, no card")
|
||||||
|
|
@ -123,7 +123,7 @@ func _test_effects() -> void:
|
||||||
pick.options_from = "@contacts"
|
pick.options_from = "@contacts"
|
||||||
_eq(Describe.effect("@[option] += 1", b, pick), "Chosen value +1", "indirect outside a collection")
|
_eq(Describe.effect("@[option] += 1", b, pick), "Chosen value +1", "indirect outside a collection")
|
||||||
_eq(Describe.effect("hero = \"Bob\"", b), "Hero = Bob", "chain target")
|
_eq(Describe.effect("hero = \"Bob\"", b), "Hero = Bob", "chain target")
|
||||||
_eq(Describe.effects("@luck -= 1; @str = 7\nreset @skill_*", b), ["Luck −1", "Strength = 7", "Clear all Skills"] as Array[String], "effects field")
|
_eq(Describe.effects("@luck -= 1; @str = 7\nreset @skill_*", b), ["Luck −1", "Strength = 7", "Reset all Skills"] as Array[String], "effects field")
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------- conditions
|
# ---------------------------------------------------------------- conditions
|
||||||
|
|
@ -152,15 +152,15 @@ func _test_conditions() -> void:
|
||||||
|
|
||||||
func _test_dice() -> void:
|
func _test_dice() -> void:
|
||||||
var b := _board()
|
var b := _board()
|
||||||
_eq(Describe.dice("2d6 + dm(@str)", b), "2D + Strength modifier", "2D + modifier")
|
_eq(Describe.dice("2d6 + dm(@str)", b), "2d6 + Strength modifier", "2d6 + modifier")
|
||||||
_eq(Describe.dice("1d6 + tier", b), "1D + Tier", "input in dice")
|
_eq(Describe.dice("1d6 + tier", b), "d6 + Tier", "input in dice")
|
||||||
_eq(Describe.dice("d20", b), "d20", "d20")
|
_eq(Describe.dice("d20", b), "d20", "d20")
|
||||||
_eq(Describe.dice("3d8 - 2", b), "3d8 − 2", "3d8 − 2")
|
_eq(Describe.dice("3d8 - 2", b), "3d8 − 2", "3d8 − 2")
|
||||||
_eq(Describe.dice("2D", b), "2D", "2D")
|
_eq(Describe.dice("2D", b), "2d6", "2D input reads as 2d6")
|
||||||
_eq(Describe.dice("@terms", b), "Terms", "a value")
|
_eq(Describe.dice("@terms", b), "Terms", "a value")
|
||||||
_eq(Describe.dice("-1", b), "−1", "negative number")
|
_eq(Describe.dice("-1", b), "−1", "negative number")
|
||||||
_eq(Describe.dice("max(@str, 3)", b), "max(Strength, 3)", "function call")
|
_eq(Describe.dice("max(@str, 3)", b), "max(Strength, 3)", "function call")
|
||||||
_eq(Describe.dice("(1d6 + 1) * 10", b), "(1D + 1) × 10", "parentheses")
|
_eq(Describe.dice("(1d6 + 1) * 10", b), "(d6 + 1) × 10", "parentheses")
|
||||||
_eq(Describe.dice("count(@skill_*)", b), "count(Skills)", "prefix argument")
|
_eq(Describe.dice("count(@skill_*)", b), "count(Skills)", "prefix argument")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -208,13 +208,13 @@ func _test_pipes() -> void:
|
||||||
func _test_check() -> void:
|
func _test_check() -> void:
|
||||||
var b := _board()
|
var b := _board()
|
||||||
var t := RollTable.create(RollTable.KIND_CHECK, "c", "Check")
|
var t := RollTable.create(RollTable.KIND_CHECK, "c", "Check")
|
||||||
_eq(Describe.check(t, b), "Roll 2D, need 8 or more", "default check")
|
_eq(Describe.check(t, b), "Roll 2d6, need 8 or more", "default check")
|
||||||
t.check_mod = "dm(@str)"
|
t.check_mod = "dm(@str)"
|
||||||
_eq(Describe.check(t, b), "Roll 2D + Strength modifier, need 8 or more", "with modifier")
|
_eq(Describe.check(t, b), "Roll 2d6 + Strength modifier, need 8 or more", "with modifier")
|
||||||
t.check_cmp = "le"
|
t.check_cmp = "le"
|
||||||
t.check_target = "@soc"
|
t.check_target = "@soc"
|
||||||
t.check_mod = "-1"
|
t.check_mod = "-1"
|
||||||
_eq(Describe.check(t, b), "Roll 2D − 1, need at most Social Standing", "roll-under, value target")
|
_eq(Describe.check(t, b), "Roll 2d6 − 1, need at most Social Standing", "roll-under, value target")
|
||||||
_eq(Describe.check(_one("r"), b), "", "not a check")
|
_eq(Describe.check(_one("r"), b), "", "not a check")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -259,7 +259,7 @@ func _test_why_facts() -> void:
|
||||||
_eq(W.call({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}), "Luck went from 2 to 1", "effect")
|
_eq(W.call({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}), "Luck went from 2 to 1", "effect")
|
||||||
_eq(W.call({"type": "effect", "var": "@skill_pilot", "op": "+=", "before": null, "after": 1}), "Pilot became 1", "effect from unset")
|
_eq(W.call({"type": "effect", "var": "@skill_pilot", "op": "+=", "before": null, "after": 1}), "Pilot became 1", "effect from unset")
|
||||||
_eq(W.call({"type": "effect", "var": "@dex", "op": "reset", "before": 4, "after": null}), "Dex was cleared", "reset effect")
|
_eq(W.call({"type": "effect", "var": "@dex", "op": "reset", "before": 4, "after": null}), "Dex was cleared", "reset effect")
|
||||||
_eq(W.call({"type": "effect", "var": "@skill_*", "op": "reset", "count": 3}), "Cleared all Skills (3)", "prefix reset")
|
_eq(W.call({"type": "effect", "var": "@skill_*", "op": "reset", "count": 3}), "Reset all Skills (3)", "prefix reset")
|
||||||
_eq(W.call({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}, false), "@luck -=: 2 → 1", "effect text mode")
|
_eq(W.call({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}, false), "@luck -=: 2 → 1", "effect text mode")
|
||||||
_eq(W.call({"type": "input", "name": "tier", "value": 3, "from": "pipe"}), "Tier was 3 (from the pipe)", "input")
|
_eq(W.call({"type": "input", "name": "tier", "value": 3, "from": "pipe"}), "Tier was 3 (from the pipe)", "input")
|
||||||
_eq(W.call({"type": "input", "name": "tier", "value": 1, "from": "default"}), "Tier was 1 (default)", "input default")
|
_eq(W.call({"type": "input", "name": "tier", "value": 1, "from": "default"}), "Tier was 1 (default)", "input default")
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ func _test_search() -> void:
|
||||||
var entry := _find(r, "agent", "e25")
|
var entry := _find(r, "agent", "e25")
|
||||||
_check(not entry.is_empty() and entry["field"] == BoardSearch.FIELD_RESULT, "entry text matches, BBCode stripped")
|
_check(not entry.is_empty() and entry["field"] == BoardSearch.FIELD_RESULT, "entry text matches, BBCode stripped")
|
||||||
_check(not entry.is_empty() and str(entry["snippet"]).substr(entry["hl_from"], entry["hl_len"]) == "gem", "and the snippet marks the match: %s" % str(entry))
|
_check(not entry.is_empty() and str(entry["snippet"]).substr(entry["hl_from"], entry["hl_len"]) == "gem", "and the snippet marks the match: %s" % str(entry))
|
||||||
_check(not entry.is_empty() and entry["group"] == "Careers" and entry["name"] == "Agent" and entry["kind"] == "Table", "results name the card, its kind and its group")
|
_check(not entry.is_empty() and entry["group"] == "Careers" and entry["name"] == "Agent" and entry["kind"] == "Roll table", "results name the card, its kind and its group")
|
||||||
_check(not _find(r, "army", "").is_empty(), "details match too")
|
_check(not _find(r, "army", "").is_empty(), "details match too")
|
||||||
var acc := s.find("RARE")
|
var acc := s.find("RARE")
|
||||||
_check(not acc.is_empty() and acc[0]["table_id"] == "agent" and acc[0]["entry_id"] == "e25", "matching ignores case and accents")
|
_check(not acc.is_empty() and acc[0]["table_id"] == "agent" and acc[0]["entry_id"] == "e25", "matching ignores case and accents")
|
||||||
|
|
|
||||||
|
|
@ -218,11 +218,11 @@ func _test_rules_view_helpers() -> void:
|
||||||
var times := RollTable.create(RollTable.KIND_LOOP, "t", "T")
|
var times := RollTable.create(RollTable.KIND_LOOP, "t", "T")
|
||||||
times.loop_expr = "@terms"
|
times.loop_expr = "@terms"
|
||||||
_eq(RulesView.loop_rule(times, b, true), "× Terms", "a count loop reads × Terms")
|
_eq(RulesView.loop_rule(times, b, true), "× Terms", "a count loop reads × Terms")
|
||||||
_eq(RulesView.dice("2d6 + dm(@str)", b, true), "2D + Strength modifier", "expression dice")
|
_eq(RulesView.dice("2d6 + dm(@str)", b, true), "2d6 + Strength modifier", "expression dice")
|
||||||
_eq(Describe.condition("@luck != \"\"", b), "Luck is not empty", "empty text reads as empty")
|
_eq(Describe.condition("@luck != \"\"", b), "Luck is not empty", "empty text reads as empty")
|
||||||
_eq(RulesView.check_outlets(b.get_table("gate")), ["8+", "≤7"] as Array[String], "check outlets")
|
_eq(RulesView.check_outlets(b.get_table("gate")), ["8+", "≤7"] as Array[String], "check outlets")
|
||||||
_eq(TrayText.effect_fact_line({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}, b), "Luck 2 → 1", "tray effect line")
|
_eq(TrayText.effect_fact_line({"type": "effect", "var": "@luck", "op": "-=", "before": 2, "after": 1}, b), "Luck 2 → 1", "tray effect line")
|
||||||
_eq(TrayText.effect_fact_line({"type": "effect", "var": "@skill_*", "op": "reset", "count": 3}, b), "Cleared all Skills (3)", "tray prefix reset line")
|
_eq(TrayText.effect_fact_line({"type": "effect", "var": "@skill_*", "op": "reset", "count": 3}, b), "Reset all Skills (3)", "tray prefix reset line")
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------- cards
|
# ---------------------------------------------------------------- cards
|
||||||
|
|
@ -231,7 +231,7 @@ func _test_card_chips() -> void:
|
||||||
var beyond := main.card_for("beyond")
|
var beyond := main.card_for("beyond")
|
||||||
_check(_chips(beyond).has("Luck −1"), "an effects chip reads Luck −1")
|
_check(_chips(beyond).has("Luck −1"), "an effects chip reads Luck −1")
|
||||||
var loot := main.card_for("loot")
|
var loot := main.card_for("loot")
|
||||||
_check(_has(loot, "Roll 1D + Tier · 3 ranges"), "expression dice read in words under the title")
|
_check(_has(loot, "Roll d6 + Tier · 3 ranges"), "expression dice read in words under the title")
|
||||||
_check(_has(main.card_for("rounds"), "repeat while Luck is more than 0"), "a loop's rule reads in words")
|
_check(_has(main.card_for("rounds"), "repeat while Luck is more than 0"), "a loop's rule reads in words")
|
||||||
_check(_has(main.card_for("v_luck"), "Number · kept between rolls"), "a variable card says it's kept")
|
_check(_has(main.card_for("v_luck"), "Number · kept between rolls"), "a variable card says it's kept")
|
||||||
|
|
||||||
|
|
@ -274,8 +274,8 @@ func _test_router_and_choice() -> void:
|
||||||
|
|
||||||
func _test_check_card() -> void:
|
func _test_check_card() -> void:
|
||||||
var gate := main.card_for("gate")
|
var gate := main.card_for("gate")
|
||||||
_check(_has(gate, "Roll 2D + Strength modifier, need 8 or more"), "the check card's sentence")
|
_check(_has(gate, "Roll 2d6 + Strength modifier, need 8 or more"), "the check card's sentence")
|
||||||
_check(_has(gate, "2D"), "the 2D badge")
|
_check(_has(gate, "2d6"), "the 2d6 badge")
|
||||||
_check(_has(gate, "Success · the bars give") and _has(gate, "Failure · it holds"), "Success and Failure outlets with their labels")
|
_check(_has(gate, "Success · the bars give") and _has(gate, "Failure · it holds"), "Success and Failure outlets with their labels")
|
||||||
_check(_has(gate, "8+") and _has(gate, "≤7"), "outlet ranges")
|
_check(_has(gate, "8+") and _has(gate, "≤7"), "outlet ranges")
|
||||||
await process_frame
|
await process_frame
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ func _test_builtins() -> void:
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
_check(rows.size() >= 5, "five built-in templates ship: %d" % rows.size())
|
_check(rows.size() >= 5, "five built-in templates ship: %d" % rows.size())
|
||||||
_check(lib.errors.is_empty(), "every built-in template reads: %s" % str(lib.errors))
|
_check(lib.errors.is_empty(), "every built-in template reads: %s" % str(lib.errors))
|
||||||
var want := {"builtin:2d-check": false, "builtin:ask-and-repeat": false, "builtin:pick-menu": false, "builtin:counter": false, "builtin:simple-sheet": false}
|
var want := {"builtin:skill-check": false, "builtin:ask-and-repeat": false, "builtin:pick-menu": false, "builtin:counter": false, "builtin:simple-sheet": false}
|
||||||
for row: Dictionary in rows:
|
for row: Dictionary in rows:
|
||||||
if want.has(row["id"]):
|
if want.has(row["id"]):
|
||||||
want[row["id"]] = true
|
want[row["id"]] = true
|
||||||
|
|
@ -201,21 +201,22 @@ func _test_builtins() -> void:
|
||||||
_check(false, "%s: %s logs an error: %s" % [row["id"], t.name, str(l)])
|
_check(false, "%s: %s logs an error: %s" % [row["id"], t.name, str(l)])
|
||||||
for k: String in want:
|
for k: String in want:
|
||||||
_check(want[k], "built-in %s is listed" % k)
|
_check(want[k], "built-in %s is listed" % k)
|
||||||
var chk := lib.get_template("builtin:2d-check")
|
var chk := lib.get_template("builtin:skill-check")
|
||||||
var b2 := TowerBoard.new()
|
var b2 := TowerBoard.new()
|
||||||
var r2 := TemplateKit.insert(chk, {"skill": "pilot", "target": "8"}, b2, Vector2.ZERO)
|
var r2 := TemplateKit.insert(chk, {"skill": "pilot", "target": "8"}, b2, Vector2.ZERO)
|
||||||
var t2: RollTable = r2["tables"][0]
|
var t2: RollTable = r2["tables"][0]
|
||||||
_check(t2.dice == "2d6 + @pilot - 8" and t2.name == "pilot check, 8+", "the 2D check reads 2d6 + @pilot against 8: %s" % t2.dice)
|
_check(t2.kind == RollTable.KIND_CHECK and t2.check_dice == "2d6" and t2.check_mod == "@pilot" and t2.check_target == "8" and t2.name == "pilot check, 8+",
|
||||||
|
"the skill check is a Check card: 2d6 + @pilot against 8 (%s + %s vs %s)" % [t2.check_dice, t2.check_mod, t2.check_target])
|
||||||
var passes := 0
|
var passes := 0
|
||||||
var rng := RandomNumberGenerator.new()
|
var rng := RandomNumberGenerator.new()
|
||||||
rng.seed = 3
|
rng.seed = 3
|
||||||
for i in 400:
|
for i in 400:
|
||||||
var ctx := Roller.new_context(b2, rng, {"pilot": {"value": 2, "source": ""}})
|
var ctx := Roller.new_context(b2, rng, {"pilot": {"value": 2, "source": ""}})
|
||||||
var n := Roller.roll(b2, t2.id, rng, 0, {}, ctx)
|
var n := Roller.roll(b2, t2.id, rng, 0, {}, ctx)
|
||||||
if (n["entry"] as TableEntry).text == "Pass":
|
if n.get("entry") and (n["entry"] as TableEntry).text == "Success":
|
||||||
passes += 1
|
passes += 1
|
||||||
# 2d6 + 2 >= 8 means 2d6 >= 6: 26/36 = 72%.
|
# 2d6 + 2 >= 8 means 2d6 >= 6: 26/36 = 72%.
|
||||||
_check(passes > 250 and passes < 330, "with DM +2, a target of 8 passes about 72%% of the time (%d/400)" % passes)
|
_check(passes > 250 and passes < 330, "with a +2 modifier, a target of 8 succeeds about 72%% of the time (%d/400)" % passes)
|
||||||
|
|
||||||
|
|
||||||
func _test_app() -> void:
|
func _test_app() -> void:
|
||||||
|
|
@ -243,7 +244,7 @@ func _test_app() -> void:
|
||||||
var picker := main.templating.open_template_picker()
|
var picker := main.templating.open_template_picker()
|
||||||
await process_frame
|
await process_frame
|
||||||
var ids := picker.shown_ids()
|
var ids := picker.shown_ids()
|
||||||
_check(ids.has("builtin:2d-check") and ids.has("builtin:counter"), "the list shows the built-in templates")
|
_check(ids.has("builtin:skill-check") and ids.has("builtin:counter"), "the list shows the built-in templates")
|
||||||
picker._search.text = "counter"
|
picker._search.text = "counter"
|
||||||
picker.refresh()
|
picker.refresh()
|
||||||
_check(picker.shown_ids() == ["builtin:counter"], "search filters the list: %s" % str(picker.shown_ids()))
|
_check(picker.shown_ids() == ["builtin:counter"], "search filters the list: %s" % str(picker.shown_ids()))
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ func _test_pipes() -> void:
|
||||||
main.undo_redo.undo()
|
main.undo_redo.undo()
|
||||||
_check(_t("a").entries[1].pipes.is_empty(), "undo takes the pipe away")
|
_check(_t("a").entries[1].pipes.is_empty(), "undo takes the pipe away")
|
||||||
main.remove_pipe("a:e1>b")
|
main.remove_pipe("a:e1>b")
|
||||||
_check(_label() == "Remove pipe Loot → Gems" and main.top_bar._toast_undo.visible, "removing a pipe, with an undo toast: %s" % _label())
|
_check(_label() == "Delete pipe Loot → Gems" and main.top_bar._toast_undo.visible, "removing a pipe, with an undo toast: %s" % _label())
|
||||||
main.undo_redo.undo()
|
main.undo_redo.undo()
|
||||||
_check(_t("a").entries[0].pipes == ["b"], "undo lays it again")
|
_check(_t("a").entries[0].pipes == ["b"], "undo lays it again")
|
||||||
var e := _t("a").entries[0]
|
var e := _t("a").entries[0]
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,6 @@ const FIELD_WEIGHT := {
|
||||||
FIELD_NAME: 100, FIELD_GROUP: 90, FIELD_VARIABLE: 80, FIELD_PROMPT: 50,
|
FIELD_NAME: 100, FIELD_GROUP: 90, FIELD_VARIABLE: 80, FIELD_PROMPT: 50,
|
||||||
FIELD_RESULT: 40, FIELD_EFFECTS: 30, FIELD_DETAILS: 20,
|
FIELD_RESULT: 40, FIELD_EFFECTS: 30, FIELD_DETAILS: 20,
|
||||||
}
|
}
|
||||||
const KIND_LABELS := {
|
|
||||||
RollTable.KIND_ROLL: "Table", RollTable.KIND_CHOICE: "Choice", RollTable.KIND_LOOP: "Loop",
|
|
||||||
RollTable.KIND_VARIABLE: "Variable", RollTable.KIND_SHEET: "Sheet",
|
|
||||||
}
|
|
||||||
const SNIPPET_BEFORE := 28
|
const SNIPPET_BEFORE := 28
|
||||||
const SNIPPET_AFTER := 60
|
const SNIPPET_AFTER := 60
|
||||||
|
|
||||||
|
|
@ -95,7 +91,7 @@ func build(board: TowerBoard) -> void:
|
||||||
_add("", "", g.id, FIELD_DETAILS, plain(g.details))
|
_add("", "", g.id, FIELD_DETAILS, plain(g.details))
|
||||||
for t in board.tables:
|
for t in board.tables:
|
||||||
_names[t.id] = plain(t.name)
|
_names[t.id] = plain(t.name)
|
||||||
_kinds[t.id] = str(KIND_LABELS.get(t.kind, "Table"))
|
_kinds[t.id] = Describe.kind_label(t)
|
||||||
_add(t.id, "", "", FIELD_NAME, _names[t.id])
|
_add(t.id, "", "", FIELD_NAME, _names[t.id])
|
||||||
_add(t.id, "", "", FIELD_DETAILS, plain(t.details))
|
_add(t.id, "", "", FIELD_DETAILS, plain(t.details))
|
||||||
if t.kind == RollTable.KIND_VARIABLE and t.var_name != "":
|
if t.kind == RollTable.KIND_VARIABLE and t.var_name != "":
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,8 @@ func _show_var(owner: Control, name: String) -> void:
|
||||||
func table_summary(t: RollTable) -> String:
|
func table_summary(t: RollTable) -> String:
|
||||||
match t.kind:
|
match t.kind:
|
||||||
RollTable.KIND_CHOICE:
|
RollTable.KIND_CHOICE:
|
||||||
return {"pick": "Choice · %d options" % t.entries.size(), "number": "Choice · a number", "text": "Choice · open ended"}.get(t.choice, "Choice")
|
var sub := "Choice · " + Describe.choice_label(t.choice).to_lower()
|
||||||
|
return sub + " · %d options" % t.entries.size() if t.choice == "pick" else sub
|
||||||
RollTable.KIND_LOOP:
|
RollTable.KIND_LOOP:
|
||||||
return "Loop · " + RulesView.loop_rule(t, main.data, RulesView.plain(main))
|
return "Loop · " + RulesView.loop_rule(t, main.data, RulesView.plain(main))
|
||||||
RollTable.KIND_VARIABLE:
|
RollTable.KIND_VARIABLE:
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ static func _table_label(ta: Dictionary, tb: Dictionary, b: Dictionary) -> Strin
|
||||||
if not e["pipes_added"].is_empty():
|
if not e["pipes_added"].is_empty():
|
||||||
return "Add pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_added"][0])]
|
return "Add pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_added"][0])]
|
||||||
if not e["pipes_removed"].is_empty():
|
if not e["pipes_removed"].is_empty():
|
||||||
return "Remove pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_removed"][0])]
|
return "Delete pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_removed"][0])]
|
||||||
if not e["pipes_changed"].is_empty():
|
if not e["pipes_changed"].is_empty():
|
||||||
return "Edit pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_changed"][0])]
|
return "Edit pipe %s → %s" % [tname, _name(b, "ids", "tables", e["pipes_changed"][0])]
|
||||||
if ta.get("name") != tb.get("name"):
|
if ta.get("name") != tb.get("name"):
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ func _pipe_box(t: RollTable, e: TableEntry, to: String) -> Control:
|
||||||
v.add_child(sr)
|
v.add_child(sr)
|
||||||
v.add_child(cerr)
|
v.add_child(cerr)
|
||||||
|
|
||||||
var rm := InspectorKit.link("Remove pipe", "Delete this pipe")
|
var rm := InspectorKit.link("Delete pipe", "Delete this pipe")
|
||||||
rm.add_theme_color_override("font_color", Style.DANGER_INK)
|
rm.add_theme_color_override("font_color", Style.DANGER_INK)
|
||||||
rm.add_theme_color_override("font_hover_color", Style.DANGER_INK)
|
rm.add_theme_color_override("font_hover_color", Style.DANGER_INK)
|
||||||
rm.pressed.connect(func() -> void: remove_pipe(to))
|
rm.pressed.connect(func() -> void: remove_pipe(to))
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,13 @@ extends RefCounted
|
||||||
## through Inspector (apply_settings / wrote), so the settings dialog's rules
|
## through Inspector (apply_settings / wrote), so the settings dialog's rules
|
||||||
## and the undo history apply.
|
## and the undo history apply.
|
||||||
|
|
||||||
const KIND_NAMES := {
|
|
||||||
RollTable.KIND_ROLL: "Roll table", RollTable.KIND_CHOICE: "Choice", RollTable.KIND_LOOP: "Loop",
|
|
||||||
RollTable.KIND_VARIABLE: "Variable", RollTable.KIND_SHEET: "Sheet", RollTable.KIND_ROUTER: "Router",
|
|
||||||
RollTable.KIND_CHECK: "Check",
|
|
||||||
}
|
|
||||||
const DM_PATTERN := "^dm\\(\\s*(@[a-z_][a-z0-9_]*)\\s*\\)$"
|
const DM_PATTERN := "^dm\\(\\s*(@[a-z_][a-z0-9_]*)\\s*\\)$"
|
||||||
const NONE := "__none"
|
const NONE := "__none"
|
||||||
const AS_TEXT := "__text"
|
const AS_TEXT := "__text"
|
||||||
|
|
||||||
|
|
||||||
static func build(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
|
static func build(insp: Inspector, box: VBoxContainer, t: RollTable) -> void:
|
||||||
var kind := "Collection" if t.is_collection() else str(KIND_NAMES.get(t.kind, "Card"))
|
box.add_child(insp._head("Selected card · " + Describe.kind_label(t), Inspector._title_of(t.name, "(no name)")))
|
||||||
box.add_child(insp._head("Selected card · " + kind, Inspector._title_of(t.name, "(no name)")))
|
|
||||||
var plain := insp.main.rules_plain()
|
var plain := insp.main.rules_plain()
|
||||||
|
|
||||||
var name := InspectorKit.line(t.name, "Name")
|
var name := InspectorKit.line(t.name, "Name")
|
||||||
|
|
@ -309,7 +303,7 @@ static func _rebuild_as_text(insp: Inspector) -> void:
|
||||||
static func _choice(insp: Inspector, box: VBoxContainer, t: RollTable, plain: bool) -> void:
|
static func _choice(insp: Inspector, box: VBoxContainer, t: RollTable, plain: bool) -> void:
|
||||||
var main := insp.main
|
var main := insp.main
|
||||||
var err := InspectorKit.error_label()
|
var err := InspectorKit.error_label()
|
||||||
var seg := ModalCard.segmented(TableSettingsDialog.CHOICE_LABELS, maxi(0, RollTable.CHOICES.find(t.choice)), func(i: int) -> void:
|
var seg := ModalCard.segmented(Describe.choice_labels(), maxi(0, RollTable.CHOICES.find(t.choice)), func(i: int) -> void:
|
||||||
InspectorKit.show_error(err, insp.apply_settings({"choice": RollTable.CHOICES[i]}, true))
|
InspectorKit.show_error(err, insp.apply_settings({"choice": RollTable.CHOICES[i]}, true))
|
||||||
)
|
)
|
||||||
box.add_child(InspectorKit.field("Type", seg))
|
box.add_child(InspectorKit.field("Type", seg))
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ extends VBoxContainer
|
||||||
signal changed(text: String)
|
signal changed(text: String)
|
||||||
|
|
||||||
const OPS := ["set", "add", "subtract", "multiply", "divide", "reset", "append", "remove"]
|
const OPS := ["set", "add", "subtract", "multiply", "divide", "reset", "append", "remove"]
|
||||||
const OP_LABELS := ["Set", "Add", "Subtract", "Multiply", "Divide", "Clear", "Add to list", "Remove from list"]
|
const OP_LABELS := ["Set", "Add", "Subtract", "Multiply", "Divide", "Reset", "Add to list", "Remove from list"]
|
||||||
|
|
||||||
var main: Main
|
var main: Main
|
||||||
var table: RollTable
|
var table: RollTable
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ func remove_pipe(key: String) -> void:
|
||||||
if card:
|
if card:
|
||||||
card.rebuild()
|
card.rebuild()
|
||||||
m.undo_redo._end_edit()
|
m.undo_redo._end_edit()
|
||||||
m.toast("Removed pipe from “%s” to %s" % [e.text, target.name if target else to], true)
|
m.toast("Deleted pipe from “%s” to %s" % [e.text, target.name if target else to], true)
|
||||||
|
|
||||||
|
|
||||||
func start_link(tid: String, eid: String) -> void:
|
func start_link(tid: String, eid: String) -> void:
|
||||||
|
|
@ -251,7 +251,7 @@ func finish_link() -> void:
|
||||||
if e == null or e.pipes.has(over.table.id):
|
if e == null or e.pipes.has(over.table.id):
|
||||||
return
|
return
|
||||||
if over.table.kind == RollTable.KIND_VARIABLE:
|
if over.table.kind == RollTable.KIND_VARIABLE:
|
||||||
m.toast("Variable cards aren't rolled, so pipes can't lead into them. Use an effect such as @%s += 1." % over.table.var_name)
|
m.toast("Variable cards aren't rolled, so pipes can't lead into them. Use a change such as @%s += 1." % over.table.var_name)
|
||||||
return
|
return
|
||||||
m.undo_redo._begin_edit()
|
m.undo_redo._begin_edit()
|
||||||
# Each range on a ranged table takes a single pipe, so a new one replaces the old.
|
# Each range on a ranged table takes a single pipe, so a new one replaces the old.
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ func save_template_from(table_ids: Array, kind: String, group_ids: Array = []) -
|
||||||
if id == "":
|
if id == "":
|
||||||
m.toast("Couldn't save the template")
|
m.toast("Couldn't save the template")
|
||||||
else:
|
else:
|
||||||
m.toast("Saved template “%s”. Insert it from + Table ▾ → From template…" % out["name"])
|
m.toast("Saved template “%s”. Insert it from + Card ▾ → From template…" % out["name"])
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ func setup(p_main: Main) -> void:
|
||||||
_when.placeholder_text = "always (or e.g. @str >= 8)"
|
_when.placeholder_text = "always (or e.g. @str >= 8)"
|
||||||
_when.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
_when.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
_when.max_length = 200
|
_when.max_length = 200
|
||||||
_when.tooltip_text = "The pipe runs only when this is true. Every condition on the entry is checked once, before any of its pipes run."
|
_when.tooltip_text = "The pipe runs only when this is true. Every condition on the result is checked once, before any of its pipes run."
|
||||||
_when.add_theme_stylebox_override("normal", field_ok)
|
_when.add_theme_stylebox_override("normal", field_ok)
|
||||||
_when.add_theme_stylebox_override("focus", field_focus)
|
_when.add_theme_stylebox_override("focus", field_focus)
|
||||||
_when.text_changed.connect(func(_s: String) -> void: _check_when())
|
_when.text_changed.connect(func(_s: String) -> void: _check_when())
|
||||||
|
|
@ -162,7 +162,7 @@ func setup(p_main: Main) -> void:
|
||||||
v.add_child(hint)
|
v.add_child(hint)
|
||||||
|
|
||||||
var remove := Button.new()
|
var remove := Button.new()
|
||||||
remove.text = "Remove pipe"
|
remove.text = "Delete pipe"
|
||||||
remove.add_theme_font_size_override("font_size", 14)
|
remove.add_theme_font_size_override("font_size", 14)
|
||||||
var rn := Style.bordered(Style.box(Color(0, 0, 0, 0), 6, [10, 4, 10, 4]), 1, Style.DASH)
|
var rn := Style.bordered(Style.box(Color(0, 0, 0, 0), 6, [10, 4, 10, 4]), 1, Style.DASH)
|
||||||
var rh := Style.bordered(Style.box(Style.WARN_BG, 6, [10, 4, 10, 4]), 1, Style.DANGER_INK)
|
var rh := Style.bordered(Style.box(Style.WARN_BG, 6, [10, 4, 10, 4]), 1, Style.DANGER_INK)
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func build() -> void:
|
||||||
match table.kind:
|
match table.kind:
|
||||||
RollTable.KIND_CHOICE:
|
RollTable.KIND_CHOICE:
|
||||||
box.add_child(ModalCard.section("Question type"))
|
box.add_child(ModalCard.section("Question type"))
|
||||||
box.add_child(ModalCard.segmented(TableSettingsDialog.CHOICE_LABELS, RollTable.CHOICES.find(_choice), func(i: int) -> void:
|
box.add_child(ModalCard.segmented(Describe.choice_labels(), RollTable.CHOICES.find(_choice), func(i: int) -> void:
|
||||||
_choice = RollTable.CHOICES[i]
|
_choice = RollTable.CHOICES[i]
|
||||||
d._refresh()
|
d._refresh()
|
||||||
))
|
))
|
||||||
|
|
@ -255,17 +255,17 @@ func refresh() -> void:
|
||||||
_minmax_row.visible = _choice == "number"
|
_minmax_row.visible = _choice == "number"
|
||||||
var msg := ""
|
var msg := ""
|
||||||
if _choice != table.choice and table.choice == "pick":
|
if _choice != table.choice and table.choice == "pick":
|
||||||
msg = "Only the first option is kept, as the Answer row (its effects and pipes stay)."
|
msg = "Only the first option is kept, as the Answer result (its changes and pipes stay)."
|
||||||
elif _choice != table.choice and _choice == "pick":
|
elif _choice != table.choice and _choice == "pick":
|
||||||
msg = "The Answer row becomes the first option; two more are added."
|
msg = "The Answer result becomes the first option; two more are added."
|
||||||
elif _choice == "pick" and _options_mode == "vars" and table.is_dynamic():
|
elif _choice == "pick" and _options_mode == "vars" and table.is_dynamic():
|
||||||
msg = "The player picks one of the options from variables or a fixed extra, or Random."
|
msg = "The player picks one of the options from variables or a fixed extra, or Random."
|
||||||
elif _choice == "pick" and _options_mode == "fixed" and table.is_dynamic():
|
elif _choice == "pick" and _options_mode == "fixed" and table.is_dynamic():
|
||||||
msg = "Back to a fixed list: the Chosen row becomes an ordinary option (or goes, if it does nothing)."
|
msg = "Back to a fixed list: the Chosen result becomes an ordinary option (or goes, if it does nothing)."
|
||||||
elif _choice == "pick":
|
elif _choice == "pick":
|
||||||
msg = "The player picks one of the card's options, or Random."
|
msg = "The player picks one of the card's options, or Random."
|
||||||
else:
|
else:
|
||||||
msg = "The answer goes in {answer}; the Answer row's effects and pipes run after it."
|
msg = "The answer goes in {answer}; the Answer result's changes and pipes run after it."
|
||||||
_choice_note.text = msg
|
_choice_note.text = msg
|
||||||
_mark(_save_as, s["save_as"] == "" or TableSettingsRules._re(TableSettingsRules.SAVE_PATTERN).search(TemplateKit.probe(s["save_as"])) != null)
|
_mark(_save_as, s["save_as"] == "" or TableSettingsRules._re(TableSettingsRules.SAVE_PATTERN).search(TemplateKit.probe(s["save_as"])) != null)
|
||||||
var pick := _choice == "pick"
|
var pick := _choice == "pick"
|
||||||
|
|
@ -278,10 +278,10 @@ func refresh() -> void:
|
||||||
var desc := RollTable.new()
|
var desc := RollTable.new()
|
||||||
desc.options_from = s["options_from"]
|
desc.options_from = s["options_from"]
|
||||||
desc.options_where = s["options_where"]
|
desc.options_where = s["options_where"]
|
||||||
var how := "One option for %s, labelled with its name and value, after any fixed options. The Chosen row runs for whichever is picked; option, option_label and option_value hold it, e.g. @[option] += 1." % desc.options_description() \
|
var how := "One option for %s, labelled with its name and value, after any fixed options. The Chosen result runs for whichever is picked; option, option_label and option_value hold it, e.g. @[option] += 1." % desc.options_description() \
|
||||||
if TableSettingsRules.options_from_error(s["options_from"]) == "" else "Write @skill_* for each set variable with that prefix, or @contacts for each item of a list."
|
if TableSettingsRules.options_from_error(s["options_from"]) == "" else "Write @skill_* for each set variable with that prefix, or @contacts for each item of a list."
|
||||||
if not table.is_dynamic():
|
if not table.is_dynamic():
|
||||||
how += " A Chosen row is added first; the options already on the card stay as fixed extras."
|
how += " A Chosen result is added first; the options already on the card stay as fixed extras."
|
||||||
_opt_note.text = how
|
_opt_note.text = how
|
||||||
elif pick and table.is_dynamic():
|
elif pick and table.is_dynamic():
|
||||||
_opt_note.text = ""
|
_opt_note.text = ""
|
||||||
|
|
|
||||||
|
|
@ -224,8 +224,7 @@ func _make_kind_header(_build: bool) -> Control:
|
||||||
prompt_label = RichText.label("", 15, Style.INK, true)
|
prompt_label = RichText.label("", 15, Style.INK, true)
|
||||||
prompt_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
prompt_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
v.add_child(prompt_label)
|
v.add_child(prompt_label)
|
||||||
var kinds := {"pick": "Pick one", "number": "A number", "text": "Your words"}
|
var info := Describe.choice_label(table.choice)
|
||||||
var info := str(kinds.get(table.choice, ""))
|
|
||||||
if table.choice == "number":
|
if table.choice == "number":
|
||||||
info += " · %s to %s" % [RulesView.dice(table.min_expr, data, plain), RulesView.dice(table.max_expr, data, plain)]
|
info += " · %s to %s" % [RulesView.dice(table.min_expr, data, plain), RulesView.dice(table.max_expr, data, plain)]
|
||||||
if table.save_as != "":
|
if table.save_as != "":
|
||||||
|
|
@ -239,7 +238,7 @@ func _make_kind_header(_build: bool) -> Control:
|
||||||
var ol := Style.make_label(RulesView.options_line(table, data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.COPPER_DARK)
|
var ol := Style.make_label(RulesView.options_line(table, data, plain), Style.body_bold(true), 12, Style.DANGER_INK if bad else Style.COPPER_DARK)
|
||||||
ol.mouse_filter = Control.MOUSE_FILTER_PASS
|
ol.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||||
ol.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
ol.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||||
ol.tooltip_text = "One option per %s; the Chosen row runs for whichever is picked (option, option_label and option_value hold it)" % table.options_description()
|
ol.tooltip_text = "One option per %s; the Chosen result runs for whichever is picked (option, option_label and option_value hold it)" % table.options_description()
|
||||||
v.add_child(ol)
|
v.add_child(ol)
|
||||||
if not _build:
|
if not _build:
|
||||||
options_label = Style.make_label("", Style.body(true), 12, Style.MUTED)
|
options_label = Style.make_label("", Style.body(true), 12, Style.MUTED)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ static func check_badge(t: RollTable) -> String:
|
||||||
return d if d.length() <= 5 else "Roll"
|
return d if d.length() <= 5 else "Roll"
|
||||||
|
|
||||||
|
|
||||||
## The check card's sentence under its header, as BBCode: "Roll 2D +
|
## The check card's sentence under its header, as BBCode: "Roll 2d6 +
|
||||||
## Strength modifier, need [b]8 or more[/b]" (plain) or "[code]2d6 + dm(@str)
|
## Strength modifier, need [b]8 or more[/b]" (plain) or "[code]2d6 + dm(@str)
|
||||||
## vs 8+[/code]" style text.
|
## vs 8+[/code]" style text.
|
||||||
static func check_sentence(t: RollTable, board: TowerBoard, plain: bool) -> String:
|
static func check_sentence(t: RollTable, board: TowerBoard, plain: bool) -> String:
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ static func build(board: TowerBoard, table_id: String, opts: Dictionary = {}) ->
|
||||||
static func kind_line(t: RollTable) -> String:
|
static func kind_line(t: RollTable) -> String:
|
||||||
match t.kind:
|
match t.kind:
|
||||||
RollTable.KIND_CHOICE:
|
RollTable.KIND_CHOICE:
|
||||||
return "Choice card · " + {"pick": "pick an option", "number": "enter a number", "text": "enter text"}.get(t.choice, t.choice)
|
return "Choice card · " + Describe.choice_label(t.choice).to_lower()
|
||||||
RollTable.KIND_LOOP:
|
RollTable.KIND_LOOP:
|
||||||
return "Loop card"
|
return "Loop card"
|
||||||
RollTable.KIND_VARIABLE:
|
RollTable.KIND_VARIABLE:
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,6 @@ var _type_box: Control
|
||||||
var _card_box: Control
|
var _card_box: Control
|
||||||
var _kind: SettingsKindFields
|
var _kind: SettingsKindFields
|
||||||
|
|
||||||
const TITLES := {
|
|
||||||
RollTable.KIND_ROLL: "Table settings",
|
|
||||||
RollTable.KIND_CHOICE: "Choice settings",
|
|
||||||
RollTable.KIND_LOOP: "Loop settings",
|
|
||||||
RollTable.KIND_VARIABLE: "Variable settings",
|
|
||||||
RollTable.KIND_SHEET: "Sheet settings",
|
|
||||||
RollTable.KIND_ROUTER: "Router settings",
|
|
||||||
}
|
|
||||||
const CHOICE_LABELS := ["Which option", "How many", "Open ended"]
|
|
||||||
const OPTION_LABELS := ["Fixed list", "From variables (+ fixed extras)"]
|
const OPTION_LABELS := ["Fixed list", "From variables (+ fixed extras)"]
|
||||||
const LOOP_LABELS := ["Times", "While", "Until"]
|
const LOOP_LABELS := ["Times", "While", "Until"]
|
||||||
const LOOP_NOTES := {
|
const LOOP_NOTES := {
|
||||||
|
|
@ -53,7 +44,7 @@ const LOOP_NOTES := {
|
||||||
|
|
||||||
|
|
||||||
func _init(p_table: RollTable = null) -> void:
|
func _init(p_table: RollTable = null) -> void:
|
||||||
super._init(TITLES.get(p_table.kind, "Table settings") if p_table else "Table settings", 560.0)
|
super._init(Describe.kind_label(p_table) + " settings" if p_table else "Card settings", 560.0)
|
||||||
table = p_table
|
table = p_table
|
||||||
_ranged = table.is_ranged()
|
_ranged = table.is_ranged()
|
||||||
_card_mode = table.card_mode
|
_card_mode = table.card_mode
|
||||||
|
|
@ -147,7 +138,7 @@ func _build() -> void:
|
||||||
_card_mode = i == 1
|
_card_mode = i == 1
|
||||||
_refresh()
|
_refresh()
|
||||||
))
|
))
|
||||||
card_box.add_child(note("Entries are dealt like cards, without repeats, until the deck runs out."))
|
card_box.add_child(note("Results are dealt like cards, without repeats, until the deck runs out."))
|
||||||
var deck := VBoxContainer.new()
|
var deck := VBoxContainer.new()
|
||||||
deck.add_theme_constant_override("separation", 6)
|
deck.add_theme_constant_override("separation", 6)
|
||||||
deck.add_child(section("When the deck runs out"))
|
deck.add_child(section("When the deck runs out"))
|
||||||
|
|
@ -258,9 +249,9 @@ func _refresh() -> void:
|
||||||
if _ranged and not table.is_ranged():
|
if _ranged and not table.is_ranged():
|
||||||
msgs.append("Each entry gets a range sized by its weight; adjust them on the card.")
|
msgs.append("Each entry gets a range sized by its weight; adjust them on the card.")
|
||||||
if _ranged and TableSettingsRules.extra_pipe_count(table) > 0:
|
if _ranged and TableSettingsRules.extra_pipe_count(table) > 0:
|
||||||
msgs.append("A range takes one pipe, so extra pipes on an entry will be dropped.")
|
msgs.append("A range takes one pipe, so extra pipes on a result will be dropped.")
|
||||||
if not _ranged and table.is_ranged():
|
if not _ranged and table.is_ranged():
|
||||||
msgs.append("Ranges are removed; entries become plain picks.")
|
msgs.append("Ranges are removed; results become plain picks.")
|
||||||
_type_note.text = " ".join(msgs)
|
_type_note.text = " ".join(msgs)
|
||||||
_type_note.visible = not msgs.is_empty()
|
_type_note.visible = not msgs.is_empty()
|
||||||
var problem := ""
|
var problem := ""
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ static func save_dialog(tpl: Dictionary, on_save: Callable) -> ModalCard:
|
||||||
var rows: Array = []
|
var rows: Array = []
|
||||||
var params: Array = tpl.get("params", [])
|
var params: Array = tpl.get("params", [])
|
||||||
if params.is_empty():
|
if params.is_empty():
|
||||||
d.body.add_child(ModalCard.note("None found. Write {$name} in any text (card names, results, effects, expressions, prompts, variable names) and it becomes a parameter you fill in when inserting."))
|
d.body.add_child(ModalCard.note("None found. Write {$name} in any text (card names, results, changes, expressions, prompts, variable names) and it becomes a parameter you fill in when inserting."))
|
||||||
else:
|
else:
|
||||||
d.body.add_child(ModalCard.note("Found in the cards' text. Give each a label and a default for the insert form."))
|
d.body.add_child(ModalCard.note("Found in the cards' text. Give each a label and a default for the insert form."))
|
||||||
for p: Dictionary in params:
|
for p: Dictionary in params:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class_name TemplatePicker
|
class_name TemplatePicker
|
||||||
extends ModalCard
|
extends ModalCard
|
||||||
## "+ Table ▾ → From template…": the template list with search, each row
|
## "+ Card ▾ → From template…": the template list with search, each row
|
||||||
## showing its name, description and a small preview. The user's own
|
## showing its name, description and a small preview. The user's own
|
||||||
## templates can be renamed, exported and deleted here; built-in ones are
|
## templates can be renamed, exported and deleted here; built-in ones are
|
||||||
## read-only. Import… adds a template file. Insert asks for parameters (if
|
## read-only. Import… adds a template file. Insert asks for parameters (if
|
||||||
|
|
|
||||||
|
|
@ -243,16 +243,16 @@ func _show_report(report: Dictionary, problems: Array) -> void:
|
||||||
for p: Dictionary in problems:
|
for p: Dictionary in problems:
|
||||||
items.append({"table_id": p["table_id"], "entry_id": p["entry_id"],
|
items.append({"table_id": p["table_id"], "entry_id": p["entry_id"],
|
||||||
"text": "%s%s: %s" % [_table_label(p["table_id"]) if board.get_table(p["table_id"]) != null else "Board",
|
"text": "%s%s: %s" % [_table_label(p["table_id"]) if board.get_table(p["table_id"]) != null else "Board",
|
||||||
"" if str(p["entry_id"]) == "" else ", entry " + str(p["entry_id"]), p["text"]]})
|
"" if str(p["entry_id"]) == "" else ", result " + str(p["entry_id"]), p["text"]]})
|
||||||
_add_section("Problems", "Static checks", items, true)
|
_add_section("Problems", "Static checks", items, true)
|
||||||
# Errors: effect / expression errors, unset markers and action-limit halts
|
# Errors: effect / expression errors, unset markers and action-limit halts
|
||||||
items = []
|
items = []
|
||||||
for e: Dictionary in report["errors"]:
|
for e: Dictionary in report["errors"]:
|
||||||
items.append({"table_id": e["table_id"], "entry_id": e["entry_id"],
|
items.append({"table_id": e["table_id"], "entry_id": e["entry_id"],
|
||||||
"text": "%dx %s, entry \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]]})
|
"text": "%dx %s, result \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]]})
|
||||||
for e: Dictionary in report["unset_markers"]:
|
for e: Dictionary in report["unset_markers"]:
|
||||||
items.append({"table_id": e["table_id"], "entry_id": e["entry_id"],
|
items.append({"table_id": e["table_id"], "entry_id": e["entry_id"],
|
||||||
"text": "%dx %s, entry \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]]})
|
"text": "%dx %s, result \"%s\": %s" % [e["count"], e["table"], e["entry"], e["text"]]})
|
||||||
for why: String in report["halted"]:
|
for why: String in report["halted"]:
|
||||||
var top: Array = (report["longest"] as Dictionary).get("top", [])
|
var top: Array = (report["longest"] as Dictionary).get("top", [])
|
||||||
items.append({"table_id": str(top[0]["table"]) if not top.is_empty() else "", "entry_id": "",
|
items.append({"table_id": str(top[0]["table"]) if not top.is_empty() else "", "entry_id": "",
|
||||||
|
|
@ -274,7 +274,7 @@ func _show_report(report: Dictionary, problems: Array) -> void:
|
||||||
var ids: Array = report["unchosen_ids"][id]
|
var ids: Array = report["unchosen_ids"][id]
|
||||||
for k in texts.size():
|
for k in texts.size():
|
||||||
items.append({"table_id": id, "entry_id": ids[k], "text": "%s: \"%s\"" % [_table_label(id), texts[k]]})
|
items.append({"table_id": id, "entry_id": ids[k], "text": "%s: \"%s\"" % [_table_label(id), texts[k]]})
|
||||||
_add_section("Never chosen", "Entries no run picked", items, false)
|
_add_section("Never chosen", "Results no run picked", items, false)
|
||||||
|
|
||||||
if str(report["sample_sheet"]) != "":
|
if str(report["sample_sheet"]) != "":
|
||||||
var sheet := Style.make_label("Sample sheet", Style.caps(), 12, Style.MUTED)
|
var sheet := Style.make_label("Sample sheet", Style.caps(), 12, Style.MUTED)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ static func caption_for(step: Dictionary, board: TowerBoard = null, plain: bool
|
||||||
|
|
||||||
|
|
||||||
## A step's effect lines for its chip: in plain words, one per value that
|
## A step's effect lines for its chip: in plain words, one per value that
|
||||||
## changed ("Luck 2 → 1", "Town = Millbrook", "Cleared all Skills (3)") from
|
## changed ("Luck 2 → 1", "Town = Millbrook", "Reset all Skills (3)") from
|
||||||
## its why facts, then any errors from its log; else the log as it is.
|
## its why facts, then any errors from its log; else the log as it is.
|
||||||
static func effect_lines_for(step: Dictionary, board: TowerBoard, plain: bool) -> Array:
|
static func effect_lines_for(step: Dictionary, board: TowerBoard, plain: bool) -> Array:
|
||||||
var fx: Array = step.get("effects", [])
|
var fx: Array = step.get("effects", [])
|
||||||
|
|
@ -93,11 +93,11 @@ static func effect_lines_for(step: Dictionary, board: TowerBoard, plain: bool) -
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
## "Luck 2 → 1", "Town = Millbrook", "Loot cleared", "Cleared all Skills (3)".
|
## "Luck 2 → 1", "Town = Millbrook", "Loot cleared", "Reset all Skills (3)".
|
||||||
static func effect_fact_line(f: Dictionary, board: TowerBoard) -> String:
|
static func effect_fact_line(f: Dictionary, board: TowerBoard) -> String:
|
||||||
var lab := Describe.label(str(f.get("var", "")), board)
|
var lab := Describe.label(str(f.get("var", "")), board)
|
||||||
if f.has("count"):
|
if f.has("count"):
|
||||||
return "Cleared all %s (%s)" % [lab, Expr.format_value(f["count"])]
|
return "Reset all %s (%s)" % [lab, Expr.format_value(f["count"])]
|
||||||
var before: Variant = f.get("before")
|
var before: Variant = f.get("before")
|
||||||
var after: Variant = f.get("after")
|
var after: Variant = f.get("after")
|
||||||
if after == null:
|
if after == null:
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ func render() -> void:
|
||||||
var names := main.variable_names()
|
var names := main.variable_names()
|
||||||
_reset_all.disabled = names.is_empty()
|
_reset_all.disabled = names.is_empty()
|
||||||
if names.is_empty():
|
if names.is_empty():
|
||||||
var empty := RichText.label("No saved variables yet. A pipe that saves as [color=#%s]@name[/color], an effect such as [color=#%s]@hp = 10[/color], or [lb][lb]Table -> @name]] in a result, keeps its value here." % [Style.BRASS.to_html(false), Style.BRASS.to_html(false)],
|
var empty := RichText.label("No saved variables yet. A pipe that saves as [color=#%s]@name[/color], a change such as [color=#%s]@hp = 10[/color], or [lb][lb]Table -> @name]] in a result, keeps its value here." % [Style.BRASS.to_html(false), Style.BRASS.to_html(false)],
|
||||||
14, Style.ON_FELT_MUTED, false)
|
14, Style.ON_FELT_MUTED, false)
|
||||||
_list.add_child(empty)
|
_list.add_child(empty)
|
||||||
for n in names:
|
for n in names:
|
||||||
|
|
@ -134,7 +134,7 @@ func _var_row(name: String) -> Control:
|
||||||
var source := str(v.get("source", "")) if v is Dictionary else ""
|
var source := str(v.get("source", "")) if v is Dictionary else ""
|
||||||
var st := main.data.get_table(source) if source != "" else null
|
var st := main.data.get_table(source) if source != "" else null
|
||||||
var can := main.can_reroll_variable(name)
|
var can := main.can_reroll_variable(name)
|
||||||
var again := _icon_button("↻", ("Re-roll from %s" % Formatter.strip_tags(st.name)) if can else "Set by an effect or answer; no table to re-roll from")
|
var again := _icon_button("↻", ("Re-roll from %s" % Formatter.strip_tags(st.name)) if can else "Set by a change or answer; no table to re-roll from")
|
||||||
again.disabled = not can
|
again.disabled = not can
|
||||||
again.pressed.connect(func() -> void: main.reroll_variable(name))
|
again.pressed.connect(func() -> void: main.reroll_variable(name))
|
||||||
row.add_child(again)
|
row.add_child(again)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue