Docs: scales, columns, thread dice and rerolls (LOGIC §3e, §3f, §5.4; ARCHITECTURE §3c)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3cc925e42
commit
a97709128c
3 changed files with 65 additions and 1 deletions
|
|
@ -164,6 +164,18 @@ templates/ built-in templates · examples/logic_demo.json (original demo board)
|
|||
group `parent`; table `color`, `w`, `list_h`, `roll_floor`, `roll_ceiling`, `deck_empty_text`;
|
||||
result `page`, `image`, `cost {value, amount}`; thread `color`, `combine`, `pause`.
|
||||
|
||||
## 3c. Modules added 2026-11-10 (book tables)
|
||||
- **Scales:** `core/scales.gd` (store/read step names), `core/expr_base.gd` (Expression's base
|
||||
instance, split out of `expr.gd`: `_lit` turns a step name beside a scale into its number,
|
||||
`toward()`), `Effects._assign_scale`, `RollContext.scale_steps`.
|
||||
- **Columns:** `core/roll_columns.gd` (fills the other columns after a roll), `RollTable.columns`
|
||||
/ `column_rolls` / `cell_text`, `TableEntry.cells`.
|
||||
- **Thread dice and rerolls:** `TableEntry.pipe_dice` / `pipe_reroll`, `RollCards.pick_for`,
|
||||
`RollRange.roll_value(…, dice_text)`.
|
||||
- **Checks and IO:** `core/roll_lint_book.gd`; `core/roll_table_io.gd` (RollTable to/from JSON,
|
||||
split out of `roll_table.gd`). JSON keys: table `columns`, `column_rolls`, `steps`; result
|
||||
`cells`; thread `dice`, `reroll`. Spec: LOGIC.md §3e, §3f, §5.4.
|
||||
|
||||
## 4. Data and storage
|
||||
- **Collections:** `user://collections/<id>.json`, format_version 2 (`{format_version, id,
|
||||
name, tables, groups?}`). On Linux that's `~/.local/share/godot/app_userdata/TableTower/`.
|
||||
|
|
|
|||
|
|
@ -277,6 +277,37 @@ may pass values with `"with": {"<name>": "<expression>"}`.
|
|||
it needs no recursion and respects the 10,000-action limit; a halted roll still puts the
|
||||
values back.
|
||||
|
||||
## 3e. Columns (multi-column tables)
|
||||
|
||||
Many books print one table with several result columns (Size → Diameter, Gravity, Moons,
|
||||
Regions). A roll card may have `columns`: `[{name, save_as?, when?}]`. Column 0 is each
|
||||
result's own `text`; the other columns are the result's `cells` (Strings, full text: `[[refs]]`,
|
||||
`{@x}`, `{= 2d10*10}`).
|
||||
|
||||
- `column_rolls: "row"` (the default): one roll picks the row, and every column reads it.
|
||||
- `column_rolls: "each"`: "roll 1d10 for each of …". Column 0 is the card's own roll, so its
|
||||
result's changes and threads happen as usual. Every other column is rolled on its own, the
|
||||
same way (a thread's dice and rerolls included, §3f). Those extra rolls don't run changes or
|
||||
threads.
|
||||
- Left to right, each column's text is saved under its `save_as` before the next one starts,
|
||||
so a later column's `when` ("only roll Life if Atmosphere is at least Thin") can read it.
|
||||
A column whose `when` is false (or fails, with a red line) is skipped and saves nothing.
|
||||
- The node gets `columns: [{name, text, index, value?, skipped?}]` and the summary
|
||||
"Resources: Rich · Water: Plentiful". Extra column rolls add `roll` why facts with a
|
||||
`column` key. Code: `core/roll_columns.gd`.
|
||||
|
||||
## 3f. Threads that roll with other dice or roll again
|
||||
|
||||
Two more thread options (stored on the thread object):
|
||||
- **`dice`** ("Roll it with 3d10+70 instead"): a ranged roll card is rolled with these dice
|
||||
(or an expression) instead of its own; its modifier and limits still apply, and a total past
|
||||
the ends counts as the end result. Other card kinds ignore it (a lint hint).
|
||||
- **`reroll`** ("Roll again if it comes up: 96–00"): result ids of the target card. When one
|
||||
comes up, the roll is made again (up to 100 times) and the skipped rolls are listed in a
|
||||
`reroll` why fact (`skipped: [{value, text}]`). If every result is skipped, the node stops
|
||||
with "This thread rolls again on every result" (and the board check says so). Repeated
|
||||
rolls (a count) reroll each roll separately. Code: `RollCards.pick_for()`.
|
||||
|
||||
## 4. Expressions
|
||||
|
||||
Expressions appear in loop rules, pipe counts, pipe conditions, router cases, `min`/`max`,
|
||||
|
|
@ -368,6 +399,21 @@ statement shows a red marker in the tray and in Build mode rather than stopping
|
|||
`{@name?}` marker, a bad name an error marker.
|
||||
- The existing `{@var|Table}`, `{hero}` and `[[refs]]` work as before.
|
||||
|
||||
### 5.4 Scales (ordered steps)
|
||||
A variable card with `var_type: "scale"` lists `steps`, lowest first (Supercold, Cold,
|
||||
Temperate, Hot, Superhot). Code: `core/scales.gd`, `ExprBase._lit`.
|
||||
- The value is stored as the step's name, so `{@climate}` shows "Cold".
|
||||
- In expressions it reads as the step's number (1 = the first step; unset reads 0). A quoted
|
||||
step name next to it reads as that step's number too: each text literal goes with the
|
||||
nearest `@variable` (left first), and turns into a number only when that variable is a
|
||||
scale and the text is one of its steps. So `@atmo >= "Thin"`, `@climate = "Cold"` and
|
||||
`@climate = "Cold" and @atmo >= "Thin"` all work; `"Cold" + "!"` stays text.
|
||||
- Saving a number picks that step, stopping at the ends; saving a name matches without
|
||||
caring about capitals; any other text is kept as it is.
|
||||
- Changes: `@climate += 1` / `-= 2` move steps; `@climate = toward(@climate, "Temperate")`
|
||||
moves one step toward a step; `@atmo = max(@atmo, "Medium")` raises to at least,
|
||||
`min(…)` lowers to at most. `*=` and `/=` are refused.
|
||||
|
||||
## 6. Sheet cards
|
||||
A sheet card holds one template (its single entry's text, multi-line BBCode). On the board it
|
||||
always shows the template rendered with current values, so a character sheet stays up to
|
||||
|
|
@ -417,14 +463,18 @@ Table keys:
|
|||
- `inputs`: `[{"name": "tier", "label": "Tier", "default": "1"}]` (any card; `label` and
|
||||
`default` left out when empty)
|
||||
|
||||
- `steps` (scale variable cards, Array of Strings), `columns` and `column_rolls` (§3e)
|
||||
|
||||
Entry keys:
|
||||
- `cells` (Array of Strings, columns 1.. of a card with columns)
|
||||
- `effects` (String)
|
||||
- `when` (String, router cases; empty or missing is Otherwise)
|
||||
- `show_if` (String, pick options; empty or missing is always shown)
|
||||
|
||||
Pipe objects may have `"count": "<expression>"`, `"when": "<expression>"`,
|
||||
`"otherwise": true` (left out when the pipe has a `when`) and
|
||||
`"with": {"<input name>": "<expression>"}` (§3d).
|
||||
`"with": {"<input name>": "<expression>"}` (§3d), `"dice": "3d10+70"` and
|
||||
`"reroll": ["<result id>", …]` (§3f).
|
||||
|
||||
## 10. Why trace
|
||||
|
||||
|
|
@ -444,6 +494,7 @@ so history keeps them. The key is left out when a node has no facts. Each fact h
|
|||
| `effect` | any node whose entry has effects, one per statement that ran | `var` (the real target, `@[…]` resolved), `op` (`=`, `+=`, `-=`, `*=`, `/=`, `reset`), `before`, `after` (null when unset); a prefix reset has `count` instead |
|
||||
| `when` | the node whose entry has the pipe, one per conditional pipe | `to` (table id), `expr`, `values`, `result`, `error`? |
|
||||
| `otherwise` | likewise, one per otherwise pipe | `to`, `result` |
|
||||
| `reroll` | a node a thread rolled again (§3f) | `skipped: [{value, text}]`; `column` on an extra column's roll |
|
||||
|
||||
`values` maps each variable the expression reads (`"@luck"`, or a chain name such as `"tier"`) to
|
||||
its value when it was evaluated (null when unset); indirect `@[…]` names aren't listed. The
|
||||
|
|
|
|||
1
tests/test_book_tables.gd.uid
Normal file
1
tests/test_book_tables.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cl4oubyynnt0v
|
||||
Loading…
Reference in a new issue