TableTower/examples/logic_demo.json
RobinFiredrake dbbb9750eb Conditional pipes and router cards
Pipes can carry "when" (Only if) and "otherwise". When an entry is
chosen, its effects run, its text expands, then every pipe condition and
count is evaluated once as a snapshot before any pipe runs; when pipes
run if true, otherwise pipes if no when pipe was true, plain pipes
always. Condition errors count as false and show as error lines.

New router card (kind "router"): its entries are cases with an
entry-level "when"; the first true case is chosen (empty = Otherwise),
and "No case matched" stops the node. One action. JSON round trip for
entry/pipe when and pipe otherwise, including JsonIO.canonical and
edge labels. Roller.lint_pipes() and Roller.lint_router() for board
checks. A pick choice's save_as is now stored before the snapshot.

UI: Only if / Otherwise in the pipe popover with live validation, pipe
labels ("if @str >= 8", "otherwise") and a source-end diamond on
conditional pipes, router card with fork icon, per-case condition rows,
case editing / reordering in Build, router settings, "+ Table" entry,
router cases in table previews. Logic demo now routes through a router.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 17:53:00 -06:00

157 lines
4.4 KiB
JSON

{
"format_version": 2,
"id": "logic-demo",
"name": "Logic demo",
"tables": [
{
"id": "start",
"name": "Start a delve",
"x": 40,
"y": 40,
"details": "Click the die to send a new delver down the stairs. It resets the variables, then asks two questions.",
"entries": [
{
"id": "e1",
"text": "A new delver steps up",
"effects": "reset @hp; reset @gold; reset @luck; reset @loot",
"pipes": ["name_q"]
}
]
},
{
"id": "v_hp",
"name": "Hit points",
"kind": "variable",
"x": 40,
"y": 640,
"details": "Traps and fights take these away.",
"var_name": "hp",
"initial": "10",
"entries": []
},
{
"id": "v_gold",
"name": "Gold",
"kind": "variable",
"x": 360,
"y": 640,
"var_name": "gold",
"initial": "0",
"entries": []
},
{
"id": "v_luck",
"name": "Luck",
"kind": "variable",
"x": 680,
"y": 640,
"details": "Added to every room check.",
"var_name": "luck",
"initial": "0",
"entries": []
},
{
"id": "v_loot",
"name": "Loot",
"kind": "variable",
"x": 1000,
"y": 640,
"var_name": "loot",
"var_type": "list",
"entries": []
},
{
"id": "name_q",
"name": "Name your delver",
"kind": "choice",
"choice": "text",
"prompt": "Who goes down the stairs?",
"save_as": "@name",
"x": 360,
"y": 40,
"entries": [
{ "id": "e1", "text": "Answer", "pipes": ["rooms_q"] }
]
},
{
"id": "rooms_q",
"name": "How many rooms?",
"kind": "choice",
"choice": "number",
"prompt": "[b]{@name}[/b] studies the map. How many rooms will they try?",
"save_as": "@rooms",
"min": "1",
"max": "5",
"x": 360,
"y": 270,
"entries": [
{ "id": "e1", "text": "Answer", "pipes": ["explore"] }
]
},
{
"id": "explore",
"name": "Explore",
"kind": "loop",
"loop_expr": "@rooms",
"x": 680,
"y": 40,
"details": "One room check per room the player chose, then the way out.",
"entries": [
{ "id": "e1", "text": "Room {i}", "pipes": ["room_check"] },
{ "id": "e2", "text": "Head back up", "pipes": ["climb"] }
]
},
{
"id": "room_check",
"name": "Room check",
"x": 1000,
"y": 40,
"dice": "2d6 + @luck",
"details": "2d6 plus Luck. Low rolls hurt, high rolls pay.",
"entries": [
{ "id": "e1", "text": "A trap snaps shut", "effects": "@hp -= 2", "range": [2, 6] },
{ "id": "e2", "text": "Dust and echoes", "range": [7, 9] },
{ "id": "e3", "text": "A glinting cache", "effects": "@gold += 2d6\n@loot += \"gem\"", "range": [10, 12] }
]
},
{
"id": "climb",
"name": "On the way up",
"kind": "router",
"x": 680,
"y": 330,
"details": "Checks the delver's state once, top to bottom: the first case that's true is the one that happens.",
"entries": [
{ "id": "e1", "text": "Carried up by a passing patrol", "when": "@hp <= 0", "effects": "@hp = 1", "pipes": ["report"] },
{ "id": "e2", "text": "Pockets heavy with gold", "when": "@gold >= 12", "details": "The guard at the top has noticed.", "pipes": ["way_out"] },
{ "id": "e3", "text": "Up the stairs", "pipes": ["way_out"] }
]
},
{
"id": "way_out",
"name": "Way out",
"kind": "choice",
"prompt": "{@name} has {@gold} gold and {@hp} HP left. How do they leave?",
"x": 1000,
"y": 330,
"entries": [
{ "id": "e1", "text": "Sneak past the guard", "details": "Quiet and slow. Luck grows.", "effects": "@luck += 1", "pipes": ["report"] },
{ "id": "e2", "text": "Fight through", "details": "Costs some blood.", "effects": "@hp -= 1d3", "pipes": ["report"] },
{ "id": "e3", "text": "Pay the toll", "details": "Ten gold, if they have it.", "effects": "@gold -= min(@gold, 10)", "pipes": ["report"] }
]
},
{
"id": "report",
"name": "Delve report",
"kind": "sheet",
"x": 1320,
"y": 330,
"entries": [
{
"id": "e1",
"text": "[b]{@name}[/b] the delver\nRooms tried: {@rooms}\nHP {@hp} · Gold {@gold} · Luck {@luck}\nLoot: {@loot}\nScore: {= @gold + @hp * 5}"
}
]
}
]
}