Compare commits

...

35 commits

Author SHA1 Message Date
8abe90b407 Splash screen: the fortune teller on the Tarot purple
The boot splash shows the mascot art on its own background colour
(#390853), so it blends edge to edge; the app icon is the mascot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 20:14:43 -06:00
c97a87d9c9 DESIGN.md: audits done; remaining size candidates; TestBase
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:57:08 -06:00
82d67eb64f Size audit: split ChoiceDialog and TableCard into helpers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:56:20 -06:00
29d6d4eae9 Tests: extract shared TestBase (guard, main loading, check helpers, summary)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:53:22 -06:00
03a192f47d Split inspector.gd: result, thread and sync helpers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:51:23 -06:00
97258b0d2b Size audit: split MainLayout out of Main, EditLabels out of EditHistory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:45:56 -06:00
b1525687ad Size audit: split Describe and JsonIO into helper files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:41:08 -06:00
9f06af9676 Fix: resize corner caught clicks far outside cards; left-drag selects in Play too
CardGrip._has_point only checked 'right of and below' the corner, and
Godot asks controls about points outside their box, so everything to the
bottom-right of every card acted as its resize handle. It's now bounded to
the corner square inside the card.

A left-drag on empty space now draws a selection box in Play as well as
Build, and selected cards move together in both; panning is middle-drag or
Space+drag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:38:15 -06:00
4a4dc62c3d DESIGN.md: all twelve plan steps done on tarot; decisions waiting on the user
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:25:06 -06:00
b1616373be Help: topics for every new feature, a cheat sheet, and Try a demo spreads
Twelve new Help topics (menus, selecting and resizing, nested groups,
themes, List view, the Book, rolling more than once, pausing, costs,
one table adjusting another, sheets and saving, pictures, phones), and a
Keyboard shortcuts topic split into keys, mouse and touch. Topics with
[demo]key[/demo] get a 'Try a demo spread' link: DemoSpreads builds a
small example, DemoMode shows it unsaved and unlisted with Keep a copy
and Back to my spread. --demo=KEY opens one from the command line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:24:57 -06:00
57041d41b3 Pictures on results and Book pages; export/import keeps everything new
A result or page can have a picture (TableEntry.image, BookPage.image),
chosen from a file, shrunk to 512 px and kept in the spread file as WebP
under "images" (BoardImages; only used pictures are saved). It shows as
a thumbnail on the card row and in the details pop-up, and comes with a
page. Imported BBCode still can't point at files.

Fix: the Table Tarot JSON export and import (JsonIO.canonical) dropped
every key it didn't know, losing the Book, pictures, card colours and
sizes, limits, nesting, costs and thread options. They now pass through;
a round-trip test covers them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:21:05 -06:00
8fd2b2b8c9 Sheets: a line-per-value helper and Save as a file (Text, Markdown, web page)
The Sheet card's inspector adds a 'Label: {@value}' line for any value
picked. The tray's Copy ▾ gets Save as a file: the roll's sheet (or one
line per result) as Text, Markdown, or an HTML page a browser can print
to PDF, with bold, italics and colours kept where the format allows
(SheetExport). The test runner prints a compile error shared by many
suites once, with the suite names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:17:27 -06:00
61395fa573 DESIGN.md: plan status after steps 7-9; suggested audits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:15:28 -06:00
ef1dc846d1 Adjust later rolls: Never below / Never above on ranged cards
RollTable.roll_floor and roll_ceiling (numbers or values) limit a ranged
roll's total after its modifier (RollRange.limit). An earlier result's
change (e.g. @atmo_min = 7) can thereby raise or cap a later card's roll.
The inspector's Limits rows take a number or a value; the Why trace says
'raised to 7 (never below Atmo min)'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:15:09 -06:00
25018ebdf3 Costs on choice options
A pick option can cost an amount of a value (TableEntry.cost_value and
cost_amount, JSON "cost"; the inspector's Costs row). The pop-up shows
the cost, and greys the option out with the reason when there isn't
enough; Random never picks it. Picking it takes the amount away as an
ordinary change (RollCosts). A costly Reroll option that threads back to a
card gives spend-a-point rerolls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:12:06 -06:00
fe133d3a94 Pause: a thread can wait for the player
A thread with 'Wait for me first' (TableEntry.pipe_pause, JSON "pause")
stops the roll before it runs (Roller.OP_PAUSE, a "pause" request). The
tray shows Continue ▸ and Stop here; starting another roll sets the paused
one aside with its chip kept, and Continue makes it the current roll again
(RollPauses; each roll's token lives in a holder so it can be revived).
Stop here ends the roll and the chip says where it stopped. Headless rolls
continue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:10:11 -06:00
a527bf545c Batches: Roll several times… on a card's menu
Rolls the card's whole chain a chosen number of times (up to 100) and
shows every result together, with Copy all. Each run asks its questions,
changes values and decks, and goes into Earlier like a normal roll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:07:37 -06:00
1ca38f35b6 Combine repeated rolls: add together, keep highest/lowest, or let me choose
A thread that rolls its card more than once gets a 'then' choice
(TableEntry.pipe_combine, JSON "combine"): keep every roll (as before),
add them together, keep the highest or lowest, or let the player choose
(the choice pop-up). The repeats hold their own threads until the combine
step (Roller.OP_COMBINE, RollCombine) keeps one, which then follows its
threads; save-as keeps the total or the kept result. Set-aside rolls show
faded in the tray.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:06:55 -06:00
193794a9e0 The Book: reusable results (Pages) to drag onto tables
BookPage (text with BBCode, details, tags, a name) lives in the spread file
under "book"; a result linked to a page (TableEntry.page) follows its
text and details, so one edit reaches every copy. The Book panel (View ▾,
☰ or right-click) lists pages with search over names, text and tags, and
edits the selected page with a live preview. Drag a page onto a result to
link it, or onto a card to add it as a new result. The inspector offers
Save to the Book, or shows the page with Unlink; editing a result's own
text unlinks it; linked rows show a §. Undo covers the Book.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 19:02:46 -06:00
2fe9317b27 Phone layout and touch gestures
MobileLayout (Android, or --mobile to try it on a desktop): the List fills
the screen with a Spread/List swap; the bar drops the title, hint, zoom,
View, Help and Play/Build (the last three move into ☰); the tray hides its
Earlier column and shortens Roll again; DPI scaling. TouchInput (every
platform): a long press is a right-click, two fingers pan and pinch-zoom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:58:33 -06:00
0ede1d7cd1 List view: the spread as a list with folders
A left-docked panel (View ▾ → List view, ☰ or right-click the spread)
lists every card, with groups as folders. Rows show threads in and out
(hover for where they lead) and a Roll cell; click selects in Build,
double-click shows the card on the spread, right-click opens its menu.
Drag to reorder (the spread's own order, saved and undoable), onto a
folder to move in, folder into folder to nest. Own search, + Folder,
resizable edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:50:32 -06:00
5d427d3856 Nested groups: groups can hold groups
TableGroup.parent (JSON "parent") puts a group inside another. Grouping a
selection that includes groups nests them (the new group goes in the group
they all share). A collapsed group hides every card and group inside it and
stands in for them on threads; moving, deleting, search, focus (opens every
collapsed group around a card), packing, undo and templates all work
through the nesting. Ungroup hands the contents to the outer group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:47:05 -06:00
1199fafcf9 DESIGN.md: plan status after steps 1-6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:43:31 -06:00
f00f36b598 Deck mode: faded drawn results, Wait for Shuffle with an Empty result
Deck-mode cards fade the results already drawn until the deck is shuffled.
The inspector gets a Deck mode section (Draw without repeats; when empty,
Shuffle by itself or Wait for Shuffle; the Empty result's text, saved as
deck_empty_text). A waiting empty deck gives its Empty result in normal
ink, not as an error. Reshuffle reads Shuffle everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:43:16 -06:00
1358678889 Small UI items: bold chip sources, thread lists, backwards ranges, template replace
- Tray chips name their card in bold, dark text; how it was rolled follows, muted.
- The card inspector lists Threads in (from which card and result) and
  Threads out (from which result, to which card); click one to select it.
- A range typed backwards (start above end) is no longer swapped: the card
  warns and its die is greyed out until it's fixed.
- Save as template… can replace one of your templates; the template list's
  Rename became Edit… (name, description, fill-in labels).
- Spread ▾ export: the Table Tarot file first, other formats in a submenu.
- Test spread section hints in plain words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:40:53 -06:00
608641df66 Zoomed-out cards: names as tooltips, drag, right-click, and click to roll in Play
Below 45% zoom a CardShield covers each card and collapsed group: the name
shows as a tooltip, dragging moves it, right-click opens its menu, and in
Play a click rolls it. Zoom back in and the card's own controls return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:37:26 -06:00
748ffad21a Right-click menus and a ☰ actions menu, from one shared action list
Actions builds the menu for a card, thread, group or the empty spread;
the card and group ⋯ buttons, right-click, and the top bar's ☰ menu all
use it. The spread menu adds a card where you clicked, groups the
selection, searches, shuffles all decks (new), fits the spread and opens
the theme. Cards and threads get a Colour ▸ submenu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:35:24 -06:00
d85a6018ce Resizable cards: drag the corner grip for width and list height
The grip in each card's bottom-right corner sets RollTable.width and
list_height (saved as "w" and "list_h"); with a height the results
list scrolls. Double-click the grip for the automatic size again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:32:09 -06:00
9fcaf5c123 No more drag walls; drag box selects; middle/Space-drag pans; groups move with the selection
Cards, selections, new cards and inserted templates may sit anywhere,
including left of or above the old edge. In Build a drag on empty space
draws a selection box (Ctrl/Shift adds); middle-drag or Space+drag pans
(a plain drag still pans in Play). The box also picks up collapsed groups
it touches and expanded groups it covers, and dragging any selected card
or group moves the whole selection (MainSelection). Ctrl-click a group's
title to add it to the selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:30:13 -06:00
781aaf1be8 Magic sparkles on the thread pulse and on landing results
Sparkles (CPU particles, mobile-safe) in the theme's GLOW colour: a trail
follows the pulse up each thread, and a short burst plays over a result as
it lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:26:02 -06:00
ea1e7a6492 Rename to Table Tarot in the UI: spreads, threads, deck mode, branch, repeat
User-facing text only; code names, JSON keys and the project's internal
name (and so the user:// folder) are unchanged. The Collection card kind
keeps its name until a new one is chosen. The window title says Table
Tarot; the top bar shows the theme's logo (the fortune teller, drawn from a
copy of the art without its background square); the app icon is the
mascot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:24:23 -06:00
f9aa66d74d Beaded card frames and per-card / per-thread colours
CardFrame draws the user's frame_corner/frame_border art around each card,
tiling the bead strip so it fits any size; a small shader recolours the art
to the theme's trim (or the card's own colour). Themes choose the border
(Tarot: beaded, Felt: plain). Cards (RollTable.color) and threads
(TableEntry.pipe_color, JSON "color") can have their own colour from the
inspector's Colour row (presets, Theme, or any colour).

tools/run_tests.sh imports first and prints at most 8 lines per failing suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:20:46 -06:00
ebe81d9f1e Theme system: runtime colour tokens, theme sets and a Theme dialog
Style's colours become static vars named by role (BG, PANEL, CARD, THREAD,
ACCENT, TRIM, GLOW…) instead of materials (felt, copper, brass), so a theme
can replace them. Stray hard-coded colours moved into tokens.

ThemeStore applies built-in sets (Tarot, the new default: jewel-purple
cloth with a shine; Felt, the old look) and the user's own sets from
user://themes/. Fills for the background and panels can be gradients; the
background pattern (dots, stars, none) and logo are per set. View ▾ →
Theme… edits a set; changes to a built-in save as a new set. Using a theme
reloads the UI and keeps the open spread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:10:16 -06:00
0c9ab1aa71 Slim DESIGN.md to a status page; add parallel test runner
DESIGN.md (read every session) keeps status, names and the agreed plan;
architecture and history move to ARCHITECTURE.md and HISTORY.md, read on
demand. tools/run_tests.sh runs the suites in parallel and fails on SCRIPT
ERROR as well as on a missing PASS line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 18:03:10 -06:00
97305889b9 Let ranged results pipe into several cards (fan-out)
Dropping a pipe from a range on a ranged table replaced the range's
existing pipe. Ranges now add pipes like weighted results do, so one
result can feed several tables in one roll. DESIGN.md records the
change and the decision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 12:22:56 -06:00
235 changed files with 10572 additions and 3984 deletions

View file

@ -1,4 +1,4 @@
# TableTower
# Table Tarot
Random roll tables for tabletop games, built as a board of table cards joined by pipes.
Click the die on any table and the result flows down its pipes into the next table.
@ -84,7 +84,7 @@ godot --path .
Double-click the edge to go back to the default size.
- **Collapsing:** the arrow beside a table's name collapses it. A collapsed table still shows
its last result. **View ▾ → Collapse all tables / Expand all tables** does every table at once.
- **Groups:** in Build mode, Ctrl- or Shift-click card headers (or Ctrl-drag on the felt) to
- **Groups:** in Build mode, Ctrl- or Shift-click card headers (or drag a box on empty space) to
select cards, then **Group** (Ctrl+G, the selection bar, or **+ Card ▾**). A group is a
frame behind its cards; drag its title bar to move them all, drop a card into a frame to
add it, drag it out to take it out. The chevron collapses the group into one compact

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://jank70o552kk"
path="res://.godot/imported/fortune_teller.png-51e43d125e970eb5dc5acd92909929b2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/fortune_teller.png"
dest_files=["res://.godot/imported/fortune_teller.png-51e43d125e970eb5dc5acd92909929b2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,625 @@
<svg xmlns="http://www.w3.org/2000/svg" width="2048" height="2048" viewBox="0 0 2048 2048">
<!-- Traced from fortune_teller.png with potrace, one layer per palette colour. -->
<rect id="background" width="2048" height="2048" fill="#390853"/>
<path id="outline" fill="#1c0329" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M11542 20143 c-113 -359 -208 -671 -248 -813 -25 -91 -58 -205 -72
-254 l-27 -90 -85 -22 c-47 -12 -111 -32 -142 -43 -32 -12 -74 -21 -95 -21
-21 0 -56 -5 -78 -10 -104 -24 -254 -31 -308 -15 -96 28 -863 108 -1202 125
-115 5 -200 14 -235 25 -184 55 -795 -66 -1095 -218 -143 -72 -382 -273 -706
-597 -124 -124 -304 -299 -399 -390 -861 -820 -1579 -2044 -1880 -3205 -107
-412 -161 -852 -121 -983 22 -71 45 -112 64 -112 12 0 63 -78 56 -84 -2 -1
-20 -12 -39 -24 -183 -110 -182 -371 2 -480 45 -27 37 -52 -12 -39 -63 17 -65
1 -11 -83 l48 -75 6 -183 6 -182 -38 -28 c-51 -35 -144 -87 -153 -84 -11 3
-10 -6 2 -29 14 -25 75 -25 146 -1 l51 18 6 -80 c7 -89 7 -92 -21 -77 -30 16
-98 13 -116 -5 -23 -22 2 -78 54 -124 50 -44 50 -42 -10 -69 -27 -12 -50 -27
-50 -31 0 -17 41 -31 72 -25 l30 7 -29 -43 c-50 -74 -54 -85 -42 -113 25 -54
44 -44 136 68 36 44 34 46 49 -59 7 -54 17 -45 29 27 l6 37 36 -25 c20 -13 41
-23 47 -21 16 6 9 104 -10 156 l-17 44 32 26 c36 30 39 41 11 41 -18 0 -17 4
10 63 52 109 29 115 -72 18 l-38 -35 0 29 c0 45 -11 75 -26 75 -11 0 -14 19
-14 81 0 80 0 81 40 126 58 66 83 141 77 225 -7 81 -55 203 -97 243 -43 41
-41 77 2 64 41 -11 109 -12 127 0 24 16 -4 48 -49 55 -22 3 -59 14 -81 23
l-41 16 7 136 c4 85 3 166 -4 216 -10 69 -9 80 4 88 9 5 20 19 25 31 11 30
147 122 233 159 97 40 197 56 357 57 l135 0 48 -89 c97 -182 186 -445 224
-666 28 -163 25 -598 -5 -769 -30 -167 -73 -309 -127 -421 -53 -111 -67 -124
-157 -147 -215 -55 -525 -278 -542 -391 -4 -26 -3 -54 3 -65 8 -16 4 -21 -27
-36 -203 -97 -548 -475 -714 -782 -23 -43 -90 -146 -147 -229 -247 -353 -342
-508 -591 -965 -762 -1396 -1201 -2048 -1753 -2604 -182 -183 -380 -356 -408
-356 -47 0 -687 -62 -783 -75 -143 -21 -180 -37 -211 -90 -27 -45 -33 -100
-13 -108 7 -2 54 4 103 14 82 16 920 83 2075 164 1186 83 2309 132 3595 154
562 10 3034 10 3870 0 352 -4 1205 -15 1895 -23 4425 -56 6175 -59 7112 -11
l276 14 128 63 c112 55 162 88 164 109 0 3 -73 32 -162 64 -185 66 -172 64
-671 85 l-258 10 -102 79 c-56 43 -145 108 -196 145 -103 72 -113 84 -559 581
-152 170 -365 402 -472 515 -626 657 -1251 1471 -1453 1892 -128 268 -223 421
-438 709 -349 467 -616 760 -816 892 -60 40 -89 65 -83 71 33 33 -24 107 -130
170 -153 91 -744 357 -859 387 -109 28 -261 148 -434 343 l-61 68 64 -7 c345
-37 665 -85 1275 -189 225 -39 408 -59 734 -81 343 -23 361 -21 492 46 36 18
52 39 29 39 -6 0 -9 82 -9 218 0 461 -58 696 -280 1139 -347 693 -847 1301
-1403 1706 -70 51 -108 85 -110 99 -2 17 -40 41 -178 109 -406 203 -624 279
-985 343 l-180 33 -32 144 c-31 136 -62 327 -98 592 l-16 117 129 128 c156
155 228 258 272 389 47 144 23 210 -68 184 -16 -5 -96 -5 -178 0 -82 4 -158 8
-170 8 -20 1 -21 8 -28 169 -3 92 -12 204 -19 250 l-13 83 60 49 c105 84 214
202 232 251 53 146 62 203 53 325 -19 253 -95 534 -224 827 -48 109 -108 197
-120 177 -5 -8 -11 -8 -19 -1 -12 10 -86 -65 -86 -87 0 -10 -224 -255 -298
-326 l-40 -38 45 133 c103 310 128 496 97 746 -5 48 -11 57 -62 104 -114 104
-248 178 -324 179 -27 0 -38 4 -38 15 0 8 -8 15 -18 15 -15 0 -25 -21 -50 -97z
m79 -1560 c-10 -16 -40 -48 -65 -73 -59 -56 -59 -70 -2 -70 59 0 61 -7 24 -80
-29 -56 -31 -63 -15 -71 20 -12 5 -49 -33 -84 -12 -11 -36 -40 -53 -64 -27
-40 -31 -42 -43 -27 -15 22 -9 42 23 78 16 17 23 33 19 45 -4 12 5 37 24 66
40 63 39 77 -5 77 -25 0 -37 6 -46 21 -10 20 -4 28 56 85 42 40 65 69 62 78
-4 9 6 20 26 30 45 22 51 20 28 -11z m83 -1626 c3 -18 1 -48 -5 -65 -8 -24 -8
-36 1 -47 14 -16 4 -39 -33 -73 -25 -24 -25 -24 -36 -4 -16 30 -14 52 11 99
20 37 21 44 9 67 -11 21 -12 28 -1 41 22 27 47 18 54 -18z m-1056 -48 c88 -40
231 -93 307 -114 117 -32 191 -58 289 -102 277 -124 459 -165 738 -167 205 -2
186 -14 -54 -33 -137 -12 -139 -13 -131 -116 5 -70 12 -94 49 -167 25 -49 50
-119 59 -165 20 -94 41 -140 69 -154 16 -8 -2 -9 -64 -5 -47 4 -86 8 -88 9 -1
1 3 35 9 76 20 140 -56 328 -206 504 -43 51 -44 51 -139 69 -77 14 -100 23
-115 42 -13 17 -39 28 -87 39 -286 66 -551 173 -707 286 -55 40 -19 39 71 -2z
m-2208 -149 c349 -30 783 -217 972 -419 70 -75 229 -324 215 -337 -9 -9 -414
245 -617 386 -252 176 -532 270 -800 270 -126 0 -173 10 -164 34 9 25 103 57
188 65 44 5 83 9 86 10 3 0 57 -4 120 -9z m-686 -192 c-4 -7 -20 -32 -36 -56
-46 -68 -95 -179 -127 -290 -16 -57 -37 -115 -47 -129 -37 -58 -2 -378 78
-698 134 -538 324 -976 836 -1920 232 -427 344 -653 411 -830 47 -125 51 -130
80 -133 27 -3 32 -10 60 -80 l29 -77 74 0 c134 0 681 25 783 36 55 6 187 26
294 45 107 19 220 34 251 34 32 0 111 9 177 21 65 12 172 22 238 24 66 1 171
8 233 15 88 11 126 11 176 2 35 -7 81 -12 102 -12 22 0 50 -7 64 -15 14 -8 33
-17 42 -21 16 -6 20 -35 7 -48 -13 -14 -141 -26 -160 -16 -15 8 -63 8 -175 -1
-140 -11 -156 -14 -166 -33 -6 -12 -30 -43 -53 -71 -110 -131 -173 -263 -225
-462 -14 -56 -53 -123 -66 -115 -74 48 -18 329 114 574 20 37 33 71 29 75 -12
11 -839 -50 -1037 -77 -236 -32 -543 -41 -671 -20 -95 15 -89 7 -263 370 -70
146 -185 375 -256 510 -71 135 -154 298 -184 362 -38 80 -62 118 -76 123 -43
14 -264 501 -393 870 -19 55 -58 147 -85 205 -64 133 -125 310 -163 468 -16
68 -36 134 -44 146 -19 28 -51 166 -70 297 -9 57 -23 133 -32 169 -25 102 -24
293 3 350 11 25 29 79 39 120 38 160 68 207 176 277 41 26 42 26 33 11z m3276
-628 c431 -23 593 -39 697 -70 169 -50 243 -78 322 -121 42 -23 102 -55 134
-71 85 -42 139 -77 132 -88 -3 -5 7 -16 22 -24 37 -20 40 -20 -159 14 -240 42
-612 93 -933 130 -614 70 -675 81 -729 131 -20 18 -20 19 0 40 64 71 131 79
514 59z m1265 -90 l20 -9 -20 1 c-11 0 -31 4 -45 8 l-25 8 25 0 c14 0 34 -3
45 -8z m-2385 -260 c-30 -42 -123 -154 -214 -256 -95 -107 -187 -229 -229
-303 -42 -74 -47 -47 -6 29 84 158 271 396 389 496 86 73 89 75 60 34z m3731
-416 c24 -20 63 -49 87 -66 29 -20 40 -34 34 -40 -16 -16 -137 -45 -307 -73
-220 -36 -207 -32 -200 -66 12 -54 -102 -131 -235 -159 l-61 -13 3 -36 c3 -38
-3 -34 106 -61 33 -9 62 -29 117 -81 67 -64 73 -73 78 -120 8 -66 5 -73 -67
-123 -328 -233 -1154 -426 -1891 -443 -860 -19 -1596 135 -1983 417 -46 33
-89 60 -96 60 -16 0 -54 -122 -66 -213 -16 -108 -23 -115 -64 -66 -32 38 -33
74 -6 187 24 100 36 124 100 201 49 59 51 60 69 42 29 -29 276 -147 377 -180
609 -199 1963 -179 2794 41 100 27 119 51 48 62 -69 11 -88 29 -88 81 0 61 62
181 107 208 24 13 33 26 34 45 0 15 15 54 32 87 42 77 70 91 223 111 151 19
156 21 186 86 42 87 58 96 173 103 55 3 142 10 193 16 70 8 97 8 107 -1 19
-16 112 -3 119 16 9 23 31 16 77 -22z m-5279 -841 c153 -184 256 -265 463
-368 514 -253 1396 -412 3025 -545 1121 -92 1502 -147 2020 -292 482 -134 729
-262 1210 -627 222 -167 225 -178 40 -116 -72 24 -130 41 -130 37 0 -3 -5 -1
-11 5 -6 6 -18 9 -25 6 -8 -3 -14 0 -14 6 0 6 -7 8 -17 4 -11 -4 -14 -3 -9 5
5 8 2 10 -8 6 -10 -4 -16 -1 -16 8 0 10 -75 38 -242 92 -134 42 -364 117 -513
166 -746 246 -1060 302 -2190 395 -1137 93 -1856 205 -2501 390 -537 155 -868
336 -1065 585 -81 102 -151 217 -151 246 0 24 37 84 52 84 5 0 42 -39 82 -87z
m-3392 -1179 c-6 -71 -13 -130 -14 -132 -10 -9 -46 90 -46 127 0 49 47 158 62
143 5 -5 5 -58 -2 -138z m4211 -96 c209 -325 348 -470 539 -562 54 -26 78 -42
66 -44 -10 -2 -21 0 -25 5 -3 5 -40 25 -81 44 -187 89 -402 303 -510 511 -38
73 -73 158 -66 158 2 0 37 -51 77 -112z m2846 -644 l32 -6 -31 -61 c-18 -34
-39 -86 -49 -116 l-16 -55 -109 -22 c-60 -12 -134 -31 -164 -43 l-55 -22 -63
68 c-34 37 -92 108 -127 158 l-64 90 77 5 c118 9 533 11 569 4z m-1311 -2785
c3 -5 -8 -9 -24 -9 -21 0 -31 6 -35 19 -4 17 -2 18 24 9 16 -5 32 -14 35 -19z
M13398 5081 c-27 -11 -77 -46 -114 -80 -167 -152 -527 -353 -891 -496 l-122
-48 69 -48 c37 -26 78 -62 89 -78 23 -32 223 -183 476 -358 752 -522 2320
-1426 2737 -1578 57 -21 119 -46 139 -56 l36 -18 75 37 c41 21 81 43 89 50 8
7 102 65 209 128 728 430 1528 1071 1868 1497 31 40 60 74 63 77 18 16 80 143
73 150 -5 4 -101 31 -214 58 -881 218 -3660 693 -4315 738 -71 5 -103 12 -111
22 -7 10 -21 13 -38 10 -14 -3 -29 -1 -32 3 -8 13 -34 10 -86 -10z M7465 5023
c-22 -2 -166 -12 -320 -24 -368 -26 -810 -67 -1460 -135 -734 -76 -1342 -137
-1794 -179 -389 -36 -530 -53 -858 -103 -101 -16 -186 -25 -191 -20 -4 4 -27
-2 -50 -14 l-43 -21 24 -26 c13 -14 32 -38 42 -53 9 -16 25 -28 34 -28 10 0
42 -30 72 -66 65 -81 259 -260 428 -398 69 -55 204 -177 300 -270 581 -558
1105 -941 1781 -1301 91 -48 210 -112 264 -142 156 -84 166 -85 231 -24 30 28
59 51 65 51 7 0 37 19 68 43 32 23 100 69 152 102 128 79 169 108 825 575 861
614 1110 786 1410 975 77 49 169 112 205 141 36 28 119 88 185 133 66 44 141
100 168 124 l47 43 -97 33 c-159 53 -317 118 -495 202 -92 44 -263 119 -380
168 -117 48 -258 109 -312 135 -54 25 -105 46 -112 46 -7 0 -18 9 -24 20 -11
20 -46 23 -165 13z M11910 4349 c-302 -82 -570 -128 -973 -164 l-68 -7 6 -96
c4 -54 13 -117 21 -142 8 -25 28 -164 44 -310 37 -324 73 -596 151 -1150 88
-627 141 -1041 136 -1055 -4 -10 4 -53 38 -203 l6 -24 202 7 c1052 32 2304
274 3263 630 126 47 209 80 579 232 61 25 113 48 117 51 4 4 -38 34 -94 67
-55 33 -117 74 -137 92 -21 18 -285 187 -587 376 -302 189 -643 404 -759 479
-541 348 -1633 1072 -1651 1094 -24 30 -169 154 -179 153 -5 -1 -57 -14 -115
-30z M9267 4215 c-60 -57 -133 -120 -163 -142 -156 -110 -2134 -1686 -2349
-1872 -109 -93 -275 -270 -275 -291 0 -9 71 -42 110 -51 19 -4 134 -42 255
-83 1050 -358 2250 -557 3570 -592 148 -4 263 -11 266 -16 4 -7 14 -6 27 1 11
6 52 14 90 17 l70 7 7 51 c32 234 -55 2150 -116 2566 -6 41 -12 86 -14 100 -1
14 -10 79 -20 145 l-18 120 -54 -3 c-255 -17 -974 65 -1263 143 -9 2 -60 -39
-123 -100z"/>
<path id="cloth" fill="#5d0e75" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M9025 18829 c-22 -4 -126 -8 -231 -8 -213 -1 -364 -13 -502 -41 l-92
-18 -109 -104 c-60 -57 -146 -131 -191 -164 -547 -398 -661 -497 -910 -794
-421 -501 -416 -493 -692 -1164 -310 -755 -374 -1368 -209 -2016 62 -241 18
-221 -63 30 -181 559 -156 1207 70 1865 97 280 84 286 -83 38 -479 -711 -811
-1451 -977 -2178 -93 -408 -97 -601 -13 -692 29 -32 44 -29 117 28 181 139
447 209 626 165 102 -26 236 -87 249 -113 7 -12 34 -46 61 -75 37 -39 54 -67
63 -103 7 -27 25 -75 41 -105 220 -428 161 -1323 -116 -1762 -33 -52 -31 -58
20 -58 193 0 432 -44 586 -107 117 -48 250 -66 620 -83 169 -8 210 -13 310
-40 136 -36 146 -43 94 -65 -280 -121 -505 -114 -1042 29 -74 20 -151 36 -172
36 -22 0 -141 20 -266 45 -255 51 -280 53 -333 25 -31 -15 -259 -90 -277 -90
-2 0 -4 -6 -4 -14 0 -8 25 -26 56 -40 78 -36 175 -117 247 -206 47 -59 75 -83
130 -113 38 -20 89 -51 113 -68 74 -51 244 -134 339 -165 89 -29 92 -29 325
-29 359 0 590 64 880 244 155 97 430 337 430 376 0 6 20 49 44 96 118 226 141
350 132 722 -7 277 -7 278 -41 396 -43 150 -101 282 -197 446 -41 72 -87 154
-102 183 -15 29 -62 108 -104 175 -328 522 -608 1355 -671 1997 -25 252 -21
654 8 707 5 10 21 54 36 98 66 195 194 407 324 534 128 126 135 136 332 527
100 198 212 413 250 479 40 71 98 198 143 312 72 185 191 469 236 563 l21 45
-6 -55 c-10 -86 -71 -339 -109 -453 -33 -101 -59 -160 -205 -475 -92 -200 -92
-199 3 -157 144 64 367 96 538 77 224 -25 367 -82 541 -219 142 -111 259 -185
345 -217 69 -26 319 -96 344 -96 22 0 94 80 122 135 52 106 58 182 26 325 -22
94 -24 128 -24 320 1 334 44 493 186 680 40 53 108 163 108 175 0 8 -28 15
-86 19 -47 4 -194 30 -327 57 -634 130 -850 162 -962 138z m635 -807 c64 -149
89 -213 77 -202 -5 5 -175 384 -184 410 -20 60 52 -80 107 -208z m-4402 -3878
c68 -37 172 -103 172 -109 0 -10 -113 30 -175 60 -79 39 -85 41 -85 20 0 -19
89 -208 128 -270 37 -59 34 -65 -26 -65 -111 0 -265 71 -230 106 13 13 19 13
49 0 60 -27 165 -66 177 -66 17 0 15 18 -7 48 -36 52 -73 135 -92 209 -18 72
-18 77 -1 89 22 17 13 19 90 -22z m2038 -1890 c59 -20 135 -42 168 -49 34 -7
51 -14 38 -14 -78 -3 -362 83 -494 149 -68 34 -218 127 -218 135 0 2 90 -39
200 -91 109 -52 247 -110 306 -130z m287 -71 c-7 -2 -21 -2 -30 0 -10 3 -4 5
12 5 17 0 24 -2 18 -5z m-388 -584 c33 -5 -3 -7 -110 -4 -88 3 -178 9 -200 13
-53 12 243 3 310 -9z M10523 18603 c-122 -130 -233 -288 -233 -332 0 -10 -13
-86 -29 -168 -54 -271 -65 -500 -35 -715 26 -182 2 -271 -98 -371 -26 -26 -48
-52 -48 -57 0 -15 -13 -19 -114 -35 -199 -32 -405 29 -582 173 -94 77 -435
246 -559 278 -183 48 -453 45 -611 -7 -113 -37 -145 -64 -208 -182 -81 -151
-82 -150 77 -72 220 107 338 124 519 76 106 -29 312 -137 510 -268 184 -122
255 -155 452 -213 72 -21 150 -46 174 -54 53 -19 207 -56 233 -56 10 0 38 10
62 21 41 20 48 31 115 163 40 77 94 181 121 230 101 183 120 282 131 701 5
182 13 355 19 385 37 185 117 384 208 513 41 58 41 67 1 67 -27 0 -44 -12
-105 -77z M10935 18548 c-146 -87 -306 -285 -325 -404 -15 -93 -13 -214 4
-214 43 0 246 282 360 501 92 176 87 192 -39 117z M11845 17614 c-162 -78
-432 -176 -647 -235 -59 -16 -88 -28 -88 -38 0 -12 38 -13 258 -8 260 7 644
26 651 33 2 2 -8 50 -23 106 -15 57 -32 120 -37 141 -12 46 -22 46 -114 1z
M12100 16511 c-14 -4 -76 -11 -139 -15 -164 -10 -167 -11 -162 -116 3 -77 7
-93 46 -170 26 -50 51 -118 60 -165 25 -115 41 -142 95 -161 25 -9 63 -25 86
-35 50 -23 83 -24 128 -2 29 13 42 14 70 6 43 -13 58 12 32 52 -9 13 -20 64
-26 112 -16 146 -89 457 -112 478 -19 18 -49 24 -78 16z M7352 16218 c-60
-122 -95 -225 -111 -328 -7 -41 -16 -93 -22 -115 -11 -45 58 -627 106 -890
112 -618 417 -1417 641 -1680 182 -215 294 -447 350 -724 14 -69 34 -160 44
-201 61 -243 44 -502 -50 -737 -201 -503 -841 -959 -1400 -999 -199 -14 -548
75 -733 186 -90 54 -102 53 -93 -7 4 -27 10 -75 13 -108 6 -59 7 -61 73 -119
184 -163 382 -231 675 -230 329 0 636 92 952 285 308 189 614 521 779 844 l37
75 10 227 c23 535 -34 751 -399 1506 -402 830 -576 1275 -709 1812 -117 471
-155 926 -100 1195 30 147 7 150 -63 8z M7838 16148 c-4 -91 19 -362 38 -458
35 -176 61 -235 122 -282 71 -53 83 -63 145 -117 57 -49 128 -96 204 -134 64
-33 250 -97 280 -97 13 0 40 -7 62 -16 40 -16 40 -16 88 17 140 97 296 264
416 446 36 56 71 104 77 108 30 19 3 19 -47 1 -50 -18 -80 -21 -218 -20 -241
1 -404 38 -610 140 -114 56 -330 208 -320 225 4 5 0 9 -8 9 -16 0 -207 195
-207 211 0 5 -4 9 -10 9 -5 0 -11 -19 -12 -42z M4981 13442 c-199 -103 -252
-317 -114 -455 87 -88 278 -156 332 -119 27 19 -4 47 -67 60 -128 26 -222 121
-222 223 0 49 55 166 117 251 52 71 38 83 -46 40z M4866 12892 c-3 -5 28 -58
68 -119 82 -125 100 -176 94 -262 -7 -96 -51 -149 -190 -225 -29 -17 -56 -29
-60 -28 -12 3 -9 -12 6 -33 11 -15 22 -17 69 -12 184 19 327 178 314 349 -8
92 -55 202 -110 256 -57 56 -174 101 -191 74z M12300 12375 c0 -32 -13 -67
-50 -138 l-50 -95 0 -144 c0 -326 59 -529 211 -731 93 -124 267 -257 359 -276
592 -121 958 -31 1278 316 51 56 109 112 127 125 19 12 35 28 35 35 0 10 -175
73 -203 73 -5 0 -39 -28 -76 -62 -156 -148 -352 -239 -552 -259 -360 -35 -556
-16 -730 72 -125 63 -226 232 -286 478 -51 213 -35 334 63 477 39 57 82 151
72 159 -2 1 -47 5 -100 7 l-98 5 0 -42z M12554 12358 c0 -44 -50 -188 -66
-188 -15 0 3 -359 24 -465 22 -115 65 -225 107 -276 110 -133 497 -202 806
-144 139 26 309 106 422 197 98 80 96 82 -111 152 -177 59 -231 86 -402 200
-57 38 -92 55 -100 50 -7 -5 -56 -42 -111 -83 -139 -105 -140 -105 -24 7 57
55 102 105 100 110 -5 14 -147 132 -158 132 -6 0 -40 -58 -77 -130 -126 -245
-152 -247 -55 -3 82 206 79 183 25 250 -51 63 -69 98 -85 171 l-10 49 -97 6
c-53 4 -118 7 -143 7 l-46 0 1 -42z M5047 12123 c-4 -3 -7 -27 -7 -52 l0 -45
-27 26 c-40 37 -66 48 -112 48 -84 0 -84 -67 -1 -140 50 -44 50 -42 -10 -69
-27 -12 -50 -27 -50 -31 0 -17 41 -31 72 -25 l30 7 -29 -43 c-50 -74 -54 -85
-42 -113 25 -54 44 -44 136 68 36 44 34 46 49 -59 7 -54 17 -45 29 27 l6 37
36 -25 c20 -13 41 -23 47 -21 16 6 9 104 -10 156 l-17 44 32 26 c36 30 39 41
11 41 -18 0 -17 4 10 63 52 109 29 115 -72 18 l-38 -35 0 29 c0 61 -20 92 -43
68z M11670 11939 c0 -6 -21 -42 -46 -80 -43 -65 -108 -122 -260 -227 -41 -28
-204 -109 -238 -118 -34 -8 -33 -29 2 -42 164 -63 249 -92 266 -92 51 0 238
136 406 297 63 60 130 118 148 128 31 19 33 23 27 60 -8 50 4 44 -122 66 -124
21 -183 24 -183 8z M9032 11760 l3 -72 115 -35 c474 -143 821 -399 880 -653
23 -98 67 -215 82 -218 14 -3 135 254 145 309 4 24 -9 36 -169 150 -95 67
-218 157 -273 200 -264 202 -551 350 -748 384 l-38 6 3 -71z M11980 11692 c0
-54 -288 -267 -431 -318 -59 -21 -61 -34 -12 -58 44 -21 158 -95 195 -128 l27
-23 -13 -110 c-25 -206 -74 -349 -223 -645 -90 -180 -90 -178 -68 -241 9 -23
25 -124 36 -223 11 -100 31 -224 44 -277 14 -52 38 -163 55 -245 132 -636 251
-936 712 -1789 203 -376 597 -851 900 -1086 l63 -49 2588 0 c2063 0 2587 3
2587 13 0 6 -44 40 -98 74 -127 81 -322 243 -502 418 -139 135 -333 295 -360
295 -6 0 -44 -30 -84 -66 -241 -224 -531 -336 -865 -333 l-146 1 65 15 c353
78 611 177 785 301 88 62 165 130 165 145 0 16 -245 247 -262 247 -8 0 -32
-18 -53 -41 -83 -85 -327 -219 -465 -255 -61 -15 -252 -45 -258 -39 -1 1 32
15 75 30 264 92 598 270 633 336 14 25 6 49 -14 49 -9 0 -13 6 -10 14 4 9 -34
60 -97 133 -233 269 -484 599 -684 898 -124 186 -117 175 -164 266 -22 42 -46
79 -54 82 -14 5 -113 164 -219 352 -60 106 -121 228 -169 339 -22 50 -50 102
-63 116 -41 44 -139 179 -291 400 -509 739 -731 983 -920 1012 -27 4 -59 10
-71 13 -16 5 -32 -8 -84 -72 -142 -173 -235 -256 -375 -336 -279 -160 -649
-219 -884 -141 -84 29 -405 191 -479 243 -210 149 -359 347 -448 596 -20 57
-38 91 -48 93 -9 2 -16 -1 -16 -6z m2695 -1808 l102 -16 -24 -24 c-13 -13 -28
-24 -32 -24 -11 0 -125 -75 -149 -97 -10 -10 -58 -54 -105 -98 -48 -44 -87
-85 -87 -91 0 -6 -9 -19 -19 -29 -11 -9 -37 -44 -58 -76 -20 -32 -40 -59 -44
-59 -9 0 -88 -105 -116 -155 -91 -162 -127 -276 -138 -436 -6 -92 14 -349 27
-349 4 0 8 -13 8 -28 0 -27 28 -117 54 -177 8 -16 17 -41 21 -55 5 -14 19 -42
31 -62 13 -21 24 -42 24 -47 0 -5 6 -16 13 -23 8 -7 26 -32 40 -55 35 -56 225
-251 263 -271 18 -10 58 -35 90 -57 109 -75 264 -135 459 -180 127 -29 629
-60 788 -48 l88 6 -100 -102 c-56 -55 -106 -101 -111 -101 -11 0 -91 -50 -100
-62 -12 -15 -219 -108 -275 -122 -383 -99 -652 -109 -1031 -41 -328 59 -739
264 -902 449 -15 18 -35 35 -43 38 -8 3 -28 25 -44 49 -17 24 -35 49 -41 54
-13 11 -84 143 -84 156 0 8 -64 105 -85 129 -25 28 -125 234 -125 256 0 13 -4
26 -10 29 -5 3 -10 22 -10 42 0 47 -22 163 -30 163 -4 0 -10 17 -13 38 -3 20
-13 68 -21 105 -17 77 -14 333 4 367 5 10 10 29 10 41 0 39 47 172 96 274 71
144 239 364 279 365 6 0 26 14 45 32 46 43 238 152 320 182 330 122 703 162
1035 110z M14010 9663 c-34 -5 -265 -71 -315 -90 -40 -15 -194 -104 -217 -126
-7 -7 -45 -37 -83 -68 -39 -31 -85 -76 -103 -100 -84 -113 -100 -137 -124
-184 -89 -172 -119 -304 -113 -494 5 -159 25 -282 60 -356 7 -16 17 -43 21
-60 4 -16 10 -32 14 -35 4 -3 17 -26 28 -52 11 -27 25 -48 30 -48 5 0 21 -17
34 -37 14 -21 38 -52 54 -69 16 -17 41 -44 55 -60 15 -16 33 -34 40 -40 8 -6
37 -38 64 -70 101 -118 255 -260 318 -293 17 -10 79 -42 137 -73 126 -67 175
-83 304 -98 106 -13 197 -36 208 -53 18 -29 377 -36 547 -12 131 20 291 64
291 81 0 14 -3 15 -205 39 -172 21 -318 61 -452 126 -56 27 -108 49 -115 49
-20 0 -250 173 -308 231 -67 67 -200 226 -200 239 0 4 -14 25 -31 46 -17 22
-37 53 -45 69 -7 17 -18 37 -23 45 -20 32 -71 147 -71 161 0 8 -4 19 -9 24
-10 11 -42 118 -62 210 -32 141 -13 432 37 568 8 23 22 61 29 85 20 61 95 211
126 252 14 19 28 40 30 47 2 6 30 39 62 72 75 81 74 88 -13 74z M9007 11513
c-27 -145 -122 -308 -298 -510 -30 -34 -81 -102 -114 -150 -118 -173 -346
-382 -567 -519 -137 -85 -541 -286 -640 -319 -49 -17 -88 -33 -88 -37 0 -4 13
-34 30 -66 46 -91 84 -263 69 -307 -13 -35 -32 -45 -45 -24 -5 8 -47 10 -149
5 -148 -8 -621 18 -639 35 -5 5 -2 19 8 33 9 14 16 32 16 40 0 8 23 60 51 116
28 56 49 103 47 104 -1 2 -44 8 -95 15 -277 35 -546 143 -664 268 -133 140
-162 252 -114 444 l16 65 -39 92 c-52 119 -92 181 -159 242 -92 84 -83 87
-283 -94 -52 -48 -162 -139 -245 -204 -300 -234 -419 -396 -578 -787 -180
-443 -307 -699 -595 -1200 -358 -623 -697 -1149 -1000 -1548 -57 -75 -102
-143 -99 -151 13 -33 280 -167 445 -222 269 -91 794 -125 1209 -80 153 16 203
16 203 -4 0 -58 -405 -108 -780 -97 -560 17 -901 131 -1051 351 -13 20 -31 36
-39 36 -8 0 -61 -55 -117 -123 -209 -252 -440 -484 -655 -660 -49 -39 -88 -77
-88 -84 0 -18 -5 -18 555 32 1317 117 2265 179 3455 225 531 20 570 22 570 30
0 5 -9 24 -19 42 -31 54 -46 115 -34 141 12 27 69 44 194 57 278 31 386 40
484 43 l109 2 8 -50 c4 -27 3 -88 -2 -134 -5 -47 -8 -86 -6 -88 2 -2 230 1
507 7 277 5 619 10 759 10 l255 0 76 103 c362 486 719 1263 965 2095 41 141
104 347 139 457 102 322 124 405 135 511 6 54 18 126 27 159 31 115 29 126
-19 159 -182 125 -251 202 -215 238 7 7 28 56 46 108 18 52 53 147 78 210 l44
116 -39 68 c-25 41 -49 101 -62 156 -24 96 -28 102 -142 243 -165 203 -355
331 -651 441 -54 20 -111 39 -126 42 l-28 6 -16 -89z m-3532 -1712 c251 -61
408 -133 492 -225 95 -104 95 -103 38 -188 -27 -40 -78 -100 -114 -133 -36
-33 -116 -109 -179 -170 -117 -114 -131 -120 -132 -54 0 14 -42 117 -93 230
-52 112 -116 269 -142 349 -29 88 -55 150 -67 158 -23 16 -16 28 25 46 43 19
37 20 172 -13z m3204 -57 c11 -3 6 -13 -16 -37 -17 -18 -34 -48 -38 -67 -21
-102 -305 -568 -381 -626 -32 -25 -54 -25 -54 -1 0 7 -34 37 -75 67 -49 36
-96 81 -132 130 -31 41 -81 103 -111 137 -75 87 -69 97 103 183 167 84 459
204 535 220 33 8 139 3 169 -6z m-1737 -405 c267 -45 564 -242 720 -479 369
-560 266 -1226 -244 -1578 -351 -241 -780 -312 -1075 -178 -425 195 -722 864
-594 1340 24 92 120 336 132 336 4 0 19 25 33 55 170 372 589 577 1028 504z
m1519 -848 c244 -83 315 -115 440 -197 36 -24 76 -44 88 -44 27 0 27 -3 -10
-56 -65 -96 -181 -170 -439 -284 -192 -85 -242 -92 -255 -36 -9 38 -35 340
-35 402 0 99 37 264 58 264 5 0 74 -22 153 -49z m-3066 12 c32 -37 60 -105 73
-174 12 -68 5 -493 -10 -529 -34 -87 -163 -88 -333 -3 -55 27 -161 87 -236
134 -75 46 -157 96 -183 111 -61 36 -64 49 -31 118 l28 59 256 127 c229 113
381 183 404 184 4 0 19 -12 32 -27z m2797 -1111 c21 -22 272 -457 298 -517 11
-26 29 -83 41 -128 11 -45 27 -89 35 -98 29 -32 -15 -38 -99 -14 -29 8 -88 19
-132 25 -138 18 -587 134 -622 160 -31 22 -31 23 -17 62 29 84 82 164 164 253
47 50 125 135 175 189 96 103 114 111 157 68z m-2592 -105 c0 -2 80 -85 178
-183 219 -221 256 -266 248 -297 -10 -42 -45 -77 -76 -77 -16 0 -59 -16 -94
-36 -165 -90 -556 -113 -637 -37 -39 37 -39 37 35 147 71 107 156 267 207 394
18 45 46 98 62 117 l28 35 25 -29 c13 -16 24 -31 24 -34z m-2440 -27 c189
-121 561 -245 802 -266 87 -8 109 -20 77 -42 -60 -42 -511 53 -724 153 -92 43
-146 84 -185 139 -36 54 -33 56 30 16z M5350 9717 c0 -7 23 -44 51 -82 83
-114 134 -208 185 -345 27 -71 53 -130 58 -130 5 0 61 53 125 119 87 89 130
125 174 146 71 34 72 49 5 70 -29 10 -123 50 -208 90 -144 68 -343 145 -376
145 -8 0 -14 -6 -14 -13z M8305 9549 c-236 -70 -385 -120 -385 -132 0 -7 32
-37 71 -67 83 -64 138 -127 170 -193 13 -26 28 -47 35 -47 7 0 44 60 82 133
38 73 93 172 121 221 76 132 74 134 -94 85z M6575 9106 c-129 -26 -235 -75
-341 -160 -115 -91 -221 -239 -245 -339 -6 -29 -22 -71 -36 -93 -69 -120 -69
-477 0 -679 128 -373 363 -572 687 -583 192 -6 366 43 563 160 330 195 471
413 471 723 -1 474 -280 843 -722 956 -102 26 -285 33 -377 15z M8324 8428
c29 -100 37 -177 38 -350 1 -119 5 -188 11 -188 15 0 188 109 331 209 72 50
149 99 173 108 64 26 54 37 -59 62 -111 25 -182 50 -355 130 -127 58 -149 62
-139 29z M5170 8324 c-151 -67 -365 -154 -380 -154 -42 0 14 -37 151 -99 175
-81 247 -123 325 -194 75 -68 77 -66 67 66 -4 61 -8 185 -8 275 0 139 -2 162
-15 162 -8 -1 -71 -26 -140 -56z M8107 7261 c-98 -175 -205 -315 -272 -358
-53 -33 -57 -50 -12 -57 393 -65 477 -83 564 -121 97 -43 107 -28 41 63 -24
33 -95 163 -158 290 -63 128 -119 232 -125 232 -5 0 -22 -22 -38 -49z M5540
7123 c-52 -114 -132 -246 -211 -345 -38 -48 -69 -92 -69 -98 0 -28 193 1 397
60 76 22 160 43 188 46 49 6 105 43 105 68 0 6 -24 27 -52 46 -59 40 -183 162
-248 243 -59 74 -68 72 -110 -20z M10605 11509 c-2 -8 -27 -79 -56 -158 -69
-196 -109 -288 -147 -340 -18 -24 -32 -54 -32 -66 0 -12 -58 -141 -129 -286
-138 -281 -221 -464 -221 -484 0 -7 39 -30 87 -51 48 -22 156 -78 241 -126 84
-49 158 -88 164 -88 14 0 77 -38 108 -65 39 -34 351 -207 364 -202 7 3 45 85
85 183 148 360 373 880 422 975 27 53 83 145 124 204 41 58 75 110 75 114 0 4
-42 15 -92 25 -133 25 -193 47 -585 215 -384 164 -400 170 -408 150z m167
-214 c55 -10 149 -40 250 -79 90 -35 213 -81 273 -102 130 -44 121 -39 107
-67 -6 -12 -32 -79 -57 -149 -25 -69 -81 -207 -126 -305 -154 -338 -289 -682
-289 -734 0 -49 -33 -35 -440 194 -213 120 -253 145 -318 203 l-44 39 47 109
c83 194 308 618 398 749 26 38 47 74 47 82 0 14 47 75 58 75 4 0 46 -7 94 -15z
M10652 11168 c-25 -82 -61 -156 -173 -358 -123 -220 -269 -512 -269 -539 0 -4
19 -16 43 -27 23 -10 101 -54 172 -98 526 -319 489 -302 498 -231 17 124 216
651 349 924 43 90 77 169 75 175 -3 6 -29 18 -58 25 -94 24 -423 132 -464 153
-22 12 -56 34 -76 49 -56 44 -62 40 -97 -73z M11280 9940 c-27 -55 -50 -113
-50 -128 0 -40 37 -220 105 -507 31 -132 79 -343 105 -470 65 -308 183 -643
366 -1038 110 -238 332 -637 355 -637 5 0 9 -4 9 -9 0 -36 254 -366 438 -568
l75 -83 219 0 c169 0 218 3 218 13 0 7 -86 98 -191 202 -427 426 -628 710
-1000 1420 -309 589 -495 1198 -565 1843 -9 87 -25 80 -84 -38z M7070 9950
c-147 -11 -275 -31 -279 -43 -2 -6 -33 -53 -67 -105 -35 -51 -64 -97 -64 -101
0 -4 98 -12 218 -18 180 -9 235 -15 325 -38 59 -15 110 -25 114 -22 3 3 -13
61 -35 129 -22 68 -43 142 -47 166 -8 48 9 45 -165 32z M10216 9787 c-3 -56
-11 -129 -16 -162 -5 -33 -17 -125 -25 -205 -50 -466 -160 -881 -367 -1394
-210 -519 -522 -1085 -784 -1423 -35 -45 -64 -86 -64 -92 0 -8 68 -11 213 -11
l212 1 61 82 c458 615 724 1332 879 2367 40 272 51 328 111 584 24 103 44 196
44 206 0 16 -221 150 -248 150 -5 0 -12 -46 -16 -103z M11020 9035 c-30 -8
-116 -21 -190 -30 -214 -24 -196 -18 -203 -73 -4 -26 -23 -131 -43 -235 -21
-103 -35 -190 -31 -193 3 -3 46 4 96 15 150 35 400 71 499 71 50 0 92 2 92 4
0 1 -13 55 -30 117 -16 63 -38 164 -48 224 l-19 110 -34 2 c-19 1 -59 -5 -89
-12z M11370 8029 c-19 -5 -87 -13 -150 -19 -63 -5 -155 -19 -205 -30 -49 -11
-211 -31 -360 -46 -148 -14 -273 -28 -276 -32 -9 -12 -139 -366 -139 -381 0
-9 8 -12 23 -8 429 93 767 146 971 152 205 6 339 24 332 44 -20 62 -143 331
-151 330 -5 -1 -26 -5 -45 -10z M11885 7059 c-123 -25 -353 -53 -690 -84 -209
-19 -501 -46 -650 -60 -148 -14 -359 -31 -467 -37 l-197 -12 -49 -71 c-27 -38
-86 -116 -130 -171 -45 -56 -82 -107 -82 -113 0 -8 375 -11 1415 -11 856 0
1415 4 1415 9 0 5 -82 92 -183 193 -101 101 -215 225 -253 275 -38 51 -73 92
-79 92 -5 -1 -28 -5 -50 -10z M7090 6634 c-110 -28 -343 -56 -417 -52 -40 3
-73 1 -73 -4 0 -4 7 -35 16 -67 l17 -58 186 4 c241 5 332 12 335 26 2 7 13 44
25 83 11 39 21 73 21 77 0 10 -48 6 -110 -9z M13530 5010 c-8 -5 -25 -10 -36
-10 -14 0 -26 -10 -34 -30 -27 -65 -203 -208 -425 -345 -132 -81 -449 -245
-474 -245 -51 0 82 -96 444 -322 510 -317 1209 -707 2130 -1188 182 -95 403
-214 491 -266 89 -52 167 -94 174 -94 20 0 269 138 495 273 588 351 1128 762
1537 1168 87 86 158 163 158 171 0 10 -54 23 -202 50 -112 20 -525 106 -918
192 -919 199 -1432 305 -2230 460 -1018 198 -1076 208 -1110 186z m878 -300
c1828 -305 2219 -391 2912 -641 74 -27 144 -49 156 -49 72 0 21 -82 -175 -283
-336 -343 -652 -594 -924 -733 -61 -31 -171 -97 -245 -145 -73 -49 -139 -89
-145 -89 -7 0 -43 -18 -80 -40 -98 -57 -126 -63 -192 -40 -99 34 -218 96 -390
202 -220 136 -280 170 -580 325 -137 72 -401 218 -585 325 -417 242 -557 320
-885 493 -335 177 -453 245 -422 245 12 0 918 -446 1117 -550 579 -303 732
-389 1013 -568 84 -54 250 -151 370 -217 120 -66 256 -148 303 -182 96 -71 96
-71 138 -39 17 13 50 33 73 44 23 12 70 43 105 69 35 27 133 88 218 137 88 51
198 125 255 171 55 45 165 130 245 190 318 238 760 622 760 660 0 8 -74 27
-207 54 -416 85 -773 161 -988 210 -386 87 -772 164 -1705 341 -206 39 -512
101 -680 137 -168 36 -314 67 -325 70 -15 3 -33 -13 -73 -65 -117 -151 -317
-295 -539 -388 -51 -21 -94 -44 -95 -51 -2 -8 -8 -8 -23 3 -26 20 -11 33 118
102 123 67 229 142 354 249 82 70 249 188 272 192 3 1 385 -62 849 -139z
m-748 -61 c0 -14 -7 -19 -25 -19 -27 0 -32 -18 -15 -50 12 -22 3 -50 -16 -50
-8 0 -14 -9 -14 -21 0 -11 -21 -42 -47 -67 -44 -45 -49 -47 -97 -45 -47 2 -52
0 -67 -26 -16 -28 -18 -28 -116 -29 -158 -2 -177 45 -25 63 49 5 69 13 94 37
29 27 38 30 77 25 39 -4 48 -1 73 23 15 16 28 33 28 39 0 6 14 18 31 27 25 12
30 20 24 37 -16 51 -12 62 25 65 19 2 39 7 44 12 13 13 26 2 26 -21z M7595
4949 c-11 -5 -238 -34 -505 -64 -425 -49 -941 -116 -1860 -240 -355 -48 -1017
-130 -1250 -155 -382 -41 -498 -50 -737 -57 -171 -4 -243 -9 -243 -17 0 -18
71 -82 210 -191 69 -54 213 -176 320 -270 489 -429 463 -409 1070 -802 377
-243 548 -348 752 -461 191 -106 503 -262 524 -262 8 0 55 33 102 73 210 176
309 247 682 497 907 606 1580 1024 1903 1181 89 44 87 57 -15 99 -365 147
-679 377 -886 648 -26 34 -34 36 -67 21z m-52 -120 c30 -16 -126 -57 -248 -65
-65 -5 -161 -25 -345 -74 -583 -155 -1162 -277 -1665 -350 -357 -52 -466 -61
-865 -71 -450 -11 -520 -16 -520 -33 0 -6 110 -87 244 -179 133 -92 308 -217
387 -278 578 -440 767 -573 1070 -755 132 -78 375 -204 396 -204 5 0 37 20 70
45 34 24 139 92 234 151 94 59 217 144 273 189 307 249 857 612 1327 877 120
68 218 128 219 134 0 6 -21 26 -47 44 -219 155 -414 352 -482 488 l-22 43 22
-11 c27 -15 159 -147 303 -303 60 -65 145 -150 190 -190 51 -45 81 -79 81 -92
0 -15 -51 -52 -220 -158 -283 -177 -565 -363 -785 -517 -277 -194 -395 -272
-545 -357 -77 -44 -201 -123 -275 -176 -130 -93 -285 -182 -361 -206 -33 -11
-44 -8 -130 29 -366 158 -1139 654 -1494 959 -55 47 -194 179 -309 293 -209
206 -210 207 -182 218 49 18 157 29 361 35 126 4 264 15 375 30 96 14 285 36
420 50 659 68 1077 138 1905 317 294 63 569 122 593 127 2 1 13 -4 25 -10z
m-121 -201 c-2 -53 0 -58 19 -58 55 0 73 -38 44 -94 -22 -42 -19 -46 30 -46
80 0 42 -39 -43 -45 -63 -4 -96 16 -87 54 6 26 3 29 -27 35 -39 7 -74 29 -88
56 -9 16 -4 27 25 58 19 22 35 46 35 55 0 22 40 48 70 45 24 -3 25 -6 22 -60z
m253 -299 c4 -5 1 -24 -5 -40 -16 -39 -11 -43 44 -31 74 16 61 -30 -21 -72
-40 -20 -43 -20 -43 2 0 9 -10 22 -22 27 -17 8 -22 17 -20 38 3 27 3 27 -56
27 -46 0 -66 5 -88 23 l-29 22 35 6 c60 11 198 10 205 -2z M12020 4179 c-114
-47 -598 -159 -835 -194 -186 -27 -175 -24 -175 -48 0 -12 13 -103 30 -202
212 -1289 287 -1748 324 -2004 25 -167 47 -306 50 -308 7 -7 361 13 591 32
836 72 1523 197 2200 400 360 108 795 267 795 290 0 7 -120 90 -267 185 -828
536 -1648 1110 -2465 1727 -179 135 -195 143 -248 122z m161 -290 c258 -130
1123 -685 1469 -942 263 -196 365 -284 463 -402 27 -33 61 -66 76 -74 67 -35
125 -90 163 -153 l40 -67 -36 -34 c-75 -71 -572 -257 -1022 -382 -594 -166
-1254 -259 -1599 -226 -165 15 -269 32 -254 42 38 23 -19 430 -190 1349 -61
326 -73 403 -92 627 -14 166 -14 166 53 158 39 -5 81 0 158 19 171 40 462 96
547 105 140 15 159 13 224 -20z M11939 3870 c-83 -29 -168 -47 -375 -81 l-269
-43 -34 -38 -34 -38 47 -162 c57 -199 79 -306 155 -763 77 -459 117 -737 133
-920 7 -86 16 -145 23 -145 5 0 66 11 135 25 69 14 244 36 390 50 534 50 898
110 1325 216 352 88 865 250 865 274 0 8 -21 28 -47 46 -27 18 -64 47 -83 65
-19 18 -89 65 -155 104 -138 82 -190 121 -445 330 -246 202 -503 396 -920 695
-190 136 -395 287 -456 336 -62 49 -120 88 -130 88 -11 -1 -67 -18 -125 -39z
m150 -74 c17 -18 21 -30 15 -36 -7 -7 -16 -4 -29 10 -28 31 -43 25 -47 -17 -3
-35 -6 -38 -35 -41 -21 -2 -33 -9 -33 -18 0 -9 -10 -14 -29 -14 -16 0 -34 -7
-42 -16 -10 -12 -23 -14 -54 -9 -38 5 -43 3 -53 -20 -6 -14 -17 -26 -24 -26
-58 -5 -87 -4 -115 4 -25 8 -34 7 -49 -7 -41 -42 -122 -33 -125 14 -4 58 9 76
55 72 19 -2 37 1 41 7 10 17 40 13 68 -9 30 -24 55 -26 63 -5 4 10 14 13 30 9
19 -5 29 0 45 20 20 26 21 26 50 9 24 -15 33 -15 49 -5 11 7 31 10 44 6 16 -4
25 -1 29 11 5 11 14 14 32 9 22 -6 25 -3 25 23 0 71 38 83 89 29z M8964 3852
c-880 -757 -1975 -1681 -2088 -1762 -25 -18 -46 -39 -46 -45 0 -14 256 -99
540 -181 917 -262 1977 -418 3068 -450 l232 -7 0 859 c0 789 -13 1606 -25
1645 -5 15 -40 17 -308 22 -376 6 -637 33 -957 98 -79 16 -151 29 -160 29 -8
-1 -123 -94 -256 -208z m456 23 c10 -12 38 -15 136 -15 69 0 220 -11 337 -25
250 -29 553 -54 577 -48 29 8 78 -24 84 -54 4 -16 11 -282 16 -593 6 -311 13
-686 16 -835 5 -209 3 -309 -10 -445 -15 -155 -15 -175 -1 -183 33 -18 -5 -98
-56 -116 -17 -6 -142 -16 -277 -22 -666 -30 -1548 50 -1947 178 -60 19 -203
73 -316 119 -125 51 -244 93 -300 105 -52 11 -132 36 -179 56 -54 23 -102 37
-132 37 -25 1 -49 4 -53 7 -23 24 209 219 260 219 27 0 114 74 227 194 51 55
210 208 353 340 338 313 586 548 870 826 220 216 233 227 295 247 78 27 84 27
100 8z M9305 3790 c-49 -22 -95 -40 -101 -40 -6 0 -40 -33 -75 -72 -248 -283
-475 -524 -739 -788 -356 -357 -449 -440 -665 -603 -288 -217 -303 -231 -252
-241 12 -3 52 -7 89 -10 36 -3 131 -23 210 -44 78 -22 162 -43 186 -47 23 -4
42 -12 42 -18 0 -8 70 -20 213 -35 116 -13 295 -39 397 -57 564 -104 963 -143
1543 -152 328 -5 377 -4 377 9 0 8 -13 79 -29 159 -55 265 -62 337 -68 661 -5
285 10 1066 23 1186 l6 52 -138 0 c-293 0 -630 26 -803 61 -119 24 -110 25
-216 -21z m128 -86 c19 -25 23 -26 87 -20 60 6 67 5 86 -16 36 -39 34 -43 -14
-44 -26 0 -68 -4 -95 -8 -90 -16 -167 44 -122 94 24 26 33 25 58 -6z m324 -45
c8 -8 21 -8 47 1 36 12 76 1 76 -21 0 -7 14 -8 40 -4 23 4 53 2 74 -6 28 -10
42 -10 76 1 37 12 42 12 63 -8 29 -27 42 -27 75 -1 l27 21 27 -32 c27 -33 44
-92 32 -111 -4 -7 -20 -8 -41 -4 -29 5 -38 2 -50 -14 -18 -27 -72 -28 -100 -2
-12 11 -42 21 -74 25 -102 12 -184 15 -189 7 -3 -4 -27 -5 -55 -1 -27 4 -44 8
-37 9 16 1 16 31 -1 31 -15 0 -67 51 -67 66 0 15 39 54 53 54 7 0 18 -5 24
-11z"/>
<path id="trim" fill="#823d08" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M10523 18603 c-122 -130 -233 -288 -233 -332 0 -10 -13 -86 -29 -168
-54 -271 -65 -500 -35 -715 26 -182 2 -271 -98 -371 -26 -26 -48 -52 -48 -57
0 -15 -13 -19 -114 -35 -199 -32 -405 29 -582 173 -94 77 -435 246 -559 278
-183 48 -453 45 -611 -7 -113 -37 -145 -64 -208 -182 -81 -151 -82 -150 77
-72 220 107 338 124 519 76 106 -29 312 -137 510 -268 184 -122 255 -155 452
-213 72 -21 150 -46 174 -54 53 -19 207 -56 233 -56 10 0 38 10 62 21 41 20
48 31 115 163 40 77 94 181 121 230 101 183 120 282 131 701 5 182 13 355 19
385 37 185 117 384 208 513 41 58 41 67 1 67 -27 0 -44 -12 -105 -77z M7352
16218 c-60 -122 -95 -225 -111 -328 -7 -41 -16 -93 -22 -115 -11 -45 58 -627
106 -890 112 -618 417 -1417 641 -1680 182 -215 294 -447 350 -724 14 -69 34
-160 44 -201 61 -243 44 -502 -50 -737 -201 -503 -841 -959 -1400 -999 -199
-14 -548 75 -733 186 -90 54 -102 53 -93 -7 4 -27 10 -75 13 -108 6 -59 7 -61
73 -119 184 -163 382 -231 675 -230 329 0 636 92 952 285 308 189 614 521 779
844 l37 75 10 227 c23 535 -34 751 -399 1506 -402 830 -576 1275 -709 1812
-117 471 -155 926 -100 1195 30 147 7 150 -63 8z M7838 16148 c-4 -91 19 -362
38 -458 35 -176 61 -235 122 -282 71 -53 83 -63 145 -117 57 -49 128 -96 204
-134 64 -33 250 -97 280 -97 13 0 40 -7 62 -16 40 -16 40 -16 88 17 140 97
296 264 416 446 36 56 71 104 77 108 30 19 3 19 -47 1 -50 -18 -80 -21 -218
-20 -241 1 -404 38 -610 140 -114 56 -330 208 -320 225 4 5 0 9 -8 9 -16 0
-207 195 -207 211 0 5 -4 9 -10 9 -5 0 -11 -19 -12 -42z M4981 13442 c-199
-103 -252 -317 -114 -455 87 -88 278 -156 332 -119 27 19 -4 47 -67 60 -128
26 -222 121 -222 223 0 49 55 166 117 251 52 71 38 83 -46 40z M4866 12892
c-3 -5 28 -58 68 -119 82 -125 100 -176 94 -262 -7 -96 -51 -149 -190 -225
-29 -17 -56 -29 -60 -28 -12 3 -9 -12 6 -33 11 -15 22 -17 69 -12 184 19 327
178 314 349 -8 92 -55 202 -110 256 -57 56 -174 101 -191 74z M12300 12375 c0
-32 -13 -67 -50 -138 l-50 -95 0 -144 c0 -326 59 -529 211 -731 93 -124 267
-257 359 -276 592 -121 958 -31 1278 316 51 56 109 112 127 125 19 12 35 28
35 35 0 10 -175 73 -203 73 -5 0 -39 -28 -76 -62 -156 -148 -352 -239 -552
-259 -360 -35 -556 -16 -730 72 -125 63 -226 232 -286 478 -51 213 -35 334 63
477 39 57 82 151 72 159 -2 1 -47 5 -100 7 l-98 5 0 -42z M5047 12123 c-4 -3
-7 -27 -7 -52 l0 -45 -27 26 c-40 37 -66 48 -112 48 -84 0 -84 -67 -1 -140 50
-44 50 -42 -10 -69 -27 -12 -50 -27 -50 -31 0 -17 41 -31 72 -25 l30 7 -29
-43 c-50 -74 -54 -85 -42 -113 25 -54 44 -44 136 68 36 44 34 46 49 -59 7 -54
17 -45 29 27 l6 37 36 -25 c20 -13 41 -23 47 -21 16 6 9 104 -10 156 l-17 44
32 26 c36 30 39 41 11 41 -18 0 -17 4 10 63 52 109 29 115 -72 18 l-38 -35 0
29 c0 61 -20 92 -43 68z M11670 11939 c0 -6 -21 -42 -46 -80 -43 -65 -108
-122 -260 -227 -41 -28 -204 -109 -238 -118 -34 -8 -33 -29 2 -42 164 -63 249
-92 266 -92 51 0 238 136 406 297 63 60 130 118 148 128 31 19 33 23 27 60 -8
50 4 44 -122 66 -124 21 -183 24 -183 8z M9032 11760 l3 -72 115 -35 c474
-143 821 -399 880 -653 23 -98 67 -215 82 -218 14 -3 135 254 145 309 4 24 -9
36 -169 150 -95 67 -218 157 -273 200 -264 202 -551 350 -748 384 l-38 6 3
-71z M10605 11509 c-2 -8 -27 -79 -56 -158 -69 -196 -109 -288 -147 -340 -18
-24 -32 -54 -32 -66 0 -12 -58 -141 -129 -286 -138 -281 -221 -464 -221 -484
0 -7 39 -30 87 -51 48 -22 156 -78 241 -126 84 -49 158 -88 164 -88 14 0 77
-38 108 -65 39 -34 351 -207 364 -202 7 3 45 85 85 183 148 360 373 880 422
975 27 53 83 145 124 204 41 58 75 110 75 114 0 4 -42 15 -92 25 -133 25 -193
47 -585 215 -384 164 -400 170 -408 150z m167 -214 c55 -10 149 -40 250 -79
90 -35 213 -81 273 -102 130 -44 121 -39 107 -67 -6 -12 -32 -79 -57 -149 -25
-69 -81 -207 -126 -305 -154 -338 -289 -682 -289 -734 0 -49 -33 -35 -440 194
-213 120 -253 145 -318 203 l-44 39 47 109 c83 194 308 618 398 749 26 38 47
74 47 82 0 14 47 75 58 75 4 0 46 -7 94 -15z M10808 10805 l-83 -105 -72 7
-73 6 0 -41 c0 -32 5 -44 26 -59 29 -21 27 -63 -2 -63 -34 0 -74 -56 -74 -103
0 -64 19 -76 62 -39 71 62 113 69 123 20 10 -49 39 -138 45 -138 13 0 45 69
65 139 l22 75 54 13 c30 6 67 12 83 13 28 0 96 56 96 79 0 21 -50 42 -119 50
-39 4 -73 10 -76 13 -11 10 17 142 37 178 19 32 19 35 2 47 -27 20 -28 20
-116 -92z M11280 9940 c-27 -55 -50 -113 -50 -128 0 -40 37 -220 105 -507 31
-132 79 -343 105 -470 65 -308 183 -643 366 -1038 110 -238 332 -637 355 -637
5 0 9 -4 9 -9 0 -36 254 -366 438 -568 l75 -83 219 0 c169 0 218 3 218 13 0 7
-86 98 -191 202 -427 426 -628 710 -1000 1420 -309 589 -495 1198 -565 1843
-9 87 -25 80 -84 -38z M7070 9950 c-147 -11 -275 -31 -279 -43 -2 -6 -33 -53
-67 -105 -35 -51 -64 -97 -64 -101 0 -4 98 -12 218 -18 180 -9 235 -15 325
-38 59 -15 110 -25 114 -22 3 3 -13 61 -35 129 -22 68 -43 142 -47 166 -8 48
9 45 -165 32z M10216 9787 c-3 -56 -11 -129 -16 -162 -5 -33 -17 -125 -25
-205 -50 -466 -160 -881 -367 -1394 -210 -519 -522 -1085 -784 -1423 -35 -45
-64 -86 -64 -92 0 -8 68 -11 213 -11 l212 1 61 82 c458 615 724 1332 879 2367
40 272 51 328 111 584 24 103 44 196 44 206 0 16 -221 150 -248 150 -5 0 -12
-46 -16 -103z M5350 9717 c0 -7 23 -44 51 -82 83 -114 134 -208 185 -345 27
-71 53 -130 58 -130 5 0 61 53 125 119 87 89 130 125 174 146 71 34 72 49 5
70 -29 10 -123 50 -208 90 -144 68 -343 145 -376 145 -8 0 -14 -6 -14 -13z
M14010 9663 c-34 -5 -265 -71 -315 -90 -40 -15 -194 -104 -217 -126 -7 -7 -45
-37 -83 -68 -39 -31 -85 -76 -103 -100 -84 -113 -100 -137 -124 -184 -89 -172
-119 -304 -113 -494 5 -159 25 -282 60 -356 7 -16 17 -43 21 -60 4 -16 10 -32
14 -35 4 -3 17 -26 28 -52 11 -27 25 -48 30 -48 5 0 21 -17 34 -37 14 -21 38
-52 54 -69 16 -17 41 -44 55 -60 15 -16 33 -34 40 -40 8 -6 37 -38 64 -70 101
-118 255 -260 318 -293 17 -10 79 -42 137 -73 126 -67 175 -83 304 -98 106
-13 197 -36 208 -53 18 -29 377 -36 547 -12 131 20 291 64 291 81 0 14 -3 15
-205 39 -172 21 -318 61 -452 126 -56 27 -108 49 -115 49 -20 0 -250 173 -308
231 -67 67 -200 226 -200 239 0 4 -14 25 -31 46 -17 22 -37 53 -45 69 -7 17
-18 37 -23 45 -20 32 -71 147 -71 161 0 8 -4 19 -9 24 -10 11 -42 118 -62 210
-32 141 -13 432 37 568 8 23 22 61 29 85 20 61 95 211 126 252 14 19 28 40 30
47 2 6 30 39 62 72 75 81 74 88 -13 74z M8305 9549 c-236 -70 -385 -120 -385
-132 0 -7 32 -37 71 -67 83 -64 138 -127 170 -193 13 -26 28 -47 35 -47 7 0
44 60 82 133 38 73 93 172 121 221 76 132 74 134 -94 85z M6575 9106 c-129
-26 -235 -75 -341 -160 -115 -91 -221 -239 -245 -339 -6 -29 -22 -71 -36 -93
-69 -120 -69 -477 0 -679 128 -373 363 -572 687 -583 192 -6 366 43 563 160
330 195 471 413 471 723 -1 474 -280 843 -722 956 -102 26 -285 33 -377 15z
M8324 8428 c29 -100 37 -177 38 -350 1 -119 5 -188 11 -188 15 0 188 109 331
209 72 50 149 99 173 108 64 26 54 37 -59 62 -111 25 -182 50 -355 130 -127
58 -149 62 -139 29z M5170 8324 c-151 -67 -365 -154 -380 -154 -42 0 14 -37
151 -99 175 -81 247 -123 325 -194 75 -68 77 -66 67 66 -4 61 -8 185 -8 275 0
139 -2 162 -15 162 -8 -1 -71 -26 -140 -56z M8107 7261 c-98 -175 -205 -315
-272 -358 -53 -33 -57 -50 -12 -57 393 -65 477 -83 564 -121 97 -43 107 -28
41 63 -24 33 -95 163 -158 290 -63 128 -119 232 -125 232 -5 0 -22 -22 -38
-49z M5540 7123 c-52 -114 -132 -246 -211 -345 -38 -48 -69 -92 -69 -98 0 -28
193 1 397 60 76 22 160 43 188 46 49 6 105 43 105 68 0 6 -24 27 -52 46 -59
40 -183 162 -248 243 -59 74 -68 72 -110 -20z M7090 6634 c-110 -28 -343 -56
-417 -52 -40 3 -73 1 -73 -4 0 -4 7 -35 16 -67 l17 -58 186 4 c241 5 332 12
335 26 2 7 13 44 25 83 11 39 21 73 21 77 0 10 -48 6 -110 -9z M13530 5010
c-8 -5 -25 -10 -36 -10 -14 0 -26 -10 -34 -30 -27 -65 -203 -208 -425 -345
-132 -81 -449 -245 -474 -245 -51 0 82 -96 444 -322 510 -317 1209 -707 2130
-1188 182 -95 403 -214 491 -266 89 -52 167 -94 174 -94 20 0 269 138 495 273
588 351 1128 762 1537 1168 87 86 158 163 158 171 0 10 -54 23 -202 50 -112
20 -525 106 -918 192 -919 199 -1432 305 -2230 460 -1018 198 -1076 208 -1110
186z m878 -300 c1828 -305 2219 -391 2912 -641 74 -27 144 -49 156 -49 72 0
21 -82 -175 -283 -336 -343 -652 -594 -924 -733 -61 -31 -171 -97 -245 -145
-73 -49 -139 -89 -145 -89 -7 0 -43 -18 -80 -40 -98 -57 -126 -63 -192 -40
-99 34 -218 96 -390 202 -220 136 -280 169 -580 325 -137 72 -416 227 -620
345 -389 225 -581 332 -935 518 -252 133 -303 163 -355 209 l-39 34 22 18 c12
9 64 40 115 67 123 67 229 142 354 249 82 70 249 188 272 192 3 1 385 -62 849
-139z M14650 4300 c-367 -36 -608 -140 -681 -294 -43 -91 -34 -133 40 -174
110 -62 409 -72 428 -15 11 32 -33 50 -138 57 -175 12 -249 34 -249 72 0 81
201 183 413 208 47 6 57 5 57 -8 0 -8 -5 -18 -10 -21 -16 -10 -58 -97 -65
-136 -30 -158 215 -333 495 -356 82 -6 194 12 305 48 209 70 237 218 80 425
-18 24 4 26 107 9 312 -52 568 -149 568 -215 0 -27 -55 -42 -301 -81 -219 -36
-218 -35 -64 -65 205 -41 424 9 491 111 59 90 -96 232 -344 315 -271 91 -825
149 -1132 120z M7595 4949 c-11 -5 -238 -34 -505 -64 -425 -49 -941 -116
-1860 -240 -355 -48 -1017 -130 -1250 -155 -382 -41 -498 -50 -737 -57 -171
-4 -243 -9 -243 -17 0 -18 71 -82 210 -191 69 -54 213 -176 320 -270 489 -429
463 -409 1070 -802 377 -243 548 -348 752 -461 191 -106 503 -262 524 -262 8
0 55 33 102 73 210 176 309 247 682 497 907 606 1580 1024 1903 1181 89 44 87
57 -15 99 -365 147 -679 377 -886 648 -26 34 -34 36 -67 21z m-14 -156 c75
-67 186 -179 313 -316 60 -65 145 -150 190 -190 51 -45 81 -79 81 -92 0 -15
-51 -52 -220 -158 -283 -177 -565 -363 -785 -517 -277 -194 -395 -272 -545
-357 -77 -44 -201 -123 -275 -176 -130 -93 -285 -182 -361 -206 -33 -11 -44
-8 -130 29 -366 158 -1139 654 -1494 959 -55 47 -194 179 -309 293 -209 206
-210 207 -182 218 49 18 157 29 361 35 126 4 264 15 375 30 96 14 285 36 420
50 659 68 1077 138 1905 317 467 101 588 127 596 127 4 1 30 -20 60 -46z
M6446 4333 c-11 -29 -6 -49 29 -97 74 -104 96 -249 59 -377 -42 -144 -372
-359 -553 -359 -189 0 -395 77 -635 239 -70 47 -192 120 -270 162 -165 89
-161 91 -121 -58 60 -220 149 -316 410 -443 453 -219 946 -177 1201 103 145
158 188 446 98 648 -44 98 -201 229 -218 182z M12020 4179 c-114 -47 -598
-159 -835 -194 -186 -27 -175 -24 -175 -48 0 -12 13 -103 30 -202 212 -1289
287 -1748 324 -2004 25 -167 47 -306 50 -308 7 -7 361 13 591 32 836 72 1523
197 2200 400 360 108 795 267 795 290 0 7 -120 90 -267 185 -828 536 -1648
1110 -2465 1727 -179 135 -195 143 -248 122z m161 -290 c258 -130 1123 -685
1469 -942 263 -196 365 -284 463 -402 27 -33 61 -66 76 -74 67 -35 125 -90
163 -153 l40 -67 -36 -34 c-75 -71 -572 -257 -1022 -382 -594 -166 -1254 -259
-1599 -226 -165 15 -269 32 -254 42 38 23 -19 430 -190 1349 -61 326 -73 403
-92 627 -14 166 -14 166 53 158 39 -5 81 0 158 19 171 40 462 96 547 105 140
15 159 13 224 -20z M12143 3538 c-6 -7 -13 -87 -17 -178 -4 -90 -9 -166 -11
-168 -7 -7 -210 39 -232 53 -58 38 -143 40 -143 4 0 -11 138 -149 149 -149 3
0 51 -44 105 -99 l98 -98 -12 -79 c-6 -43 -25 -141 -41 -217 -34 -163 -36
-205 -9 -257 29 -56 52 -66 107 -45 47 18 161 105 228 174 21 23 47 41 56 41
10 0 66 -50 126 -111 177 -182 198 -193 231 -126 15 31 -6 92 -94 269 -30 59
-54 111 -54 116 0 4 55 34 123 65 100 48 127 65 150 97 58 82 36 100 -258 204
-120 42 -223 83 -231 91 -13 12 -100 209 -163 368 -23 55 -24 57 -61 57 -21 0
-42 -6 -47 -12z M8964 3852 c-880 -757 -1975 -1681 -2088 -1762 -25 -18 -46
-39 -46 -45 0 -14 256 -99 540 -181 917 -262 1977 -418 3068 -450 l232 -7 0
859 c0 789 -13 1606 -25 1645 -5 15 -40 17 -308 22 -376 6 -637 33 -957 98
-79 16 -151 29 -160 29 -8 -1 -123 -94 -256 -208z m456 23 c10 -12 38 -15 136
-15 69 0 220 -11 337 -25 250 -29 553 -54 577 -48 29 8 78 -24 84 -54 4 -16
11 -282 16 -593 6 -311 13 -686 16 -835 5 -209 3 -309 -10 -445 -15 -155 -15
-175 -1 -183 33 -18 -5 -98 -56 -116 -17 -6 -142 -16 -277 -22 -666 -30 -1548
50 -1947 178 -60 19 -203 73 -316 119 -125 51 -244 93 -300 105 -52 11 -132
36 -179 56 -54 23 -102 37 -132 37 -25 1 -49 4 -53 7 -23 24 209 219 260 219
27 0 114 74 227 194 51 55 210 208 353 340 338 313 586 548 870 826 220 216
233 227 295 247 78 27 84 27 100 8z M9194 3551 c-44 -33 -99 -119 -108 -169
-7 -38 29 -81 68 -83 89 -4 136 24 155 96 11 41 -11 130 -40 161 -28 30 -27
30 -75 -5z M9706 3478 c-29 -39 -42 -83 -27 -92 6 -4 11 -16 11 -26 0 -46 87
-66 133 -30 33 26 42 67 26 122 -16 52 -23 58 -76 58 -36 0 -46 -5 -67 -32z
M10133 3314 c-68 -34 -132 -157 -119 -228 9 -46 58 -103 96 -111 51 -11 141
13 172 47 40 43 44 84 18 170 -36 118 -92 159 -167 122z M9425 3249 c-164 -38
-351 -188 -432 -345 -96 -184 -72 -329 73 -463 154 -141 275 -169 489 -115
249 64 403 315 340 553 -56 215 -168 330 -350 361 -27 5 -57 11 -65 13 -8 3
-33 1 -55 -4z M8756 3105 c-43 -43 -59 -67 -72 -112 l-17 -57 32 -28 c41 -37
138 -41 172 -7 55 55 57 148 5 226 -31 47 -56 43 -120 -22z M10169 2735 c-46
-35 -106 -125 -114 -175 -15 -91 86 -166 178 -131 57 22 94 158 65 242 -30 89
-68 108 -129 64z M8549 2530 c-70 -37 -119 -120 -119 -202 0 -50 52 -88 121
-88 56 0 88 22 125 87 26 43 26 46 13 101 -23 97 -76 135 -140 102z M9948
2234 c-80 -67 -110 -121 -113 -208 -3 -74 -3 -76 27 -101 28 -24 36 -26 121
-23 l90 3 20 38 c36 70 15 224 -42 294 -33 42 -49 41 -103 -3z M9237 2139
c-54 -29 -105 -110 -118 -190 -10 -63 -10 -64 18 -87 83 -69 201 -55 256 30
32 50 33 75 6 156 -34 102 -86 131 -162 91z"/>
<path id="eye" fill="#04837e" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M7838 16148 c-4 -91 19 -362 38 -458 35 -176 61 -235 122 -282 71
-53 83 -63 145 -117 57 -49 128 -96 204 -134 64 -33 250 -97 280 -97 13 0 40
-7 62 -16 40 -16 40 -16 88 17 140 97 296 264 416 446 36 56 71 104 77 108 30
19 3 19 -47 1 -50 -18 -80 -21 -218 -20 -241 1 -404 38 -610 140 -114 56 -330
208 -320 225 4 5 0 9 -8 9 -16 0 -207 195 -207 211 0 5 -4 9 -10 9 -5 0 -11
-19 -12 -42z"/>
<path id="eye_glint" fill="#0fd077" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M7846 16181 c-30 -48 16 -474 70 -648 24 -77 30 -85 79 -122 l54 -41
-39 75 c-79 156 -92 323 -35 439 17 33 39 65 50 70 11 6 22 12 24 14 3 1 -31
40 -75 85 -45 45 -90 95 -102 110 -11 15 -23 23 -26 18z M9222 15618 c-30 -10
-86 -23 -125 -29 l-72 -11 -2 -66 c-3 -161 -132 -338 -305 -420 -58 -28 -72
-42 -40 -42 10 0 23 -5 29 -11 25 -25 199 112 325 257 63 72 262 350 246 343
-2 -1 -27 -10 -56 -21z"/>
</svg>

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dkgqjm6y55p6k"
path="res://.godot/imported/fortune_teller.svg-26b2d1470e7041a80e0cff58e1a65231.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/fortune_teller.svg"
dest_files=["res://.godot/imported/fortune_teller.svg-26b2d1470e7041a80e0cff58e1a65231.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=0.25
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View file

@ -0,0 +1,624 @@
<svg xmlns="http://www.w3.org/2000/svg" width="2048" height="2048" viewBox="0 0 2048 2048">
<!-- Traced from fortune_teller.png with potrace, one layer per palette colour. -->
<path id="outline" fill="#1c0329" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M11542 20143 c-113 -359 -208 -671 -248 -813 -25 -91 -58 -205 -72
-254 l-27 -90 -85 -22 c-47 -12 -111 -32 -142 -43 -32 -12 -74 -21 -95 -21
-21 0 -56 -5 -78 -10 -104 -24 -254 -31 -308 -15 -96 28 -863 108 -1202 125
-115 5 -200 14 -235 25 -184 55 -795 -66 -1095 -218 -143 -72 -382 -273 -706
-597 -124 -124 -304 -299 -399 -390 -861 -820 -1579 -2044 -1880 -3205 -107
-412 -161 -852 -121 -983 22 -71 45 -112 64 -112 12 0 63 -78 56 -84 -2 -1
-20 -12 -39 -24 -183 -110 -182 -371 2 -480 45 -27 37 -52 -12 -39 -63 17 -65
1 -11 -83 l48 -75 6 -183 6 -182 -38 -28 c-51 -35 -144 -87 -153 -84 -11 3
-10 -6 2 -29 14 -25 75 -25 146 -1 l51 18 6 -80 c7 -89 7 -92 -21 -77 -30 16
-98 13 -116 -5 -23 -22 2 -78 54 -124 50 -44 50 -42 -10 -69 -27 -12 -50 -27
-50 -31 0 -17 41 -31 72 -25 l30 7 -29 -43 c-50 -74 -54 -85 -42 -113 25 -54
44 -44 136 68 36 44 34 46 49 -59 7 -54 17 -45 29 27 l6 37 36 -25 c20 -13 41
-23 47 -21 16 6 9 104 -10 156 l-17 44 32 26 c36 30 39 41 11 41 -18 0 -17 4
10 63 52 109 29 115 -72 18 l-38 -35 0 29 c0 45 -11 75 -26 75 -11 0 -14 19
-14 81 0 80 0 81 40 126 58 66 83 141 77 225 -7 81 -55 203 -97 243 -43 41
-41 77 2 64 41 -11 109 -12 127 0 24 16 -4 48 -49 55 -22 3 -59 14 -81 23
l-41 16 7 136 c4 85 3 166 -4 216 -10 69 -9 80 4 88 9 5 20 19 25 31 11 30
147 122 233 159 97 40 197 56 357 57 l135 0 48 -89 c97 -182 186 -445 224
-666 28 -163 25 -598 -5 -769 -30 -167 -73 -309 -127 -421 -53 -111 -67 -124
-157 -147 -215 -55 -525 -278 -542 -391 -4 -26 -3 -54 3 -65 8 -16 4 -21 -27
-36 -203 -97 -548 -475 -714 -782 -23 -43 -90 -146 -147 -229 -247 -353 -342
-508 -591 -965 -762 -1396 -1201 -2048 -1753 -2604 -182 -183 -380 -356 -408
-356 -47 0 -687 -62 -783 -75 -143 -21 -180 -37 -211 -90 -27 -45 -33 -100
-13 -108 7 -2 54 4 103 14 82 16 920 83 2075 164 1186 83 2309 132 3595 154
562 10 3034 10 3870 0 352 -4 1205 -15 1895 -23 4425 -56 6175 -59 7112 -11
l276 14 128 63 c112 55 162 88 164 109 0 3 -73 32 -162 64 -185 66 -172 64
-671 85 l-258 10 -102 79 c-56 43 -145 108 -196 145 -103 72 -113 84 -559 581
-152 170 -365 402 -472 515 -626 657 -1251 1471 -1453 1892 -128 268 -223 421
-438 709 -349 467 -616 760 -816 892 -60 40 -89 65 -83 71 33 33 -24 107 -130
170 -153 91 -744 357 -859 387 -109 28 -261 148 -434 343 l-61 68 64 -7 c345
-37 665 -85 1275 -189 225 -39 408 -59 734 -81 343 -23 361 -21 492 46 36 18
52 39 29 39 -6 0 -9 82 -9 218 0 461 -58 696 -280 1139 -347 693 -847 1301
-1403 1706 -70 51 -108 85 -110 99 -2 17 -40 41 -178 109 -406 203 -624 279
-985 343 l-180 33 -32 144 c-31 136 -62 327 -98 592 l-16 117 129 128 c156
155 228 258 272 389 47 144 23 210 -68 184 -16 -5 -96 -5 -178 0 -82 4 -158 8
-170 8 -20 1 -21 8 -28 169 -3 92 -12 204 -19 250 l-13 83 60 49 c105 84 214
202 232 251 53 146 62 203 53 325 -19 253 -95 534 -224 827 -48 109 -108 197
-120 177 -5 -8 -11 -8 -19 -1 -12 10 -86 -65 -86 -87 0 -10 -224 -255 -298
-326 l-40 -38 45 133 c103 310 128 496 97 746 -5 48 -11 57 -62 104 -114 104
-248 178 -324 179 -27 0 -38 4 -38 15 0 8 -8 15 -18 15 -15 0 -25 -21 -50 -97z
m79 -1560 c-10 -16 -40 -48 -65 -73 -59 -56 -59 -70 -2 -70 59 0 61 -7 24 -80
-29 -56 -31 -63 -15 -71 20 -12 5 -49 -33 -84 -12 -11 -36 -40 -53 -64 -27
-40 -31 -42 -43 -27 -15 22 -9 42 23 78 16 17 23 33 19 45 -4 12 5 37 24 66
40 63 39 77 -5 77 -25 0 -37 6 -46 21 -10 20 -4 28 56 85 42 40 65 69 62 78
-4 9 6 20 26 30 45 22 51 20 28 -11z m83 -1626 c3 -18 1 -48 -5 -65 -8 -24 -8
-36 1 -47 14 -16 4 -39 -33 -73 -25 -24 -25 -24 -36 -4 -16 30 -14 52 11 99
20 37 21 44 9 67 -11 21 -12 28 -1 41 22 27 47 18 54 -18z m-1056 -48 c88 -40
231 -93 307 -114 117 -32 191 -58 289 -102 277 -124 459 -165 738 -167 205 -2
186 -14 -54 -33 -137 -12 -139 -13 -131 -116 5 -70 12 -94 49 -167 25 -49 50
-119 59 -165 20 -94 41 -140 69 -154 16 -8 -2 -9 -64 -5 -47 4 -86 8 -88 9 -1
1 3 35 9 76 20 140 -56 328 -206 504 -43 51 -44 51 -139 69 -77 14 -100 23
-115 42 -13 17 -39 28 -87 39 -286 66 -551 173 -707 286 -55 40 -19 39 71 -2z
m-2208 -149 c349 -30 783 -217 972 -419 70 -75 229 -324 215 -337 -9 -9 -414
245 -617 386 -252 176 -532 270 -800 270 -126 0 -173 10 -164 34 9 25 103 57
188 65 44 5 83 9 86 10 3 0 57 -4 120 -9z m-686 -192 c-4 -7 -20 -32 -36 -56
-46 -68 -95 -179 -127 -290 -16 -57 -37 -115 -47 -129 -37 -58 -2 -378 78
-698 134 -538 324 -976 836 -1920 232 -427 344 -653 411 -830 47 -125 51 -130
80 -133 27 -3 32 -10 60 -80 l29 -77 74 0 c134 0 681 25 783 36 55 6 187 26
294 45 107 19 220 34 251 34 32 0 111 9 177 21 65 12 172 22 238 24 66 1 171
8 233 15 88 11 126 11 176 2 35 -7 81 -12 102 -12 22 0 50 -7 64 -15 14 -8 33
-17 42 -21 16 -6 20 -35 7 -48 -13 -14 -141 -26 -160 -16 -15 8 -63 8 -175 -1
-140 -11 -156 -14 -166 -33 -6 -12 -30 -43 -53 -71 -110 -131 -173 -263 -225
-462 -14 -56 -53 -123 -66 -115 -74 48 -18 329 114 574 20 37 33 71 29 75 -12
11 -839 -50 -1037 -77 -236 -32 -543 -41 -671 -20 -95 15 -89 7 -263 370 -70
146 -185 375 -256 510 -71 135 -154 298 -184 362 -38 80 -62 118 -76 123 -43
14 -264 501 -393 870 -19 55 -58 147 -85 205 -64 133 -125 310 -163 468 -16
68 -36 134 -44 146 -19 28 -51 166 -70 297 -9 57 -23 133 -32 169 -25 102 -24
293 3 350 11 25 29 79 39 120 38 160 68 207 176 277 41 26 42 26 33 11z m3276
-628 c431 -23 593 -39 697 -70 169 -50 243 -78 322 -121 42 -23 102 -55 134
-71 85 -42 139 -77 132 -88 -3 -5 7 -16 22 -24 37 -20 40 -20 -159 14 -240 42
-612 93 -933 130 -614 70 -675 81 -729 131 -20 18 -20 19 0 40 64 71 131 79
514 59z m1265 -90 l20 -9 -20 1 c-11 0 -31 4 -45 8 l-25 8 25 0 c14 0 34 -3
45 -8z m-2385 -260 c-30 -42 -123 -154 -214 -256 -95 -107 -187 -229 -229
-303 -42 -74 -47 -47 -6 29 84 158 271 396 389 496 86 73 89 75 60 34z m3731
-416 c24 -20 63 -49 87 -66 29 -20 40 -34 34 -40 -16 -16 -137 -45 -307 -73
-220 -36 -207 -32 -200 -66 12 -54 -102 -131 -235 -159 l-61 -13 3 -36 c3 -38
-3 -34 106 -61 33 -9 62 -29 117 -81 67 -64 73 -73 78 -120 8 -66 5 -73 -67
-123 -328 -233 -1154 -426 -1891 -443 -860 -19 -1596 135 -1983 417 -46 33
-89 60 -96 60 -16 0 -54 -122 -66 -213 -16 -108 -23 -115 -64 -66 -32 38 -33
74 -6 187 24 100 36 124 100 201 49 59 51 60 69 42 29 -29 276 -147 377 -180
609 -199 1963 -179 2794 41 100 27 119 51 48 62 -69 11 -88 29 -88 81 0 61 62
181 107 208 24 13 33 26 34 45 0 15 15 54 32 87 42 77 70 91 223 111 151 19
156 21 186 86 42 87 58 96 173 103 55 3 142 10 193 16 70 8 97 8 107 -1 19
-16 112 -3 119 16 9 23 31 16 77 -22z m-5279 -841 c153 -184 256 -265 463
-368 514 -253 1396 -412 3025 -545 1121 -92 1502 -147 2020 -292 482 -134 729
-262 1210 -627 222 -167 225 -178 40 -116 -72 24 -130 41 -130 37 0 -3 -5 -1
-11 5 -6 6 -18 9 -25 6 -8 -3 -14 0 -14 6 0 6 -7 8 -17 4 -11 -4 -14 -3 -9 5
5 8 2 10 -8 6 -10 -4 -16 -1 -16 8 0 10 -75 38 -242 92 -134 42 -364 117 -513
166 -746 246 -1060 302 -2190 395 -1137 93 -1856 205 -2501 390 -537 155 -868
336 -1065 585 -81 102 -151 217 -151 246 0 24 37 84 52 84 5 0 42 -39 82 -87z
m-3392 -1179 c-6 -71 -13 -130 -14 -132 -10 -9 -46 90 -46 127 0 49 47 158 62
143 5 -5 5 -58 -2 -138z m4211 -96 c209 -325 348 -470 539 -562 54 -26 78 -42
66 -44 -10 -2 -21 0 -25 5 -3 5 -40 25 -81 44 -187 89 -402 303 -510 511 -38
73 -73 158 -66 158 2 0 37 -51 77 -112z m2846 -644 l32 -6 -31 -61 c-18 -34
-39 -86 -49 -116 l-16 -55 -109 -22 c-60 -12 -134 -31 -164 -43 l-55 -22 -63
68 c-34 37 -92 108 -127 158 l-64 90 77 5 c118 9 533 11 569 4z m-1311 -2785
c3 -5 -8 -9 -24 -9 -21 0 -31 6 -35 19 -4 17 -2 18 24 9 16 -5 32 -14 35 -19z
M13398 5081 c-27 -11 -77 -46 -114 -80 -167 -152 -527 -353 -891 -496 l-122
-48 69 -48 c37 -26 78 -62 89 -78 23 -32 223 -183 476 -358 752 -522 2320
-1426 2737 -1578 57 -21 119 -46 139 -56 l36 -18 75 37 c41 21 81 43 89 50 8
7 102 65 209 128 728 430 1528 1071 1868 1497 31 40 60 74 63 77 18 16 80 143
73 150 -5 4 -101 31 -214 58 -881 218 -3660 693 -4315 738 -71 5 -103 12 -111
22 -7 10 -21 13 -38 10 -14 -3 -29 -1 -32 3 -8 13 -34 10 -86 -10z M7465 5023
c-22 -2 -166 -12 -320 -24 -368 -26 -810 -67 -1460 -135 -734 -76 -1342 -137
-1794 -179 -389 -36 -530 -53 -858 -103 -101 -16 -186 -25 -191 -20 -4 4 -27
-2 -50 -14 l-43 -21 24 -26 c13 -14 32 -38 42 -53 9 -16 25 -28 34 -28 10 0
42 -30 72 -66 65 -81 259 -260 428 -398 69 -55 204 -177 300 -270 581 -558
1105 -941 1781 -1301 91 -48 210 -112 264 -142 156 -84 166 -85 231 -24 30 28
59 51 65 51 7 0 37 19 68 43 32 23 100 69 152 102 128 79 169 108 825 575 861
614 1110 786 1410 975 77 49 169 112 205 141 36 28 119 88 185 133 66 44 141
100 168 124 l47 43 -97 33 c-159 53 -317 118 -495 202 -92 44 -263 119 -380
168 -117 48 -258 109 -312 135 -54 25 -105 46 -112 46 -7 0 -18 9 -24 20 -11
20 -46 23 -165 13z M11910 4349 c-302 -82 -570 -128 -973 -164 l-68 -7 6 -96
c4 -54 13 -117 21 -142 8 -25 28 -164 44 -310 37 -324 73 -596 151 -1150 88
-627 141 -1041 136 -1055 -4 -10 4 -53 38 -203 l6 -24 202 7 c1052 32 2304
274 3263 630 126 47 209 80 579 232 61 25 113 48 117 51 4 4 -38 34 -94 67
-55 33 -117 74 -137 92 -21 18 -285 187 -587 376 -302 189 -643 404 -759 479
-541 348 -1633 1072 -1651 1094 -24 30 -169 154 -179 153 -5 -1 -57 -14 -115
-30z M9267 4215 c-60 -57 -133 -120 -163 -142 -156 -110 -2134 -1686 -2349
-1872 -109 -93 -275 -270 -275 -291 0 -9 71 -42 110 -51 19 -4 134 -42 255
-83 1050 -358 2250 -557 3570 -592 148 -4 263 -11 266 -16 4 -7 14 -6 27 1 11
6 52 14 90 17 l70 7 7 51 c32 234 -55 2150 -116 2566 -6 41 -12 86 -14 100 -1
14 -10 79 -20 145 l-18 120 -54 -3 c-255 -17 -974 65 -1263 143 -9 2 -60 -39
-123 -100z"/>
<path id="cloth" fill="#5d0e75" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M9025 18829 c-22 -4 -126 -8 -231 -8 -213 -1 -364 -13 -502 -41 l-92
-18 -109 -104 c-60 -57 -146 -131 -191 -164 -547 -398 -661 -497 -910 -794
-421 -501 -416 -493 -692 -1164 -310 -755 -374 -1368 -209 -2016 62 -241 18
-221 -63 30 -181 559 -156 1207 70 1865 97 280 84 286 -83 38 -479 -711 -811
-1451 -977 -2178 -93 -408 -97 -601 -13 -692 29 -32 44 -29 117 28 181 139
447 209 626 165 102 -26 236 -87 249 -113 7 -12 34 -46 61 -75 37 -39 54 -67
63 -103 7 -27 25 -75 41 -105 220 -428 161 -1323 -116 -1762 -33 -52 -31 -58
20 -58 193 0 432 -44 586 -107 117 -48 250 -66 620 -83 169 -8 210 -13 310
-40 136 -36 146 -43 94 -65 -280 -121 -505 -114 -1042 29 -74 20 -151 36 -172
36 -22 0 -141 20 -266 45 -255 51 -280 53 -333 25 -31 -15 -259 -90 -277 -90
-2 0 -4 -6 -4 -14 0 -8 25 -26 56 -40 78 -36 175 -117 247 -206 47 -59 75 -83
130 -113 38 -20 89 -51 113 -68 74 -51 244 -134 339 -165 89 -29 92 -29 325
-29 359 0 590 64 880 244 155 97 430 337 430 376 0 6 20 49 44 96 118 226 141
350 132 722 -7 277 -7 278 -41 396 -43 150 -101 282 -197 446 -41 72 -87 154
-102 183 -15 29 -62 108 -104 175 -328 522 -608 1355 -671 1997 -25 252 -21
654 8 707 5 10 21 54 36 98 66 195 194 407 324 534 128 126 135 136 332 527
100 198 212 413 250 479 40 71 98 198 143 312 72 185 191 469 236 563 l21 45
-6 -55 c-10 -86 -71 -339 -109 -453 -33 -101 -59 -160 -205 -475 -92 -200 -92
-199 3 -157 144 64 367 96 538 77 224 -25 367 -82 541 -219 142 -111 259 -185
345 -217 69 -26 319 -96 344 -96 22 0 94 80 122 135 52 106 58 182 26 325 -22
94 -24 128 -24 320 1 334 44 493 186 680 40 53 108 163 108 175 0 8 -28 15
-86 19 -47 4 -194 30 -327 57 -634 130 -850 162 -962 138z m635 -807 c64 -149
89 -213 77 -202 -5 5 -175 384 -184 410 -20 60 52 -80 107 -208z m-4402 -3878
c68 -37 172 -103 172 -109 0 -10 -113 30 -175 60 -79 39 -85 41 -85 20 0 -19
89 -208 128 -270 37 -59 34 -65 -26 -65 -111 0 -265 71 -230 106 13 13 19 13
49 0 60 -27 165 -66 177 -66 17 0 15 18 -7 48 -36 52 -73 135 -92 209 -18 72
-18 77 -1 89 22 17 13 19 90 -22z m2038 -1890 c59 -20 135 -42 168 -49 34 -7
51 -14 38 -14 -78 -3 -362 83 -494 149 -68 34 -218 127 -218 135 0 2 90 -39
200 -91 109 -52 247 -110 306 -130z m287 -71 c-7 -2 -21 -2 -30 0 -10 3 -4 5
12 5 17 0 24 -2 18 -5z m-388 -584 c33 -5 -3 -7 -110 -4 -88 3 -178 9 -200 13
-53 12 243 3 310 -9z M10523 18603 c-122 -130 -233 -288 -233 -332 0 -10 -13
-86 -29 -168 -54 -271 -65 -500 -35 -715 26 -182 2 -271 -98 -371 -26 -26 -48
-52 -48 -57 0 -15 -13 -19 -114 -35 -199 -32 -405 29 -582 173 -94 77 -435
246 -559 278 -183 48 -453 45 -611 -7 -113 -37 -145 -64 -208 -182 -81 -151
-82 -150 77 -72 220 107 338 124 519 76 106 -29 312 -137 510 -268 184 -122
255 -155 452 -213 72 -21 150 -46 174 -54 53 -19 207 -56 233 -56 10 0 38 10
62 21 41 20 48 31 115 163 40 77 94 181 121 230 101 183 120 282 131 701 5
182 13 355 19 385 37 185 117 384 208 513 41 58 41 67 1 67 -27 0 -44 -12
-105 -77z M10935 18548 c-146 -87 -306 -285 -325 -404 -15 -93 -13 -214 4
-214 43 0 246 282 360 501 92 176 87 192 -39 117z M11845 17614 c-162 -78
-432 -176 -647 -235 -59 -16 -88 -28 -88 -38 0 -12 38 -13 258 -8 260 7 644
26 651 33 2 2 -8 50 -23 106 -15 57 -32 120 -37 141 -12 46 -22 46 -114 1z
M12100 16511 c-14 -4 -76 -11 -139 -15 -164 -10 -167 -11 -162 -116 3 -77 7
-93 46 -170 26 -50 51 -118 60 -165 25 -115 41 -142 95 -161 25 -9 63 -25 86
-35 50 -23 83 -24 128 -2 29 13 42 14 70 6 43 -13 58 12 32 52 -9 13 -20 64
-26 112 -16 146 -89 457 -112 478 -19 18 -49 24 -78 16z M7352 16218 c-60
-122 -95 -225 -111 -328 -7 -41 -16 -93 -22 -115 -11 -45 58 -627 106 -890
112 -618 417 -1417 641 -1680 182 -215 294 -447 350 -724 14 -69 34 -160 44
-201 61 -243 44 -502 -50 -737 -201 -503 -841 -959 -1400 -999 -199 -14 -548
75 -733 186 -90 54 -102 53 -93 -7 4 -27 10 -75 13 -108 6 -59 7 -61 73 -119
184 -163 382 -231 675 -230 329 0 636 92 952 285 308 189 614 521 779 844 l37
75 10 227 c23 535 -34 751 -399 1506 -402 830 -576 1275 -709 1812 -117 471
-155 926 -100 1195 30 147 7 150 -63 8z M7838 16148 c-4 -91 19 -362 38 -458
35 -176 61 -235 122 -282 71 -53 83 -63 145 -117 57 -49 128 -96 204 -134 64
-33 250 -97 280 -97 13 0 40 -7 62 -16 40 -16 40 -16 88 17 140 97 296 264
416 446 36 56 71 104 77 108 30 19 3 19 -47 1 -50 -18 -80 -21 -218 -20 -241
1 -404 38 -610 140 -114 56 -330 208 -320 225 4 5 0 9 -8 9 -16 0 -207 195
-207 211 0 5 -4 9 -10 9 -5 0 -11 -19 -12 -42z M4981 13442 c-199 -103 -252
-317 -114 -455 87 -88 278 -156 332 -119 27 19 -4 47 -67 60 -128 26 -222 121
-222 223 0 49 55 166 117 251 52 71 38 83 -46 40z M4866 12892 c-3 -5 28 -58
68 -119 82 -125 100 -176 94 -262 -7 -96 -51 -149 -190 -225 -29 -17 -56 -29
-60 -28 -12 3 -9 -12 6 -33 11 -15 22 -17 69 -12 184 19 327 178 314 349 -8
92 -55 202 -110 256 -57 56 -174 101 -191 74z M12300 12375 c0 -32 -13 -67
-50 -138 l-50 -95 0 -144 c0 -326 59 -529 211 -731 93 -124 267 -257 359 -276
592 -121 958 -31 1278 316 51 56 109 112 127 125 19 12 35 28 35 35 0 10 -175
73 -203 73 -5 0 -39 -28 -76 -62 -156 -148 -352 -239 -552 -259 -360 -35 -556
-16 -730 72 -125 63 -226 232 -286 478 -51 213 -35 334 63 477 39 57 82 151
72 159 -2 1 -47 5 -100 7 l-98 5 0 -42z M12554 12358 c0 -44 -50 -188 -66
-188 -15 0 3 -359 24 -465 22 -115 65 -225 107 -276 110 -133 497 -202 806
-144 139 26 309 106 422 197 98 80 96 82 -111 152 -177 59 -231 86 -402 200
-57 38 -92 55 -100 50 -7 -5 -56 -42 -111 -83 -139 -105 -140 -105 -24 7 57
55 102 105 100 110 -5 14 -147 132 -158 132 -6 0 -40 -58 -77 -130 -126 -245
-152 -247 -55 -3 82 206 79 183 25 250 -51 63 -69 98 -85 171 l-10 49 -97 6
c-53 4 -118 7 -143 7 l-46 0 1 -42z M5047 12123 c-4 -3 -7 -27 -7 -52 l0 -45
-27 26 c-40 37 -66 48 -112 48 -84 0 -84 -67 -1 -140 50 -44 50 -42 -10 -69
-27 -12 -50 -27 -50 -31 0 -17 41 -31 72 -25 l30 7 -29 -43 c-50 -74 -54 -85
-42 -113 25 -54 44 -44 136 68 36 44 34 46 49 -59 7 -54 17 -45 29 27 l6 37
36 -25 c20 -13 41 -23 47 -21 16 6 9 104 -10 156 l-17 44 32 26 c36 30 39 41
11 41 -18 0 -17 4 10 63 52 109 29 115 -72 18 l-38 -35 0 29 c0 61 -20 92 -43
68z M11670 11939 c0 -6 -21 -42 -46 -80 -43 -65 -108 -122 -260 -227 -41 -28
-204 -109 -238 -118 -34 -8 -33 -29 2 -42 164 -63 249 -92 266 -92 51 0 238
136 406 297 63 60 130 118 148 128 31 19 33 23 27 60 -8 50 4 44 -122 66 -124
21 -183 24 -183 8z M9032 11760 l3 -72 115 -35 c474 -143 821 -399 880 -653
23 -98 67 -215 82 -218 14 -3 135 254 145 309 4 24 -9 36 -169 150 -95 67
-218 157 -273 200 -264 202 -551 350 -748 384 l-38 6 3 -71z M11980 11692 c0
-54 -288 -267 -431 -318 -59 -21 -61 -34 -12 -58 44 -21 158 -95 195 -128 l27
-23 -13 -110 c-25 -206 -74 -349 -223 -645 -90 -180 -90 -178 -68 -241 9 -23
25 -124 36 -223 11 -100 31 -224 44 -277 14 -52 38 -163 55 -245 132 -636 251
-936 712 -1789 203 -376 597 -851 900 -1086 l63 -49 2588 0 c2063 0 2587 3
2587 13 0 6 -44 40 -98 74 -127 81 -322 243 -502 418 -139 135 -333 295 -360
295 -6 0 -44 -30 -84 -66 -241 -224 -531 -336 -865 -333 l-146 1 65 15 c353
78 611 177 785 301 88 62 165 130 165 145 0 16 -245 247 -262 247 -8 0 -32
-18 -53 -41 -83 -85 -327 -219 -465 -255 -61 -15 -252 -45 -258 -39 -1 1 32
15 75 30 264 92 598 270 633 336 14 25 6 49 -14 49 -9 0 -13 6 -10 14 4 9 -34
60 -97 133 -233 269 -484 599 -684 898 -124 186 -117 175 -164 266 -22 42 -46
79 -54 82 -14 5 -113 164 -219 352 -60 106 -121 228 -169 339 -22 50 -50 102
-63 116 -41 44 -139 179 -291 400 -509 739 -731 983 -920 1012 -27 4 -59 10
-71 13 -16 5 -32 -8 -84 -72 -142 -173 -235 -256 -375 -336 -279 -160 -649
-219 -884 -141 -84 29 -405 191 -479 243 -210 149 -359 347 -448 596 -20 57
-38 91 -48 93 -9 2 -16 -1 -16 -6z m2695 -1808 l102 -16 -24 -24 c-13 -13 -28
-24 -32 -24 -11 0 -125 -75 -149 -97 -10 -10 -58 -54 -105 -98 -48 -44 -87
-85 -87 -91 0 -6 -9 -19 -19 -29 -11 -9 -37 -44 -58 -76 -20 -32 -40 -59 -44
-59 -9 0 -88 -105 -116 -155 -91 -162 -127 -276 -138 -436 -6 -92 14 -349 27
-349 4 0 8 -13 8 -28 0 -27 28 -117 54 -177 8 -16 17 -41 21 -55 5 -14 19 -42
31 -62 13 -21 24 -42 24 -47 0 -5 6 -16 13 -23 8 -7 26 -32 40 -55 35 -56 225
-251 263 -271 18 -10 58 -35 90 -57 109 -75 264 -135 459 -180 127 -29 629
-60 788 -48 l88 6 -100 -102 c-56 -55 -106 -101 -111 -101 -11 0 -91 -50 -100
-62 -12 -15 -219 -108 -275 -122 -383 -99 -652 -109 -1031 -41 -328 59 -739
264 -902 449 -15 18 -35 35 -43 38 -8 3 -28 25 -44 49 -17 24 -35 49 -41 54
-13 11 -84 143 -84 156 0 8 -64 105 -85 129 -25 28 -125 234 -125 256 0 13 -4
26 -10 29 -5 3 -10 22 -10 42 0 47 -22 163 -30 163 -4 0 -10 17 -13 38 -3 20
-13 68 -21 105 -17 77 -14 333 4 367 5 10 10 29 10 41 0 39 47 172 96 274 71
144 239 364 279 365 6 0 26 14 45 32 46 43 238 152 320 182 330 122 703 162
1035 110z M14010 9663 c-34 -5 -265 -71 -315 -90 -40 -15 -194 -104 -217 -126
-7 -7 -45 -37 -83 -68 -39 -31 -85 -76 -103 -100 -84 -113 -100 -137 -124
-184 -89 -172 -119 -304 -113 -494 5 -159 25 -282 60 -356 7 -16 17 -43 21
-60 4 -16 10 -32 14 -35 4 -3 17 -26 28 -52 11 -27 25 -48 30 -48 5 0 21 -17
34 -37 14 -21 38 -52 54 -69 16 -17 41 -44 55 -60 15 -16 33 -34 40 -40 8 -6
37 -38 64 -70 101 -118 255 -260 318 -293 17 -10 79 -42 137 -73 126 -67 175
-83 304 -98 106 -13 197 -36 208 -53 18 -29 377 -36 547 -12 131 20 291 64
291 81 0 14 -3 15 -205 39 -172 21 -318 61 -452 126 -56 27 -108 49 -115 49
-20 0 -250 173 -308 231 -67 67 -200 226 -200 239 0 4 -14 25 -31 46 -17 22
-37 53 -45 69 -7 17 -18 37 -23 45 -20 32 -71 147 -71 161 0 8 -4 19 -9 24
-10 11 -42 118 -62 210 -32 141 -13 432 37 568 8 23 22 61 29 85 20 61 95 211
126 252 14 19 28 40 30 47 2 6 30 39 62 72 75 81 74 88 -13 74z M9007 11513
c-27 -145 -122 -308 -298 -510 -30 -34 -81 -102 -114 -150 -118 -173 -346
-382 -567 -519 -137 -85 -541 -286 -640 -319 -49 -17 -88 -33 -88 -37 0 -4 13
-34 30 -66 46 -91 84 -263 69 -307 -13 -35 -32 -45 -45 -24 -5 8 -47 10 -149
5 -148 -8 -621 18 -639 35 -5 5 -2 19 8 33 9 14 16 32 16 40 0 8 23 60 51 116
28 56 49 103 47 104 -1 2 -44 8 -95 15 -277 35 -546 143 -664 268 -133 140
-162 252 -114 444 l16 65 -39 92 c-52 119 -92 181 -159 242 -92 84 -83 87
-283 -94 -52 -48 -162 -139 -245 -204 -300 -234 -419 -396 -578 -787 -180
-443 -307 -699 -595 -1200 -358 -623 -697 -1149 -1000 -1548 -57 -75 -102
-143 -99 -151 13 -33 280 -167 445 -222 269 -91 794 -125 1209 -80 153 16 203
16 203 -4 0 -58 -405 -108 -780 -97 -560 17 -901 131 -1051 351 -13 20 -31 36
-39 36 -8 0 -61 -55 -117 -123 -209 -252 -440 -484 -655 -660 -49 -39 -88 -77
-88 -84 0 -18 -5 -18 555 32 1317 117 2265 179 3455 225 531 20 570 22 570 30
0 5 -9 24 -19 42 -31 54 -46 115 -34 141 12 27 69 44 194 57 278 31 386 40
484 43 l109 2 8 -50 c4 -27 3 -88 -2 -134 -5 -47 -8 -86 -6 -88 2 -2 230 1
507 7 277 5 619 10 759 10 l255 0 76 103 c362 486 719 1263 965 2095 41 141
104 347 139 457 102 322 124 405 135 511 6 54 18 126 27 159 31 115 29 126
-19 159 -182 125 -251 202 -215 238 7 7 28 56 46 108 18 52 53 147 78 210 l44
116 -39 68 c-25 41 -49 101 -62 156 -24 96 -28 102 -142 243 -165 203 -355
331 -651 441 -54 20 -111 39 -126 42 l-28 6 -16 -89z m-3532 -1712 c251 -61
408 -133 492 -225 95 -104 95 -103 38 -188 -27 -40 -78 -100 -114 -133 -36
-33 -116 -109 -179 -170 -117 -114 -131 -120 -132 -54 0 14 -42 117 -93 230
-52 112 -116 269 -142 349 -29 88 -55 150 -67 158 -23 16 -16 28 25 46 43 19
37 20 172 -13z m3204 -57 c11 -3 6 -13 -16 -37 -17 -18 -34 -48 -38 -67 -21
-102 -305 -568 -381 -626 -32 -25 -54 -25 -54 -1 0 7 -34 37 -75 67 -49 36
-96 81 -132 130 -31 41 -81 103 -111 137 -75 87 -69 97 103 183 167 84 459
204 535 220 33 8 139 3 169 -6z m-1737 -405 c267 -45 564 -242 720 -479 369
-560 266 -1226 -244 -1578 -351 -241 -780 -312 -1075 -178 -425 195 -722 864
-594 1340 24 92 120 336 132 336 4 0 19 25 33 55 170 372 589 577 1028 504z
m1519 -848 c244 -83 315 -115 440 -197 36 -24 76 -44 88 -44 27 0 27 -3 -10
-56 -65 -96 -181 -170 -439 -284 -192 -85 -242 -92 -255 -36 -9 38 -35 340
-35 402 0 99 37 264 58 264 5 0 74 -22 153 -49z m-3066 12 c32 -37 60 -105 73
-174 12 -68 5 -493 -10 -529 -34 -87 -163 -88 -333 -3 -55 27 -161 87 -236
134 -75 46 -157 96 -183 111 -61 36 -64 49 -31 118 l28 59 256 127 c229 113
381 183 404 184 4 0 19 -12 32 -27z m2797 -1111 c21 -22 272 -457 298 -517 11
-26 29 -83 41 -128 11 -45 27 -89 35 -98 29 -32 -15 -38 -99 -14 -29 8 -88 19
-132 25 -138 18 -587 134 -622 160 -31 22 -31 23 -17 62 29 84 82 164 164 253
47 50 125 135 175 189 96 103 114 111 157 68z m-2592 -105 c0 -2 80 -85 178
-183 219 -221 256 -266 248 -297 -10 -42 -45 -77 -76 -77 -16 0 -59 -16 -94
-36 -165 -90 -556 -113 -637 -37 -39 37 -39 37 35 147 71 107 156 267 207 394
18 45 46 98 62 117 l28 35 25 -29 c13 -16 24 -31 24 -34z m-2440 -27 c189
-121 561 -245 802 -266 87 -8 109 -20 77 -42 -60 -42 -511 53 -724 153 -92 43
-146 84 -185 139 -36 54 -33 56 30 16z M5350 9717 c0 -7 23 -44 51 -82 83
-114 134 -208 185 -345 27 -71 53 -130 58 -130 5 0 61 53 125 119 87 89 130
125 174 146 71 34 72 49 5 70 -29 10 -123 50 -208 90 -144 68 -343 145 -376
145 -8 0 -14 -6 -14 -13z M8305 9549 c-236 -70 -385 -120 -385 -132 0 -7 32
-37 71 -67 83 -64 138 -127 170 -193 13 -26 28 -47 35 -47 7 0 44 60 82 133
38 73 93 172 121 221 76 132 74 134 -94 85z M6575 9106 c-129 -26 -235 -75
-341 -160 -115 -91 -221 -239 -245 -339 -6 -29 -22 -71 -36 -93 -69 -120 -69
-477 0 -679 128 -373 363 -572 687 -583 192 -6 366 43 563 160 330 195 471
413 471 723 -1 474 -280 843 -722 956 -102 26 -285 33 -377 15z M8324 8428
c29 -100 37 -177 38 -350 1 -119 5 -188 11 -188 15 0 188 109 331 209 72 50
149 99 173 108 64 26 54 37 -59 62 -111 25 -182 50 -355 130 -127 58 -149 62
-139 29z M5170 8324 c-151 -67 -365 -154 -380 -154 -42 0 14 -37 151 -99 175
-81 247 -123 325 -194 75 -68 77 -66 67 66 -4 61 -8 185 -8 275 0 139 -2 162
-15 162 -8 -1 -71 -26 -140 -56z M8107 7261 c-98 -175 -205 -315 -272 -358
-53 -33 -57 -50 -12 -57 393 -65 477 -83 564 -121 97 -43 107 -28 41 63 -24
33 -95 163 -158 290 -63 128 -119 232 -125 232 -5 0 -22 -22 -38 -49z M5540
7123 c-52 -114 -132 -246 -211 -345 -38 -48 -69 -92 -69 -98 0 -28 193 1 397
60 76 22 160 43 188 46 49 6 105 43 105 68 0 6 -24 27 -52 46 -59 40 -183 162
-248 243 -59 74 -68 72 -110 -20z M10605 11509 c-2 -8 -27 -79 -56 -158 -69
-196 -109 -288 -147 -340 -18 -24 -32 -54 -32 -66 0 -12 -58 -141 -129 -286
-138 -281 -221 -464 -221 -484 0 -7 39 -30 87 -51 48 -22 156 -78 241 -126 84
-49 158 -88 164 -88 14 0 77 -38 108 -65 39 -34 351 -207 364 -202 7 3 45 85
85 183 148 360 373 880 422 975 27 53 83 145 124 204 41 58 75 110 75 114 0 4
-42 15 -92 25 -133 25 -193 47 -585 215 -384 164 -400 170 -408 150z m167
-214 c55 -10 149 -40 250 -79 90 -35 213 -81 273 -102 130 -44 121 -39 107
-67 -6 -12 -32 -79 -57 -149 -25 -69 -81 -207 -126 -305 -154 -338 -289 -682
-289 -734 0 -49 -33 -35 -440 194 -213 120 -253 145 -318 203 l-44 39 47 109
c83 194 308 618 398 749 26 38 47 74 47 82 0 14 47 75 58 75 4 0 46 -7 94 -15z
M10652 11168 c-25 -82 -61 -156 -173 -358 -123 -220 -269 -512 -269 -539 0 -4
19 -16 43 -27 23 -10 101 -54 172 -98 526 -319 489 -302 498 -231 17 124 216
651 349 924 43 90 77 169 75 175 -3 6 -29 18 -58 25 -94 24 -423 132 -464 153
-22 12 -56 34 -76 49 -56 44 -62 40 -97 -73z M11280 9940 c-27 -55 -50 -113
-50 -128 0 -40 37 -220 105 -507 31 -132 79 -343 105 -470 65 -308 183 -643
366 -1038 110 -238 332 -637 355 -637 5 0 9 -4 9 -9 0 -36 254 -366 438 -568
l75 -83 219 0 c169 0 218 3 218 13 0 7 -86 98 -191 202 -427 426 -628 710
-1000 1420 -309 589 -495 1198 -565 1843 -9 87 -25 80 -84 -38z M7070 9950
c-147 -11 -275 -31 -279 -43 -2 -6 -33 -53 -67 -105 -35 -51 -64 -97 -64 -101
0 -4 98 -12 218 -18 180 -9 235 -15 325 -38 59 -15 110 -25 114 -22 3 3 -13
61 -35 129 -22 68 -43 142 -47 166 -8 48 9 45 -165 32z M10216 9787 c-3 -56
-11 -129 -16 -162 -5 -33 -17 -125 -25 -205 -50 -466 -160 -881 -367 -1394
-210 -519 -522 -1085 -784 -1423 -35 -45 -64 -86 -64 -92 0 -8 68 -11 213 -11
l212 1 61 82 c458 615 724 1332 879 2367 40 272 51 328 111 584 24 103 44 196
44 206 0 16 -221 150 -248 150 -5 0 -12 -46 -16 -103z M11020 9035 c-30 -8
-116 -21 -190 -30 -214 -24 -196 -18 -203 -73 -4 -26 -23 -131 -43 -235 -21
-103 -35 -190 -31 -193 3 -3 46 4 96 15 150 35 400 71 499 71 50 0 92 2 92 4
0 1 -13 55 -30 117 -16 63 -38 164 -48 224 l-19 110 -34 2 c-19 1 -59 -5 -89
-12z M11370 8029 c-19 -5 -87 -13 -150 -19 -63 -5 -155 -19 -205 -30 -49 -11
-211 -31 -360 -46 -148 -14 -273 -28 -276 -32 -9 -12 -139 -366 -139 -381 0
-9 8 -12 23 -8 429 93 767 146 971 152 205 6 339 24 332 44 -20 62 -143 331
-151 330 -5 -1 -26 -5 -45 -10z M11885 7059 c-123 -25 -353 -53 -690 -84 -209
-19 -501 -46 -650 -60 -148 -14 -359 -31 -467 -37 l-197 -12 -49 -71 c-27 -38
-86 -116 -130 -171 -45 -56 -82 -107 -82 -113 0 -8 375 -11 1415 -11 856 0
1415 4 1415 9 0 5 -82 92 -183 193 -101 101 -215 225 -253 275 -38 51 -73 92
-79 92 -5 -1 -28 -5 -50 -10z M7090 6634 c-110 -28 -343 -56 -417 -52 -40 3
-73 1 -73 -4 0 -4 7 -35 16 -67 l17 -58 186 4 c241 5 332 12 335 26 2 7 13 44
25 83 11 39 21 73 21 77 0 10 -48 6 -110 -9z M13530 5010 c-8 -5 -25 -10 -36
-10 -14 0 -26 -10 -34 -30 -27 -65 -203 -208 -425 -345 -132 -81 -449 -245
-474 -245 -51 0 82 -96 444 -322 510 -317 1209 -707 2130 -1188 182 -95 403
-214 491 -266 89 -52 167 -94 174 -94 20 0 269 138 495 273 588 351 1128 762
1537 1168 87 86 158 163 158 171 0 10 -54 23 -202 50 -112 20 -525 106 -918
192 -919 199 -1432 305 -2230 460 -1018 198 -1076 208 -1110 186z m878 -300
c1828 -305 2219 -391 2912 -641 74 -27 144 -49 156 -49 72 0 21 -82 -175 -283
-336 -343 -652 -594 -924 -733 -61 -31 -171 -97 -245 -145 -73 -49 -139 -89
-145 -89 -7 0 -43 -18 -80 -40 -98 -57 -126 -63 -192 -40 -99 34 -218 96 -390
202 -220 136 -280 170 -580 325 -137 72 -401 218 -585 325 -417 242 -557 320
-885 493 -335 177 -453 245 -422 245 12 0 918 -446 1117 -550 579 -303 732
-389 1013 -568 84 -54 250 -151 370 -217 120 -66 256 -148 303 -182 96 -71 96
-71 138 -39 17 13 50 33 73 44 23 12 70 43 105 69 35 27 133 88 218 137 88 51
198 125 255 171 55 45 165 130 245 190 318 238 760 622 760 660 0 8 -74 27
-207 54 -416 85 -773 161 -988 210 -386 87 -772 164 -1705 341 -206 39 -512
101 -680 137 -168 36 -314 67 -325 70 -15 3 -33 -13 -73 -65 -117 -151 -317
-295 -539 -388 -51 -21 -94 -44 -95 -51 -2 -8 -8 -8 -23 3 -26 20 -11 33 118
102 123 67 229 142 354 249 82 70 249 188 272 192 3 1 385 -62 849 -139z
m-748 -61 c0 -14 -7 -19 -25 -19 -27 0 -32 -18 -15 -50 12 -22 3 -50 -16 -50
-8 0 -14 -9 -14 -21 0 -11 -21 -42 -47 -67 -44 -45 -49 -47 -97 -45 -47 2 -52
0 -67 -26 -16 -28 -18 -28 -116 -29 -158 -2 -177 45 -25 63 49 5 69 13 94 37
29 27 38 30 77 25 39 -4 48 -1 73 23 15 16 28 33 28 39 0 6 14 18 31 27 25 12
30 20 24 37 -16 51 -12 62 25 65 19 2 39 7 44 12 13 13 26 2 26 -21z M7595
4949 c-11 -5 -238 -34 -505 -64 -425 -49 -941 -116 -1860 -240 -355 -48 -1017
-130 -1250 -155 -382 -41 -498 -50 -737 -57 -171 -4 -243 -9 -243 -17 0 -18
71 -82 210 -191 69 -54 213 -176 320 -270 489 -429 463 -409 1070 -802 377
-243 548 -348 752 -461 191 -106 503 -262 524 -262 8 0 55 33 102 73 210 176
309 247 682 497 907 606 1580 1024 1903 1181 89 44 87 57 -15 99 -365 147
-679 377 -886 648 -26 34 -34 36 -67 21z m-52 -120 c30 -16 -126 -57 -248 -65
-65 -5 -161 -25 -345 -74 -583 -155 -1162 -277 -1665 -350 -357 -52 -466 -61
-865 -71 -450 -11 -520 -16 -520 -33 0 -6 110 -87 244 -179 133 -92 308 -217
387 -278 578 -440 767 -573 1070 -755 132 -78 375 -204 396 -204 5 0 37 20 70
45 34 24 139 92 234 151 94 59 217 144 273 189 307 249 857 612 1327 877 120
68 218 128 219 134 0 6 -21 26 -47 44 -219 155 -414 352 -482 488 l-22 43 22
-11 c27 -15 159 -147 303 -303 60 -65 145 -150 190 -190 51 -45 81 -79 81 -92
0 -15 -51 -52 -220 -158 -283 -177 -565 -363 -785 -517 -277 -194 -395 -272
-545 -357 -77 -44 -201 -123 -275 -176 -130 -93 -285 -182 -361 -206 -33 -11
-44 -8 -130 29 -366 158 -1139 654 -1494 959 -55 47 -194 179 -309 293 -209
206 -210 207 -182 218 49 18 157 29 361 35 126 4 264 15 375 30 96 14 285 36
420 50 659 68 1077 138 1905 317 294 63 569 122 593 127 2 1 13 -4 25 -10z
m-121 -201 c-2 -53 0 -58 19 -58 55 0 73 -38 44 -94 -22 -42 -19 -46 30 -46
80 0 42 -39 -43 -45 -63 -4 -96 16 -87 54 6 26 3 29 -27 35 -39 7 -74 29 -88
56 -9 16 -4 27 25 58 19 22 35 46 35 55 0 22 40 48 70 45 24 -3 25 -6 22 -60z
m253 -299 c4 -5 1 -24 -5 -40 -16 -39 -11 -43 44 -31 74 16 61 -30 -21 -72
-40 -20 -43 -20 -43 2 0 9 -10 22 -22 27 -17 8 -22 17 -20 38 3 27 3 27 -56
27 -46 0 -66 5 -88 23 l-29 22 35 6 c60 11 198 10 205 -2z M12020 4179 c-114
-47 -598 -159 -835 -194 -186 -27 -175 -24 -175 -48 0 -12 13 -103 30 -202
212 -1289 287 -1748 324 -2004 25 -167 47 -306 50 -308 7 -7 361 13 591 32
836 72 1523 197 2200 400 360 108 795 267 795 290 0 7 -120 90 -267 185 -828
536 -1648 1110 -2465 1727 -179 135 -195 143 -248 122z m161 -290 c258 -130
1123 -685 1469 -942 263 -196 365 -284 463 -402 27 -33 61 -66 76 -74 67 -35
125 -90 163 -153 l40 -67 -36 -34 c-75 -71 -572 -257 -1022 -382 -594 -166
-1254 -259 -1599 -226 -165 15 -269 32 -254 42 38 23 -19 430 -190 1349 -61
326 -73 403 -92 627 -14 166 -14 166 53 158 39 -5 81 0 158 19 171 40 462 96
547 105 140 15 159 13 224 -20z M11939 3870 c-83 -29 -168 -47 -375 -81 l-269
-43 -34 -38 -34 -38 47 -162 c57 -199 79 -306 155 -763 77 -459 117 -737 133
-920 7 -86 16 -145 23 -145 5 0 66 11 135 25 69 14 244 36 390 50 534 50 898
110 1325 216 352 88 865 250 865 274 0 8 -21 28 -47 46 -27 18 -64 47 -83 65
-19 18 -89 65 -155 104 -138 82 -190 121 -445 330 -246 202 -503 396 -920 695
-190 136 -395 287 -456 336 -62 49 -120 88 -130 88 -11 -1 -67 -18 -125 -39z
m150 -74 c17 -18 21 -30 15 -36 -7 -7 -16 -4 -29 10 -28 31 -43 25 -47 -17 -3
-35 -6 -38 -35 -41 -21 -2 -33 -9 -33 -18 0 -9 -10 -14 -29 -14 -16 0 -34 -7
-42 -16 -10 -12 -23 -14 -54 -9 -38 5 -43 3 -53 -20 -6 -14 -17 -26 -24 -26
-58 -5 -87 -4 -115 4 -25 8 -34 7 -49 -7 -41 -42 -122 -33 -125 14 -4 58 9 76
55 72 19 -2 37 1 41 7 10 17 40 13 68 -9 30 -24 55 -26 63 -5 4 10 14 13 30 9
19 -5 29 0 45 20 20 26 21 26 50 9 24 -15 33 -15 49 -5 11 7 31 10 44 6 16 -4
25 -1 29 11 5 11 14 14 32 9 22 -6 25 -3 25 23 0 71 38 83 89 29z M8964 3852
c-880 -757 -1975 -1681 -2088 -1762 -25 -18 -46 -39 -46 -45 0 -14 256 -99
540 -181 917 -262 1977 -418 3068 -450 l232 -7 0 859 c0 789 -13 1606 -25
1645 -5 15 -40 17 -308 22 -376 6 -637 33 -957 98 -79 16 -151 29 -160 29 -8
-1 -123 -94 -256 -208z m456 23 c10 -12 38 -15 136 -15 69 0 220 -11 337 -25
250 -29 553 -54 577 -48 29 8 78 -24 84 -54 4 -16 11 -282 16 -593 6 -311 13
-686 16 -835 5 -209 3 -309 -10 -445 -15 -155 -15 -175 -1 -183 33 -18 -5 -98
-56 -116 -17 -6 -142 -16 -277 -22 -666 -30 -1548 50 -1947 178 -60 19 -203
73 -316 119 -125 51 -244 93 -300 105 -52 11 -132 36 -179 56 -54 23 -102 37
-132 37 -25 1 -49 4 -53 7 -23 24 209 219 260 219 27 0 114 74 227 194 51 55
210 208 353 340 338 313 586 548 870 826 220 216 233 227 295 247 78 27 84 27
100 8z M9305 3790 c-49 -22 -95 -40 -101 -40 -6 0 -40 -33 -75 -72 -248 -283
-475 -524 -739 -788 -356 -357 -449 -440 -665 -603 -288 -217 -303 -231 -252
-241 12 -3 52 -7 89 -10 36 -3 131 -23 210 -44 78 -22 162 -43 186 -47 23 -4
42 -12 42 -18 0 -8 70 -20 213 -35 116 -13 295 -39 397 -57 564 -104 963 -143
1543 -152 328 -5 377 -4 377 9 0 8 -13 79 -29 159 -55 265 -62 337 -68 661 -5
285 10 1066 23 1186 l6 52 -138 0 c-293 0 -630 26 -803 61 -119 24 -110 25
-216 -21z m128 -86 c19 -25 23 -26 87 -20 60 6 67 5 86 -16 36 -39 34 -43 -14
-44 -26 0 -68 -4 -95 -8 -90 -16 -167 44 -122 94 24 26 33 25 58 -6z m324 -45
c8 -8 21 -8 47 1 36 12 76 1 76 -21 0 -7 14 -8 40 -4 23 4 53 2 74 -6 28 -10
42 -10 76 1 37 12 42 12 63 -8 29 -27 42 -27 75 -1 l27 21 27 -32 c27 -33 44
-92 32 -111 -4 -7 -20 -8 -41 -4 -29 5 -38 2 -50 -14 -18 -27 -72 -28 -100 -2
-12 11 -42 21 -74 25 -102 12 -184 15 -189 7 -3 -4 -27 -5 -55 -1 -27 4 -44 8
-37 9 16 1 16 31 -1 31 -15 0 -67 51 -67 66 0 15 39 54 53 54 7 0 18 -5 24
-11z"/>
<path id="trim" fill="#823d08" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M10523 18603 c-122 -130 -233 -288 -233 -332 0 -10 -13 -86 -29 -168
-54 -271 -65 -500 -35 -715 26 -182 2 -271 -98 -371 -26 -26 -48 -52 -48 -57
0 -15 -13 -19 -114 -35 -199 -32 -405 29 -582 173 -94 77 -435 246 -559 278
-183 48 -453 45 -611 -7 -113 -37 -145 -64 -208 -182 -81 -151 -82 -150 77
-72 220 107 338 124 519 76 106 -29 312 -137 510 -268 184 -122 255 -155 452
-213 72 -21 150 -46 174 -54 53 -19 207 -56 233 -56 10 0 38 10 62 21 41 20
48 31 115 163 40 77 94 181 121 230 101 183 120 282 131 701 5 182 13 355 19
385 37 185 117 384 208 513 41 58 41 67 1 67 -27 0 -44 -12 -105 -77z M7352
16218 c-60 -122 -95 -225 -111 -328 -7 -41 -16 -93 -22 -115 -11 -45 58 -627
106 -890 112 -618 417 -1417 641 -1680 182 -215 294 -447 350 -724 14 -69 34
-160 44 -201 61 -243 44 -502 -50 -737 -201 -503 -841 -959 -1400 -999 -199
-14 -548 75 -733 186 -90 54 -102 53 -93 -7 4 -27 10 -75 13 -108 6 -59 7 -61
73 -119 184 -163 382 -231 675 -230 329 0 636 92 952 285 308 189 614 521 779
844 l37 75 10 227 c23 535 -34 751 -399 1506 -402 830 -576 1275 -709 1812
-117 471 -155 926 -100 1195 30 147 7 150 -63 8z M7838 16148 c-4 -91 19 -362
38 -458 35 -176 61 -235 122 -282 71 -53 83 -63 145 -117 57 -49 128 -96 204
-134 64 -33 250 -97 280 -97 13 0 40 -7 62 -16 40 -16 40 -16 88 17 140 97
296 264 416 446 36 56 71 104 77 108 30 19 3 19 -47 1 -50 -18 -80 -21 -218
-20 -241 1 -404 38 -610 140 -114 56 -330 208 -320 225 4 5 0 9 -8 9 -16 0
-207 195 -207 211 0 5 -4 9 -10 9 -5 0 -11 -19 -12 -42z M4981 13442 c-199
-103 -252 -317 -114 -455 87 -88 278 -156 332 -119 27 19 -4 47 -67 60 -128
26 -222 121 -222 223 0 49 55 166 117 251 52 71 38 83 -46 40z M4866 12892
c-3 -5 28 -58 68 -119 82 -125 100 -176 94 -262 -7 -96 -51 -149 -190 -225
-29 -17 -56 -29 -60 -28 -12 3 -9 -12 6 -33 11 -15 22 -17 69 -12 184 19 327
178 314 349 -8 92 -55 202 -110 256 -57 56 -174 101 -191 74z M12300 12375 c0
-32 -13 -67 -50 -138 l-50 -95 0 -144 c0 -326 59 -529 211 -731 93 -124 267
-257 359 -276 592 -121 958 -31 1278 316 51 56 109 112 127 125 19 12 35 28
35 35 0 10 -175 73 -203 73 -5 0 -39 -28 -76 -62 -156 -148 -352 -239 -552
-259 -360 -35 -556 -16 -730 72 -125 63 -226 232 -286 478 -51 213 -35 334 63
477 39 57 82 151 72 159 -2 1 -47 5 -100 7 l-98 5 0 -42z M5047 12123 c-4 -3
-7 -27 -7 -52 l0 -45 -27 26 c-40 37 -66 48 -112 48 -84 0 -84 -67 -1 -140 50
-44 50 -42 -10 -69 -27 -12 -50 -27 -50 -31 0 -17 41 -31 72 -25 l30 7 -29
-43 c-50 -74 -54 -85 -42 -113 25 -54 44 -44 136 68 36 44 34 46 49 -59 7 -54
17 -45 29 27 l6 37 36 -25 c20 -13 41 -23 47 -21 16 6 9 104 -10 156 l-17 44
32 26 c36 30 39 41 11 41 -18 0 -17 4 10 63 52 109 29 115 -72 18 l-38 -35 0
29 c0 61 -20 92 -43 68z M11670 11939 c0 -6 -21 -42 -46 -80 -43 -65 -108
-122 -260 -227 -41 -28 -204 -109 -238 -118 -34 -8 -33 -29 2 -42 164 -63 249
-92 266 -92 51 0 238 136 406 297 63 60 130 118 148 128 31 19 33 23 27 60 -8
50 4 44 -122 66 -124 21 -183 24 -183 8z M9032 11760 l3 -72 115 -35 c474
-143 821 -399 880 -653 23 -98 67 -215 82 -218 14 -3 135 254 145 309 4 24 -9
36 -169 150 -95 67 -218 157 -273 200 -264 202 -551 350 -748 384 l-38 6 3
-71z M10605 11509 c-2 -8 -27 -79 -56 -158 -69 -196 -109 -288 -147 -340 -18
-24 -32 -54 -32 -66 0 -12 -58 -141 -129 -286 -138 -281 -221 -464 -221 -484
0 -7 39 -30 87 -51 48 -22 156 -78 241 -126 84 -49 158 -88 164 -88 14 0 77
-38 108 -65 39 -34 351 -207 364 -202 7 3 45 85 85 183 148 360 373 880 422
975 27 53 83 145 124 204 41 58 75 110 75 114 0 4 -42 15 -92 25 -133 25 -193
47 -585 215 -384 164 -400 170 -408 150z m167 -214 c55 -10 149 -40 250 -79
90 -35 213 -81 273 -102 130 -44 121 -39 107 -67 -6 -12 -32 -79 -57 -149 -25
-69 -81 -207 -126 -305 -154 -338 -289 -682 -289 -734 0 -49 -33 -35 -440 194
-213 120 -253 145 -318 203 l-44 39 47 109 c83 194 308 618 398 749 26 38 47
74 47 82 0 14 47 75 58 75 4 0 46 -7 94 -15z M10808 10805 l-83 -105 -72 7
-73 6 0 -41 c0 -32 5 -44 26 -59 29 -21 27 -63 -2 -63 -34 0 -74 -56 -74 -103
0 -64 19 -76 62 -39 71 62 113 69 123 20 10 -49 39 -138 45 -138 13 0 45 69
65 139 l22 75 54 13 c30 6 67 12 83 13 28 0 96 56 96 79 0 21 -50 42 -119 50
-39 4 -73 10 -76 13 -11 10 17 142 37 178 19 32 19 35 2 47 -27 20 -28 20
-116 -92z M11280 9940 c-27 -55 -50 -113 -50 -128 0 -40 37 -220 105 -507 31
-132 79 -343 105 -470 65 -308 183 -643 366 -1038 110 -238 332 -637 355 -637
5 0 9 -4 9 -9 0 -36 254 -366 438 -568 l75 -83 219 0 c169 0 218 3 218 13 0 7
-86 98 -191 202 -427 426 -628 710 -1000 1420 -309 589 -495 1198 -565 1843
-9 87 -25 80 -84 -38z M7070 9950 c-147 -11 -275 -31 -279 -43 -2 -6 -33 -53
-67 -105 -35 -51 -64 -97 -64 -101 0 -4 98 -12 218 -18 180 -9 235 -15 325
-38 59 -15 110 -25 114 -22 3 3 -13 61 -35 129 -22 68 -43 142 -47 166 -8 48
9 45 -165 32z M10216 9787 c-3 -56 -11 -129 -16 -162 -5 -33 -17 -125 -25
-205 -50 -466 -160 -881 -367 -1394 -210 -519 -522 -1085 -784 -1423 -35 -45
-64 -86 -64 -92 0 -8 68 -11 213 -11 l212 1 61 82 c458 615 724 1332 879 2367
40 272 51 328 111 584 24 103 44 196 44 206 0 16 -221 150 -248 150 -5 0 -12
-46 -16 -103z M5350 9717 c0 -7 23 -44 51 -82 83 -114 134 -208 185 -345 27
-71 53 -130 58 -130 5 0 61 53 125 119 87 89 130 125 174 146 71 34 72 49 5
70 -29 10 -123 50 -208 90 -144 68 -343 145 -376 145 -8 0 -14 -6 -14 -13z
M14010 9663 c-34 -5 -265 -71 -315 -90 -40 -15 -194 -104 -217 -126 -7 -7 -45
-37 -83 -68 -39 -31 -85 -76 -103 -100 -84 -113 -100 -137 -124 -184 -89 -172
-119 -304 -113 -494 5 -159 25 -282 60 -356 7 -16 17 -43 21 -60 4 -16 10 -32
14 -35 4 -3 17 -26 28 -52 11 -27 25 -48 30 -48 5 0 21 -17 34 -37 14 -21 38
-52 54 -69 16 -17 41 -44 55 -60 15 -16 33 -34 40 -40 8 -6 37 -38 64 -70 101
-118 255 -260 318 -293 17 -10 79 -42 137 -73 126 -67 175 -83 304 -98 106
-13 197 -36 208 -53 18 -29 377 -36 547 -12 131 20 291 64 291 81 0 14 -3 15
-205 39 -172 21 -318 61 -452 126 -56 27 -108 49 -115 49 -20 0 -250 173 -308
231 -67 67 -200 226 -200 239 0 4 -14 25 -31 46 -17 22 -37 53 -45 69 -7 17
-18 37 -23 45 -20 32 -71 147 -71 161 0 8 -4 19 -9 24 -10 11 -42 118 -62 210
-32 141 -13 432 37 568 8 23 22 61 29 85 20 61 95 211 126 252 14 19 28 40 30
47 2 6 30 39 62 72 75 81 74 88 -13 74z M8305 9549 c-236 -70 -385 -120 -385
-132 0 -7 32 -37 71 -67 83 -64 138 -127 170 -193 13 -26 28 -47 35 -47 7 0
44 60 82 133 38 73 93 172 121 221 76 132 74 134 -94 85z M6575 9106 c-129
-26 -235 -75 -341 -160 -115 -91 -221 -239 -245 -339 -6 -29 -22 -71 -36 -93
-69 -120 -69 -477 0 -679 128 -373 363 -572 687 -583 192 -6 366 43 563 160
330 195 471 413 471 723 -1 474 -280 843 -722 956 -102 26 -285 33 -377 15z
M8324 8428 c29 -100 37 -177 38 -350 1 -119 5 -188 11 -188 15 0 188 109 331
209 72 50 149 99 173 108 64 26 54 37 -59 62 -111 25 -182 50 -355 130 -127
58 -149 62 -139 29z M5170 8324 c-151 -67 -365 -154 -380 -154 -42 0 14 -37
151 -99 175 -81 247 -123 325 -194 75 -68 77 -66 67 66 -4 61 -8 185 -8 275 0
139 -2 162 -15 162 -8 -1 -71 -26 -140 -56z M8107 7261 c-98 -175 -205 -315
-272 -358 -53 -33 -57 -50 -12 -57 393 -65 477 -83 564 -121 97 -43 107 -28
41 63 -24 33 -95 163 -158 290 -63 128 -119 232 -125 232 -5 0 -22 -22 -38
-49z M5540 7123 c-52 -114 -132 -246 -211 -345 -38 -48 -69 -92 -69 -98 0 -28
193 1 397 60 76 22 160 43 188 46 49 6 105 43 105 68 0 6 -24 27 -52 46 -59
40 -183 162 -248 243 -59 74 -68 72 -110 -20z M7090 6634 c-110 -28 -343 -56
-417 -52 -40 3 -73 1 -73 -4 0 -4 7 -35 16 -67 l17 -58 186 4 c241 5 332 12
335 26 2 7 13 44 25 83 11 39 21 73 21 77 0 10 -48 6 -110 -9z M13530 5010
c-8 -5 -25 -10 -36 -10 -14 0 -26 -10 -34 -30 -27 -65 -203 -208 -425 -345
-132 -81 -449 -245 -474 -245 -51 0 82 -96 444 -322 510 -317 1209 -707 2130
-1188 182 -95 403 -214 491 -266 89 -52 167 -94 174 -94 20 0 269 138 495 273
588 351 1128 762 1537 1168 87 86 158 163 158 171 0 10 -54 23 -202 50 -112
20 -525 106 -918 192 -919 199 -1432 305 -2230 460 -1018 198 -1076 208 -1110
186z m878 -300 c1828 -305 2219 -391 2912 -641 74 -27 144 -49 156 -49 72 0
21 -82 -175 -283 -336 -343 -652 -594 -924 -733 -61 -31 -171 -97 -245 -145
-73 -49 -139 -89 -145 -89 -7 0 -43 -18 -80 -40 -98 -57 -126 -63 -192 -40
-99 34 -218 96 -390 202 -220 136 -280 169 -580 325 -137 72 -416 227 -620
345 -389 225 -581 332 -935 518 -252 133 -303 163 -355 209 l-39 34 22 18 c12
9 64 40 115 67 123 67 229 142 354 249 82 70 249 188 272 192 3 1 385 -62 849
-139z M14650 4300 c-367 -36 -608 -140 -681 -294 -43 -91 -34 -133 40 -174
110 -62 409 -72 428 -15 11 32 -33 50 -138 57 -175 12 -249 34 -249 72 0 81
201 183 413 208 47 6 57 5 57 -8 0 -8 -5 -18 -10 -21 -16 -10 -58 -97 -65
-136 -30 -158 215 -333 495 -356 82 -6 194 12 305 48 209 70 237 218 80 425
-18 24 4 26 107 9 312 -52 568 -149 568 -215 0 -27 -55 -42 -301 -81 -219 -36
-218 -35 -64 -65 205 -41 424 9 491 111 59 90 -96 232 -344 315 -271 91 -825
149 -1132 120z M7595 4949 c-11 -5 -238 -34 -505 -64 -425 -49 -941 -116
-1860 -240 -355 -48 -1017 -130 -1250 -155 -382 -41 -498 -50 -737 -57 -171
-4 -243 -9 -243 -17 0 -18 71 -82 210 -191 69 -54 213 -176 320 -270 489 -429
463 -409 1070 -802 377 -243 548 -348 752 -461 191 -106 503 -262 524 -262 8
0 55 33 102 73 210 176 309 247 682 497 907 606 1580 1024 1903 1181 89 44 87
57 -15 99 -365 147 -679 377 -886 648 -26 34 -34 36 -67 21z m-14 -156 c75
-67 186 -179 313 -316 60 -65 145 -150 190 -190 51 -45 81 -79 81 -92 0 -15
-51 -52 -220 -158 -283 -177 -565 -363 -785 -517 -277 -194 -395 -272 -545
-357 -77 -44 -201 -123 -275 -176 -130 -93 -285 -182 -361 -206 -33 -11 -44
-8 -130 29 -366 158 -1139 654 -1494 959 -55 47 -194 179 -309 293 -209 206
-210 207 -182 218 49 18 157 29 361 35 126 4 264 15 375 30 96 14 285 36 420
50 659 68 1077 138 1905 317 467 101 588 127 596 127 4 1 30 -20 60 -46z
M6446 4333 c-11 -29 -6 -49 29 -97 74 -104 96 -249 59 -377 -42 -144 -372
-359 -553 -359 -189 0 -395 77 -635 239 -70 47 -192 120 -270 162 -165 89
-161 91 -121 -58 60 -220 149 -316 410 -443 453 -219 946 -177 1201 103 145
158 188 446 98 648 -44 98 -201 229 -218 182z M12020 4179 c-114 -47 -598
-159 -835 -194 -186 -27 -175 -24 -175 -48 0 -12 13 -103 30 -202 212 -1289
287 -1748 324 -2004 25 -167 47 -306 50 -308 7 -7 361 13 591 32 836 72 1523
197 2200 400 360 108 795 267 795 290 0 7 -120 90 -267 185 -828 536 -1648
1110 -2465 1727 -179 135 -195 143 -248 122z m161 -290 c258 -130 1123 -685
1469 -942 263 -196 365 -284 463 -402 27 -33 61 -66 76 -74 67 -35 125 -90
163 -153 l40 -67 -36 -34 c-75 -71 -572 -257 -1022 -382 -594 -166 -1254 -259
-1599 -226 -165 15 -269 32 -254 42 38 23 -19 430 -190 1349 -61 326 -73 403
-92 627 -14 166 -14 166 53 158 39 -5 81 0 158 19 171 40 462 96 547 105 140
15 159 13 224 -20z M12143 3538 c-6 -7 -13 -87 -17 -178 -4 -90 -9 -166 -11
-168 -7 -7 -210 39 -232 53 -58 38 -143 40 -143 4 0 -11 138 -149 149 -149 3
0 51 -44 105 -99 l98 -98 -12 -79 c-6 -43 -25 -141 -41 -217 -34 -163 -36
-205 -9 -257 29 -56 52 -66 107 -45 47 18 161 105 228 174 21 23 47 41 56 41
10 0 66 -50 126 -111 177 -182 198 -193 231 -126 15 31 -6 92 -94 269 -30 59
-54 111 -54 116 0 4 55 34 123 65 100 48 127 65 150 97 58 82 36 100 -258 204
-120 42 -223 83 -231 91 -13 12 -100 209 -163 368 -23 55 -24 57 -61 57 -21 0
-42 -6 -47 -12z M8964 3852 c-880 -757 -1975 -1681 -2088 -1762 -25 -18 -46
-39 -46 -45 0 -14 256 -99 540 -181 917 -262 1977 -418 3068 -450 l232 -7 0
859 c0 789 -13 1606 -25 1645 -5 15 -40 17 -308 22 -376 6 -637 33 -957 98
-79 16 -151 29 -160 29 -8 -1 -123 -94 -256 -208z m456 23 c10 -12 38 -15 136
-15 69 0 220 -11 337 -25 250 -29 553 -54 577 -48 29 8 78 -24 84 -54 4 -16
11 -282 16 -593 6 -311 13 -686 16 -835 5 -209 3 -309 -10 -445 -15 -155 -15
-175 -1 -183 33 -18 -5 -98 -56 -116 -17 -6 -142 -16 -277 -22 -666 -30 -1548
50 -1947 178 -60 19 -203 73 -316 119 -125 51 -244 93 -300 105 -52 11 -132
36 -179 56 -54 23 -102 37 -132 37 -25 1 -49 4 -53 7 -23 24 209 219 260 219
27 0 114 74 227 194 51 55 210 208 353 340 338 313 586 548 870 826 220 216
233 227 295 247 78 27 84 27 100 8z M9194 3551 c-44 -33 -99 -119 -108 -169
-7 -38 29 -81 68 -83 89 -4 136 24 155 96 11 41 -11 130 -40 161 -28 30 -27
30 -75 -5z M9706 3478 c-29 -39 -42 -83 -27 -92 6 -4 11 -16 11 -26 0 -46 87
-66 133 -30 33 26 42 67 26 122 -16 52 -23 58 -76 58 -36 0 -46 -5 -67 -32z
M10133 3314 c-68 -34 -132 -157 -119 -228 9 -46 58 -103 96 -111 51 -11 141
13 172 47 40 43 44 84 18 170 -36 118 -92 159 -167 122z M9425 3249 c-164 -38
-351 -188 -432 -345 -96 -184 -72 -329 73 -463 154 -141 275 -169 489 -115
249 64 403 315 340 553 -56 215 -168 330 -350 361 -27 5 -57 11 -65 13 -8 3
-33 1 -55 -4z M8756 3105 c-43 -43 -59 -67 -72 -112 l-17 -57 32 -28 c41 -37
138 -41 172 -7 55 55 57 148 5 226 -31 47 -56 43 -120 -22z M10169 2735 c-46
-35 -106 -125 -114 -175 -15 -91 86 -166 178 -131 57 22 94 158 65 242 -30 89
-68 108 -129 64z M8549 2530 c-70 -37 -119 -120 -119 -202 0 -50 52 -88 121
-88 56 0 88 22 125 87 26 43 26 46 13 101 -23 97 -76 135 -140 102z M9948
2234 c-80 -67 -110 -121 -113 -208 -3 -74 -3 -76 27 -101 28 -24 36 -26 121
-23 l90 3 20 38 c36 70 15 224 -42 294 -33 42 -49 41 -103 -3z M9237 2139
c-54 -29 -105 -110 -118 -190 -10 -63 -10 -64 18 -87 83 -69 201 -55 256 30
32 50 33 75 6 156 -34 102 -86 131 -162 91z"/>
<path id="eye" fill="#04837e" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M7838 16148 c-4 -91 19 -362 38 -458 35 -176 61 -235 122 -282 71
-53 83 -63 145 -117 57 -49 128 -96 204 -134 64 -33 250 -97 280 -97 13 0 40
-7 62 -16 40 -16 40 -16 88 17 140 97 296 264 416 446 36 56 71 104 77 108 30
19 3 19 -47 1 -50 -18 -80 -21 -218 -20 -241 1 -404 38 -610 140 -114 56 -330
208 -320 225 4 5 0 9 -8 9 -16 0 -207 195 -207 211 0 5 -4 9 -10 9 -5 0 -11
-19 -12 -42z"/>
<path id="eye_glint" fill="#0fd077" transform="translate(0.000000,2048.000000) scale(0.100000,-0.100000)" d="M7846 16181 c-30 -48 16 -474 70 -648 24 -77 30 -85 79 -122 l54 -41
-39 75 c-79 156 -92 323 -35 439 17 33 39 65 50 70 11 6 22 12 24 14 3 1 -31
40 -75 85 -45 45 -90 95 -102 110 -11 15 -23 23 -26 18z M9222 15618 c-30 -10
-86 -23 -125 -29 l-72 -11 -2 -66 c-3 -161 -132 -338 -305 -420 -58 -28 -72
-42 -40 -42 10 0 23 -5 29 -11 25 -25 199 112 325 257 63 72 262 350 246 343
-2 -1 -27 -10 -56 -21z"/>
</svg>

After

Width:  |  Height:  |  Size: 46 KiB

View file

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://drx0r4ci8h5ts"
path="res://.godot/imported/fortune_teller_logo.svg-efad97bd871de6a5fbe287e31d86930a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/art/fortune_teller_logo.svg"
dest_files=["res://.godot/imported/fortune_teller_logo.svg-efad97bd871de6a5fbe287e31d86930a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=0.25
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View file

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="44" height="50" viewBox="0 0 44 50">
<!-- One tile of the vertical beaded border; repeats seamlessly top-to-bottom.
Strip spans the full height so neighbouring tiles join with no seam. -->
<rect x="8" y="0" width="28" height="50" fill="#1c0329"/>
<path fill="#823c07" d="M22,4 C34,4 43,11 43,23 C43,36 33,46 22,46 C11,46 1,36 1,23 C1,11 10,4 22,4 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 419 B

View file

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d3rhv7shtr7bp"
path="res://.godot/imported/frame_border.svg-528d2c5d86ed50a2330d153461182811.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/frame_border.svg"
dest_files=["res://.godot/imported/frame_border.svg-528d2c5d86ed50a2330d153461182811.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=0.5
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View file

@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="194" viewBox="0 0 200 194">
<!-- Top-left frame corner. Rotate/mirror for the other three.
The dark tabs are 28px wide to line up with frame_border.svg's strip. -->
<g fill="#1c0329">
<rect x="172" y="19" width="28" height="28"/>
<rect x="15" y="170" width="28" height="24"/>
</g>
<path fill="#823c07" d="M123.7,0.8 C133.6,0.8 141.6,1.2 148.7,1.8 C155.7,2.4 161.1,3.4 165.9,4.5 C170.8,5.6 174.7,7.0 177.6,8.5 C180.6,10.0 182.3,11.7 183.6,13.5 C184.9,15.3 185.1,17.3 185.4,19.5 C185.6,21.7 185.4,24.0 185.1,26.4 C184.7,28.9 184.0,31.5 183.1,34.1 C182.1,36.7 181.0,39.3 179.3,42.0 C177.7,44.7 175.8,47.3 173.2,50.0 C170.6,52.7 167.2,55.3 163.5,58.0 C159.8,60.7 155.2,63.3 150.7,66.1 C146.2,68.9 141.4,71.8 136.4,74.8 C131.4,77.8 126.1,80.9 120.8,84.1 C115.5,87.3 109.7,90.7 104.6,94.0 C99.4,97.3 94.3,100.7 89.9,104.0 C85.5,107.3 81.6,110.7 78.2,114.0 C74.9,117.3 72.1,120.7 69.6,124.0 C67.1,127.3 65.2,130.7 63.4,134.0 C61.6,137.3 60.1,140.7 58.8,144.0 C57.4,147.3 56.3,150.7 55.0,153.9 C53.7,157.1 52.6,160.3 51.2,163.2 C49.8,166.1 48.2,168.9 46.6,171.4 C44.9,173.9 43.1,176.1 41.3,178.1 C39.6,180.1 37.9,181.9 36.0,183.4 C34.1,185.0 32.4,186.3 30.2,187.4 C28.0,188.4 25.4,189.2 22.8,189.6 C20.2,190.0 17.1,190.0 14.8,189.6 C12.4,189.2 10.2,188.4 8.8,187.4 C7.3,186.3 6.5,185.0 5.9,183.4 C5.2,181.9 5.1,180.1 4.8,178.1 C4.5,176.1 4.4,173.9 4.2,171.4 C4.1,168.9 3.9,166.1 3.7,163.2 C3.5,160.3 3.2,157.1 3.0,153.9 C2.8,150.7 2.5,147.3 2.3,144.0 C2.1,140.7 1.9,137.3 1.8,134.0 C1.6,130.7 1.4,127.3 1.3,124.0 C1.2,120.7 1.1,117.3 1.0,114.0 C0.9,110.7 0.8,107.3 0.7,104.0 C0.6,100.7 0.4,97.3 0.3,94.0 C0.2,90.7 0.1,87.3 0.1,84.1 C0.0,80.9 0.0,77.8 0.1,74.8 C0.1,71.8 0.2,68.9 0.4,66.1 C0.5,63.3 0.8,60.7 1.0,58.0 C1.2,55.3 1.4,52.7 1.6,50.0 C1.7,47.3 1.6,44.7 1.7,42.0 C1.7,39.3 1.6,36.7 1.8,34.1 C2.0,31.5 2.3,28.9 2.9,26.4 C3.5,24.0 4.1,21.7 5.5,19.5 C6.9,17.3 8.1,15.3 11.5,13.5 C14.9,11.7 18.9,10.0 25.8,8.5 C32.6,7.0 42.2,5.6 52.8,4.5 C63.3,3.4 77.4,2.4 89.2,1.8 C101.0,1.2 113.8,0.8 123.7,0.8 Z"/>
<!-- Inner groove -->
<path fill="#662c00" d="M166.0,54.0 C162.5,53.2 154.3,50.3 145.0,49.5 C135.7,48.7 120.8,49.0 110.0,49.0 C99.2,49.0 88.0,49.3 80.0,49.5 C72.0,49.7 66.3,49.6 62.0,50.0 C57.7,50.4 56.2,50.7 54.0,52.0 C51.8,53.3 50.1,55.0 49.0,58.0 C47.9,61.0 47.9,63.0 47.5,70.0 C47.1,77.0 46.8,88.3 46.5,100.0 C46.2,111.7 45.6,130.0 45.5,140.0 C45.4,150.0 45.7,154.7 46.0,160.0 C46.3,165.3 47.2,170.0 47.5,172.0 C48.0,170.3 49.6,167.3 50.5,162.0 C51.4,156.7 52.4,148.7 53.0,140.0 C53.6,131.3 53.7,120.0 54.0,110.0 C54.3,100.0 54.8,87.3 55.0,80.0 C55.2,72.7 55.2,69.0 55.5,66.0 C55.8,63.0 55.9,62.8 57.0,62.0 C58.1,61.2 54.8,61.2 62.0,61.0 C69.2,60.8 88.0,61.1 100.0,61.0 C112.0,60.9 125.3,60.9 134.0,60.5 C142.7,60.1 146.7,59.6 152.0,58.5 C157.3,57.4 163.7,54.8 166.0,54.0 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cw0ppr3c0q6o2"
path="res://.godot/imported/frame_corner.svg-199c8ced7321cc056b8a09ed1de82e79.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/frame_corner.svg"
dest_files=["res://.godot/imported/frame_corner.svg-199c8ced7321cc056b8a09ed1de82e79.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=0.5
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

57
core/board_images.gd Normal file
View file

@ -0,0 +1,57 @@
class_name BoardImages
extends RefCounted
## Pictures kept inside a spread file, so exports and imports carry them:
## shrunk to at most MAX_SIDE pixels, stored as base64 WebP under an id
## (TowerBoard.images). Results and Book pages point at them by id
## (TableEntry.image, BookPage.image). Only pictures something uses are saved.
const MAX_SIDE := 512
## Pictures bigger than this after shrinking are refused (keeps files sane).
const MAX_BYTES := 400_000
static var _textures: Dictionary = {}
## Loads a picture file, shrinks it and returns {id, data} or {error}.
static func from_file(path: String) -> Dictionary:
var img := Image.load_from_file(path)
if img == null or img.is_empty():
return {"error": "Couldn't read %s as a picture" % path.get_file()}
return from_image(img)
static func from_image(img: Image) -> Dictionary:
var side := maxi(img.get_width(), img.get_height())
if side > MAX_SIDE:
var k := float(MAX_SIDE) / float(side)
img.resize(maxi(1, roundi(img.get_width() * k)), maxi(1, roundi(img.get_height() * k)), Image.INTERPOLATE_LANCZOS)
var bytes := img.save_webp_to_buffer(true, 0.85)
if bytes.size() > MAX_BYTES:
return {"error": "That picture is too big even after shrinking"}
var data := Marshalls.raw_to_base64(bytes)
return {"id": "img_" + data.md5_text().left(12), "data": data}
## The texture for stored data (cached by id).
static func texture(id: String, data: String) -> Texture2D:
if id == "" or data == "":
return null
if not _textures.has(id):
var img := Image.new()
if img.load_webp_from_buffer(Marshalls.base64_to_raw(data)) != OK:
return null
_textures[id] = ImageTexture.create_from_image(img)
return _textures[id]
## Only the pictures that results or pages use.
static func used(board: TowerBoard) -> Dictionary:
var out := {}
for t in board.tables:
for e in t.entries:
if e.image != "" and board.images.has(e.image):
out[e.image] = board.images[e.image]
for p in board.book:
if p.image != "" and board.images.has(p.image):
out[p.image] = board.images[p.image]
return out

1
core/board_images.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dsjbrc5jrldag

View file

@ -278,7 +278,7 @@ static func static_checks(b: TowerBoard) -> Array[Dictionary]:
add.call("range", t, "", rp)
match t.kind:
RollTable.KIND_LOOP:
expr.call("Loop rule", t.loop_expr)
expr.call("Repeat rule", t.loop_expr)
RollTable.KIND_CHOICE:
if t.choice == "pick" and t.entries.is_empty():
add.call("empty_choice", t, "", "Choice card has no options.")
@ -296,10 +296,10 @@ static func static_checks(b: TowerBoard) -> Array[Dictionary]:
add.call("effect", t, e.id, "Change \"%s\": %s" % [p["src"], p["error"]])
for target in e.pipes:
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, "Thread to a table that doesn't exist (%s)." % target)
var ce := e.count_expr(target)
if ce != "":
expr.call("Pipe count", ce, e.id)
expr.call("Thread count", ce, e.id)
for id in Roller.endless_cycles(b):
var t := b.get_table(id)
add.call("cycle", t, "", "Can never finish: every result leads back into an endless cycle.")

44
core/book_page.gd Normal file
View file

@ -0,0 +1,44 @@
class_name BookPage
extends RefCounted
## A Page in the spread's Book: a reusable result (its text with any BBCode,
## its details tooltip and tags). Results linked to a page (TableEntry.page)
## show its text and details; editing the page updates every linked result
## (TowerBoard.sync_page). Saved in the spread file under "book".
var id: String = ""
## The page's name in the Book's list ("" = its text without formatting).
var name: String = ""
var text: String = ""
var details: String = ""
var tags: Array[String] = []
## A picture (BoardImages id). "" = none.
var image: String = ""
func label() -> String:
return name if name.strip_edges() != "" else Formatter.strip_tags(text).strip_edges()
func to_dict() -> Dictionary:
var d := {"id": id, "text": text}
if name != "":
d["name"] = name
if details != "":
d["details"] = details
if not tags.is_empty():
d["tags"] = tags.duplicate()
if image != "":
d["image"] = image
return d
static func from_dict(d: Dictionary) -> BookPage:
var p := BookPage.new()
p.id = str(d.get("id", ""))
p.name = str(d.get("name", ""))
p.text = str(d.get("text", ""))
p.details = str(d.get("details", ""))
p.image = str(d.get("image", ""))
for t: Variant in d.get("tags", []):
p.tags.append(str(t))
return p

1
core/book_page.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cs20opv3eneki

View file

@ -38,6 +38,11 @@ static func copies_of(table: RollTable, e: TableEntry) -> int:
return maxi(0, e.weight)
## How many copies of this result are still in the deck.
func remaining(table: RollTable, e: TableEntry) -> int:
return _remaining(table, e)
func _remaining(table: RollTable, e: TableEntry) -> int:
return maxi(0, copies_of(table, e) - int(drawn.get(e.id, 0)))

119
core/demo_spreads.gd Normal file
View file

@ -0,0 +1,119 @@
class_name DemoSpreads
extends RefCounted
## Small example spreads, one per feature, opened from Help ("Try a demo").
## They're built here, opened unsaved, and never listed with the user's
## spreads. Each is a spread dictionary (the file format) kept tiny.
const TITLES := {
"threads": "Demo: threads",
"deck": "Demo: Deck mode",
"repeats": "Demo: rolling more than once",
"pause": "Demo: pausing a roll",
"costs": "Demo: options that cost",
"limits": "Demo: one table adjusting another",
"book": "Demo: the Book",
"groups": "Demo: groups inside groups",
"sheet": "Demo: a sheet",
}
static func has(key: String) -> bool:
return TITLES.has(key)
static func build(key: String) -> TowerBoard:
var d: Dictionary = _spec(key)
d["format_version"] = TowerBoard.FORMAT_VERSION
d["id"] = "demo-" + key
d["name"] = TITLES.get(key, "Demo")
var b := TowerBoard.new()
b.load_dict(d)
for p in b.book:
b.sync_page(p.id)
return b
static func _t(id: String, name: String, x: int, y: int, entries: Array, extra: Dictionary = {}) -> Dictionary:
var list: Array = []
for i in entries.size():
var e: Variant = entries[i]
list.append(e if e is Dictionary else {"id": "e%d" % i, "text": str(e)})
var t := {"id": id, "name": name, "x": x, "y": y, "entries": list}
t.merge(extra, true)
return t
static func _e(id: String, text: String, extra: Dictionary = {}) -> Dictionary:
var e := {"id": id, "text": text}
e.merge(extra, true)
return e
static func _spec(key: String) -> Dictionary:
match key:
"threads":
return {"tables": [
_t("weather", "Weather", 40, 60, [_e("w1", "Clear skies", {"pipes": ["event"]}), _e("w2", "Storm", {"pipes": ["event", "shelter"]})]),
_t("event", "Event", 380, 40, ["A traveller waves", "Tracks in the mud", "A lost coin"]),
_t("shelter", "Shelter", 380, 300, ["A cave", "An old barn"]),
]}
"deck":
return {"tables": [_t("roles", "Party roles", 40, 60, ["Scout", "Cook", "Map keeper", "Lookout"],
{"card_mode": true, "deck_empty": "stop", "deck_empty_text": "Everyone has a role"})]}
"repeats":
return {"tables": [
_t("chest", "Open the chest", 40, 60, [
_e("c1", "Coins (add three rolls)", {"pipes": [{"table": "coins", "count": 3, "combine": "sum"}]}),
_e("c2", "Best of two gems", {"pipes": [{"table": "gems", "count": 2, "combine": "max"}]}),
_e("c3", "Pick one of three trinkets", {"pipes": [{"table": "trinket", "count": 3, "combine": "choose"}]})]),
_t("coins", "Coins", 440, 0, ["10", "20", "30", "40", "50", "60"]),
_t("gems", "Gems", 440, 360, ["1", "2", "3", "4", "5", "6"], {"dice": "1d6"}),
_t("trinket", "Trinket", 440, 720, ["A bent key", "A glass eye", "A tiny bell", "A pressed flower"]),
]}
"pause":
return {"tables": [
_t("door", "The old door", 40, 60, [_e("d1", "It creaks open…", {"pipes": [{"table": "inside", "pause": true}]})]),
_t("inside", "Inside", 420, 60, ["A dusty library", "A sleeping dragon", "An empty room"]),
]}
"costs":
return {"tables": [
_t("pts", "Points", 40, 40, [_e("v", "")], {"kind": "variable", "var_name": "points", "initial": "2"}),
_t("loot", "Find loot", 40, 260, ["A rusty sword", "A torn map", "A copper ring"], {"dice": "1d3"}),
_t("again", "Happy with it?", 420, 260, [
_e("k", "Keep it"),
_e("r", "Reroll the loot", {"cost": {"value": "@points", "amount": "1"}, "pipes": ["loot"]})],
{"kind": "choice", "choice": "pick", "prompt": "Spend a point to reroll?"}),
]}
"limits":
return {"tables": [
_t("feature", "Planet feature", 40, 60, [
_e("f1", "Thick haze (atmosphere at least 7)", {"effects": "@atmo_min = 7", "pipes": ["atmo"]}),
_e("f2", "Nothing special", {"effects": "@atmo_min = 2", "pipes": ["atmo"]})]),
_t("atmo", "Atmosphere", 440, 40, [
_e("a1", "Thin", {"range": [2, 6]}), _e("a2", "Standard", {"range": [7, 9]}), _e("a3", "Dense", {"range": [10, 12]})],
{"dice": "2d6", "roll_floor": "@atmo_min"}),
]}
"book":
return {"book": [{"id": "p_sword", "name": "Sword of Holy Light",
"text": "[b][color=#c99a1c]The Sword of Holy Light[/color][/b]", "details": "Glows near the undead.", "tags": ["weapon"]}],
"tables": [
_t("goblin", "Goblin loot", 40, 60, ["A bent spoon", _e("s", "", {"page": "p_sword"})]),
_t("dragon", "Dragon hoard", 420, 60, ["A mountain of coins", _e("s", "", {"page": "p_sword"})]),
]}
"groups":
return {"groups": [
{"id": "g_world", "name": "World", "x": 20, "y": 0, "w": 800, "h": 520, "members": ["region"]},
{"id": "g_town", "name": "Town", "x": 60, "y": 230, "w": 700, "h": 260, "members": ["shop", "inn"], "parent": "g_world"}],
"tables": [
_t("region", "Region", 60, 70, ["Hills", "Coast", "Forest"]),
_t("shop", "Shop", 100, 300, ["Bakery", "Smithy"]),
_t("inn", "Inn", 420, 300, ["The Grey Goose", "The Lantern"]),
]}
"sheet":
return {"tables": [
_t("hero", "New hero", 40, 60, [_e("h", "Roll a hero", {"pipes": [{"table": "name", "save_as": "@name"}, {"table": "job", "save_as": "@job"}, "sheet"]})]),
_t("name", "Name", 400, 20, ["Ash", "Briar", "Corin", "Dana"]),
_t("job", "Job", 400, 240, ["Baker", "Guard", "Thief", "Bard"]),
_t("sheet", "Hero sheet", 760, 60, [_e("s", "[b]Name:[/b] {@name}\n[b]Job:[/b] {@job}")], {"kind": "sheet"}),
]}
return {"tables": []}

1
core/demo_spreads.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://vc1thcoyv2vo

View file

@ -24,8 +24,8 @@ const _OPS := {"*": "×", "/": "÷", "-": MINUS, "==": "=", "!=": "≠", ">=": "
## 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_ROLL: "Roll table", RollTable.KIND_CHOICE: "Choice", RollTable.KIND_LOOP: "Repeat",
RollTable.KIND_ROUTER: "Branch", 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).
@ -356,368 +356,8 @@ static func _expr(expr: String, L: Dictionary) -> String:
return _short(out, src)
# ---------------------------------------------------------------- cards and pipes
## A pick card's dynamic options source: "your Skills, level 1 or more",
## "your Contacts", "your Skill values, where Chosen option is not Pilot".
## "" for a card without options_from; the pattern as written when it's bad.
static func options(table: RollTable, board: TowerBoard) -> String:
if table == null or table.options_from.strip_edges() == "":
return ""
var L := _labels(board)
var p := RollTable.parse_options_from(table.options_from)
var s := ""
match str(p["kind"]):
"prefix":
s = "your " + _label("@%s*" % p["name"], L)
"list":
s = "your " + _label("@" + str(p["name"]), L)
_:
return table.options_from.strip_edges()
var w := _where(table.options_where, L)
if w != "":
s += ", " + w
return _short(s, table.options_description())
## The options_where filter as a short tail: "level 1 or more" for one
## comparison on option_value, else "where <condition>"; "" when empty.
static func _where(where: String, L: Dictionary) -> String:
var src := where.strip_edges()
if src == "":
return ""
var m := Builder.parse_condition(src)
if m["ok"] and (m["clauses"] as Array).size() == 1:
var c: Dictionary = m["clauses"][0]
if str(c["var"]) == "option_value" and ["eq", "ge", "le", "gt", "lt"].has(str(c["cmp"])):
var tail := _tail(str(c["cmp"]), str(c["value"]), L).trim_prefix("is ")
return "level " + tail
return "where " + _condition(src, L)
## A pipe's label in plain words, parts joined with " · ": its inputs ("Tier
## 3"), "only if <condition>" or "otherwise", the count ("×2", "×Terms") and
## "saves <name>". "" for a plain pipe.
static func pipe(entry: TableEntry, target_id: String, board: TowerBoard) -> String:
if entry == null:
return ""
var L := _labels(board)
var parts := PackedStringArray()
var w := entry.with_for(target_id)
for nm: String in w:
parts.append("%s %s" % [_label(nm, L), _expr(str(w[nm]), L)])
var cond := entry.when_for(target_id)
if cond != "":
parts.append("only if " + _condition(cond, L))
elif entry.is_otherwise(target_id):
parts.append("otherwise")
var ce := entry.count_expr(target_id)
if ce != "":
parts.append("×" + _expr(ce, L))
elif entry.count_for(target_id) != 1:
parts.append("×%d" % entry.count_for(target_id))
var sv := entry.save_for(target_id)
if sv != "":
parts.append("saves " + _label(sv, L))
return " · ".join(parts)
## A check card: "Roll 2d6 + Strength modifier, need 8 or more" ("need 5 or
## less" for a roll-under check). "" for other kinds.
static func check(table: RollTable, board: TowerBoard) -> String:
if table == null or table.kind != RollTable.KIND_CHECK:
return ""
var L := _labels(board)
var roll := _with_mod(table.check_dice, table.check_mod, L)
var mod := table.check_mod.strip_edges()
var target := _expr(table.check_target, L)
var num := Expr.is_number(table.check_target.strip_edges())
var need := ""
if table.check_cmp == "le":
need = ("%s or less" % target) if num else "at most " + target
else:
need = ("%s or more" % target) if num else "at least " + target
return _short("Roll %s, need %s" % [roll, need], "Roll %s %s vs %s" % [table.check_dice, mod, table.check_target])
## A ranged roll table's roll: "Roll d20 + Luck", "Roll 2D − Fatigue",
## "Roll d100". "" for other cards.
static func roll(table: RollTable, board: TowerBoard) -> String:
if table == null or table.kind != RollTable.KIND_ROLL or not table.is_ranged():
return ""
return "Roll " + _with_mod(table.dice, table.dice_mod, _labels(board))
## Dice plus a modifier in words: "2D + Strength modifier", "d20 − Fatigue".
static func _with_mod(dice_src: String, mod_src: String, L: Dictionary) -> String:
var out := _expr(dice_src, L)
var mod := mod_src.strip_edges()
if mod != "":
var mt := Builder.tokens(mod)
if not mt.is_empty() and mt[0]["s"] == "-":
out += " %s %s" % [MINUS, _expr(mod.substr(1), L)]
else:
out += " + " + _expr(mod, L)
return out
# ---------------------------------------------------------------- why
## One trace fact (Roller node/step "why") as a sentence. Plain mode uses
## labels and words ("Skipped Tier 3 because Luck was 1 (needs 2 or more)");
## text mode (plain = false) shows the rules as written ("Skipped tier3: when
## @luck >= 2 was false (@luck = 1)"). Unknown facts give a short dump.
static func why(fact: Dictionary, board: TowerBoard, plain: bool = true) -> String:
if fact == null:
return ""
var L := _labels(board)
var s := ""
match str(fact.get("type", "")):
"roll":
s = _why_roll(fact, L, plain)
"check":
s = _why_check(fact, L, plain)
"when":
s = _why_when(fact, board, L, plain)
"otherwise":
var to := _table(str(fact.get("to", "")), board, plain)
if bool(fact.get("result", false)):
s = "Took %s because no condition was true" % to if plain else "%s: otherwise, ran (no condition was true)" % to
else:
s = "Skipped %s because a condition was true" % to if plain else "%s: otherwise, skipped" % to
"case":
s = _why_case(fact, L, plain)
"show_if":
var h := int(fact.get("hidden", 0))
var parts := PackedStringArray()
if h > 0:
parts.append(("%d option hidden by its condition" if h == 1 else "%d options hidden by their conditions") % h)
if bool(fact.get("chosen_hidden", false)):
parts.append("the options from values were hidden")
s = ", and ".join(parts)
if s != "":
s = s.substr(0, 1).to_upper() + s.substr(1)
if not plain:
s = "show_if hid %d option(s)%s" % [h, ", and the Chosen result" if bool(fact.get("chosen_hidden", false)) else ""]
"options_where":
var kept := int(fact.get("kept", 0))
var total := int(fact.get("total", 0))
if plain:
var from := str(fact.get("from", ""))
var p := RollTable.parse_options_from(from)
var what := _label("@%s*" % p["name"], L) if str(p["kind"]) == "prefix" else (_label("@" + str(p["name"]), L) if str(p["kind"]) == "list" else "options")
s = "Offered %d of %d %s (%s)" % [kept, total, what, _where(str(fact.get("expr", "")), L)]
else:
s = "options_where %s kept %d of %d" % [fact.get("expr", ""), kept, total]
"effect":
s = _why_effect(fact, L, plain)
"input":
var nm := str(fact.get("name", ""))
var val := Expr.format_value(fact.get("value"))
var from_pipe := str(fact.get("from", "")) == "pipe"
if plain:
s = "%s was %s (%s)" % [_label(nm, L), val, "from the pipe" if from_pipe else "default"]
else:
s = "input %s = %s (%s)" % [nm, val, "with" if from_pipe else "default"]
_:
s = JSON.stringify(fact)
if s.length() > MAX_LEN * 2:
s = s.substr(0, MAX_LEN * 2 - 1) + "…"
return s
static func _table(id: String, board: TowerBoard, plain: bool) -> String:
if not plain or board == null:
return id
var t := board.get_table(id)
if t == null:
return id
var n := Formatter.strip_tags(t.name).strip_edges()
return n if n != "" else id
## "3 + 4 = 7" (or "5" for one die).
static func _faces(faces: Variant) -> String:
if not (faces is Array) or (faces as Array).is_empty():
return ""
var parts := PackedStringArray()
var sum := 0.0
for f: Variant in faces:
parts.append(Expr.format_value(f))
sum += float(Expr.to_value(f)) if Expr.is_number(f) else 0.0
if parts.size() == 1:
return parts[0]
return "%s = %s" % [" + ".join(parts), Expr.format_value(sum)]
static func _nonzero(v: Variant) -> bool:
var n: Variant = Expr.to_value(v)
return Expr.is_number(n) and n != 0
## "+2", "−1", "+0".
static func signed_number(n: int) -> String:
return _signed(n)
static func _signed(v: Variant) -> String:
var n: Variant = Expr.to_value(v)
if not Expr.is_number(n):
return str(v)
return ("+" + Expr.format_value(n)) if n >= 0 else (MINUS + Expr.format_value(-n))
## A roll fact as a sentence: "Rolled 17, +3 for Luck = 20". A total past
## the table's ends adds "past the top of the table, so it counts as 24"
## (fact key counts_as).
static func _why_roll(f: Dictionary, L: Dictionary, plain: bool) -> String:
var total := Expr.format_value(f.get("total"))
match str(f.get("pick", "dice")):
"weighted":
return "Rolled %s on %s" % [total, f.get("dice", "")] if plain else "roll %s: %s" % [f.get("dice", ""), total]
"card":
return "Drew card %s" % total if plain else "draw: card %s" % total
var faces := _faces(f.get("faces"))
var past := f.has("counts_as")
var ends := Expr.format_value(f.get("counts_as"))
if not plain:
var t := "roll %s: %s" % [f.get("dice", ""), faces if faces != "" else total]
if f.has("mod") and _nonzero(f["mod"]):
t += " %s = %s" % [_signed(f["mod"]).replace(MINUS, "-"), total]
if past:
t += " (past the end: %s)" % ends
return t
var s := "Worked out %s" % total
if faces != "":
s = "Rolled " + faces
if f.has("mod") and _nonzero(f["mod"]):
var why_mod := ""
if str(f.get("mod_expr", "")) != "":
why_mod = " for " + _expr(str(f["mod_expr"]).trim_prefix("-"), L)
s += ", %s%s = %s" % [_signed(f["mod"]), why_mod, total]
if past:
var top: bool = float(Expr.to_value(f.get("counts_as"))) < float(Expr.to_value(f.get("total")))
s += ", past the %s of the table, so it counts as %s" % ["top" if top else "bottom", ends]
return s
static func _why_check(f: Dictionary, L: Dictionary, plain: bool) -> String:
var faces := _faces(f.get("faces"))
var nat := Expr.format_value(f.get("nat"))
var total := Expr.format_value(f.get("total"))
var target := Expr.format_value(f.get("target"))
var le := str(f.get("cmp", "ge")) == "le"
var ok := bool(f.get("success", false))
if not plain:
return "check %s%s vs %s (%s): %s %s = %s → %s" % [f.get("dice", ""),
(" + " + str(f.get("mod_expr", ""))) if str(f.get("mod_expr", "")) != "" else "", f.get("target_expr", target),
f.get("cmp", "ge"), nat, _signed(f.get("mod", 0)).replace(MINUS, "-"), total, "success" if ok else "failure"]
var s := "Rolled " + (faces if faces != "" else nat)
if _nonzero(f.get("mod", 0)):
s += ", %s = %s" % [_signed(f.get("mod", 0)), total]
s += ": needed %s or %s, %s" % [target, "less" if le else "more", "success" if ok else "failure"]
return s
## "Luck was 1 and Social Standing was 9" from a fact's values.
static func _values(values: Variant, L: Dictionary, plain: bool) -> String:
if not (values is Dictionary) or (values as Dictionary).is_empty():
return ""
var parts := PackedStringArray()
for key: Variant in values:
var nm := str(key)
var v: Variant = values[key]
if plain:
parts.append(("%s wasn't set" % _label(nm, L)) if v == null else "%s was %s" % [_label(nm, L), _shown(v)])
else:
parts.append("%s = %s" % [nm, "unset" if v == null else Expr.format_value(v)])
if not plain:
return ", ".join(parts)
if parts.size() == 1:
return parts[0]
return ", ".join(parts.slice(0, parts.size() - 1)) + " and " + parts[parts.size() - 1]
static func _shown(v: Variant) -> String:
var s := Expr.format_value(v)
return s if s != "" else "empty"
## "(needs 2 or more)" for one comparison on a value that was read, else
## "(rule: <condition>)".
static func _needs(expr: String, values: Variant, L: Dictionary) -> String:
var m := Builder.parse_condition(expr)
if m["ok"] and (m["clauses"] as Array).size() == 1:
var c: Dictionary = m["clauses"][0]
if values is Dictionary and (values as Dictionary).has(str(c["var"])):
var tail := _tail(str(c["cmp"]), str(c["value"]), L)
if tail.begins_with("is "):
tail = tail.substr(3)
elif tail.begins_with("includes "):
tail = "to include " + tail.substr(9)
return "(needs %s)" % tail
return "(rule: %s)" % _condition(expr, L)
static func _why_when(f: Dictionary, board: TowerBoard, L: Dictionary, plain: bool) -> String:
var to := _table(str(f.get("to", "")), board, plain)
var expr := str(f.get("expr", ""))
var ok := bool(f.get("result", false))
if not plain:
var t := "%s %s: when %s was %s" % ["Took" if ok else "Skipped", to, expr, "true" if ok else "false"]
if f.has("error"):
t = "Skipped %s: when %s failed: %s" % [to, expr, f["error"]]
var vals := _values(f.get("values"), L, false)
return t + (" (%s)" % vals if vals != "" else "")
if f.has("error"):
return "Skipped %s: its condition couldn't be worked out (%s)" % [to, f["error"]]
var vals2 := _values(f.get("values"), L, true)
var verb := "Took" if ok else "Skipped"
if vals2 == "":
return "%s %s: %s was %s" % [verb, to, _condition(expr, L), "true" if ok else "false"]
return "%s %s because %s %s" % [verb, to, vals2, _needs(expr, f.get("values"), L)]
static func _why_case(f: Dictionary, L: Dictionary, plain: bool) -> String:
var n := int(f.get("index", 0)) + 1
var expr := str(f.get("expr", ""))
var ok := bool(f.get("result", false))
if expr == "":
return "Otherwise (case %d): no case before it matched" % n if plain else "case %d: otherwise" % n
if not plain:
var t := "case %d: %s → %s" % [n, expr, "error: " + str(f["error"]) if f.has("error") else ("true" if ok else "false")]
var vals := _values(f.get("values"), L, false)
return t + (" (%s)" % vals if vals != "" else "")
if f.has("error"):
return "Case %d couldn't be worked out (%s)" % [n, f["error"]]
var vals2 := _values(f.get("values"), L, true)
var verb := "matched" if ok else "didn't match"
if vals2 == "":
return "Case %d %s: %s was %s" % [n, verb, _condition(expr, L), "true" if ok else "false"]
return "Case %d %s because %s %s" % [n, verb, vals2, _needs(expr, f.get("values"), L)]
static func _why_effect(f: Dictionary, L: Dictionary, plain: bool) -> String:
var v := str(f.get("var", ""))
var op := str(f.get("op", ""))
if not plain:
if f.has("count"):
return "reset %s (%s)" % [v, Expr.format_value(f["count"])]
return "%s %s: %s → %s" % [v, op, _raw(f.get("before")), _raw(f.get("after"))]
var lab := _label(v, L)
if f.has("count"):
return "Reset all %s (%s)" % [lab, Expr.format_value(f["count"])]
var before: Variant = f.get("before")
var after: Variant = f.get("after")
if op == "reset" and after == null:
return "%s was cleared" % lab
if before == null:
return "%s became %s" % [lab, _shown(after)]
return "%s went from %s to %s" % [lab, _shown(before), _shown(after)]
static func _raw(v: Variant) -> String:
return "unset" if v == null else Expr.format_value(v)
# ---------------------------------------------------------------- helpers
@ -729,3 +369,27 @@ static func _short(s: String, original: String) -> String:
if original.length() <= MAX_LEN:
return original
return s.substr(0, MAX_LEN - 1) + "…"
static func check(table: RollTable, board: TowerBoard) -> String:
return DescribeCards.check(table, board)
static func options(table: RollTable, board: TowerBoard) -> String:
return DescribeCards.options(table, board)
static func pipe(entry: TableEntry, target_id: String, board: TowerBoard) -> String:
return DescribeCards.pipe(entry, target_id, board)
static func roll(table: RollTable, board: TowerBoard) -> String:
return DescribeCards.roll(table, board)
static func signed_number(n: int) -> String:
return DescribeWhy.signed_number(n)
static func why(fact: Dictionary, board: TowerBoard, plain: bool = true) -> String:
return DescribeWhy.why(fact, board, plain)

106
core/describe_cards.gd Normal file
View file

@ -0,0 +1,106 @@
class_name DescribeCards
extends RefCounted
## Plain-language sentences for cards, options and pipes (see Describe).
## A pick card's dynamic options source: "your Skills, level 1 or more",
## "your Contacts", "your Skill values, where Chosen option is not Pilot".
## "" for a card without options_from; the pattern as written when it's bad.
static func options(table: RollTable, board: TowerBoard) -> String:
if table == null or table.options_from.strip_edges() == "":
return ""
var L := Describe._labels(board)
var p := RollTable.parse_options_from(table.options_from)
var s := ""
match str(p["kind"]):
"prefix":
s = "your " + Describe._label("@%s*" % p["name"], L)
"list":
s = "your " + Describe._label("@" + str(p["name"]), L)
_:
return table.options_from.strip_edges()
var w := _where(table.options_where, L)
if w != "":
s += ", " + w
return Describe._short(s, table.options_description())
## The options_where filter as a short tail: "level 1 or more" for one
## comparison on option_value, else "where <condition>"; "" when empty.
static func _where(where: String, L: Dictionary) -> String:
var src := where.strip_edges()
if src == "":
return ""
var m := Builder.parse_condition(src)
if m["ok"] and (m["clauses"] as Array).size() == 1:
var c: Dictionary = m["clauses"][0]
if str(c["var"]) == "option_value" and ["eq", "ge", "le", "gt", "lt"].has(str(c["cmp"])):
var tail := Describe._tail(str(c["cmp"]), str(c["value"]), L).trim_prefix("is ")
return "level " + tail
return "where " + Describe._condition(src, L)
## A pipe's label in plain words, parts joined with " · ": its inputs ("Tier
## 3"), "only if <condition>" or "otherwise", the count ("×2", "×Terms") and
## "saves <name>". "" for a plain pipe.
static func pipe(entry: TableEntry, target_id: String, board: TowerBoard) -> String:
if entry == null:
return ""
var L := Describe._labels(board)
var parts := PackedStringArray()
var w := entry.with_for(target_id)
for nm: String in w:
parts.append("%s %s" % [Describe._label(nm, L), Describe._expr(str(w[nm]), L)])
var cond := entry.when_for(target_id)
if cond != "":
parts.append("only if " + Describe._condition(cond, L))
elif entry.is_otherwise(target_id):
parts.append("otherwise")
var ce := entry.count_expr(target_id)
if ce != "":
parts.append("×" + Describe._expr(ce, L))
elif entry.count_for(target_id) != 1:
parts.append("×%d" % entry.count_for(target_id))
var sv := entry.save_for(target_id)
if sv != "":
parts.append("saves " + Describe._label(sv, L))
return " · ".join(parts)
## A check card: "Roll 2d6 + Strength modifier, need 8 or more" ("need 5 or
## less" for a roll-under check). "" for other kinds.
static func check(table: RollTable, board: TowerBoard) -> String:
if table == null or table.kind != RollTable.KIND_CHECK:
return ""
var L := Describe._labels(board)
var roll := _with_mod(table.check_dice, table.check_mod, L)
var mod := table.check_mod.strip_edges()
var target := Describe._expr(table.check_target, L)
var num := Expr.is_number(table.check_target.strip_edges())
var need := ""
if table.check_cmp == "le":
need = ("%s or less" % target) if num else "at most " + target
else:
need = ("%s or more" % target) if num else "at least " + target
return Describe._short("Roll %s, need %s" % [roll, need], "Roll %s %s vs %s" % [table.check_dice, mod, table.check_target])
## A ranged roll table's roll: "Roll d20 + Luck", "Roll 2D − Fatigue",
## "Roll d100". "" for other cards.
static func roll(table: RollTable, board: TowerBoard) -> String:
if table == null or table.kind != RollTable.KIND_ROLL or not table.is_ranged():
return ""
return "Roll " + _with_mod(table.dice, table.dice_mod, Describe._labels(board))
## Dice plus a modifier in words: "2D + Strength modifier", "d20 − Fatigue".
static func _with_mod(dice_src: String, mod_src: String, L: Dictionary) -> String:
var out := Describe._expr(dice_src, L)
var mod := mod_src.strip_edges()
if mod != "":
var mt := Builder.tokens(mod)
if not mt.is_empty() and mt[0]["s"] == "-":
out += " %s %s" % [Describe.MINUS, Describe._expr(mod.substr(1), L)]
else:
out += " + " + Describe._expr(mod, L)
return out

View file

@ -0,0 +1 @@
uid://b55xjcxnywwu3

265
core/describe_why.gd Normal file
View file

@ -0,0 +1,265 @@
class_name DescribeWhy
extends RefCounted
## The "Why this?" sentences for trace facts (see Describe).
## One trace fact (Roller node/step "why") as a sentence. Plain mode uses
## labels and words ("Skipped Tier 3 because Luck was 1 (needs 2 or more)");
## text mode (plain = false) shows the rules as written ("Skipped tier3: when
## @luck >= 2 was false (@luck = 1)"). Unknown facts give a short dump.
static func why(fact: Dictionary, board: TowerBoard, plain: bool = true) -> String:
if fact == null:
return ""
var L := Describe._labels(board)
var s := ""
match str(fact.get("type", "")):
"roll":
s = _why_roll(fact, L, plain)
"check":
s = _why_check(fact, L, plain)
"when":
s = _why_when(fact, board, L, plain)
"otherwise":
var to := _table(str(fact.get("to", "")), board, plain)
if bool(fact.get("result", false)):
s = "Took %s because no condition was true" % to if plain else "%s: otherwise, ran (no condition was true)" % to
else:
s = "Skipped %s because a condition was true" % to if plain else "%s: otherwise, skipped" % to
"case":
s = _why_case(fact, L, plain)
"show_if":
var h := int(fact.get("hidden", 0))
var parts := PackedStringArray()
if h > 0:
parts.append(("%d option hidden by its condition" if h == 1 else "%d options hidden by their conditions") % h)
if bool(fact.get("chosen_hidden", false)):
parts.append("the options from values were hidden")
s = ", and ".join(parts)
if s != "":
s = s.substr(0, 1).to_upper() + s.substr(1)
if not plain:
s = "show_if hid %d option(s)%s" % [h, ", and the Chosen result" if bool(fact.get("chosen_hidden", false)) else ""]
"options_where":
var kept := int(fact.get("kept", 0))
var total := int(fact.get("total", 0))
if plain:
var from := str(fact.get("from", ""))
var p := RollTable.parse_options_from(from)
var what := Describe._label("@%s*" % p["name"], L) if str(p["kind"]) == "prefix" else (Describe._label("@" + str(p["name"]), L) if str(p["kind"]) == "list" else "options")
s = "Offered %d of %d %s (%s)" % [kept, total, what, DescribeCards._where(str(fact.get("expr", "")), L)]
else:
s = "options_where %s kept %d of %d" % [fact.get("expr", ""), kept, total]
"effect":
s = _why_effect(fact, L, plain)
"input":
var nm := str(fact.get("name", ""))
var val := Expr.format_value(fact.get("value"))
var from_pipe := str(fact.get("from", "")) == "pipe"
if plain:
s = "%s was %s (%s)" % [Describe._label(nm, L), val, "from the thread" if from_pipe else "default"]
else:
s = "input %s = %s (%s)" % [nm, val, "with" if from_pipe else "default"]
_:
s = JSON.stringify(fact)
if s.length() > Describe.MAX_LEN * 2:
s = s.substr(0, Describe.MAX_LEN * 2 - 1) + "…"
return s
static func _table(id: String, board: TowerBoard, plain: bool) -> String:
if not plain or board == null:
return id
var t := board.get_table(id)
if t == null:
return id
var n := Formatter.strip_tags(t.name).strip_edges()
return n if n != "" else id
## "3 + 4 = 7" (or "5" for one die).
static func _faces(faces: Variant) -> String:
if not (faces is Array) or (faces as Array).is_empty():
return ""
var parts := PackedStringArray()
var sum := 0.0
for f: Variant in faces:
parts.append(Expr.format_value(f))
sum += float(Expr.to_value(f)) if Expr.is_number(f) else 0.0
if parts.size() == 1:
return parts[0]
return "%s = %s" % [" + ".join(parts), Expr.format_value(sum)]
static func _nonzero(v: Variant) -> bool:
var n: Variant = Expr.to_value(v)
return Expr.is_number(n) and n != 0
## "+2", "−1", "+0".
static func signed_number(n: int) -> String:
return _signed(n)
static func _signed(v: Variant) -> String:
var n: Variant = Expr.to_value(v)
if not Expr.is_number(n):
return str(v)
return ("+" + Expr.format_value(n)) if n >= 0 else (Describe.MINUS + Expr.format_value(-n))
## A roll fact as a sentence: "Rolled 17, +3 for Luck = 20". A total past
## the table's ends adds "past the top of the table, so it counts as 24"
## (fact key counts_as).
static func _why_roll(f: Dictionary, L: Dictionary, plain: bool) -> String:
var total := Expr.format_value(f.get("total"))
match str(f.get("pick", "dice")):
"weighted":
return "Rolled %s on %s" % [total, f.get("dice", "")] if plain else "roll %s: %s" % [f.get("dice", ""), total]
"card":
return "Drew card %s" % total if plain else "draw: card %s" % total
var faces := _faces(f.get("faces"))
var past := f.has("counts_as")
var ends := Expr.format_value(f.get("counts_as"))
if not plain:
var t := "roll %s: %s" % [f.get("dice", ""), faces if faces != "" else total]
if f.has("mod") and _nonzero(f["mod"]):
t += " %s = %s" % [_signed(f["mod"]).replace(Describe.MINUS, "-"), Expr.format_value(f.get("raw", f.get("total")))]
if f.has("limited"):
t += " (%s %s: %s)" % ["min" if f["limited"] == "floor" else "max", f.get("limit_expr", ""), total]
if past:
t += " (past the end: %s)" % ends
return t
var s := "Worked out %s" % total
if faces != "":
s = "Rolled " + faces
if f.has("mod") and _nonzero(f["mod"]):
var why_mod := ""
if str(f.get("mod_expr", "")) != "":
why_mod = " for " + Describe._expr(str(f["mod_expr"]).trim_prefix("-"), L)
s += ", %s%s = %s" % [_signed(f["mod"]), why_mod, Expr.format_value(f.get("raw", f.get("total")))]
if f.has("limited"):
var up: bool = f["limited"] == "floor"
s += ", %s to %s (never %s %s)" % ["raised" if up else "lowered", total, "below" if up else "above", Describe._expr(str(f.get("limit_expr", "")), L)]
if past:
var top: bool = float(Expr.to_value(f.get("counts_as"))) < float(Expr.to_value(f.get("total")))
s += ", past the %s of the table, so it counts as %s" % ["top" if top else "bottom", ends]
return s
static func _why_check(f: Dictionary, L: Dictionary, plain: bool) -> String:
var faces := _faces(f.get("faces"))
var nat := Expr.format_value(f.get("nat"))
var total := Expr.format_value(f.get("total"))
var target := Expr.format_value(f.get("target"))
var le := str(f.get("cmp", "ge")) == "le"
var ok := bool(f.get("success", false))
if not plain:
return "check %s%s vs %s (%s): %s %s = %s → %s" % [f.get("dice", ""),
(" + " + str(f.get("mod_expr", ""))) if str(f.get("mod_expr", "")) != "" else "", f.get("target_expr", target),
f.get("cmp", "ge"), nat, _signed(f.get("mod", 0)).replace(Describe.MINUS, "-"), total, "success" if ok else "failure"]
var s := "Rolled " + (faces if faces != "" else nat)
if _nonzero(f.get("mod", 0)):
s += ", %s = %s" % [_signed(f.get("mod", 0)), total]
s += ": needed %s or %s, %s" % [target, "less" if le else "more", "success" if ok else "failure"]
return s
## "Luck was 1 and Social Standing was 9" from a fact's values.
static func _values(values: Variant, L: Dictionary, plain: bool) -> String:
if not (values is Dictionary) or (values as Dictionary).is_empty():
return ""
var parts := PackedStringArray()
for key: Variant in values:
var nm := str(key)
var v: Variant = values[key]
if plain:
parts.append(("%s wasn't set" % Describe._label(nm, L)) if v == null else "%s was %s" % [Describe._label(nm, L), _shown(v)])
else:
parts.append("%s = %s" % [nm, "unset" if v == null else Expr.format_value(v)])
if not plain:
return ", ".join(parts)
if parts.size() == 1:
return parts[0]
return ", ".join(parts.slice(0, parts.size() - 1)) + " and " + parts[parts.size() - 1]
static func _shown(v: Variant) -> String:
var s := Expr.format_value(v)
return s if s != "" else "empty"
## "(needs 2 or more)" for one comparison on a value that was read, else
## "(rule: <condition>)".
static func _needs(expr: String, values: Variant, L: Dictionary) -> String:
var m := Builder.parse_condition(expr)
if m["ok"] and (m["clauses"] as Array).size() == 1:
var c: Dictionary = m["clauses"][0]
if values is Dictionary and (values as Dictionary).has(str(c["var"])):
var tail := Describe._tail(str(c["cmp"]), str(c["value"]), L)
if tail.begins_with("is "):
tail = tail.substr(3)
elif tail.begins_with("includes "):
tail = "to include " + tail.substr(9)
return "(needs %s)" % tail
return "(rule: %s)" % Describe._condition(expr, L)
static func _why_when(f: Dictionary, board: TowerBoard, L: Dictionary, plain: bool) -> String:
var to := _table(str(f.get("to", "")), board, plain)
var expr := str(f.get("expr", ""))
var ok := bool(f.get("result", false))
if not plain:
var t := "%s %s: when %s was %s" % ["Took" if ok else "Skipped", to, expr, "true" if ok else "false"]
if f.has("error"):
t = "Skipped %s: when %s failed: %s" % [to, expr, f["error"]]
var vals := _values(f.get("values"), L, false)
return t + (" (%s)" % vals if vals != "" else "")
if f.has("error"):
return "Skipped %s: its condition couldn't be worked out (%s)" % [to, f["error"]]
var vals2 := _values(f.get("values"), L, true)
var verb := "Took" if ok else "Skipped"
if vals2 == "":
return "%s %s: %s was %s" % [verb, to, Describe._condition(expr, L), "true" if ok else "false"]
return "%s %s because %s %s" % [verb, to, vals2, _needs(expr, f.get("values"), L)]
static func _why_case(f: Dictionary, L: Dictionary, plain: bool) -> String:
var n := int(f.get("index", 0)) + 1
var expr := str(f.get("expr", ""))
var ok := bool(f.get("result", false))
if expr == "":
return "Otherwise (case %d): no case before it matched" % n if plain else "case %d: otherwise" % n
if not plain:
var t := "case %d: %s → %s" % [n, expr, "error: " + str(f["error"]) if f.has("error") else ("true" if ok else "false")]
var vals := _values(f.get("values"), L, false)
return t + (" (%s)" % vals if vals != "" else "")
if f.has("error"):
return "Case %d couldn't be worked out (%s)" % [n, f["error"]]
var vals2 := _values(f.get("values"), L, true)
var verb := "matched" if ok else "didn't match"
if vals2 == "":
return "Case %d %s: %s was %s" % [n, verb, Describe._condition(expr, L), "true" if ok else "false"]
return "Case %d %s because %s %s" % [n, verb, vals2, _needs(expr, f.get("values"), L)]
static func _why_effect(f: Dictionary, L: Dictionary, plain: bool) -> String:
var v := str(f.get("var", ""))
var op := str(f.get("op", ""))
if not plain:
if f.has("count"):
return "reset %s (%s)" % [v, Expr.format_value(f["count"])]
return "%s %s: %s → %s" % [v, op, _raw(f.get("before")), _raw(f.get("after"))]
var lab := Describe._label(v, L)
if f.has("count"):
return "Reset all %s (%s)" % [lab, Expr.format_value(f["count"])]
var before: Variant = f.get("before")
var after: Variant = f.get("after")
if op == "reset" and after == null:
return "%s was cleared" % lab
if before == null:
return "%s became %s" % [lab, _shown(after)]
return "%s went from %s to %s" % [lab, _shown(before), _shown(after)]
static func _raw(v: Variant) -> String:
return "unset" if v == null else Expr.format_value(v)

1
core/describe_why.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://ctf61koova5sn

View file

@ -22,7 +22,8 @@ static func pick_node(t: RollTable, ctx: RollContext) -> Dictionary:
return Roller._stop(t, "This table has no results")
if deck.cards_left(t).x <= 0:
if t.deck_empty == "stop":
return Roller._stop(t, "Deck empty")
# Waits for Shuffle: the card gives its empty result and the chain ends here.
return Roller._stop(t, t.empty_text(), {"deck_empty": true})
deck.reshuffle()
reshuffled = true
var card := deck.draw(t, rng)
@ -41,6 +42,10 @@ static func pick_node(t: RollTable, ctx: RollContext) -> Dictionary:
return Roller._stop(t, "Can't roll %s: %s" % [t.roll_text(), rv["error"]])
value = int(rv["value"])
fact = {"type": "roll", "pick": "dice", "dice": t.roll_text(), "faces": faces, "total": value}
if rv.has("limited"):
fact["limited"] = rv["limited"]
fact["limit_expr"] = rv["limit_expr"]
fact["raw"] = rv["raw"]
# The Why line names the modifier ("+3 for Luck") when it's all of the change.
if t.has_mod() and not t.is_expr_dice() and t.dice_obj().bonus == 0:
fact["mod_expr"] = t.dice_mod.strip_edges()
@ -49,7 +54,7 @@ static func pick_node(t: RollTable, ctx: RollContext) -> Dictionary:
for x: int in faces:
nat += x
fact["nat"] = nat
fact["mod"] = value - nat
fact["mod"] = int(fact.get("raw", value)) - nat
index = t.entry_index_clamped(value)
if t.clamps():
var span := RollRange.span(t)

View file

@ -28,8 +28,15 @@ static func request_for(t: RollTable, ctx: RollContext) -> Dictionary:
if not option_shown(e, ctx, log):
hidden += 1
continue
options.append({"index": k, "entry": k, "text": TextExpander.render(e.text, ctx), "details": e.details,
"weight": e.span() if ranged else maxi(0, e.weight)})
var o := {"index": k, "entry": k, "text": TextExpander.render(e.text, ctx), "details": e.details,
"weight": e.span() if ranged else maxi(0, e.weight)}
if RollCosts.has_cost(e):
o["cost"] = RollCosts.describe(e, ctx.board)
var why_not := RollCosts.blocked(e, ctx, ctx.board)
if why_not != "":
o["disabled"] = why_not
o["weight"] = 0
options.append(o)
if t.is_dynamic() and not t.entries.is_empty() and not option_shown(t.entries[0], ctx, log):
chosen_hidden = true
elif t.is_dynamic() and not t.entries.is_empty():
@ -145,6 +152,8 @@ static func default_reply(req: Dictionary) -> Variant:
return int(req.get("min", 0))
"text":
return ""
"pause":
return true
return -1
@ -185,14 +194,14 @@ static func run(t: RollTable, f: Dictionary, ctx: RollContext, stack: Array) ->
var idx := int(reply) if (reply is int or reply is float) else -1
var opt: Dictionary = {}
for o: Dictionary in opts:
if int(o["index"]) == idx:
if int(o["index"]) == idx and not o.has("disabled"):
opt = o
break
var node: Dictionary
if not opt.is_empty():
node = _option_node(t, opt, ctx)
node["picked"] = true
elif not t.is_dynamic() and int(req["hidden"]) == 0:
elif not t.is_dynamic() and int(req["hidden"]) == 0 and not opts.any(func(o: Dictionary) -> bool: return o.has("cost")):
# A plain fixed list: Random rolls the card the usual way
# (weights, ranges, card mode).
node = RollCards.pick_node(t, ctx)
@ -206,6 +215,8 @@ static func run(t: RollTable, f: Dictionary, ctx: RollContext, stack: Array) ->
node = _option_node(t, opts[k], ctx)
node["random"] = true
node["kind"] = RollTable.KIND_CHOICE
if node.has("entry"):
RollCosts.pay(node["entry"], ctx, t, node)
Roller._log(node, req["log"])
Roller._why(node, req["why"])
Roller._attach(f, node, ctx)

95
core/roll_combine.gd Normal file
View file

@ -0,0 +1,95 @@
class_name RollCombine
extends RefCounted
## Repeated rolls, combined. A thread that rolls its card more than once can
## keep every roll ("all", the default), add them together ("sum"), keep the
## highest or lowest ("max", "min"), or let the player choose one ("choose").
## When combining, the repeated rolls don't follow their own threads; the kept
## one does, once the combine step has run (Roller.OP_COMBINE). A roll's number
## is its result text when that is a number, else the die total.
const MODES := ["all", "sum", "max", "min", "choose"]
const LABELS := ["Keep every roll", "Add them together", "Keep the highest", "Keep the lowest", "Let me choose"]
static func value_of(n: Dictionary) -> float:
var t := Formatter.strip_tags(str(n.get("summary", ""))).strip_edges()
if t.is_valid_float():
return t.to_float()
return float(n.get("value", 0))
## Runs the combine frame `f` {node, to, mode, start, save}: returns the node
## whose threads should now run, or {} for none (a total, or nothing rolled).
static func run(f: Dictionary, ctx: RollContext) -> Dictionary:
var node: Dictionary = f["node"]
var kids: Array = []
var all_kids: Array = node["children"]
for i in range(int(f["start"]), all_kids.size()):
var k: Dictionary = all_kids[i]
var t: RollTable = k.get("table")
if t and t.id == str(f["to"]) and not k.get("inline", false) and not k.has("stop"):
kids.append(k)
if kids.is_empty():
return {}
var mode := str(f["mode"])
var keep: Dictionary = {}
match mode:
"sum":
var total := 0.0
var parts := PackedStringArray()
for k: Dictionary in kids:
total += value_of(k)
parts.append(_fmt(value_of(k)))
k["dropped"] = true
var t: RollTable = kids[0]["table"]
var sum := {"table": t, "children": [], "summary": _fmt(total), "combined": "sum",
"why": [{"type": "combine", "mode": "sum", "parts": parts, "total": total}]}
all_kids.append(sum)
_save(f, ctx, total, t)
return {}
"max", "min":
keep = kids[0]
for k: Dictionary in kids:
if (mode == "max" and value_of(k) > value_of(keep)) or (mode == "min" and value_of(k) < value_of(keep)):
keep = k
"choose":
keep = await _ask(kids, ctx)
if keep.is_empty():
ctx.halted = Roller.CANCELLED
return {}
_:
return {}
for k: Dictionary in kids:
if not is_same(k, keep):
k["dropped"] = true
keep["kept"] = mode
_save(f, ctx, Formatter.to_export_bbcode(str(keep.get("summary", ""))), keep["table"])
return keep
## Asks which roll to keep, with the same pop-up as a choice card.
static func _ask(kids: Array, ctx: RollContext) -> Dictionary:
var t: RollTable = kids[0]["table"]
var options: Array = []
for i in kids.size():
options.append({"index": i, "entry": int(kids[i].get("index", 0)), "text": str(kids[i].get("summary", "")),
"details": "", "weight": 1})
var req := {"table_id": t.id, "kind": "pick", "title": t.name, "prompt": "Keep which roll?",
"options": options, "min": 0, "max": 0, "default": -1, "log": [], "hidden": 0, "why": [], "combine": true}
var reply: Variant = await RollChoice.ask(ctx, req)
if reply == null:
return {}
var i := int(reply)
if i < 0 or i >= kids.size():
i = ctx.rng.randi_range(0, kids.size() - 1)
return kids[i]
static func _save(f: Dictionary, ctx: RollContext, v: Variant, t: RollTable) -> void:
var save := str(f.get("save", ""))
if save != "":
ctx.save(save, v, t.id)
static func _fmt(x: float) -> String:
return str(int(x)) if is_equal_approx(x, roundf(x)) else str(snappedf(x, 0.01))

1
core/roll_combine.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://by3putyoyufm1

51
core/roll_costs.gd Normal file
View file

@ -0,0 +1,51 @@
class_name RollCosts
extends RefCounted
## Costs on choice options: an option can cost an amount of a value
## (TableEntry.cost_value, cost_amount). It's offered greyed out, with the
## reason, when the value is too low; picking it takes the amount away.
## A "Reroll?" option that pipes back to a card and costs a point makes a
## spend-a-point-to-reroll table.
## "" when the option can be afforded now, else why not (shown to the player).
static func blocked(e: TableEntry, ctx: RollContext, board: TowerBoard = null) -> String:
if not has_cost(e):
return ""
var have := _number(Expr.evaluate(var_ref(e), ctx))
var need := _number(Expr.evaluate(e.cost_amount, ctx))
if have >= need:
return ""
return "Needs %s %s (you have %s)" % [Expr.format_value(need), label(e, board), Expr.format_value(have)]
static func has_cost(e: TableEntry) -> bool:
return e.cost_value.strip_edges() != "" and e.cost_amount.strip_edges() != ""
## "Costs 1 Luck".
static func describe(e: TableEntry, board: TowerBoard = null) -> String:
return "Costs %s %s" % [e.cost_amount.strip_edges(), label(e, board)] if has_cost(e) else ""
## Takes the cost away (an ordinary change, so it shows in the result's
## changes and the Why trace).
static func pay(e: TableEntry, ctx: RollContext, t: RollTable, node: Dictionary) -> void:
if not has_cost(e):
return
var facts: Array = []
Roller._log(node, Effects.run("%s -= %s" % [var_ref(e), e.cost_amount.strip_edges()], ctx, t.id, facts))
Roller._why(node, facts)
static func var_ref(e: TableEntry) -> String:
var v := e.cost_value.strip_edges()
return v if v.begins_with("@") else "@" + v
static func label(e: TableEntry, board: TowerBoard) -> String:
return Describe.label(var_ref(e).trim_prefix("@"), board) if board else var_ref(e).trim_prefix("@")
static func _number(r: Dictionary) -> float:
var v: Variant = r.get("value")
return float(v) if r.get("error", "") == "" and (v is int or v is float) else 0.0

1
core/roll_costs.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://drlg4yx1p2cs1

View file

@ -85,16 +85,16 @@ static func lint_pipes(board: TowerBoard) -> Array[Dictionary]:
has_when = true
if Expr.check(pw) != "":
out.append({"table_id": t.id, "entry_id": e.id,
"message": "Pipe condition %s: %s" % [pw, Expr.check(pw)]})
"message": "Thread condition %s: %s" % [pw, Expr.check(pw)]})
if first_other != "" and not warned:
warned = true
out.append({"table_id": t.id, "entry_id": e.id,
"message": "The otherwise pipe to %s comes before a conditional pipe; put it last so it reads in order" % _table_name(board, first_other)})
"message": "The otherwise thread to %s comes before a conditional thread; put it last so it reads in order" % _table_name(board, first_other)})
elif e.is_otherwise(p) and first_other == "":
first_other = p
if first_other != "" and not has_when:
out.append({"table_id": t.id, "entry_id": e.id,
"message": "The otherwise pipe to %s always runs: no pipe on this result has a condition" % _table_name(board, first_other)})
"message": "The otherwise thread to %s always runs: no thread on this result has a condition" % _table_name(board, first_other)})
return out
@ -105,7 +105,7 @@ static func lint_router(t: RollTable) -> Array[Dictionary]:
if t.kind != RollTable.KIND_ROUTER:
return out
if t.entries.is_empty():
out.append({"table_id": t.id, "entry_id": "", "message": "This router has no cases"})
out.append({"table_id": t.id, "entry_id": "", "message": "This branch has no cases"})
for i in t.entries.size():
var e := t.entries[i]
var w := e.when.strip_edges()
@ -210,10 +210,10 @@ static func lint_inputs(board: TowerBoard, t: RollTable) -> Array[Dictionary]:
var src := str(w[nm])
if Expr.check(src) != "":
out.append({"table_id": t.id, "entry_id": e.id, "kind": "inputs", "level": "error",
"message": "Pipe input %s = %s: %s" % [nm, src, Expr.check(src)]})
"message": "Thread input %s = %s: %s" % [nm, src, Expr.check(src)]})
if target != null and target.find_input(nm).is_empty():
out.append({"table_id": t.id, "entry_id": e.id, "kind": "inputs", "level": "hint",
"message": "The pipe to %s passes %s, but that card has no input called %s" % [_table_name(board, p), nm, nm]})
"message": "The thread to %s passes %s, but that card has no input called %s" % [_table_name(board, p), nm, nm]})
return out

View file

@ -29,7 +29,7 @@ static func pipe_plan(e: TableEntry, ctx: RollContext, log: Array = [], why: Arr
var r := Expr.evaluate(w, ctx)
var fact := {"type": "when", "to": p, "expr": w, "values": Expr.values_read(w, ctx), "result": false}
if r["error"] != "":
log.append({"text": "Pipe condition %s: %s" % [w, r["error"]], "error": true})
log.append({"text": "Thread condition %s: %s" % [w, r["error"]], "error": true})
run = false
fact["error"] = str(r["error"])
else:
@ -62,7 +62,7 @@ static func with_values(e: TableEntry, target: String, ctx: RollContext, log: Ar
var src := str(w[nm])
var r := Expr.evaluate(src, ctx)
if r["error"] != "":
log.append({"text": "Pipe input %s = %s: %s" % [nm, src, r["error"]], "error": true})
log.append({"text": "Thread input %s = %s: %s" % [nm, src, r["error"]], "error": true})
else:
out[nm] = Expr.normalize(r["value"])
return out

View file

@ -214,7 +214,29 @@ static func roll_value(t: RollTable, ctx: RollContext) -> Dictionary:
var m := modifier(t.dice_mod, ctx)
if m["error"] != "":
return {"value": 0, "error": "the modifier %s %s" % [t.dice_mod.strip_edges(), m["error"]]}
return {"value": total + int(m["value"]), "error": ""}
return limit(t, total + int(m["value"]), ctx)
## Applies the card's floor and ceiling (RollTable.roll_floor, roll_ceiling:
## "Never below", "Never above"; numbers or values set by earlier results).
## {value, error, limited: "floor"|"ceiling" when it moved the total}.
static func limit(t: RollTable, v: int, ctx: RollContext) -> Dictionary:
var out := {"value": v, "error": "", "raw": v}
for side in ["floor", "ceiling"]:
var src := (t.roll_floor if side == "floor" else t.roll_ceiling).strip_edges()
if src == "":
continue
var r := Expr.evaluate(src, ctx)
if r["error"] != "":
return {"value": v, "error": "Never %s %s: %s" % ["below" if side == "floor" else "above", src, r["error"]]}
if r["value"] == null:
continue
var lim := Expr.as_int(r, v)
if (side == "floor" and out["value"] < lim) or (side == "ceiling" and out["value"] > lim):
out["value"] = lim
out["limited"] = side
out["limit_expr"] = src
return out
## The result index for a rolled total: past the ends counts as the end
@ -234,9 +256,23 @@ static func index_for(t: RollTable, value: int) -> int:
## Gaps, overlaps and (on a table that doesn't clamp) results the dice can't
## reach, or "" when clean.
## The first range whose start is above its end ("9–4"), or "". Such a card
## can't be rolled until it's fixed (the editor no longer swaps the ends).
static func backwards(t: RollTable) -> String:
if not t.is_ranged():
return ""
for e in t.entries:
if e.has_range and e.range_lo > e.range_hi:
return "%s–%s" % [fmt(t, e.range_lo), fmt(t, e.range_hi)]
return ""
static func problems(t: RollTable) -> String:
if not t.is_ranged():
return ""
var back := backwards(t)
if back != "":
return "The range %s runs backwards: make its start no bigger than its end. The card can't be rolled until then." % back
var lo := min_value(t)
var hi := max_value(t)
if clamps(t):

View file

@ -49,6 +49,16 @@ var collapsed: bool = false
## Longer description (may contain BBCode).
var details: String = ""
var tags: Array[String] = []
## The card's own colour ("#hex") for its frame and header; "" = the theme's.
var color: String = ""
## The size the user dragged the card to: its width in Play (Build adds a
## little), and the height of its results list, which then scrolls. 0 = automatic.
var width: float = 0.0
var list_height: float = 0.0
## Ranged tables: the total never goes below / above these (numbers or
## expressions such as @atmo_min, often set by an earlier result). "" = none.
var roll_floor: String = ""
var roll_ceiling: String = ""
## Dice expression for ranged tables, e.g. "1d100", "2d6", "1d8+2", or any
## expression such as "2d6 + dm(@end)".
var dice: String = DEFAULT_DICE
@ -59,6 +69,8 @@ var dice_mod: String = ""
var card_mode: bool = false
## What happens when the deck runs out: "reshuffle" or "stop".
var deck_empty: String = "reshuffle"
## What a Deck-mode card that waits for Shuffle gives once it's empty ("" = "Empty").
var deck_empty_text: String = ""
var entries: Array[TableEntry] = []
## One of KINDS.
@ -384,6 +396,11 @@ func find_entry(eid: String) -> TableEntry:
## Gaps, overlaps and out-of-reach ranges, or "" when clean (RollRange.problems).
## The result an empty Deck-mode card gives when it waits for Shuffle.
func empty_text() -> String:
return deck_empty_text if deck_empty_text.strip_edges() != "" else "Empty"
func range_problems() -> String:
return RollRange.problems(self)
@ -421,6 +438,16 @@ func to_dict() -> Dictionary:
d["details"] = details
if not tags.is_empty():
d["tags"] = tags.duplicate()
if color != "":
d["color"] = color
if roll_floor.strip_edges() != "":
d["roll_floor"] = roll_floor.strip_edges()
if roll_ceiling.strip_edges() != "":
d["roll_ceiling"] = roll_ceiling.strip_edges()
if width > 0.0:
d["w"] = roundi(width)
if list_height > 0.0:
d["list_h"] = roundi(list_height)
if is_ranged():
d["dice"] = dice
if has_mod():
@ -429,6 +456,8 @@ func to_dict() -> Dictionary:
d["card_mode"] = true
if deck_empty != "reshuffle":
d["deck_empty"] = deck_empty
if deck_empty_text != "":
d["deck_empty_text"] = deck_empty_text
if kind == KIND_CHOICE:
if choice != "pick":
d["choice"] = choice
@ -485,6 +514,11 @@ static func from_dict(d: Dictionary) -> RollTable:
t.details = str(d.get("details", ""))
for tag: Variant in d.get("tags", []):
t.tags.append(str(tag))
t.color = str(d.get("color", ""))
t.roll_floor = str(d.get("roll_floor", ""))
t.roll_ceiling = str(d.get("roll_ceiling", ""))
t.width = maxf(0.0, float(d.get("w", 0)))
t.list_height = maxf(0.0, float(d.get("list_h", 0)))
if d.has("dice"):
t.dice = str(d["dice"])
elif int(d.get("die", 0)) > 1:
@ -492,6 +526,7 @@ static func from_dict(d: Dictionary) -> RollTable:
t.dice_mod = expr_text(d.get("dice_mod", ""), "").strip_edges()
t.card_mode = bool(d.get("card_mode", false))
t.deck_empty = "stop" if str(d.get("deck_empty", "reshuffle")) == "stop" else "reshuffle"
t.deck_empty_text = str(d.get("deck_empty_text", ""))
var k := str(d.get("kind", KIND_ROLL))
t.kind = k if KINDS.has(k) else KIND_ROLL
var c := str(d.get("choice", "pick"))

View file

@ -36,7 +36,7 @@ static func step_of(n: Dictionary, depth: int = 0) -> Dictionary:
step["kind"] = n["kind"]
if n.has("effects"):
step["effects"] = (n["effects"] as Array).duplicate(true)
for k in ["answer", "passes", "pass", "after", "picked", "random", "limit", "cancelled", "case", "option", "check", "inputs"]:
for k in ["answer", "passes", "pass", "after", "picked", "random", "limit", "cancelled", "deck_empty", "dropped", "kept", "combined", "stopped_before", "case", "option", "check", "inputs"]:
if n.has(k):
step[k] = n[k]
if n.has("why"):

View file

@ -50,7 +50,9 @@ const CANCELLED := "Cancelled"
const NO_CASE := "No case matched"
const NO_OPTIONS := "No options available"
enum { OP_ROLL, OP_PIPE, OP_LOOP, OP_RESTORE }
enum { OP_ROLL, OP_PIPE, OP_LOOP, OP_RESTORE, OP_COMBINE, OP_PAUSE }
## A paused thread the player chose not to continue.
const STOPPED_HERE := "Stopped here"
## A RollContext wired to this board: it resolves [[names]] against the board's
@ -194,6 +196,12 @@ static func _chain(board: TowerBoard, table_id: String, depth: int, ctx: RollCon
await RollCards.do_loop(f, ctx, stack)
OP_RESTORE:
RollPipes.restore(f, ctx)
OP_COMBINE:
var keep: Dictionary = await RollCombine.run(f, ctx)
if not keep.is_empty():
_queue_pipes(keep, ctx, stack, int(f["depth"]))
OP_PAUSE:
await _do_pause(board, f, ctx, stack)
# A halted roll leaves frames behind: put back any card inputs they hid.
while not stack.is_empty():
var rest: Dictionary = stack.pop_back()
@ -316,6 +324,17 @@ static func _enter(node: Dictionary, f: Dictionary, ctx: RollContext, stack: Arr
ctx.save(t.save_as, Formatter.strip_tags(str(node["summary"])).strip_edges(), t.id)
if e.pipes.is_empty():
return
# A roll that is being combined with others (RollCombine) waits: only the
# one that's kept follows its threads.
if f.get("no_follow", false):
return
_queue_pipes(node, ctx, stack, depth)
## Snapshots a result's threads (RollPipes.pipe_plan) and queues the ones
## that run, last first so they run in order.
static func _queue_pipes(node: Dictionary, ctx: RollContext, stack: Array, depth: int) -> void:
var e: TableEntry = node["entry"]
var log: Array = []
var why: Array = []
var plan := RollPipes.pipe_plan(e, ctx, log, why)
@ -329,7 +348,17 @@ static func _enter(node: Dictionary, f: Dictionary, ctx: RollContext, stack: Arr
var fr := {"op": OP_PIPE, "node": node, "entry": e, "to": p, "left": int(item["count"]), "save": e.save_for(p), "depth": depth}
if item.has("with"):
fr["with"] = item["with"]
var mode := e.combine_for(p)
if mode != "all" and int(item["count"]) > 1:
# Runs after every repeat: combines them (RollCombine).
stack.append({"op": OP_COMBINE, "node": node, "to": p, "mode": mode, "save": fr["save"],
"start": (node["children"] as Array).size(), "depth": depth})
fr["no_follow"] = true
fr["save"] = ""
stack.append(fr)
if e.pipe_pause.has(p):
# Runs first: waits for the player before the thread above it.
stack.append({"op": OP_PAUSE, "node": node, "to": p, "depth": depth})
## Appends why-trace facts to a node's "why".
@ -351,6 +380,22 @@ static func _log(node: Dictionary, lines: Array) -> void:
(node["effects"] as Array).append_array(lines)
## A paused thread: asks the player (kind "pause") whether to go on. Stopping
## drops the thread waiting under this frame and marks the result.
static func _do_pause(board: TowerBoard, f: Dictionary, ctx: RollContext, stack: Array) -> void:
var t := board.get_table(str(f["to"]))
var node: Dictionary = f["node"]
var req := {"kind": "pause", "table_id": str(f["to"]), "title": t.name if t else str(f["to"]),
"prompt": "Continue to %s?" % Formatter.strip_tags(t.name if t else str(f["to"])),
"from": Formatter.strip_tags((node["table"] as RollTable).name)}
var reply: Variant = await RollChoice.ask(ctx, req)
if reply == true:
return
if not stack.is_empty() and int((stack.back() as Dictionary)["op"]) == OP_PIPE:
stack.pop_back()
node["stopped_before"] = str(f["to"])
static func _do_pipe(board: TowerBoard, f: Dictionary, ctx: RollContext, stack: Array) -> void:
if int(f["left"]) <= 0:
return
@ -362,6 +407,8 @@ static func _do_pipe(board: TowerBoard, f: Dictionary, ctx: RollContext, stack:
var fr := {"op": OP_ROLL, "id": f["to"], "parent": f["node"], "save": f["save"], "depth": f["depth"]}
if f.has("with"):
fr["with"] = f["with"]
if f.get("no_follow", false):
fr["no_follow"] = true
stack.append(fr)

View file

@ -34,6 +34,23 @@ var pipe_otherwise: Dictionary = {}
## card's inputs (docs/PLAIN.md §4.2), worked out in the entry's snapshot.
## Missing = none.
var pipe_with: Dictionary = {}
## target table id -> the thread's own colour "#hex" (missing = the theme's).
var pipe_color: Dictionary = {}
## The Book page this result is linked to ("" = none). Its text and details
## follow the page (TowerBoard.sync_page).
var page: String = ""
## target table id -> how repeated rolls combine: "sum", "max", "min" or
## "choose" (RollCombine). Missing = keep every roll.
var pipe_combine: Dictionary = {}
## target table id -> true: the roll waits before following this thread until
## the player continues (Roller.OP_PAUSE). Missing = no pause.
var pipe_pause: Dictionary = {}
## Choice options: what picking this costs (RollCosts): a value name and an
## amount (an expression). "" = free.
var cost_value: String = ""
var cost_amount: String = ""
## A picture (BoardImages id, kept in the spread file). "" = none.
var image: String = ""
## Router cards: this case's condition. "" is the Otherwise case (always
## matches). Ignored on other kinds.
var when: String = ""
@ -85,7 +102,7 @@ func count_value(target: String, ctx: RollContext, log: Array = []) -> int:
return count_for(target)
var r := Expr.evaluate(e, ctx)
if r["error"] != "":
log.append({"text": "Pipe count %s: %s" % [e, r["error"]], "error": true})
log.append({"text": "Thread count %s: %s" % [e, r["error"]], "error": true})
return 0
return clampi(Expr.as_int(r, 0), 0, MAX_EXPR_COUNT)
@ -193,6 +210,11 @@ func add_pipe(target: String, count: Variant = 1, save_as: String = "") -> void:
set_pipe_save(target, save_as)
## How a thread's repeated rolls combine (RollCombine.MODES).
func combine_for(target: String) -> String:
return str(pipe_combine.get(target, "all"))
## Removes a pipe along with its options.
func remove_pipe(target: String) -> void:
pipes.erase(target)
@ -201,6 +223,9 @@ func remove_pipe(target: String) -> void:
pipe_when.erase(target)
pipe_otherwise.erase(target)
pipe_with.erase(target)
pipe_color.erase(target)
pipe_combine.erase(target)
pipe_pause.erase(target)
func to_dict() -> Dictionary:
@ -224,7 +249,10 @@ func to_dict() -> Dictionary:
var w := when_for(p)
var other := is_otherwise(p)
var wv: Variant = pipe_with.get(p)
if expr == "" and n == 1 and s == "" and w == "" and not other and wv == null:
var col := str(pipe_color.get(p, ""))
var comb := combine_for(p)
var paused := pipe_pause.has(p)
if expr == "" and n == 1 and s == "" and w == "" and not other and wv == null and col == "" and comb == "all" and not paused:
list.append(p)
else:
var po := {"table": p}
@ -240,10 +268,22 @@ func to_dict() -> Dictionary:
po["otherwise"] = true
if wv is Dictionary and not (wv as Dictionary).is_empty():
po["with"] = (wv as Dictionary).duplicate()
if col != "":
po["color"] = col
if comb != "all":
po["combine"] = comb
if paused:
po["pause"] = true
list.append(po)
d["pipes"] = list
if has_range:
d["range"] = [range_lo, range_hi]
if page != "":
d["page"] = page
if image != "":
d["image"] = image
if cost_value.strip_edges() != "":
d["cost"] = {"value": cost_value.strip_edges(), "amount": cost_amount.strip_edges()}
return d
@ -252,6 +292,12 @@ static func from_dict(d: Dictionary) -> TableEntry:
e.details = str(d.get("details", ""))
e.weight = maxi(0, int(d.get("weight", 1)))
e.effects = str(d.get("effects", ""))
e.page = str(d.get("page", ""))
e.image = str(d.get("image", ""))
var cost: Variant = d.get("cost")
if cost is Dictionary:
e.cost_value = str(cost.get("value", ""))
e.cost_amount = str(cost.get("amount", ""))
e.when = str(d.get("when", "")).strip_edges() if d.get("when") != null else ""
e.show_if = str(d.get("show_if", "")).strip_edges() if d.get("show_if") != null else ""
for p: Variant in d.get("pipes", []):
@ -264,6 +310,12 @@ static func from_dict(d: Dictionary) -> TableEntry:
e.set_pipe_otherwise(target, bool(p.get("otherwise", false)))
if p.get("with") is Dictionary:
e.set_pipe_with(target, p["with"])
if str(p.get("color", "")) != "":
e.pipe_color[target] = str(p["color"])
if RollCombine.MODES.has(str(p.get("combine", "all"))) and str(p.get("combine", "all")) != "all":
e.pipe_combine[target] = str(p["combine"])
if bool(p.get("pause", false)):
e.pipe_pause[target] = true
elif str(p) != "":
e.add_pipe(str(p))
var r: Variant = d.get("range")

View file

@ -23,6 +23,8 @@ var collapsed: bool = false
var details: String = ""
## Ids of the member tables, in the order they were added.
var members: Array[String] = []
## The group this one sits inside ("" = on the spread itself).
var parent: String = ""
func _init(p_id: String = "", p_name: String = "") -> void:
@ -69,6 +71,8 @@ func to_dict() -> Dictionary:
d["collapsed"] = true
if details != "":
d["details"] = details
if parent != "":
d["parent"] = parent
return d
@ -78,6 +82,7 @@ static func from_dict(d: Dictionary) -> TableGroup:
g.size = Vector2(maxf(80.0, float(d.get("w", 320))), maxf(TITLE_H, float(d.get("h", 200))))
g.collapsed = bool(d.get("collapsed", false))
g.details = str(d.get("details", ""))
g.parent = str(d.get("parent", ""))
var src: Variant = d.get("members", [])
if src is Array:
for m: Variant in src:

View file

@ -36,11 +36,12 @@ static func make(board: TowerBoard, table_ids: Array, kind: String, tname: Strin
want[str(tid)] = true
var groups: Array[TableGroup] = []
for gid: Variant in group_ids:
var g := board.get_group(str(gid))
if g:
groups.append(g)
for m in g.members:
want[m] = true
# A group brings its inner groups along.
for g in board.groups_in(str(gid)):
if not groups.has(g):
groups.append(g)
for m in g.members:
want[m] = true
# The top-left corner: the tables' corner, or a group frame's when it's further out.
var origin := Vector2(INF, INF)
for t in board.tables:
@ -89,6 +90,11 @@ static func make(board: TowerBoard, table_ids: Array, kind: String, tname: Strin
members.append(m)
gd["members"] = members
gd.erase("id")
# Inner groups point at their outer group by its place in this list.
gd.erase("parent")
var outer := board.get_group(g.parent)
if outer and groups.has(outer):
gd["parent_at"] = groups.find(outer)
group_list.append(gd)
var tpl := {
"format_version": FORMAT_VERSION,
@ -279,7 +285,13 @@ static func instantiate(tpl: Dictionary, values: Dictionary, board: TowerBoard,
if id_map.has(m):
members.append(id_map[m])
g.members = members
g.parent = ""
groups.append(g)
var gsrc: Array = src["groups"].filter(func(v: Variant) -> bool: return v is Dictionary)
for i in mini(gsrc.size(), groups.size()):
var at := int((gsrc[i] as Dictionary).get("parent_at", -1))
if at >= 0 and at < groups.size() and at != i:
groups[i].parent = groups[at].id
return {"tables": tables, "groups": groups, "relinked": relinked, "dropped": dropped}

View file

@ -117,6 +117,16 @@ func _write(id: String, tpl: Dictionary) -> bool:
return true
## Writes over a user template, keeping its id ("Replace" when saving, and
## Edit… in the template list). Built-ins can't be replaced.
func replace(id: String, tpl: Dictionary) -> bool:
if is_builtin(id) or not exists(id):
return false
var out := tpl.duplicate(true)
out.erase("replace_id")
return _write(id, out)
## Renames a user template (the file keeps its id). Built-ins can't be renamed.
func rename(id: String, new_name: String) -> bool:
if is_builtin(id) or new_name.strip_edges() == "":

View file

@ -17,6 +17,10 @@ var tables: Array[RollTable] = []
## Group cards (frames around blocks of tables). Optional; a table is in at
## most one group. See TableGroup.
var groups: Array[TableGroup] = []
## The Book: reusable results (Pages) for this spread.
var book: Array[BookPage] = []
## Pictures: id -> base64 data (BoardImages). Only used ones are saved.
var images: Dictionary = {}
static func new_id(prefix: String) -> String:
@ -62,10 +66,173 @@ func group_of(table_id: String) -> TableGroup:
return null
## True when the table is hidden inside a collapsed group.
## True when the table is hidden inside a collapsed group (at any depth).
func is_hidden(table_id: String) -> bool:
var g := group_of(table_id)
return g != null and g.collapsed
while g != null:
if g.collapsed:
return true
g = get_group(g.parent)
return false
# ----- The Book (reusable results) -----
func book_list() -> Array:
var out: Array = []
for p in book:
out.append(p.to_dict())
return out
func load_book(src: Variant) -> void:
var pages: Array[BookPage] = []
if src is Array:
for v: Variant in src:
if v is Dictionary:
var p := BookPage.from_dict(v)
if p.id == "":
p.id = new_id("p")
pages.append(p)
book = pages
func get_page(pid: String) -> BookPage:
for p in book:
if p.id == pid:
return p
return null
## The texture of a stored picture, or null.
func picture(id: String) -> Texture2D:
return BoardImages.texture(id, str(images.get(id, "")))
func add_page(text: String, details: String = "") -> BookPage:
var p := BookPage.new()
p.id = new_id("p")
p.text = text
p.details = details
book.append(p)
return p
## Deletes a page; results linked to it keep their text and become ordinary.
func remove_page(pid: String) -> void:
for t in tables:
for e in t.entries:
if e.page == pid:
e.page = ""
book = book.filter(func(p: BookPage) -> bool: return p.id != pid)
## Links a result to a page and copies the page's text and details onto it.
func link_page(e: TableEntry, pid: String) -> void:
var p := get_page(pid)
if p:
e.page = pid
e.text = p.text
e.details = p.details
e.image = p.image
## Copies a page onto every result linked to it. Returns the tables touched.
func sync_page(pid: String) -> Array[String]:
var p := get_page(pid)
var touched: Array[String] = []
if p == null:
return touched
for t in tables:
for e in t.entries:
if e.page == pid:
e.text = p.text
e.details = p.details
e.image = p.image
if not touched.has(t.id):
touched.append(t.id)
return touched
## How many results are linked to a page.
func page_uses(pid: String) -> int:
var n := 0
for t in tables:
for e in t.entries:
if e.page == pid:
n += 1
return n
# ----- Nested groups -----
func child_groups(gid: String) -> Array[TableGroup]:
var out: Array[TableGroup] = []
for g in groups:
if g.parent == gid and gid != "":
out.append(g)
return out
## Every table inside a group, its inner groups' tables included.
func tables_in(gid: String) -> Array[String]:
var out: Array[String] = []
var g := get_group(gid)
if g == null:
return out
out.append_array(g.members)
for c in child_groups(gid):
out.append_array(tables_in(c.id))
return out
## The group and every group inside it, outermost first.
func groups_in(gid: String) -> Array[TableGroup]:
var out: Array[TableGroup] = []
var g := get_group(gid)
if g == null:
return out
out.append(g)
for c in child_groups(gid):
out.append_array(groups_in(c.id))
return out
## The outermost collapsed group around `g` (not `g` itself), or null when
## nothing around it is collapsed.
func hidden_by(g: TableGroup) -> TableGroup:
var out: TableGroup = null
var p := get_group(g.parent)
while p != null:
if p.collapsed:
out = p
p = get_group(p.parent)
return out
## How many groups `g` sits inside.
func depth_of(g: TableGroup) -> int:
var n := 0
var p := get_group(g.parent)
while p != null and n < groups.size():
n += 1
p = get_group(p.parent)
return n
## Puts group `gid` inside `parent_id` ("" = the spread). False when that would
## put a group inside itself.
func set_group_parent(gid: String, parent_id: String) -> bool:
var g := get_group(gid)
if g == null:
return false
var p := get_group(parent_id)
while p != null:
if p.id == gid:
return false
p = get_group(p.parent)
g.parent = parent_id
return true
## Makes a group of the given tables (taking them out of any other group).
@ -97,36 +264,46 @@ func remove_from_group(table_id: String) -> void:
g.members.erase(table_id)
## Removes the group only; its cards stay on the board.
## Removes the group only; its cards and inner groups move up to the group
## around it (or onto the spread).
func ungroup(gid: String) -> void:
var g := get_group(gid)
if g == null:
return
var outer := get_group(g.parent)
for c in child_groups(gid):
c.parent = g.parent
if outer:
for tid in g.members:
if not outer.members.has(tid):
outer.members.append(tid)
for i in range(groups.size() - 1, -1, -1):
if groups[i].id == gid:
groups.remove_at(i)
## Removes the group and every table in it. Returns the removed table ids.
## Removes the group, its inner groups and every table in them. Returns the
## removed table ids.
func delete_group(gid: String) -> Array[String]:
var g := get_group(gid)
var gone: Array[String] = []
if g == null:
if get_group(gid) == null:
return gone
gone.assign(g.members.duplicate())
ungroup(gid)
gone.assign(tables_in(gid))
for inner in groups_in(gid):
groups.erase(inner)
for tid in gone:
remove_table(tid)
return gone
## Moves a group's frame and every member table by `delta`.
## Moves a group's frame, its inner groups and every table in them by `delta`.
func move_group(gid: String, delta: Vector2) -> void:
var g := get_group(gid)
if g == null:
return
g.position += delta
for tid in g.members:
var t := get_table(tid)
if t:
t.position += delta
for g in groups_in(gid):
g.position += delta
for tid in g.members:
var t := get_table(tid)
if t:
t.position += delta
## Drops members that aren't tables, keeps each table in its first group only,
@ -147,6 +324,19 @@ func clean_groups() -> void:
taken[m] = true
keep.append(m)
g.members = keep
# Parents must exist and never loop back.
for g in groups:
if g.parent != "" and (not gids.has(g.parent) or g.parent == g.id):
g.parent = ""
for g in groups:
var seen := {g.id: true}
var p := get_group(g.parent)
while p != null:
if seen.has(p.id):
g.parent = ""
break
seen[p.id] = true
p = get_group(p.parent)
## Upgrades a parsed file to FORMAT_VERSION, one version step at a time.
@ -184,6 +374,11 @@ func to_dict() -> Dictionary:
for g in groups:
gl.append(g.to_dict())
d["groups"] = gl
if not book.is_empty():
d["book"] = book_list()
var pics := BoardImages.used(self)
if not pics.is_empty():
d["images"] = pics
return d
@ -218,6 +413,10 @@ func load_dict(src: Dictionary) -> bool:
loaded_groups.append(TableGroup.from_dict(gd))
groups = loaded_groups
clean_groups()
load_book(d.get("book", []))
# Undo snapshots carry no pictures: keep the ones already loaded.
if d.get("images") is Dictionary:
images.merge(d["images"], true)
if str(d.get("id", "")) != "":
id = str(d["id"])
if str(d.get("name", "")) != "":
@ -256,7 +455,7 @@ static func write_text_atomic(path: String, text: String) -> Error:
func save(path: String = SAVE_PATH) -> bool:
var err := write_text_atomic(path, to_json())
if err != OK:
push_warning("Couldn't save the board to %s: %s" % [path, error_string(err)])
push_warning("Couldn't save the spread to %s: %s" % [path, error_string(err)])
return false
return true

175
docs/ARCHITECTURE.md Normal file
View file

@ -0,0 +1,175 @@
# TableTower — Architecture and Features
Read on demand (not every session). Status and plan: `docs/DESIGN.md`.
## 2. Feature summary (all on `main`)
**Board and rolling**
- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a
result's ● onto another card to lay a pipe. A result can pipe into several cards (fan-out),
on ranged and weighted tables alike; one roll runs them all.
- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation.
- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the
**− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M).
- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand
all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo, + Card ▾
and Board ▾ (Test board, Reset sample, Pack collapsed groups, import, export).
- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and
selection paint over it. On by default; the `striped_rows` local setting.
- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup,
see `HelpDialog`), included in exports via the preset's include filter.
- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any
expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle).
- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to
its dice. Ranges may run past the dice (−3 to 24 on a d20); totals past the ends use the end
result. The card shows chances for the modifier's value now, and Why says "+3 for Luck".
- **Pipe options.** A count (a number or an expression), "save as", **Only if** conditions,
and **Otherwise**. A result's conditions and counts are evaluated once, as a snapshot,
before any pipe runs.
- **Text in results.** `[[Table]]` inline references, `{@var}` / `{hero}` values, and BBCode formatting.
- **The result tray** shows the chain as chips with effect lines, a sheet headline,
Earlier rolls, a Variables tab, Copy (text, BBCode, with details) and **Why this?** on each step.
- **Resizable panels.** Drag the tray's top edge or the inspector's left edge (double-click for the
default). The sizes are kept in local settings (`tray_height`, `inspector_width`). Every part of
the tray scrolls inside it.
**Logic cards** (`docs/LOGIC.md`)
- **Choice:** "Which option" (pick, with Random), "How many" (a number) or "Open
ended" (text). The pop-up can be minimized, and its options preview where they lead.
- **Loop:** repeat N times, while a condition holds, or until it does. Then "Afterwards".
- **Router:** if / else if / otherwise cases; the first true case runs.
- **Check:** roll + modifier against a target, with Success and Failure outlets. Sets `nat`, `total` and `effect`.
- **Variable** cards (with a starting value) and **Collection** cards (e.g. Skills, whose members are `@skill_*`).
- **Sheet:** a live template, e.g. a character sheet.
- **Changes** (stored as `effects`) on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names.
- **Dynamic pick options** from a collection or list (`options_from`, `options_where`), plus `show_if` on any option.
- **Card inputs:** a card declares inputs, and pipes pass values (`with`), scoped to that pipe's part of the roll.
- **A 10,000-action limit** per roll. The roller uses an explicit stack, so long loops don't overflow.
**Building** (Build mode)
- **The inspector,** docked right. It edits the selected card, result or pipe:
- effects as rows ("[Subtract] [1] from [Luck]")
- a roll or check modifier as "[Add ▾] [Luck ▾]" (ModifierEditor)
- conditions as rows ("[Luck] [is at least] [2]", with and/or)
- pipe inputs, Otherwise, count and saves-as
- kind-specific card fields
- a value picker with "+ New value…"
- "Edit as text" everywhere
- **Plain / Text** in View ▾ → Rules.
- **Card ⋯ menu** (Build): Table settings…, Save as template…, Collapse, Delete table. A row's ×
shows only on hover, keyboard focus or when the row is selected.
- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step.
- Collapse/expand isn't undoable.
- Rolls, variables and decks aren't undoable.
- Collection members aren't undoable either.
- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to
select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → Pack collapsed groups.
- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from
"+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`:
skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter
and simple sheet.
- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card.
- **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports
errors, dead ends, unreached cards and lint, and clicking an item jumps to the card.
- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower
JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only).
## 3. Architecture
```
core/ engine, no UI, testable headless
tower_board.gd a collection (tables, groups), JSON, format v2 + migration
roll_table.gd a card: kind, dice, entries, logic fields, factories (RollTable.create)
roll_range.gd a ranged card's numbers: span, natural range, labels, chances, the roll
modifier (shared with check cards), range problems
table_entry.gd a result: text, weight, range, effects, pipes (+count/save/when/otherwise/with), show_if, when
roller.gd coroutine roller with an explicit stack (_chain loop, roll/pipe steps,
apply_starting_values) plus delegators to its parts:
roll_pipes.gd pipe_plan snapshot, card inputs (`with`)
roll_cards.gd weighted picks, router, check, loops
roll_choice.gd choice requests, dynamic options, show_if, asking
roll_tree.gd flatten, step lookups, lit keys, pipe/entry keys
roll_lint.gd lint_*, endless_cycles
roll_context.gd per-roll state: chain and board variables, prompt hook, actions, depth
expr.gd / effects.gd expression evaluation (Godot Expression + rewrites), effect statements
text_expander.gd [[refs]], {vars}, {@prefix_*}, {= expr}; formatter.gd: BBCode safety and stripping
dice.gd / deck_state.gd dice parsing and distributions, card-mode decks
describe.gd rules → plain words, labels, why sentences; kind_label / choice_label
(the only place card-kind and choice-type names are defined)
builder.gd effect/condition models ↔ text, known_values
board_tester.gd simulation and static checks (used by the Test board UI and the CLI)
library_store.gd / state_store.gd collections on disk / local state (decks, variables, history, settings)
table_group.gd, template_kit.gd, template_library.gd, sample_board.gd
io/ json_io (canonical + import), canvas_io, graphml_io, mermaid_exporter, dot_exporter
ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, input) with one-line
delegators to RefCounted helpers that hold `m: Main`:
main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups,
main_history (undo), main_navigation (search/focus/minimap/arrange),
main_top_bar (bar, toast, endless-loop chip), main_state (decks, variables),
main_collections, main_templates, main_inspector
top bar parts: view_menu (View ▾), zoom_control, help_menu + help_dialog
table_card.gd + table_card_{header,rows,editing,value,text}.gd
result_tray.gd + tray_chips, tray_text, earlier_rolls
table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields
inspector_card (card fields) + inspector_roll (roll dice and modifier);
modifier_editor (the plain modifier builder); panel_splitter (drag handles)
and: board_view, card_layer, pipe_layer, port_layer, group_layer, group_card, minimap,
why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker,
rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog,
template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style
help/ topics.txt: the Help window's text (# Title per topic)
tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows)
tests/ test_*.gd: 27 headless suites
templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL)
```
**Key implementation facts**
- **Lazy cards.** Cards hidden inside collapsed groups aren't built, so
`main.card_for(id)` can return null. Pipe, port and card layers redraw only when something changes.
- **Undo** (`ui/edit_history.gd`) snapshots each table and group separately, sharing unchanged ones.
- **Prompts.** The roller awaits `ctx.prompt` for choices, and the UI shows progress before each pop-up.
- **Rules display.** The UI reads plain or text mode through `RulesView` and `main.rules_plain()`,
and `main.rules_view_changed` signals a switch.
- **Shared builders, use them rather than copying:** `Style.menu_button`, `Style.font_colors`,
`Style.field_colors`, `TableCard.vbox/hbox`, `InspectorKit.*` (fields, `focused_tag`/`refocus`,
`as_text_link`), `Main.file_dialog`/`export_dialog`, `JsonIO.entry_line`/`finish_import`.
- **Keep files small.** Aim for under ~400 lines; split by area into helper objects as above.
Next candidates, all 530–730 lines:
- core: describe (731, the largest now), roll_table, expr
- ui: choice_dialog, inspector_card, inspector, main, edit_history
- io: json_io
## 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/`.
- **Local state** (never exported): `user://state/state.json` holds decks, board
variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed,
`rules_view`, `striped_rows`). Templates live in `user://templates/`.
- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed
up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are
`traveller-chargen.before-*.json.bak` in the app data folder.
## 7. Known gaps and bugs
- **Only one pipe per target per result.** Pipes are keyed by target id, so the mockup's
two pipes into Loot (Tier 3 "only if", Tier 1 "otherwise") can't be built. Lifting this
needs pipe ids in the model, the file format, the UI keys (`tid:eid>to`) and undo.
- Long pipe labels are cut with "…" in narrow gaps, and labels draw behind cards.
- The Why pop-over opens above the tray and can cover the bottom of the board.
- Not tried by hand yet: all of this was verified with headless tests and screenshots
only. A hands-on playtest with a checklist is overdue.
- The Linux export preset exists, but the 4.7.2 export templates aren't installed. They're a
large download and the user hasn't approved it. There are no Windows or Mac presets.
- Loading a big board with every group expanded takes about 5 s (building `TableCard` nodes).
- Group frames are rectangles, so a non-member card lying inside one looks like a member.
Pipes into a collapsed group can't be clicked.
- Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON.
- `{= }` dice in live sheet and variable displays re-roll when the display refreshes.
- The simulator and Test board list results that only a modifier reaches as "never chosen" when
the modifier stays small in the runs (the demo's luck-only vault, for example).
- **Not yet looked into: Coderstanding warnings.**
- Signals emitted but never connected: `ModalCard.closed`, `SearchPanel.closed`.
- A possible wrong handler in `ModalCard.segmented` (`pressed` → `on_change`; probably a
false positive from a bound callable).
- Large class cycles in ui/ (expected from the `main` back-references).

View file

@ -1,428 +1,125 @@
# TableTower — Design and Status
# Table Tarot (repo: TableTower) — Status and Plan
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-09 (UI pass: striped rows, View/Help menus, card ⋯ menu, a fuller sample; see §10)
**Engine:** Godot 4.7.2 (GDScript) · **Started:** 2026-11-08 · **Last updated:** 2026-11-10 (plan steps 1–12 done on `tarot`, not merged)
This is the starting point for anyone picking the project up, including a new Claude
session. It records what TableTower is, how it's built, how to work on it, where things
stand, and what's next.
The short page to read at the start of every session. Everything else is read only when needed:
- `docs/ARCHITECTURE.md`: feature summary, file map, key implementation facts, data/storage, known gaps.
- `docs/HISTORY.md`: decisions on record, the private Traveller board, the old ideas list, history.
- `docs/LOGIC.md` (rule language), `docs/PLAIN.md` (plain-language layer), `README.md` (CLI flags).
**Detailed references:**
- `docs/LOGIC.md`: the rule language and every logic feature: card kinds, expressions,
effects, variables, conditional pipes, routers, dynamic options and the file keys.
- `docs/PLAIN.md`: the Plain Build usability layer: plain-language display, fill-in
builders, Check cards, card inputs, collections and the "why" trace.
- `README.md`: user-facing usage notes and command-line/screenshot flags.
## 1. What it is
A desktop (soon Android) app for building **random roll tables** as cards on a board, joined by
threads (code: pipes). A roll flows card to card; a logic layer adds choices, values, repeats,
branches and sheets.
**Open items for the next session (as of 2026-11-09)**
- **Repo privacy (waiting on the user).** The Forgejo instance is internet-facing. The user
wants every one of their repos private, with `digit` and Niles/sock as collaborators.
- Today only `RobinFiredrake/TableTower` is public.
- Niles/sock's username wasn't found: logged-out user search for "niles" or "sock" returns nothing.
- **Needed from the user:** that exact username, plus an API token (repository read/write
and user read, passed as `FORGEJO_TOKEN`), or they do it in the web UI themselves.
- Don't go looking for stored credentials.
- **Card Mode needs a UI redesign (user request, 2026-11-09).** Card mode works, but its
controls need rethinking when we get to it:
- It's switched on deep in Table settings… (an Off/On switch plus "When the deck runs out").
- The deck state is a small "4 / 6 left · ↻ Reshuffle" line under the card's name.
Start with a mockup, as for the UI pass, before changing code. The sample's Party Roles is
the card-mode example. Undecided: where the switch lives, how a dealt result looks on the card,
and how "deck empty" shows.
- **Hands-on playtest, then fix what feels wrong.** On `main`:
- The UI pass had a first look from the user ("looks fine for now"), but not every part was
tried: striped rows, View ▾ (Plain/Text moved here), the zoom control, Help ▾ / F1, the card
⋯ menu and the row × that shows on hover. In the sample, pray at Make Camp's shrine and search
the ruins until the vault turns up. An existing Fantasy Loot collection only gets the new
cards after Board ▾ → Reset sample.
- Not yet tried by hand:
- Roll modifiers: build a 1d20 + Luck table from −3 to 24 in the inspector, check that the
chances move as Luck changes, roll it, and read Why this?.
- The resizable tray and inspector: drag both edges, double-click to reset, restart the app to
check the sizes are kept, and fill Earlier with long rolls to check it scrolls.
- The terminology pass (the file splits had a first look: "looking fine so far").
- **Suggested test audit: script errors can still pass.** A suite whose test function crashes
(SCRIPT ERROR) skips the rest of that function but can still print `PASS: 0 failure(s)`.
test_groups and test_navigation did this during the UI pass. Fix: treat any SCRIPT ERROR in
a suite's output as a failure, for example in a small `tools/run_tests.sh` that runs the suites
in parallel (about 15 s) and checks both.
- **Suggested next: a size audit of `core/describe.gd`** (731 lines, now the largest file). Split
it by area (labels, effects/conditions, cards, why) with one-line delegators, as for main.gd.
The other files over ~530 lines are listed in §3 under "Keep files small".
- **Stale worktree.** `.claude/worktrees/agent-aa27e470dd86ce971` (branch `split-table-card`)
stayed locked by a finished agent. Its work is merged, so run
`git worktree remove -f -f` on it, then delete the branch.
**Product principles (from the user)**
- **General-purpose.** The Traveller board is only a capability test. No game-specific features.
- **Intuitive for non-technical people.** Flag anything programmer-y. Play mode stays simple.
- **Plain words by default**; rule text stays stored and reachable ("Edit as text").
- **Themed names are welcome** as long as they stay easy to understand.
---
## 2. Names (decided 2026-11-10; UI text only; code and JSON keys keep old names)
| UI word | Was (UI) | Code / JSON |
|---|---|---|
| Table Tarot (app) | TableTower | project, classes, `user://` folder unchanged |
| Spread (a saved set of cards) | Board / Collection | `TowerBoard`, `LibraryStore`, `collections/` |
| Thread | Pipe | `pipes`, `PipeLayer` |
| Deck mode | Card mode | `card_mode` |
| Book / Page (reusable results) | — | new |
| Branch (if… / otherwise) | Router | `router` |
| Repeat | Loop | `loop` |
The Collection *card kind* needs a new UI name (not "List", not "Collection"); undecided.
Card, Result, Change, Reset, Dice wording rules: `docs/HISTORY.md` §6 "Terminology".
## 1. What TableTower is
## 3. Plan (agreed 2026-11-10, in order)
Work is on branch `tarot` (not merged yet). Done items say so; details in `git log`.
1. **Theme system: done.** `Style` colours are static-var tokens named by role; `ThemeStore`
applies sets (built-ins in `BuiltinThemes`: Tarot default, Felt), saves user sets in
`user://themes/`; View ▾ → Theme… (`ThemeDialog`, `FillEditor` for gradients). Applying
reloads the scene (`ThemeStore.carry_board` keeps the open spread). Per-card
(`RollTable.color`) and per-thread (`TableEntry.pipe_color`) colours via `ColorChoice` and
right-click Colour ▸. **Not done:** font choice (only Atkinson + Rokkitt are bundled; add
OFL fonts first), card/thread art per theme beyond the frame on/off.
2. **Rename and reskin: done.** UI text only (code names, JSON keys and the project's internal
name, so `user://`, unchanged). Logo `assets/art/fortune_teller_logo.svg` (the art minus its
background square), app icon = mascot. `CardFrame` draws the beaded border (shader recolours
to TRIM or the card colour). `Sparkles` (CPU particles) on the thread pulse and on landing
results. Thread string art: waiting on the user's drawings.
3. **Board interaction: done** except two-finger touch pan (do with mobile). No walls; Build
drag on empty = selection box (Ctrl/Shift adds); middle-drag / Space+drag pans (Play: plain
drag pans too); `MainSelection` box-selects groups and drags the whole selection; `CardGrip`
resizes cards (`RollTable.width`, `list_height`).
4. **One menu system: done.** `Actions` builds card/thread/group/background menus for
right-click, the ⋯ buttons and the top bar's ☰. Below 45% zoom `CardShield` covers cards
(name tooltip, drag, right-click, Play click rolls). Long-press on touch: with mobile.
5. **Small UI items: done.** Bold chip sources, Threads in/out in the inspector
(`InspectorThreads`), backwards ranges warn and block rolling, template Replace and Edit…,
Other formats submenu, plain Test spread hints.
6. **Deck mode: done.** Faded drawn results, inspector Deck mode section, Wait for Shuffle with
an Empty result (`deck_empty_text`), Shuffle all decks.
7. **Nested groups, List view, phone layout: done.** `TableGroup.parent` nests groups
(`TowerBoard.tables_in/groups_in/hidden_by`); `ListView` + `ListTree` + `ListOrder` (folders =
groups, drag to reorder/move, own search, thread counts with tooltips); `MobileLayout`
(`--mobile` to try) and `TouchInput` (long press = right-click, two-finger pan/pinch).
Android export templates installed (checksum verified). **Not done:** the Android SDK
(build-tools, platform-tools) isn't installed, so no APK yet: ask the user before downloading;
no Android preset in `export_presets.cfg` (the user has uncommitted edits there).
8. **Book and Pages: done.** `BookPage` in the spread file (`"book"`), `TableEntry.page` links a
result (edit the page → every copy changes; editing the result's own text unlinks). `BookPanel`
+ `PageEditor`; drop a page on a result or a card (handled on drag end, since text fields eat
drops). Undo covers the Book. **Not done:** images on pages (step 11).
9. **Roll features: done.** `RollCombine` (thread "then": keep all / add / highest / lowest /
let me choose; Roller.OP_COMBINE), `BatchRoll` (Roll several times…), pause (`pipe_pause`,
Roller.OP_PAUSE, `RollPauses` chips with set-aside and Continue), `RollCosts` (option costs,
greyed out when unaffordable), roll floor/ceiling (`roll_floor`, `roll_ceiling`: "adjust later
rolls"). Open question for the user: should a "reroll" result that comes up during its own
reroll be ignored and rolled again (common table rule)? Not implemented.
10. **Sheets: done.** Sheet inspector "+ Add a line for" a value; tray Copy ▾ → Save as a file
(Text / Markdown / HTML, `SheetExport`).
11. **Pictures: done.** `TableEntry.image`, `BookPage.image`, stored as WebP base64 in the spread
(`BoardImages`, ≤512 px, only used ones saved); thumbnail on rows, picture in the details pop-up.
Not inline in BBCode (Godot's labels can't load outside images). JSON import/export now passes
every new key (it used to drop unknown keys; round-trip test in test_book).
12. **Help: done.** New topics, shortcut cheat sheet, `[demo]key[/demo]` links → `DemoSpreads` +
`DemoMode` (unsaved, unlisted; Keep a copy / Back).
A desktop app for building **random roll tables** and rolling on them, for tabletop GMs,
players and anyone using random prompts. Tables are **cards on a felt board**, joined by
**copper pipes**. A roll flows down the pipes from card to card, and the path lights up.
**Next, for the user to decide:** merge `tarot` into `main`; hands-on playtest of everything above
(nothing was tried by hand, only tests and screenshots); Android SDK download for an APK; extra
OFL fonts for the theme font choice; a new UI name for the Collection card kind; the reroll rule
question in step 9; thread string art when drawn.
On top of plain tables, a **logic layer** lets a board ask the player questions, remember
values, repeat steps, branch, and print a sheet. A whole procedure, such as generating a
character, can run as one chain.
**Audits done (2026-11-10).** The seven files over 600 lines were split into helpers with
one-line delegators (inspector → inspector_result/thread/sync; describe → describe_cards/why;
json_io → json_canon/links; choice_dialog → choice_preview/chrome/option_row; table_card →
table_card_skin/input/geometry/list/kind_rows; main → main_layout; edit_history → edit_labels).
Still over ~450: inspector_card (591), roll_table (569), expr (544), main_cli, board_tester (505),
builder, roller, tower_board, group_card. Tests extend `TestBase` (`tests/testbase.gd`: named so the
runner's `test_*.gd` glob skips it): `start_main()`, `require_sample()`, `_check`, `_eq`, `_frames`,
`finish()`.
### Product principles (from the user)
- **General-purpose.** Not built for any one game. The Traveller board (§8) is only a
capability test, used to find missing general features. Don't build game-specific features.
- **Play mode stays simple** for use at the game table. Advanced controls belong in Build mode.
- **Readable by normal people.** Rules show in plain words by default. The rule text is
still stored, and visible through the Plain/Text switch and "Edit as text".
- **The visual design is settled:** felt green, copper pipes, brass for lit and selected
things, Rokkitt (display) and Atkinson Hyperlegible (body). See `ui/style.gd`. Match it
and don't restyle.
**Still open from before:** repo privacy on Forgejo (waiting on the user: Niles/sock's username +
token); hands-on playtest; size audit of `core/describe.gd` (731 lines) and the other files over
~530 lines (list in ARCHITECTURE.md §3); known gaps in ARCHITECTURE.md §7.
## 2. Feature summary (all on `main`)
**Board and rolling**
- **Cards and pipes.** Cards show their numbered results and a die button. Drag from a
result's ● onto another card to lay a pipe.
- **Rolling.** Results flicker and land, and a bead travels each pipe. **Shift-click** fast-rolls with no animation.
- **Play / Build modes.** Collapse a card, or every table from **View ▾**. Pan, zoom (8%–150%) with the
**− 90% ▾ +** control (the percentage opens Fit board, Zoom to 100% and the minimap), minimap (M).
- **Top bar.** Search (icon, Ctrl+F), **View ▾** (rules as Plain words or Rule text, Collapse/Expand
all tables, Striped rows, Minimap), **Help ▾** and the zoom control. Build adds undo/redo, + Card ▾
and Board ▾ (Test board, Reset sample, Pack collapsed groups, import, export).
- **Striped rows.** Every second result row on a card is tinted (`Style.STRIPE`); lit, flicker and
selection paint over it. On by default; the `striped_rows` local setting.
- **Help.** Help ▾ lists the topics; F1 opens the window. Text in `help/topics.txt` (a small markup,
see `HelpDialog`), included in exports via the preset's include filter.
- **Table types.** Weighted plain tables, ranged dice tables (`1d100`, `2d6`, any
expression such as `2d6 + dm(@str)`), and card mode (a deck with no repeats, with Reshuffle).
- **Roll modifiers** (`dice_mod`, LOGIC.md §3c). A ranged table adds a modifier such as `@luck` to
its dice. Ranges may run past the dice (−3 to 24 on a d20); totals past the ends use the end
result. The card shows chances for the modifier's value now, and Why says "+3 for Luck".
- **Pipe options.** A count (a number or an expression), "save as", **Only if** conditions,
and **Otherwise**. A result's conditions and counts are evaluated once, as a snapshot,
before any pipe runs.
- **Text in results.** `[[Table]]` inline references, `{@var}` / `{hero}` values, and BBCode formatting.
- **The result tray** shows the chain as chips with effect lines, a sheet headline,
Earlier rolls, a Variables tab, Copy (text, BBCode, with details) and **Why this?** on each step.
- **Resizable panels.** Drag the tray's top edge or the inspector's left edge (double-click for the
default). The sizes are kept in local settings (`tray_height`, `inspector_width`). Every part of
the tray scrolls inside it.
**Logic cards** (`docs/LOGIC.md`)
- **Choice:** "Which option" (pick, with Random), "How many" (a number) or "Open
ended" (text). The pop-up can be minimized, and its options preview where they lead.
- **Loop:** repeat N times, while a condition holds, or until it does. Then "Afterwards".
- **Router:** if / else if / otherwise cases; the first true case runs.
- **Check:** roll + modifier against a target, with Success and Failure outlets. Sets `nat`, `total` and `effect`.
- **Variable** cards (with a starting value) and **Collection** cards (e.g. Skills, whose members are `@skill_*`).
- **Sheet:** a live template, e.g. a character sheet.
- **Changes** (stored as `effects`) on any result: `@x = …`, `+=`, `-=`, `reset @prefix_*`, list add/remove, and `@[expr]` indirect names.
- **Dynamic pick options** from a collection or list (`options_from`, `options_where`), plus `show_if` on any option.
- **Card inputs:** a card declares inputs, and pipes pass values (`with`), scoped to that pipe's part of the roll.
- **A 10,000-action limit** per roll. The roller uses an explicit stack, so long loops don't overflow.
**Building** (Build mode)
- **The inspector,** docked right. It edits the selected card, result or pipe:
- effects as rows ("[Subtract] [1] from [Luck]")
- a roll or check modifier as "[Add ▾] [Luck ▾]" (ModifierEditor)
- conditions as rows ("[Luck] [is at least] [2]", with and/or)
- pipe inputs, Otherwise, count and saves-as
- kind-specific card fields
- a value picker with "+ New value…"
- "Edit as text" everywhere
- **Plain / Text** in View ▾ → Rules.
- **Card ⋯ menu** (Build): Table settings…, Save as template…, Collapse, Delete table. A row's ×
shows only on hover, keyboard focus or when the row is selected.
- **Undo/redo** (Ctrl+Z, Ctrl+Shift+Z / Ctrl+Y, or ↶ ↷) for every board edit. Typing and dragging merge into one step.
- Collapse/expand isn't undoable.
- Rolls, variables and decks aren't undoable.
- Collection members aren't undoable either.
- **Group cards.** Frames that collapse whole blocks. Ctrl/Shift-click or Ctrl-drag to
select, Ctrl+G to group, then drag cards in or out, rename, ungroup or delete. Board ▾ → Pack collapsed groups.
- **Templates.** Save a card, group or selection, with `{$param}` fill-ins. Insert from
"+ Card ▾ → From template…". The library is in `user://templates/`, and generic built-ins are in `templates/`:
skill check (a Check card, 2d6 + modifier vs target), ask-and-repeat, pick menu, counter
and simple sheet.
- **Search** (button or Ctrl+F) jumps to cards, opens groups and flashes the card.
- **Test board** (Board ▾): hundreds of random rolls plus static checks. It reports
errors, dead ends, unreached cards and lint, and clicking an item jumps to the card.
- **Collections** (switcher in the top bar). Import and export via Board ▾: TableTower
JSON, JSON Canvas, GraphML (both ways), plus Mermaid and DOT (export only).
## 3. Architecture
```
core/ engine, no UI, testable headless
tower_board.gd a collection (tables, groups), JSON, format v2 + migration
roll_table.gd a card: kind, dice, entries, logic fields, factories (RollTable.create)
roll_range.gd a ranged card's numbers: span, natural range, labels, chances, the roll
modifier (shared with check cards), range problems
table_entry.gd a result: text, weight, range, effects, pipes (+count/save/when/otherwise/with), show_if, when
roller.gd coroutine roller with an explicit stack (_chain loop, roll/pipe steps,
apply_starting_values) plus delegators to its parts:
roll_pipes.gd pipe_plan snapshot, card inputs (`with`)
roll_cards.gd weighted picks, router, check, loops
roll_choice.gd choice requests, dynamic options, show_if, asking
roll_tree.gd flatten, step lookups, lit keys, pipe/entry keys
roll_lint.gd lint_*, endless_cycles
roll_context.gd per-roll state: chain and board variables, prompt hook, actions, depth
expr.gd / effects.gd expression evaluation (Godot Expression + rewrites), effect statements
text_expander.gd [[refs]], {vars}, {@prefix_*}, {= expr}; formatter.gd: BBCode safety and stripping
dice.gd / deck_state.gd dice parsing and distributions, card-mode decks
describe.gd rules → plain words, labels, why sentences; kind_label / choice_label
(the only place card-kind and choice-type names are defined)
builder.gd effect/condition models ↔ text, known_values
board_tester.gd simulation and static checks (used by the Test board UI and the CLI)
library_store.gd / state_store.gd collections on disk / local state (decks, variables, history, settings)
table_group.gd, template_kit.gd, template_library.gd, sample_board.gd
io/ json_io (canonical + import), canvas_io, graphml_io, mermaid_exporter, dot_exporter
ui/ main.gd: the app shell (shared fields, _ready, cards, collapse, input) with one-line
delegators to RefCounted helpers that hold `m: Main`:
main_cli (every CLI/screenshot flag), main_rolling, main_editing, main_groups,
main_history (undo), main_navigation (search/focus/minimap/arrange),
main_top_bar (bar, toast, endless-loop chip), main_state (decks, variables),
main_collections, main_templates, main_inspector
top bar parts: view_menu (View ▾), zoom_control, help_menu + help_dialog
table_card.gd + table_card_{header,rows,editing,value,text}.gd
result_tray.gd + tray_chips, tray_text, earlier_rolls
table_settings_dialog.gd + table_settings_rules (validation/apply), settings_kind_fields
inspector_card (card fields) + inspector_roll (roll dice and modifier);
modifier_editor (the plain modifier builder); panel_splitter (drag handles)
and: board_view, card_layer, pipe_layer, port_layer, group_layer, group_card, minimap,
why_popover, choice_dialog, table_preview, details_popup, inspector*, value_picker,
rules_view, search_panel, board_search, board_layout, edit_history, test_board_dialog,
template_*, io_menu, collection_switcher, variables_panel, modal_card, rich_text, style
help/ topics.txt: the Help window's text (# Title per topic)
tools/ simulate_board.gd (headless simulator CLI), test_window.sh (background test windows)
tests/ test_*.gd: 27 headless suites
templates/ built-in templates · examples/logic_demo.json (original demo board) · assets/fonts (OFL)
```
**Key implementation facts**
- **Lazy cards.** Cards hidden inside collapsed groups aren't built, so
`main.card_for(id)` can return null. Pipe, port and card layers redraw only when something changes.
- **Undo** (`ui/edit_history.gd`) snapshots each table and group separately, sharing unchanged ones.
- **Prompts.** The roller awaits `ctx.prompt` for choices, and the UI shows progress before each pop-up.
- **Rules display.** The UI reads plain or text mode through `RulesView` and `main.rules_plain()`,
and `main.rules_view_changed` signals a switch.
- **Shared builders, use them rather than copying:** `Style.menu_button`, `Style.font_colors`,
`Style.field_colors`, `TableCard.vbox/hbox`, `InspectorKit.*` (fields, `focused_tag`/`refocus`,
`as_text_link`), `Main.file_dialog`/`export_dialog`, `JsonIO.entry_line`/`finish_import`.
- **Keep files small.** Aim for under ~400 lines; split by area into helper objects as above.
Next candidates, all 530–730 lines:
- core: describe (731, the largest now), roll_table, expr
- ui: choice_dialog, inspector_card, inspector, main, edit_history
- io: json_io
## 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/`.
- **Local state** (never exported): `user://state/state.json` holds decks, board
variables, history (cap 50) and settings (`last_collection`, minimap, inspector collapsed,
`rules_view`, `striped_rows`). Templates live in `user://templates/`.
- **Installed collections today:** `my-tables` (migrated from the old `board.json`, backed
up as `board.json.bak`) and `traveller-chargen`. Backups of earlier Traveller boards are
`traveller-chargen.before-*.json.bak` in the app data folder.
## 5. Working on it
**Basics**
- **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. A desktop launcher "TableTower (Godot)" opens the editor on the project.
- **Tests:** `for t in tests/test_*.gd; do godot --headless --path . -s "res://$t" -- --sample; done`.
All must print `PASS: 0 failure(s)`. After adding `class_name` files, run `godot --headless --path . --import` first.
- **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample`, which must print no SCRIPT ERROR.
- **Simulator:** `godot --headless --path . -s res://tools/simulate_board.gd -- --board=<json> --start=<id> --runs=N [--check] [--prefer=regex] [--quiet]`.
- **Windowed runs and screenshots: always go through `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`.**
- It runs the game as window class "TableTower Test", and a KWin rule (KDE Plasma 6,
Wayland, in `~/.config/kwinrulesrc`) keeps that class unfocused and behind other windows.
- Never open a test window with plain `godot --path .`.
- Don't minimize test windows; Godot stops rendering when minimized.
- **Screenshot and state flags**, read in `ui/main_cli.gd` and in some UI files; README lists the main ones:
- Setup and roll: `--board`, `--roll`, `--fast`, `--answers`, `--build`, `--rules=text`, `--why`.
- Inspector and focus: `--inspect=tid[:eid][>to]`, `--search`, `--focus`, `--minimap`.
- Tools and layout: `--test-board`, `--pack`, `--perf`, `--window=WxH`.
- **Coderstanding** (the user's structure scanner, https://forgejo.smhub.duckdns.org/digit/coderstanding)
saves tokens on audits and big reads.
- **Not installed permanently.** Clone it into the scratchpad, make a venv, `pip install <clone>`.
- **Keep its config and data out of the repo.** Set `XDG_CONFIG_HOME=<scratch>/xdgconf`, then
`coderstanding add tabletower <repo> --data <scratch>/cs_data` and `coderstanding rescan tabletower`.
- **Commands:** `outline <Class>` (functions with line ranges), `hotspots`, `dupes`
(string literals only), `warnings`, `find`, `uses`, `brief`.
- **Copied code:** `dupes` doesn't find copied code blocks; use a sliding-window line hash for that.
- **Launching for the user to look at** (not a test): plain `godot --path .` in the
background is fine, so the window comes to the front.
**Git and agent workflow**
- **Git:** remote `origin` = `git@forgejo.smhub.duckdns.org:RobinFiredrake/TableTower.git`.
Work on a feature branch and merge to `main` when the user asks (fast-forward).
End commit messages with the Co-Authored-By line.
- **Agents.** Large features have been split across parallel agents in git worktrees, each owning specific files:
- Worktrees start from an old commit, so each brief says `git reset --hard <branch>` first.
- Merge one by one, run every suite and the simulator, take screenshots, then fix the seams.
- Brief each agent to keep the public API of the file it owns (one-line delegators), so
parallel splits don't conflict. Only tests may change in several branches at once.
- Merged feature branches still exist locally and on the server (`pipe-board`, `fast-roll`,
`logic-cards`, `groups-templates`, `boards-v2`, `undo-options`, `plain-build`); they can be deleted.
## 6. Decisions on record
- The three-pane UI from the first design was replaced by the pipe board (a user request: simpler at the table).
- Variables are kept between rolls until changed or reset, so a character sheet survives other rolls.
- A variable card's starting value is applied, if the variable isn't set, when a top-level roll starts.
- Expression dice clamp beyond the end ranges. Plain dice tables report gaps instead.
- Pipe conditions and counts are a snapshot taken when the result is chosen. Two true Only-if pipes both run; routers give exactly one.
- `a if c else b` is refused (Godot's Expression returns the wrong branch); use `if(c, a, b)`.
- Collapse/expand isn't undoable. Collection members aren't undoable.
- Rules are stored as text, and the plain layer sits on top of it, so old boards open unchanged.
- Traveller-derived content stays out of the repo (§8).
- **Roll modifiers (2026-11-09).** A separate `dice_mod` field, not just an expression in `dice`,
so the card knows its dice: it can show chances, the natural range and plain words. Totals past
the ends always use the end result; there's no separate "nothing happens" setting, because an end
result that says so does the same job. The Check card's modifier picker became the shared
ModifierEditor, which also adds a value as it is (`@luck`) and doesn't only use `dm()`.
- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's
`SplitContainer`. The tray used to size itself to its content and the inspector collapses to a
strip, and a handle that sets the panel's size fits both without changing the layout.
- **UI pass (2026-11-09).** View preferences (rules view, collapse all, stripes, minimap) live in
View ▾ rather than on the bar; Plain/Text is one click further away, which the user accepted.
The card ⋯ menu shares `Style.overflow_button` with the group card's ⋯. Stripes use the
"parchment" tint picked from a mockup (felt tint and hairline were the other options). The
sample's Search the Ruins uses `[[refs]]` rather than pipes, because Loot and the trinkets are
far across the board. Card mode already existed (Party Roles) and needed no new work.
- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names.
- **Card:** anything on the felt. "Roll table" means only the `roll` kind.
- **Result**, never "entry" or "row" (code: `TableEntry`, `entries`).
- **Change** in plain text, "effect" only in Text mode (code and JSON: `effects`).
- **Pipe.** Pipes are *deleted*, like cards and results. "Remove" is for taking an item out
of something.
- **Reset** = back to the starting value, or erased if the value has no card. "Clear" only
when a value really is erased.
- **Dice** always read `2d6` / `d6`. `2D` is accepted as input only.
- **Choice types:** "Which option / How many / Open ended", from `Describe.choice_label`.
- **JSON keys aren't renamed.** A rename needs a format bump plus migration.
## 7. Known gaps and bugs
- **Only one pipe per target per result.** Pipes are keyed by target id, so the mockup's
two pipes into Loot (Tier 3 "only if", Tier 1 "otherwise") can't be built. Lifting this
needs pipe ids in the model, the file format, the UI keys (`tid:eid>to`) and undo.
- Long pipe labels are cut with "…" in narrow gaps, and labels draw behind cards.
- The Why pop-over opens above the tray and can cover the bottom of the board.
- Not tried by hand yet: all of this was verified with headless tests and screenshots
only. A hands-on playtest with a checklist is overdue.
- The Linux export preset exists, but the 4.7.2 export templates aren't installed. They're a
large download and the user hasn't approved it. There are no Windows or Mac presets.
- Loading a big board with every group expanded takes about 5 s (building `TableCard` nodes).
- Group frames are rectangles, so a non-member card lying inside one looks like a member.
Pipes into a collapsed group can't be clicked.
- Groups aren't kept in the Canvas and GraphML exports. Logic keys survive only in TableTower JSON.
- `{= }` dice in live sheet and variable displays re-roll when the display refreshes.
- The simulator and Test board list results that only a modifier reaches as "never chosen" when
the modifier stays small in the runs (the demo's luck-only vault, for example).
- **Not yet looked into: Coderstanding warnings.**
- Signals emitted but never connected: `ModalCard.closed`, `SearchPanel.closed`.
- A possible wrong handler in `ModalCard.segmented` (`pressed` → `on_change`; probably a
false positive from a bound callable).
- Large class cycles in ui/ (expected from the `main` back-references).
## 8. The Traveller test board (private)
- **Location.** Private content derived from the user's Mongoose Traveller 2e rulebook lives in
`~/Repos/Godot/TableTower-private/` (outside git; see its README). That covers the rules digest
(`traveller/chargen.json`), the board generator (`traveller/board/build_board.py`,
`python3 -I`) and the generated board.
- **The board itself.** It's installed as collection `traveller-chargen`: 662 cards, 23 groups,
routers, dynamic options and `show_if`. It runs clean in the simulator (start card `new_traveller`).
- **Still worked around:**
- global "argument" variables (`@x_offer`, `@x_lvl`) feeding shared skill cards
- natural-roll pre-rolls (`rs`, `ra`, `rc`)
- `.replace()` chains for names
- counters instead of `len()`
- about 70 reset statements
- a guard before empty dynamic picks
- **Not automated:** group steps (Connections, skill packages, shared ships), contact
naming, gear choice, medical bills, anagathics, the Psion career, Noble titles, and the
total skill cap.
- **Open question for the user:** "Raise a skill you already have" counts level-0 skills as held (the rules reading); the user's earlier example was level 1+.
## 9. Improvement ideas, roughly by value
1. **Hands-on playtest** with a checklist, then fix what feels wrong. Highest value now that Build mode has changed a lot.
2. **Several pipes to the same card** (pipe ids). It unlocks Tier 3 "only if" plus Tier 1 "otherwise" into one card.
3. **Port the Traveller board to the new features:**
- card inputs instead of the `@x_*` argument variables
- Check cards
- `nat`
- collections
This also tests them end to end.
4. **Small engine additions:**
- `len(list)`
- `sum` / `max` over a prefix (enables "best of these skills" and skill caps)
- a fallback path when a dynamic pick has no options, instead of stopping the roll
- telling unset from 0
- lists that keep duplicates
- effects that run after pipes
- nicer display names ("Jack-of-all-Trades")
5. **Onboarding:** a guided tutorial board, a cheat-sheet panel, and templates surfaced as "starter blocks".
6. **Sheet output:** save a finished sheet as text or Markdown; keep finished characters as a list.
7. **Comfort:** a UI scale setting, colour-blind-friendly lit pipes, optional seeded rolls.
8. **Groups:** nested groups, only true members inside frames, clickable pipes into collapsed
groups, and groups in the Canvas and GraphML exports.
9. **Linked templates:** a plan exists. Copies record template uid, revision and role, and
offer "Update available" with a per-field merge.
10. **Faster expanded-board loads.**
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
(`[[Collection/Table]]`), touch support.
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 (also `split-table-card`, see Open items). Keep LOGIC.md and PLAIN.md in step with features.
## 10. History
**2026-11-08 (one long session): board and core features**
1. Initial Godot project and the original design doc. An HTML mockup became the pipe board, built in Godot.
2. First feature wave (parallel agents): weights, dice expressions, card mode, text references and BBCode,
collections and local state, import/export, a Linux preset, the play-side UI, and the app shell (settings,
collection switcher, import/export menu).
3. Fast roll (Shift-click).
**Logic cards**
4. Logic cards: choice, loop, variable and sheet cards, effects, expressions, the 10,000-action limit and a coroutine roller.
5. The Traveller board was generated and simulated from the rulebook digest.
**Building tools**
6. Group cards and templates. Choice pop-up minimize and option previews.
7. Conditional pipes and routers, search, minimap, packing, lazy cards (the board opens in 0.38 s, was 5 s), and Test board.
8. Undo/redo, and dynamic options with `show_if` and `@[expr]`. The Traveller board was regenerated with them (792 → 662 cards).
**Plain Build**
9. The usability mockup, then Plain Build: plain words, the inspector with builders, Check
cards, card inputs, collections, Why this?, the Plain/Text switch, and starting values applied.
**2026-11-09: token diet**
10. Split the oversized files (main.gd 3679 → 617 lines plus 11 helpers; table_card, roller,
table_settings_dialog and result_tray likewise) with no behaviour change, then a duplicate-code
pass guided by the Coderstanding scanner (shared Style/InspectorKit/JsonIO/Main helpers, dead
flags and fields removed). A terminology 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".
**2026-11-09: roll modifiers and resizable panels** (merged to `main` as 3391388)
11. Roll modifiers: `dice_mod` on ranged roll tables, results past the dice, the end results
taking totals past the ends, live chances, plain wording and Why lines. The range and chance
code moved from roll_table.gd into `RollRange`. The shared ModifierEditor serves roll and check
cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches.
12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no
longer grows with long Earlier rolls, sheets or chains.
**2026-11-09: UI pass** (merged to `main` as 8f16d33)
13. From an HTML mockup: striped result rows; View ▾ (Plain/Text, Collapse all, Striped rows,
Minimap) and the zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map;
Arrange ▾ folded into Board ▾; Search is an icon. Help ▾ and F1 open a Help window with
17 topics. Build cards get a ⋯ menu instead of the gear and footer Delete, and row × buttons
show on hover. The sample gained Luck, Make Camp (a pick card) and Search the Ruins (1d6 + Luck,
with a cave-in and a vault only a modifier reaches). New suite: test_top_bar.
## 4. Working on it
- **Godot:** `~/apps/Godot_v4.7.2-stable_linux.x86_64`. After adding `class_name` files run
`godot --headless --path . --import` first.
- **Tests:** `tools/run_tests.sh [filter]`: parallel, ~20 s, one line per suite, fails on SCRIPT
ERROR too. Prints details only for failures. Use it instead of the old for-loop.
- **Smoke test:** `godot --headless --path . --quit-after 120 -- --sample` (no SCRIPT ERROR).
- **Simulator:** `godot --headless --path . -s res://tools/simulate_board.gd -- --board=<json> --start=<id> --runs=N [--check] [--quiet]`.
- **Windowed runs/screenshots: always `tools/test_window.sh -- --sample --screenshot=/path.png [flags]`**
(KWin rule keeps it in the background; never plain `godot --path .`; don't minimize). Flags are in
`ui/main_cli.gd`. Launching for the user to look at: plain `godot --path .` in the background.
- **Keep files under ~400 lines**; split by area into RefCounted helpers holding `m: Main` with
one-line delegators. Reuse shared builders (list in ARCHITECTURE.md §3).
- **Coderstanding** (structure scanner) for audits:
clone https://forgejo.smhub.duckdns.org/digit/coderstanding into the scratchpad, venv,
`pip install`, `XDG_CONFIG_HOME=<scratch>/xdgconf`, `coderstanding add tabletower <repo> --data
<scratch>/cs_data`. Commands: `outline`, `hotspots`, `dupes`, `warnings`, `find`, `uses`, `brief`.
- **Git:** origin `git@forgejo.smhub.duckdns.org:RobinFiredrake/TableTower.git`. Feature branch,
fast-forward merge to `main` when the user asks. Co-Authored-By line on commits.
- **Agents:** only for large, separate features (each rereads context). Worktree briefs start with
`git reset --hard <branch>`, own specific files, keep public APIs as delegators. Remove worktrees
after merging.
- **Keep this page short.** Update §3 as items land; put history in HISTORY.md, not here.

154
docs/HISTORY.md Normal file
View file

@ -0,0 +1,154 @@
# TableTower — Decisions, Ideas and History
Read on demand. Status and plan: `docs/DESIGN.md`.
## 6. Decisions on record
- The three-pane UI from the first design was replaced by the pipe board (a user request: simpler at the table).
- Variables are kept between rolls until changed or reset, so a character sheet survives other rolls.
- A variable card's starting value is applied, if the variable isn't set, when a top-level roll starts.
- Expression dice clamp beyond the end ranges. Plain dice tables report gaps instead.
- Pipe conditions and counts are a snapshot taken when the result is chosen. Two true Only-if pipes both run; routers give exactly one.
- `a if c else b` is refused (Godot's Expression returns the wrong branch); use `if(c, a, b)`.
- Collapse/expand isn't undoable. Collection members aren't undoable.
- Rules are stored as text, and the plain layer sits on top of it, so old boards open unchanged.
- Traveller-derived content stays out of the repo (§8).
- **Roll modifiers (2026-11-09).** A separate `dice_mod` field, not just an expression in `dice`,
so the card knows its dice: it can show chances, the natural range and plain words. Totals past
the ends always use the end result; there's no separate "nothing happens" setting, because an end
result that says so does the same job. The Check card's modifier picker became the shared
ModifierEditor, which also adds a value as it is (`@luck`) and doesn't only use `dm()`.
- **Panel resizing** uses a small drag handle (`PanelSplitter`) rather than Godot's
`SplitContainer`. The tray used to size itself to its content and the inspector collapses to a
strip, and a handle that sets the panel's size fits both without changing the layout.
- **UI pass (2026-11-09).** View preferences (rules view, collapse all, stripes, minimap) live in
View ▾ rather than on the bar; Plain/Text is one click further away, which the user accepted.
The card ⋯ menu shares `Style.overflow_button` with the group card's ⋯. Stripes use the
"parchment" tint picked from a mockup (felt tint and hairline were the other options). The
sample's Search the Ruins uses `[[refs]]` rather than pipes, because Loot and the trinkets are
far across the board. Card mode already existed (Party Roles) and needed no new work.
- **Terminology (2026-11-09).** UI text uses these words; code and JSON keys keep their old names.
- **Card:** anything on the felt. "Roll table" means only the `roll` kind.
- **Result**, never "entry" or "row" (code: `TableEntry`, `entries`).
- **Change** in plain text, "effect" only in Text mode (code and JSON: `effects`).
- **Pipe.** Pipes are *deleted*, like cards and results. "Remove" is for taking an item out
of something.
- **Reset** = back to the starting value, or erased if the value has no card. "Clear" only
when a value really is erased.
- **Dice** always read `2d6` / `d6`. `2D` is accepted as input only.
- **Choice types:** "Which option / How many / Open ended", from `Describe.choice_label`.
- **JSON keys aren't renamed.** A rename needs a format bump plus migration.
- **Fan-out on ranged tables (2026-11-09).** Dropping a pipe from a range used to replace that
range's pipe, a rule left over from the first build. It was a user-reported bug (a "Rocky" range
could not feed Resources, Atmosphere and Water), so ranges now add pipes like weighted results.
`MainEditing.finish_link` uses `TableEntry.add_pipe`. The drop itself has no automated test.
## 8. The Traveller test board (private)
- **Location.** Private content derived from the user's Mongoose Traveller 2e rulebook lives in
`~/Repos/Godot/TableTower-private/` (outside git; see its README). That covers the rules digest
(`traveller/chargen.json`), the board generator (`traveller/board/build_board.py`,
`python3 -I`) and the generated board.
- **The board itself.** It's installed as collection `traveller-chargen`: 662 cards, 23 groups,
routers, dynamic options and `show_if`. It runs clean in the simulator (start card `new_traveller`).
- **Still worked around:**
- global "argument" variables (`@x_offer`, `@x_lvl`) feeding shared skill cards
- natural-roll pre-rolls (`rs`, `ra`, `rc`)
- `.replace()` chains for names
- counters instead of `len()`
- about 70 reset statements
- a guard before empty dynamic picks
- **Not automated:** group steps (Connections, skill packages, shared ships), contact
naming, gear choice, medical bills, anagathics, the Psion career, Noble titles, and the
total skill cap.
- **Open question for the user:** "Raise a skill you already have" counts level-0 skills as held (the rules reading); the user's earlier example was level 1+.
## 9. Improvement ideas, roughly by value
1. **Hands-on playtest** with a checklist, then fix what feels wrong. Highest value now that Build mode has changed a lot.
2. **Several pipes to the same card** (pipe ids). It unlocks Tier 3 "only if" plus Tier 1 "otherwise" into one card.
3. **Port the Traveller board to the new features:**
- card inputs instead of the `@x_*` argument variables
- Check cards
- `nat`
- collections
This also tests them end to end.
4. **Small engine additions:**
- `len(list)`
- `sum` / `max` over a prefix (enables "best of these skills" and skill caps)
- a fallback path when a dynamic pick has no options, instead of stopping the roll
- telling unset from 0
- lists that keep duplicates
- effects that run after pipes
- nicer display names ("Jack-of-all-Trades")
5. **Onboarding:** a guided tutorial board, a cheat-sheet panel, and templates surfaced as "starter blocks".
6. **Sheet output:** save a finished sheet as text or Markdown; keep finished characters as a list.
7. **Comfort:** a UI scale setting, colour-blind-friendly lit pipes, optional seeded rolls.
8. **Groups:** nested groups, only true members inside frames, clickable pipes into collapsed
groups, and groups in the Canvas and GraphML exports.
9. **Linked templates:** a plan exists. Copies record template uid, revision and role, and
offer "Update available" with a per-field merge.
10. **Faster expanded-board loads.**
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
(`[[Collection/Table]]`), touch support.
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 (also `split-table-card`, see Open items). Keep LOGIC.md and PLAIN.md in step with features.
## 10. History
**2026-11-08 (one long session): board and core features**
1. Initial Godot project and the original design doc. An HTML mockup became the pipe board, built in Godot.
2. First feature wave (parallel agents): weights, dice expressions, card mode, text references and BBCode,
collections and local state, import/export, a Linux preset, the play-side UI, and the app shell (settings,
collection switcher, import/export menu).
3. Fast roll (Shift-click).
**Logic cards**
4. Logic cards: choice, loop, variable and sheet cards, effects, expressions, the 10,000-action limit and a coroutine roller.
5. The Traveller board was generated and simulated from the rulebook digest.
**Building tools**
6. Group cards and templates. Choice pop-up minimize and option previews.
7. Conditional pipes and routers, search, minimap, packing, lazy cards (the board opens in 0.38 s, was 5 s), and Test board.
8. Undo/redo, and dynamic options with `show_if` and `@[expr]`. The Traveller board was regenerated with them (792 → 662 cards).
**Plain Build**
9. The usability mockup, then Plain Build: plain words, the inspector with builders, Check
cards, card inputs, collections, Why this?, the Plain/Text switch, and starting values applied.
**2026-11-09: token diet**
10. Split the oversized files (main.gd 3679 → 617 lines plus 11 helpers; table_card, roller,
table_settings_dialog and result_tray likewise) with no behaviour change, then a duplicate-code
pass guided by the Coderstanding scanner (shared Style/InspectorKit/JsonIO/Main helpers, dead
flags and fields removed). A terminology 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".
**2026-11-09: roll modifiers and resizable panels** (merged to `main` as 3391388)
11. Roll modifiers: `dice_mod` on ranged roll tables, results past the dice, the end results
taking totals past the ends, live chances, plain wording and Why lines. The range and chance
code moved from roll_table.gd into `RollRange`. The shared ModifierEditor serves roll and check
cards. The demo's Room check uses 2d6 + Luck and has a vault only luck reaches.
12. Resizable tray (top edge) and inspector (left edge). The Earlier tab scrolls, and the tray no
longer grows with long Earlier rolls, sheets or chains.
**2026-11-09: UI pass** (merged to `main` as 8f16d33)
13. From an HTML mockup: striped result rows; View ▾ (Plain/Text, Collapse all, Striped rows,
Minimap) and the zoom control replace the Plain|Text switch, Collapse all, −/Fit/+ and Map;
Arrange ▾ folded into Board ▾; Search is an icon. Help ▾ and F1 open a Help window with
17 topics. Build cards get a ⋯ menu instead of the gear and footer Delete, and row × buttons
show on hover. The sample gained Luck, Make Camp (a pick card) and Search the Ruins (1d6 + Luck,
with a cave-in and a vault only a modifier reaches). New suite: test_top_bar.
**2026-11-09: fan-out fix**
14. A range on a ranged table can pipe into several cards; a new pipe no longer replaces the old one.

View file

@ -1,21 +1,21 @@
# Getting started
TableTower holds [b]random tables[/b] for tabletop games. Each table is a card on the felt. Cards are joined by copper [b]pipes[/b], so one roll can lead on to the next: a travel roll finds a stranger, and the stranger gets a name.
Table Tarot holds [b]random tables[/b] for tabletop games. Each table is a card on the felt. Cards are joined by copper [b]threads[/b], so one roll can lead on to the next: a travel roll finds a stranger, and the stranger gets a name.
## Two modes
- [b]Play[/b] is for the game table. Click a die to roll, and read the result in the tray at the bottom.
- [b]Build[/b] is for making and changing tables. Click a card, a result or a pipe to edit it in the inspector on the right.
- [b]Build[/b] is for making and changing tables. Click a card, a result or a thread to edit it in the inspector on the right.
Switch between them with [b]Play | Build[/b] at the top left. Everything you build is saved as you go.
## Try the sample
The Fantasy Loot collection shows most features:
- [b]Wilderness Travel[/b] is a d100 table whose results pipe into other tables.
- [b]Party Roles[/b] deals each role once until the deck is reshuffled ([topic]Card mode[/topic]).
The Fantasy Loot spread shows most features:
- [b]Wilderness Travel[/b] is a d100 table whose results thread into other tables.
- [b]Party Roles[/b] deals each role once until the deck is reshuffled ([topic]Deck mode[/topic]).
- [b]Make Camp[/b] asks you to pick what the party does ([topic]Choice cards[/topic]).
- [b]Search the Ruins[/b] adds your [b]Luck[/b] to the roll, and two of its results can only be reached with good or bad luck ([topic]Roll modifiers[/topic]).
# Rolling
Click the die button on a card to roll it. The results flicker, one lands and lights up in brass, and the roll follows any pipes from that result to other cards.
Click the die button on a card to roll it. The results flicker, one lands and lights up in brass, and the roll follows any threads from that result to other cards.
- [b]Shift-click[/b] the die to skip the animation.
- Hover a result to read its details. A small ⓘ after a card's name means the card has details too.
- On a ranged card, the percentage beside each result is its chance right now.
@ -27,7 +27,7 @@ The tray at the bottom of the window shows the last roll as a row of steps, one
- [b]Why this?[/b] on a step explains it in plain words: what was rolled, any modifier, and why the roll went where it did.
- [b]Roll again[/b] repeats the last roll.
- [b]Copy ▾[/b] copies the result as plain text, as BBCode for forums, or with the details of each step.
- [b]Earlier[/b] lists your recent rolls. [b]Variables[/b] lists the values the board remembers between rolls, such as Luck.
- [b]Earlier[/b] lists your recent rolls. [b]Variables[/b] lists the values the spread remembers between rolls, such as Luck.
Drag the tray's top edge to make it taller or shorter. Double-click the edge to reset it.
@ -38,12 +38,12 @@ Switch to [b]Build[/b] to edit.
- The [b]×1[/b] beside a result is its weight. A weight of 3 makes that result three times as likely as a weight of 1.
- Hover a row to show its [b]×[/b] delete button.
- The card's [b]⋯[/b] menu has Table settings, Save as template, Collapse and Delete table.
- Click a card's title, a result's text or a pipe to edit it in the [b]inspector[/b] on the right. Drag the inspector's left edge to resize it.
- Click a card's title, a result's text or a thread to edit it in the [b]inspector[/b] on the right. Drag the inspector's left edge to resize it.
Every edit can be undone with [b]Ctrl+Z[/b] or the ↶ button, and redone with [b]Ctrl+Shift+Z[/b], [b]Ctrl+Y[/b] or ↷.
## Table settings
[b]Table settings…[/b] in the ⋯ menu sets the card's type, dice, details and tags, and turns on [topic]Card mode[/topic].
[b]Table settings…[/b] in the ⋯ menu sets the card's type, dice, details and tags, and turns on [topic]Deck mode[/topic].
# Ranged tables and dice
A [b]ranged table[/b] gives each result a range of numbers instead of a weight, the way printed tables do: 01–30 Travelers on the road, 31–50 Beasts on the hunt, and so on.
@ -53,19 +53,21 @@ A [b]ranged table[/b] gives each result a range of numbers instead of a weight,
Dice can be written `2d6`, `d20`, `3D` or `D3`. A missing count means 1 and missing sides mean 6, so `2D` is 2d6. To add a value to the dice, use a [topic]Roll modifiers[/topic] modifier.
# Pipes
A pipe carries the roll from a result to another card.
- In Build mode, drag from the ● at the right of a result onto another card to lay a pipe.
- When that result is rolled, the card at the other end is rolled too. The pipes of a roll light up in brass.
- Click a pipe on the felt to edit it in the inspector.
# Threads
A thread carries the roll from a result to another card.
- In Build mode, drag from the ● at the right of a result onto another card to lay a thread.
- When that result is rolled, the card at the other end is rolled too. The threads of a roll light up in brass.
- Click a thread on the felt to edit it in the inspector.
## Pipe options
## Thread options
- [b]Count[/b] rolls the next card more than once. It can be a number or an expression such as `1d3`.
- [b]Save as[/b] keeps the next card's result under a name, so later text can show it as `{name}`.
- [b]Only if[/b] runs the pipe only when a condition is true, such as `@gold >= 10`.
- [b]Otherwise[/b] runs the pipe only when none of the result's Only if pipes ran.
- [b]Only if[/b] runs the thread only when a condition is true, such as `@gold >= 10`.
- [b]Otherwise[/b] runs the thread only when none of the result's Only if threads ran.
- [b]Inputs[/b] pass values to a card that declares them.
[demo]threads[/demo]
# Roll modifiers
A ranged table can add a [b]modifier[/b] to its dice, for rules like "roll 1d20 and add your Luck".
- In Build mode, select the card and set the modifier in the inspector: [b]Add[/b] a value, [b]Subtract[/b] one, or write your own.
@ -76,24 +78,26 @@ A ranged table can add a [b]modifier[/b] to its dice, for rules like "roll 1d20
## In the sample
[b]Search the Ruins[/b] rolls 1d6 + Luck. With no Luck you can't reach "A tunnel caves in" or "A hidden vault". Pray at the shrine in [b]Make Camp[/b] to raise your Luck, gamble with the guards to lower it, then search again and watch the chances move. Why this? on the step names the modifier: "+1 for Luck".
Card mode decks ignore the modifier.
Deck mode decks ignore the modifier.
# Card mode
[b]Card mode[/b] turns a table into a deck of cards. Each result is dealt once, with no repeats, until the deck runs out.
- Turn it on in [b]Table settings… → Card mode[/b].
- The card shows how many are left, for example [b]4 / 6 left[/b].
- [b]↻ Reshuffle[/b] under the card's name puts every card back.
- [b]When the deck runs out[/b] can reshuffle by itself or stop until you reshuffle.
# Deck mode
[b]Deck mode[/b] turns a table into a deck of cards. Each result is dealt once, with no repeats, until the deck runs out.
- Turn it on in the inspector (Build mode: click the card's name) under [b]Deck mode → Draw without repeats[/b].
- The card shows how many are left, for example [b]4 / 6 left[/b], and results already drawn are faded.
- [b]↻ Shuffle[/b] under the card's name puts every card back. [b]Shuffle all decks[/b] (right-click the spread, or ☰) does every deck at once.
- [b]When the deck is empty[/b] it can shuffle by itself, or wait for you to shuffle. While it waits, rolling it gives its [b]Empty result[/b] (“Empty” unless you write something else) and the roll goes no further.
[b]Party Roles[/b] in the sample is a deck: hand one role to each player, and nobody gets the same role twice until you reshuffle.
[b]Party Roles[/b] in the sample is a deck: hand one role to each player, and nobody gets the same role twice until you shuffle.
[demo]deck[/demo]
# Choice cards
A choice card stops the roll and asks the player. Add one from [b]+ Card ▾[/b].
- [b]Which option[/b] lists the card's options to pick from. [b]Random[/b] is always offered too. The picked option runs exactly as if it had been rolled: its changes happen and its pipes follow.
- [b]Which option[/b] lists the card's options to pick from. [b]Random[/b] is always offered too. The picked option runs exactly as if it had been rolled: its changes happen and its threads follow.
- [b]How many[/b] asks for a number between a lowest and highest value.
- [b]Open ended[/b] asks for any text.
The question can show values, such as "Your Luck is {@luck}. What now?". Answers can be saved under a name for later. [b]Cancel[/b] in the pop-up stops the whole roll, and the pop-up can be minimized to look at the board first.
The question can show values, such as "Your Luck is {@luck}. What now?". Answers can be saved under a name for later. [b]Cancel[/b] in the pop-up stops the whole roll, and the pop-up can be minimized to look at the spread first.
## Options that come and go
An option can have [b]Show only if[/b], so it's offered only when a condition is true, such as `@gold >= 10`. A Which option card can also build its options from a collection of values, such as every skill the character has.
@ -101,7 +105,7 @@ An option can have [b]Show only if[/b], so it's offered only when a condition is
[b]Make Camp[/b] in the sample is a Which option card.
# Values and changes
A board can remember [b]values[/b] between rolls, such as Luck, Gold or the current town. In rules a value is written with @: `@luck`.
A spread can remember [b]values[/b] between rolls, such as Luck, Gold or the current town. In rules a value is written with @: `@luck`.
- Any result can have [b]changes[/b] that happen when it comes up: [b]Add 1 to Luck[/b], [b]Subtract 3 from Gold[/b], [b]Set Town to …[/b]. Edit them in the inspector as rows, or with Edit as text.
- A [b]Variable[/b] card gives a value a name, a type and a starting value, and shows what it is now. The sample's [b]Luck[/b] card starts at 0.
- A [b]Collection[/b] card groups related values, such as Skills, so they can be listed and picked from together.
@ -113,17 +117,17 @@ A board can remember [b]values[/b] between rolls, such as Luck, Gold or the curr
- Text values work as lists: `@traits += "Brave"` adds an item.
## Conditions
Conditions are used by Only if pipes, routers, loops and Show only if. In plain words they read "Luck is at least 2". As text: `@luck >= 2`, `@town = "Saltmere"`, `@gold > 0 and @luck < 3`.
Conditions are used by Only if threads, branches, repeats and Show only if. In plain words they read "Luck is at least 2". As text: `@luck >= 2`, `@town = "Saltmere"`, `@gold > 0 and @luck < 3`.
# Logic cards
Besides roll tables and choices, [b]+ Card ▾[/b] adds:
- [b]Check card[/b]: rolls dice plus a modifier against a target, such as 2d6 + Skill against 8, and follows its Success or Failure result.
- [b]Loop[/b]: repeats its Each time result a number of times, or while or until a condition holds, then runs Afterwards once.
- [b]Router[/b]: checks its cases from top to bottom (if, else if, otherwise) and follows the first one that's true.
- [b]Repeat[/b]: repeats its Each time result a number of times, or while or until a condition holds, then runs Afterwards once.
- [b]Branch[/b]: checks its cases from top to bottom (if, else if, otherwise) and follows the first one that's true.
- [b]Sheet[/b]: a page of text, such as a character sheet, that always shows the current values. A roll that reaches it prints it in the tray.
- [b]Variable[/b] and [b]Collection[/b]: see [topic]Values and changes[/topic].
Use [b]Test board[/b] to check that a board of logic cards works. See [topic]Testing a board[/topic].
Use [b]Test spread[/b] to check that a spread of logic cards works. See [topic]Testing a spread[/topic].
# Text in results
Result text can do more than plain words:
@ -137,10 +141,10 @@ Result text can do more than plain words:
# Groups and templates
## Groups
- Ctrl-click or Shift-click cards to select several, or Ctrl-drag a box around them.
- Drag a box on empty space to select several cards and groups (hold Ctrl or Shift to add to the selection), or Ctrl-click or Shift-click cards. Dragging any selected card or group moves them all.
- Press [b]Ctrl+G[/b] to put them in a group: a frame that moves and collapses as one.
- Drag cards into or out of a group. The group's ⋯ menu renames, saves as a template, ungroups or deletes it.
- [b]Board ▾ → Pack collapsed groups[/b] moves collapsed groups together to close the gaps.
- [b]Spread ▾ → Pack collapsed groups[/b] moves collapsed groups together to close the gaps.
## Templates
A template is a saved card, group or selection that you can insert again, with blanks to fill in.
@ -148,29 +152,97 @@ A template is a saved card, group or selection that you can insert again, with b
- Insert one from [b]+ Card ▾ → From template…[/b].
- Built-in templates include a skill check, ask-and-repeat, a pick menu, a counter and a simple sheet.
# Collections, import and export
A [b]collection[/b] is one board of tables. Use the switcher beside Play | Build (it shows the collection's name) to switch, or to make a new collection, rename, duplicate or delete one.
# Menus: right-click and ☰
Right-click almost anything for what you can do with it. On a phone or tablet, press and hold instead.
- [b]A card[/b]: roll it, roll it several times, shuffle its deck, collapse it, and in Build its settings, colour, template and delete.
- [b]A thread[/b]: go to either end, and in Build edit it, colour it or delete it.
- [b]A group[/b]: expand or collapse it, and in Build its details, template, ungroup or delete.
- [b]Empty space[/b]: a new card right there, group the selection, search, shuffle all decks, fit the spread, List view, the Book and the theme.
The [b]☰[/b] button in the top bar has the same things as right-clicking empty space.
In Build mode, [b]Board ▾[/b] has:
- [b]Import as new collection…[/b] for TableTower JSON, JSON Canvas and GraphML files.
- [b]Export as…[/b] TableTower JSON, JSON Canvas, GraphML, a Mermaid diagram or Graphviz DOT.
# Selecting, moving and resizing
- Drag a box on empty space to select cards and groups. Hold [b]Ctrl[/b] or [b]Shift[/b] to add to the selection.
- Drag any selected card or group and everything selected moves together.
- Drag the small lines in a card's bottom-right corner to make it wider or taller; a taller card's results scroll inside it. Double-click the corner to go back to its own size.
- Cards can go anywhere: there's no edge to the spread.
- Zoomed far out, cards just show their names when you hover. You can still drag them and right-click them, and in Play a click rolls them.
# Groups inside groups
Groups can hold other groups. Select a group (drag a box around it) along with any cards, and press [b]Ctrl+G[/b]: the new group holds them all. Closing the outer group hides everything inside it. [b]Ungroup[/b] hands the contents to the group around it.
[demo]groups[/demo]
# Colours and themes
- [b]View ▾ → Theme…[/b] picks a theme and lets you change its colours, the background and panel gradients, the background pattern, the card border and the logo. Changes to a built-in theme are saved as a theme of your own.
- Give a card or a thread its own colour from its right-click menu ([b]Colour[/b]) or in the inspector, to sort things at a glance.
# List view
[b]List view[/b] (View ▾, ☰ or right-click the spread) shows every card as a plain list, for when you'd rather not use the spread.
- Folders are groups. [b]+ Folder[/b] makes one; drag cards onto a folder, or a folder onto another.
- Drag cards up and down to put them in your own order.
- [b]←2 →3[/b] counts the threads coming in and going out; hover to see where they lead.
- Click [b]Roll[/b] to roll a card. Double-click a card to find it on the spread.
- The list has its own search box.
# The Book
The [b]Book[/b] holds [b]Pages[/b]: results you want to use on more than one table, with their formatting, details, tags and picture.
- Open it from View ▾, ☰ or right-click the spread. [b]+ Page[/b] adds one; in Build, a result's inspector has [b]Save to the Book[/b].
- Drag a page onto a result to use it there, or onto a card to add it as a new result. Results using a page show a small §.
- Edit a page and every result using it changes. Change a result's own text and it stops following the page ([b]Unlink[/b] does the same).
[demo]book[/demo]
# Rolling more than once
- A thread can roll its card several times ([b]Rolls 3 times[/b] in the thread's inspector). Then choose what happens: [b]Keep every roll[/b], [b]Add them together[/b], [b]Keep the highest[/b], [b]Keep the lowest[/b] or [b]Let me choose[/b]. Rolls that aren't kept are faded in the tray, and don't follow their own threads.
- [b]Roll several times…[/b] on a card's menu rolls its whole chain as many times as you like (five villagers, ten treasures) and shows every result together, ready to copy.
[demo]repeats[/demo]
# Pausing a roll
Tick [b]Wait for me first[/b] on a thread and the roll stops there, with [b]Continue ▸[/b] and [b]Stop here[/b] in the tray. Use it to reveal something a piece at a time. If you roll something else meanwhile, the paused roll waits in the tray until you continue it.
[demo]pause[/demo]
# Options that cost
An option on a [b]Which option[/b] card can cost something: in its inspector, [b]Costs [1] of [Points][/b]. Picking it takes that away; when there isn't enough, the option is greyed out and says why. An option such as [b]Reroll[/b] that threads back to the loot card and costs a point gives players a spend-a-point reroll.
[demo]costs[/demo]
# One table adjusting another
A ranged card can have limits: [b]Never below[/b] and [b]Never above[/b], each a number or a value. An earlier result can set that value with a change, so it adjusts a later roll. For example "Thick haze" sets [b]Atmo min[/b] to 7, and Atmosphere is set to never go below Atmo min. To push a later roll up or down instead, give it a [topic]Roll modifiers[/topic] value that the earlier result sets. [b]Why this?[/b] says when a limit moved a roll.
[demo]limits[/demo]
# Sheets and saving results
A [b]Sheet[/b] card shows values as a finished page, such as a character. In its inspector, [b]+ Add a line for[/b] a value adds a "Name: value" line for you.
To keep a result outside the app, use the tray's [b]Copy ▾ → Save as a file[/b]: plain text, Markdown, or a web page you can open in a browser and print as a PDF. A roll that reached a sheet saves the sheet.
[demo]sheet[/demo]
# Pictures
A result or a Book page can have a picture: [b]Picture → Choose…[/b] in its inspector or page. It shows as a small picture on the card and a bigger one when you hover. Pictures are kept inside the spread, so exports and imports bring them along.
# On a phone or tablet
- The list fills the screen; [b]Spread[/b] and [b]List[/b] swap between them.
- Press and hold for the right-click menu. Two fingers move and zoom the spread.
- View, Help and Play/Build are in the [b]☰[/b] menu.
# Spreads, import and export
A [b]spread[/b] is one layout of cards, saved under its own name. Use the switcher beside Play | Build (it shows the spread's name) to switch, or to make a new spread, rename, duplicate or delete one.
In Build mode, [b]Spread ▾[/b] has:
- [b]Import as new spread…[/b] for Table Tarot JSON, JSON Canvas and GraphML files.
- [b]Export as…[/b] Table Tarot JSON, JSON Canvas, GraphML, a Mermaid diagram or Graphviz DOT.
Exports hold the tables only. Your roll history, decks and remembered values stay on this computer.
# Testing a board
[b]Board ▾ → Test board…[/b] rolls a card hundreds of times, answering every question at random, and reports:
# Testing a spread
[b]Spread ▾ → Test spread…[/b] rolls a card hundreds of times, answering every question at random, and reports:
- errors, such as a rule that can't be worked out
- dead ends, where a roll stops unexpectedly
- cards and results that never came up
- tips, such as an option that can never be offered
Click any item in the report to jump to that card. A board that can loop forever shows a warning in the top bar while you build.
Click any item in the report to jump to that card. A spread that can loop forever shows a warning in the top bar while you build.
# Finding your way
- [b]Search[/b] (the magnifier, or [b]Ctrl+F[/b]) finds cards by name, result, question, value or group, opens closed groups and flashes the card.
- Drag the felt to move around. The mouse wheel scrolls up and down, [b]Shift+wheel[/b] scrolls sideways and [b]Ctrl+wheel[/b] zooms.
- The zoom control at the top right shows the zoom. − and + step it, and the percentage opens [b]Fit board[/b], [b]Zoom to 100%[/b] and the minimap.
- The [b]minimap[/b] (press [b]M[/b]) shows the whole board in the corner. Click or drag on it to move there.
- Drag with the middle mouse button, or hold [b]Space[/b] and drag, to move around. The mouse wheel scrolls up and down, [b]Shift+wheel[/b] scrolls sideways and [b]Ctrl+wheel[/b] zooms.
- The zoom control at the top right shows the zoom. − and + step it, and the percentage opens [b]Fit spread[/b], [b]Zoom to 100%[/b] and the minimap.
- The [b]minimap[/b] (press [b]M[/b]) shows the whole spread in the corner. Click or drag on it to move there.
## The View menu
- [b]Rules[/b]: show rules in [b]Plain words[/b] ("Subtract 1 from Luck") or as [b]Rule text[/b] (`@luck -= 1`).
@ -179,14 +251,22 @@ Click any item in the report to jump to that card. A board that can loop forever
- [b]Minimap[/b].
# Keyboard shortcuts
## Keys
- [b]F1[/b]: this help
- [b]Shift-click[/b] a die: roll without the animation
- [b]Ctrl+F[/b]: search
- [b]M[/b]: show or hide the minimap
- [b]Ctrl+wheel[/b]: zoom. [b]Shift+wheel[/b]: scroll sideways
- [b]Ctrl+Z[/b]: undo
- [b]Ctrl+Shift+Z[/b] or [b]Ctrl+Y[/b]: redo
- [b]Ctrl+G[/b]: group the selected cards
- [b]Ctrl-click[/b], [b]Shift-click[/b] or [b]Ctrl-drag[/b]: select several cards
- [b]Ctrl+Z[/b]: undo. [b]Ctrl+Shift+Z[/b] or [b]Ctrl+Y[/b]: redo
- [b]Ctrl+G[/b]: group the selected cards and groups
- [b]Esc[/b]: clear the selection, or close a window
- Double-click the tray's or the inspector's edge: reset its size
- In a question pop-up: [b]1–9[/b] pick an option, [b]R[/b] Random, [b]M[/b] or [b]Tab[/b] look at the spread
## Mouse
- [b]Shift-click[/b] a die: roll without the animation
- [b]Right-click[/b]: the menu for what's under the mouse
- [b]Drag on empty space[/b] (Build): a selection box. Add [b]Ctrl[/b] or [b]Shift[/b] to add to the selection
- [b]Middle-drag[/b], or [b]Space[/b] + drag: move around the spread
- [b]Wheel[/b]: scroll. [b]Shift+wheel[/b]: sideways. [b]Ctrl+wheel[/b]: zoom
- A card's bottom-right corner: drag to resize, double-click for its own size
- Double-click the edge of the tray, inspector, list or Book: reset its size
## Touch
- Press and hold: the menu
- Two fingers: move and zoom

View file

@ -250,7 +250,7 @@ static func import_canvas(text: String, sanitize: Callable = Callable()) -> Dict
for e in t4["entries"]:
e.erase("_has_pipes")
if edge_pipes > 0:
guesses.append("Built %d pipe(s) from edges and their labels." % edge_pipes)
guesses.append("Built %d thread(s) from edges and their labels." % edge_pipes)
var raw := {
"format_version": JsonIO.FORMAT_VERSION,
@ -259,7 +259,7 @@ static func import_canvas(text: String, sanitize: Callable = Callable()) -> Dict
"tables": tables,
}
if doc_extra.is_empty():
guesses.append("No collection name in the canvas; using a default.")
guesses.append("No spread name in the canvas; using a default.")
return JsonIO.finish_import(raw, sanitize, result)

View file

@ -215,7 +215,7 @@ static func import_graphml(text: String, sanitize: Callable = Callable()) -> Dic
tables.append(t2)
if not rich:
guesses.append("No TableTower data in this file; each node became a table and each edge an entry with a pipe.")
guesses.append("No Table Tarot data in this file; each node became a table and each edge an entry with a thread.")
var by_table := {}
for t3 in tables:
by_table[t3["id"]] = t3

204
io/json_canon.gd Normal file
View file

@ -0,0 +1,204 @@
class_name JsonCanon
extends RefCounted
## Collection normaliser behind JsonIO.canonical() (format version 2).
## Normalizes a collection to format version 2: legacy keys are converted
## (`die` -> `dice`, `triggers` -> `pipes`, `collection` -> `name`), missing
## optional keys are tolerated and unknown keys are dropped.
static func canonical(src: Dictionary) -> Dictionary:
var tables: Array = []
var src_tables: Variant = src.get("tables", [])
if src_tables is Array:
for t in src_tables:
if t is Dictionary:
tables.append(_canon_table(t))
var cname := str(src.get("name", src.get("collection", "")))
var out := {"format_version": JsonIO.FORMAT_VERSION, "id": str(src.get("id", "")), "name": cname, "tables": tables}
var groups: Array = []
var src_groups: Variant = src.get("groups", [])
if src_groups is Array:
for g in src_groups:
if g is Dictionary:
groups.append(_canon_group(g))
if not groups.is_empty():
out["groups"] = groups
# The Book and pictures (2026-11-10): taken as they are; TowerBoard checks them.
if src.get("book") is Array:
out["book"] = (src["book"] as Array).filter(func(v: Variant) -> bool: return v is Dictionary)
if src.get("images") is Dictionary:
var pics := {}
for k: Variant in src["images"]:
if src["images"][k] is String:
pics[str(k)] = src["images"][k]
out["images"] = pics
return out
## Copies the keys that are present and not empty (newer optional keys that
## need no conversion).
static func _keep(src: Dictionary, dst: Dictionary, keys: Array) -> void:
for k: String in keys:
var v: Variant = src.get(k)
if v != null and not (v is String and (v as String).strip_edges() == "") and not (v is bool and not v):
dst[k] = v
static func _canon_group(gd: Dictionary) -> Dictionary:
var g := {
"id": str(gd.get("id", "")),
"name": str(gd.get("name", "")),
"x": int(JsonIO._num(gd.get("x", 0), 0)),
"y": int(JsonIO._num(gd.get("y", 0), 0)),
"w": int(JsonIO._num(gd.get("w", 320), 320)),
"h": int(JsonIO._num(gd.get("h", 200), 200)),
}
if bool(gd.get("collapsed", false)):
g["collapsed"] = true
var details := str(gd.get("details", ""))
if details != "":
g["details"] = details
var members: Array = []
var src: Variant = gd.get("members", [])
if src is Array:
for m in src:
if str(m) != "" and not members.has(str(m)):
members.append(str(m))
g["members"] = members
_keep(gd, g, ["parent"])
return g
static func _canon_table(td: Dictionary) -> Dictionary:
var t := {
"id": str(td.get("id", "")),
"name": str(td.get("name", "")),
"x": int(JsonIO._num(td.get("x", 0), 0)),
"y": int(JsonIO._num(td.get("y", 0), 0)),
}
if bool(td.get("collapsed", false)):
t["collapsed"] = true
var details := str(td.get("details", ""))
if details != "":
t["details"] = details
var tags: Array = []
var src_tags: Variant = td.get("tags", [])
if src_tags is Array:
for tag in src_tags:
tags.append(str(tag))
if not tags.is_empty():
t["tags"] = tags
var dice := str(td.get("dice", "")).strip_edges()
if dice == "" and td.has("die"):
var die: Variant = JsonIO._num(td["die"], 0)
if (die is int or die is float) and die > 0:
dice = "1d%d" % int(die)
if dice != "":
t["dice"] = dice
for key in ["card_mode", "deck_empty"]:
var v: Variant = td.get(key)
if v != null and not (v is bool and not v) and not (v is String and v == ""):
t[key] = v
# Logic cards (docs/LOGIC.md §9). Defaults are left out.
var kind := str(td.get("kind", "roll"))
if RollTable.KINDS.has(kind) and kind != "roll":
t["kind"] = kind
var defaults := {"dice_mod": "", "choice": "pick", "prompt": "", "save_as": "", "options_from": "", "options_where": "", "min": "0", "max": "99",
"loop": "times", "loop_expr": "", "var_name": "", "var_type": "number", "initial": "",
"check_dice": RollTable.CHECK_DEFAULT_DICE, "check_mod": "", "check_cmp": "ge", "check_target": RollTable.CHECK_DEFAULT_TARGET}
for key: String in defaults:
if not td.has(key) or td[key] == null:
continue
var s := RollTable.expr_text(td[key], str(defaults[key]))
if s != str(defaults[key]):
t[key] = s
var inputs := RollTable.clean_inputs(td.get("inputs", []))
if not inputs.is_empty():
var list: Array = []
for inp: Dictionary in inputs:
var o := {"name": inp["name"]}
if str(inp["label"]) != "":
o["label"] = inp["label"]
if str(inp["default"]) != "":
o["default"] = inp["default"]
list.append(o)
t["inputs"] = list
var entries: Array = []
var src_entries: Variant = td.get("entries", [])
if src_entries is Array:
for e in src_entries:
entries.append(_canon_entry(e))
t["entries"] = entries
_keep(td, t, ["color", "w", "list_h", "roll_floor", "roll_ceiling", "deck_empty_text"])
return t
static func _canon_entry(ev: Variant) -> Dictionary:
if ev is String:
return {"id": "", "text": ev}
var ed: Dictionary = ev
var e := {"id": str(ed.get("id", "")), "text": str(ed.get("text", ""))}
var details := str(ed.get("details", ""))
if details != "":
e["details"] = details
var w: Variant = JsonIO._num(ed.get("weight", 1), 1)
if (w is int or w is float) and w != 1:
e["weight"] = w
var r: Variant = ed.get("range")
if r is Array and (r as Array).size() == 2:
e["range"] = [int(JsonIO._num(r[0], 0)), int(JsonIO._num(r[1], 0))]
var effects := str(ed.get("effects", "")) if ed.get("effects") != null else ""
if effects.strip_edges() != "":
e["effects"] = effects
var when := str(ed.get("when", "")).strip_edges() if ed.get("when") != null else ""
if when != "":
e["when"] = when
var show_if := str(ed.get("show_if", "")).strip_edges() if ed.get("show_if") != null else ""
if show_if != "":
e["show_if"] = show_if
var src_pipes: Variant = ed.get("pipes", ed.get("triggers", []))
var pipes: Array = []
if src_pipes is Array:
for p in src_pipes:
if p is String and p != "":
pipes.append(p)
elif p is Dictionary and str(p.get("table", "")) != "":
var np := {"table": str(p["table"])}
if p.has("count"):
var cnt: Variant = JsonIO._num(p["count"], null)
if cnt == null and p["count"] is String and (p["count"] as String).strip_edges() != "":
np["count"] = (p["count"] as String).strip_edges() # an expression
else:
np["count"] = int(cnt if cnt != null else 1)
if str(p.get("save_as", "")) != "":
np["save_as"] = str(p["save_as"])
var pw := str(p.get("when", "")).strip_edges() if p.get("when") != null else ""
if pw != "":
np["when"] = pw
elif p.get("otherwise", false) is bool and bool(p.get("otherwise", false)):
np["otherwise"] = true
var wv := _canon_with(p.get("with"))
if not wv.is_empty():
np["with"] = wv
_keep(p, np, ["color", "combine", "pause"])
pipes.append(np)
if not pipes.is_empty():
e["pipes"] = pipes
_keep(ed, e, ["page", "image"])
if ed.get("cost") is Dictionary:
e["cost"] = ed["cost"]
return e
## A pipe's "with" object: {input name: expression text}, names trimmed (a
## leading "@" dropped), numbers as text, empty names and values left out.
static func _canon_with(v: Variant) -> Dictionary:
var out := {}
if not (v is Dictionary):
return out
for k: Variant in v:
var nm := str(k).strip_edges().trim_prefix("@")
var ex := RollTable.expr_text(v[k], "").strip_edges()
if nm != "" and ex != "":
out[nm] = ex
return out

1
io/json_canon.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bw2ha6nahxfyo

View file

@ -49,7 +49,7 @@ static func import_json(text: String, sanitize: Callable = Callable()) -> Dictio
errors.append("Not valid JSON (line %d): %s" % [json.get_error_line(), json.get_error_message()])
return {"ok": false, "collection": {}, "errors": errors, "warnings": warnings}
if not (json.data is Dictionary):
errors.append("The file is not a collection (expected a JSON object).")
errors.append("The file is not a spread (expected a JSON object).")
return {"ok": false, "collection": {}, "errors": errors, "warnings": warnings}
return import_dict(json.data, sanitize)
@ -66,7 +66,7 @@ static func import_dict(data: Dictionary, sanitize: Callable = Callable()) -> Di
if (fv is int or fv is float) and fv > FORMAT_VERSION:
errors.append("format_version %s is newer than this version supports (%d)." % [str(fv), FORMAT_VERSION])
if not (data.get("tables") is Array):
errors.append("The collection has no \"tables\" list.")
errors.append("The spread has no \"tables\" list.")
return result
var raw_tables: Array = data["tables"]
for ti in raw_tables.size():
@ -93,8 +93,8 @@ static func import_dict(data: Dictionary, sanitize: Callable = Callable()) -> Di
c["name"] = clean.call(str(c["name"]))
if str(c["name"]) == "":
c["name"] = "Untitled collection"
warnings.append("The collection had no name; called it \"Untitled collection\".")
c["name"] = "Untitled spread"
warnings.append("The spread had no name; called it \"Untitled spread\".")
if str(c["id"]) == "":
c["id"] = slug(str(c["name"]), "collection")
@ -184,7 +184,7 @@ static func import_dict(data: Dictionary, sanitize: Callable = Callable()) -> Di
elif by_name.has(target.to_lower()):
target = by_name[target.to_lower()]
else:
warnings.append("\"%s\" pipes to unknown table \"%s\"." % [str(ed["text"]), target])
warnings.append("\"%s\" threads to unknown table \"%s\"." % [str(ed["text"]), target])
if p is Dictionary:
var np: Dictionary = (p as Dictionary).duplicate()
np["table"] = target
@ -242,183 +242,6 @@ static func _import_groups(c: Dictionary, id_map: Dictionary, by_name: Dictionar
g["members"] = keep
# ------------------------------------------------------------ canonical
## Normalizes a collection to format version 2: legacy keys are converted
## (`die` -> `dice`, `triggers` -> `pipes`, `collection` -> `name`), missing
## optional keys are tolerated and unknown keys are dropped.
static func canonical(src: Dictionary) -> Dictionary:
var tables: Array = []
var src_tables: Variant = src.get("tables", [])
if src_tables is Array:
for t in src_tables:
if t is Dictionary:
tables.append(_canon_table(t))
var cname := str(src.get("name", src.get("collection", "")))
var out := {"format_version": FORMAT_VERSION, "id": str(src.get("id", "")), "name": cname, "tables": tables}
var groups: Array = []
var src_groups: Variant = src.get("groups", [])
if src_groups is Array:
for g in src_groups:
if g is Dictionary:
groups.append(_canon_group(g))
if not groups.is_empty():
out["groups"] = groups
return out
static func _canon_group(gd: Dictionary) -> Dictionary:
var g := {
"id": str(gd.get("id", "")),
"name": str(gd.get("name", "")),
"x": int(_num(gd.get("x", 0), 0)),
"y": int(_num(gd.get("y", 0), 0)),
"w": int(_num(gd.get("w", 320), 320)),
"h": int(_num(gd.get("h", 200), 200)),
}
if bool(gd.get("collapsed", false)):
g["collapsed"] = true
var details := str(gd.get("details", ""))
if details != "":
g["details"] = details
var members: Array = []
var src: Variant = gd.get("members", [])
if src is Array:
for m in src:
if str(m) != "" and not members.has(str(m)):
members.append(str(m))
g["members"] = members
return g
static func _canon_table(td: Dictionary) -> Dictionary:
var t := {
"id": str(td.get("id", "")),
"name": str(td.get("name", "")),
"x": int(_num(td.get("x", 0), 0)),
"y": int(_num(td.get("y", 0), 0)),
}
if bool(td.get("collapsed", false)):
t["collapsed"] = true
var details := str(td.get("details", ""))
if details != "":
t["details"] = details
var tags: Array = []
var src_tags: Variant = td.get("tags", [])
if src_tags is Array:
for tag in src_tags:
tags.append(str(tag))
if not tags.is_empty():
t["tags"] = tags
var dice := str(td.get("dice", "")).strip_edges()
if dice == "" and td.has("die"):
var die: Variant = _num(td["die"], 0)
if (die is int or die is float) and die > 0:
dice = "1d%d" % int(die)
if dice != "":
t["dice"] = dice
for key in ["card_mode", "deck_empty"]:
var v: Variant = td.get(key)
if v != null and not (v is bool and not v) and not (v is String and v == ""):
t[key] = v
# Logic cards (docs/LOGIC.md §9). Defaults are left out.
var kind := str(td.get("kind", "roll"))
if RollTable.KINDS.has(kind) and kind != "roll":
t["kind"] = kind
var defaults := {"dice_mod": "", "choice": "pick", "prompt": "", "save_as": "", "options_from": "", "options_where": "", "min": "0", "max": "99",
"loop": "times", "loop_expr": "", "var_name": "", "var_type": "number", "initial": "",
"check_dice": RollTable.CHECK_DEFAULT_DICE, "check_mod": "", "check_cmp": "ge", "check_target": RollTable.CHECK_DEFAULT_TARGET}
for key: String in defaults:
if not td.has(key) or td[key] == null:
continue
var s := RollTable.expr_text(td[key], str(defaults[key]))
if s != str(defaults[key]):
t[key] = s
var inputs := RollTable.clean_inputs(td.get("inputs", []))
if not inputs.is_empty():
var list: Array = []
for inp: Dictionary in inputs:
var o := {"name": inp["name"]}
if str(inp["label"]) != "":
o["label"] = inp["label"]
if str(inp["default"]) != "":
o["default"] = inp["default"]
list.append(o)
t["inputs"] = list
var entries: Array = []
var src_entries: Variant = td.get("entries", [])
if src_entries is Array:
for e in src_entries:
entries.append(_canon_entry(e))
t["entries"] = entries
return t
static func _canon_entry(ev: Variant) -> Dictionary:
if ev is String:
return {"id": "", "text": ev}
var ed: Dictionary = ev
var e := {"id": str(ed.get("id", "")), "text": str(ed.get("text", ""))}
var details := str(ed.get("details", ""))
if details != "":
e["details"] = details
var w: Variant = _num(ed.get("weight", 1), 1)
if (w is int or w is float) and w != 1:
e["weight"] = w
var r: Variant = ed.get("range")
if r is Array and (r as Array).size() == 2:
e["range"] = [int(_num(r[0], 0)), int(_num(r[1], 0))]
var effects := str(ed.get("effects", "")) if ed.get("effects") != null else ""
if effects.strip_edges() != "":
e["effects"] = effects
var when := str(ed.get("when", "")).strip_edges() if ed.get("when") != null else ""
if when != "":
e["when"] = when
var show_if := str(ed.get("show_if", "")).strip_edges() if ed.get("show_if") != null else ""
if show_if != "":
e["show_if"] = show_if
var src_pipes: Variant = ed.get("pipes", ed.get("triggers", []))
var pipes: Array = []
if src_pipes is Array:
for p in src_pipes:
if p is String and p != "":
pipes.append(p)
elif p is Dictionary and str(p.get("table", "")) != "":
var np := {"table": str(p["table"])}
if p.has("count"):
var cnt: Variant = _num(p["count"], null)
if cnt == null and p["count"] is String and (p["count"] as String).strip_edges() != "":
np["count"] = (p["count"] as String).strip_edges() # an expression
else:
np["count"] = int(cnt if cnt != null else 1)
if str(p.get("save_as", "")) != "":
np["save_as"] = str(p["save_as"])
var pw := str(p.get("when", "")).strip_edges() if p.get("when") != null else ""
if pw != "":
np["when"] = pw
elif p.get("otherwise", false) is bool and bool(p.get("otherwise", false)):
np["otherwise"] = true
var wv := _canon_with(p.get("with"))
if not wv.is_empty():
np["with"] = wv
pipes.append(np)
if not pipes.is_empty():
e["pipes"] = pipes
return e
## A pipe's "with" object: {input name: expression text}, names trimmed (a
## leading "@" dropped), numbers as text, empty names and values left out.
static func _canon_with(v: Variant) -> Dictionary:
var out := {}
if not (v is Dictionary):
return out
for k: Variant in v:
var nm := str(k).strip_edges().trim_prefix("@")
var ex := RollTable.expr_text(v[k], "").strip_edges()
if nm != "" and ex != "":
out[nm] = ex
return out
# -------------------------------------------------------------- helpers
@ -468,7 +291,7 @@ static func pipe_info(p: Variant) -> Dictionary:
var w := str(p.get("when", "")).strip_edges() if p.get("when") != null else ""
return {"table": str(p.get("table", "")), "count": int(_num(c, 1)), "save_as": str(p.get("save_as", "")), "count_expr": expr,
"when": w, "otherwise": w == "" and p.get("otherwise", false) is bool and bool(p.get("otherwise", false)),
"with": _canon_with(p.get("with"))}
"with": JsonCanon._canon_with(p.get("with"))}
return {"table": str(p), "count": 1, "save_as": "", "count_expr": "", "when": "", "otherwise": false, "with": {}}
@ -519,84 +342,6 @@ static func dice_max(dice: String) -> int:
return m.get_string(1).to_int() * m.get_string(2).to_int()
## Id of the table whose name matches (case-insensitive), or "".
static func table_id_by_name(collection: Dictionary, table_name: String) -> String:
var want := table_name.strip_edges().to_lower()
for t in collection.get("tables", []):
if str(t.get("name", "")).to_lower() == want:
return str(t.get("id", ""))
return ""
## Every connection in a collection, pipes and inline references, in
## table/entry order. Each item: kind ("pipe" or "ref"), table_index,
## entry_index, from_table, from_entry (ids), target (table id, or "" when the
## table is missing), target_name (as written), label, count, save_as,
## entry_text (BBCode stripped). Expects a canonical collection.
static func links(collection: Dictionary) -> Array[Dictionary]:
var out: Array[Dictionary] = []
var tables: Array = collection.get("tables", [])
var ids := {}
for t in tables:
ids[str(t["id"])] = true
for ti in tables.size():
var t2: Dictionary = tables[ti]
var elist: Array = t2.get("entries", [])
for ei in elist.size():
var e: Dictionary = elist[ei]
for p in e.get("pipes", []):
var info := pipe_info(p)
var tgt: String = info["table"]
out.append({
"kind": "pipe", "table_index": ti, "entry_index": ei,
"from_table": t2["id"], "from_entry": e["id"],
"target": tgt if ids.has(tgt) else "", "target_name": tgt,
"label": pipe_label(info), "count": info["count"], "save_as": info["save_as"],
"entry_text": strip_bbcode(str(e["text"])),
})
for ref in find_refs(str(e["text"])):
var rid := table_id_by_name(collection, ref["name"])
out.append({
"kind": "ref", "table_index": ti, "entry_index": ei,
"from_table": t2["id"], "from_entry": e["id"],
"target": rid, "target_name": ref["name"],
"label": ("ref → " + ref["var"]) if ref["var"] != "" else "ref",
"count": 1, "save_as": ref["var"],
"entry_text": strip_bbcode(str(e["text"])),
})
return out
## Display label for a table number range, zero padded; the top of a d100 or
## d1000 reads as zeros ("96–00").
static func range_text(lo: int, hi: int, dmax: int) -> String:
return "%s–%s" % [_num_text(lo, dmax), _num_text(hi, dmax)]
static func _num_text(n: int, dmax: int) -> String:
if dmax >= 100 and _is_power_of_ten(dmax):
if n == dmax:
return "0".repeat(str(dmax - 1).length())
return str(n).pad_zeros(str(dmax - 1).length())
return str(n).pad_zeros(str(maxi(dmax, 1)).length())
static func _is_power_of_ten(n: int) -> bool:
while n >= 10 and n % 10 == 0:
n /= 10
return n == 1
## An entry as one plain line for an export: "3-4: text", "2 × text" or "text".
static func entry_line(e: Dictionary, dmax: int) -> String:
var plain := strip_bbcode(str(e["text"]))
if e.has("range"):
var r: Array = e["range"]
return "%s: %s" % [range_text(int(r[0]), int(r[1]), dmax), plain]
var w: Variant = e.get("weight", 1)
if w != 1:
return "%s × %s" % [str(w), plain]
return plain
## Imports a converted collection (`raw`) and adds its warnings, errors and
@ -608,3 +353,27 @@ static func finish_import(raw: Dictionary, sanitize: Callable, result: Dictionar
result["ok"] = imported["ok"]
result["collection"] = imported["collection"]
return result
static func canonical(src: Dictionary) -> Dictionary:
return JsonCanon.canonical(src)
static func entry_line(e: Dictionary, dmax: int) -> String:
return JsonLinks.entry_line(e, dmax)
static func links(collection: Dictionary) -> Array[Dictionary]:
return JsonLinks.links(collection)
static func range_text(lo: int, hi: int, dmax: int) -> String:
return JsonLinks.range_text(lo, hi, dmax)
static func table_id_by_name(collection: Dictionary, table_name: String) -> String:
return JsonLinks.table_id_by_name(collection, table_name)
static func _canon_table(td: Dictionary) -> Dictionary:
return JsonCanon._canon_table(td)

83
io/json_links.gd Normal file
View file

@ -0,0 +1,83 @@
class_name JsonLinks
extends RefCounted
## Connections and plain-text entry lines for exports (see JsonIO).
## Id of the table whose name matches (case-insensitive), or "".
static func table_id_by_name(collection: Dictionary, table_name: String) -> String:
var want := table_name.strip_edges().to_lower()
for t in collection.get("tables", []):
if str(t.get("name", "")).to_lower() == want:
return str(t.get("id", ""))
return ""
## Every connection in a collection, pipes and inline references, in
## table/entry order. Each item: kind ("pipe" or "ref"), table_index,
## entry_index, from_table, from_entry (ids), target (table id, or "" when the
## table is missing), target_name (as written), label, count, save_as,
## entry_text (BBCode stripped). Expects a canonical collection.
static func links(collection: Dictionary) -> Array[Dictionary]:
var out: Array[Dictionary] = []
var tables: Array = collection.get("tables", [])
var ids := {}
for t in tables:
ids[str(t["id"])] = true
for ti in tables.size():
var t2: Dictionary = tables[ti]
var elist: Array = t2.get("entries", [])
for ei in elist.size():
var e: Dictionary = elist[ei]
for p in e.get("pipes", []):
var info := JsonIO.pipe_info(p)
var tgt: String = info["table"]
out.append({
"kind": "pipe", "table_index": ti, "entry_index": ei,
"from_table": t2["id"], "from_entry": e["id"],
"target": tgt if ids.has(tgt) else "", "target_name": tgt,
"label": JsonIO.pipe_label(info), "count": info["count"], "save_as": info["save_as"],
"entry_text": JsonIO.strip_bbcode(str(e["text"])),
})
for ref in JsonIO.find_refs(str(e["text"])):
var rid := table_id_by_name(collection, ref["name"])
out.append({
"kind": "ref", "table_index": ti, "entry_index": ei,
"from_table": t2["id"], "from_entry": e["id"],
"target": rid, "target_name": ref["name"],
"label": ("ref → " + ref["var"]) if ref["var"] != "" else "ref",
"count": 1, "save_as": ref["var"],
"entry_text": JsonIO.strip_bbcode(str(e["text"])),
})
return out
## Display label for a table number range, zero padded; the top of a d100 or
## d1000 reads as zeros ("96–00").
static func range_text(lo: int, hi: int, dmax: int) -> String:
return "%s–%s" % [_num_text(lo, dmax), _num_text(hi, dmax)]
static func _num_text(n: int, dmax: int) -> String:
if dmax >= 100 and _is_power_of_ten(dmax):
if n == dmax:
return "0".repeat(str(dmax - 1).length())
return str(n).pad_zeros(str(dmax - 1).length())
return str(n).pad_zeros(str(maxi(dmax, 1)).length())
static func _is_power_of_ten(n: int) -> bool:
while n >= 10 and n % 10 == 0:
n /= 10
return n == 1
## An entry as one plain line for an export: "3-4: text", "2 × text" or "text".
static func entry_line(e: Dictionary, dmax: int) -> String:
var plain := JsonIO.strip_bbcode(str(e["text"]))
if e.has("range"):
var r: Array = e["range"]
return "%s: %s" % [range_text(int(r[0]), int(r[1]), dmax), plain]
var w: Variant = e.get("weight", 1)
if w != 1:
return "%s × %s" % [str(w), plain]
return plain

1
io/json_links.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://i7qjiydrprhh

View file

@ -13,8 +13,11 @@ config_version=5
config/name="TableTower"
run/main_scene="res://ui/main.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
boot_splash/bg_color=Color(0.0706, 0.1882, 0.1216, 1)
config/icon="res://icon.svg"
boot_splash/bg_color=Color(0.2235, 0.0314, 0.3255, 1)
boot_splash/image="res://assets/art/fortune_teller.png"
boot_splash/fullsize=true
boot_splash/use_filter=true
config/icon="res://assets/art/fortune_teller.svg"
[display]

69
tests/test_actions.gd Normal file
View file

@ -0,0 +1,69 @@
extends TestBase
## The shared action menus (Actions): what the card, thread, group and spread
## menus offer in Play and Build, the ☰ menu, running an action, and placing
## a new card where the spread was right-clicked.
## Run: godot --headless --path . -s res://tests/test_actions.gd -- --sample
func _init() -> void:
if not await start_main():
return
await _test_lists()
await _test_popup_and_run()
finish()
func _texts(list: Array) -> Array[String]:
var out: Array[String] = []
for a: Dictionary in list:
if a.has("text"):
out.append(str(a["text"]))
return out
func _test_lists() -> void:
var t := main.data.get_table("loot")
var play := _texts(Actions.card(main, t))
_check(play.has("Roll") and not play.has("Delete table"), "Play: a card can be rolled, not deleted: %s" % str(play))
var bg := _texts(Actions.background(main, Vector2.ZERO))
_check(bg.has("Search… Ctrl+F") and bg.has("Shuffle all decks") and not bg.has("New card"), "Play spread menu: %s" % str(bg))
main.set_mode(Main.Mode.BUILD)
await _frames()
var build := _texts(Actions.card(main, t))
_check(build.has("Table settings…") and build.has("Colour") and build.has("Delete table"), "Build card menu: %s" % str(build))
bg = _texts(Actions.background(main, Vector2.ZERO))
_check(bg.has("New card") and bg.has("Group the selection Ctrl+G"), "Build spread menu: %s" % str(bg))
var key := ""
for e in t.entries:
if not e.pipes.is_empty():
key = Roller.pipe_key(t.id, e.id, e.pipes[0])
break
var th := _texts(Actions.thread(main, key))
_check(th.has("Go to the end") and th.has("Delete thread") and th.has("Colour"), "thread menu: %s" % str(th))
_check(Actions.thread(main, "nope:x>y").is_empty(), "a missing thread has no menu")
func _test_popup_and_run() -> void:
var at := Vector2(-900, -700)
var pm := Actions.popup_at(main, Actions.background(main, at), Vector2(50, 50))
await _frames()
var sub: PopupMenu = null
for c in pm.get_children():
if c is PopupMenu:
sub = c
_check(sub != null and sub.item_count == MainEditing.ADD_KINDS.size(), "New card ▸ lists every kind")
var before := main.data.tables.size()
_check(Actions.press(sub, "Roll table"), "pressing an item runs it")
await _frames()
var added: RollTable = main.data.tables[main.data.tables.size() - 1]
_check(main.data.tables.size() == before + 1 and added.position.distance_to(at) < 2.0, "the new card goes where the spread was clicked: %s" % str(added.position))
pm.hide()
var t := main.data.get_table("loot")
Actions.set_card_colour(main, t, "#2f8a4f")
_check(t.color == "#2f8a4f", "Colour ▸ sets the card's colour")
main.undo_redo.undo()
_check(main.data.get_table("loot").color == "", "and it's undoable")
var bar_pm := main.top_bar.actions_menu.get_popup()
bar_pm.about_to_popup.emit()
_check(bar_pm.item_count > 4, "the ☰ menu fills with the spread's actions")

View file

@ -0,0 +1 @@
uid://hetav3d4sl5c

View file

@ -1,10 +1,9 @@
extends SceneTree
extends TestBase
## BoardTester: static checks, simulated runs, isolation from the caller's
## variables and decks, batches, start-table detection, and the Test board
## dialog driven through its methods.
## Run: godot --headless --path . -s res://tests/test_board_tester.gd
var _failures := 0
## Stands in for Main: just enough for the dialog.
@ -25,10 +24,10 @@ func _init() -> void:
_check(_has(probs, "effect", "start", "e1"), "a bad effect is found with its table and entry: %s" % str(probs))
_check(_has(probs, "expression", "badexpr", ""), "a bad dice expression is found")
_check(_has(probs, "expression", "pick", "") and _text_has(probs, "Prompt"), "a bad {= } in a prompt is found")
_check(_has(probs, "expression", "loop", "") and _text_has(probs, "Loop rule"), "a bad loop rule is found")
_check(_has(probs, "expression", "start", "e1") and _text_has(probs, "Pipe count"), "a bad pipe count is found")
_check(_has(probs, "expression", "loop", "") and _text_has(probs, "Repeat rule"), "a bad loop rule is found")
_check(_has(probs, "expression", "start", "e1") and _text_has(probs, "Thread count"), "a bad thread count is found")
_check(_has(probs, "range", "gap", "") and _text_has(probs, "No result for 3"), "a range gap is found")
_check(_has(probs, "missing_pipe", "start", "e1"), "a pipe to a missing table is found")
_check(_has(probs, "missing_pipe", "start", "e1"), "a thread to a missing table is found")
_check(_has(probs, "empty_choice", "empty", ""), "a choice card with no options is found")
_check(_has(probs, "cycle", "ping", ""), "an endless cycle is found")
_check(not _has(probs, "range", "okrange", "") and not _has(probs, "effect", "mine", ""), "good cards give no problems")
@ -120,8 +119,7 @@ func _init() -> void:
frames += 1
_check(not d2.running and d2.summary.text.begins_with("Cancelled after"), "cancelled run reports it: %s" % d2.summary.text)
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _board() -> TowerBoard:
@ -163,7 +161,7 @@ func _board() -> TowerBoard:
be.range_lo = 2
be.range_hi = 12
bad.entries.append(be)
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Loop", "times")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Repeat", "times")
loop.loop_expr = "3 *"
var empty := RollTable.create(RollTable.KIND_CHOICE, "empty", "Empty", "pick")
empty.entries.clear()
@ -202,12 +200,3 @@ func _text_has(probs: Array, s: String) -> bool:
return true
return false
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(str(got) == str(want), "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

110
tests/test_book.gd Normal file
View file

@ -0,0 +1,110 @@
extends TestBase
## The Book: pages saved from results, linked results following a page's edits,
## dropping a page onto a result or a card, unlinking, saving and undo.
## Run: godot --headless --path . -s res://tests/test_book.gd -- --sample
func _init() -> void:
if not await start_main():
return
main.set_mode(Main.Mode.BUILD)
await _frames()
await _test_book()
_test_pictures()
finish()
func _test_book() -> void:
var weapons := main.data.get_table("weapons")
var sword := weapons.entries[1]
var p := main.book.save_result(weapons, sword)
await _frames()
_check(main.book.visible and sword.page == p.id and p.text == sword.text, "Save to the Book makes a page and links the result")
main.book.editor.show_page(p)
p.text = "[b]The Sword of Holy Light[/b]"
p.details = "Glows near the undead."
main.book.editor._changed()
_check(sword.text == p.text and sword.details == p.details, "editing the page changes the linked result")
var loot := main.data.get_table("loot")
var target := loot.entries[0]
await _frames(2)
var row: Control = main.card_for("loot").rows[target.id]
_check(main.book.drop_page(p.id, row.get_global_rect().get_center()), "dropping a page on a result lands")
_check(target.page == p.id and target.text == p.text, "and links that result")
var n := loot.entries.size()
var card := main.card_for("loot")
main.book.drop_page(p.id, card.get_global_rect().position + Vector2(20, 12))
_check(loot.entries.size() == n + 1 and loot.entries[n].page == p.id, "dropping on the card's header adds a new linked result")
p.text = "Holy Sword"
main.book.editor._changed()
_check(target.text == "Holy Sword" and loot.entries[n].text == "Holy Sword", "one edit reaches every copy")
_check(main.data.page_uses(p.id) == 3, "the page counts its uses")
main.select_result("loot", target.id)
await _frames()
main.inspector.set_entry_text("A plain sword")
_check(target.page == "", "editing a result's own text unlinks it")
var d := main.data.to_dict()
var back := TowerBoard.new()
back.load_dict(d)
_check(back.book.size() == 1 and back.get_page(p.id).text == "Holy Sword", "the Book is saved in the spread")
main.book.list.clear()
main.book.refresh()
main.book._search.text = "nothing like it"
main.book.refresh()
_check(main.book.list.item_count == 0, "search filters pages")
main.book._search.text = ""
main.undo_redo._begin_edit()
main.data.remove_page(p.id)
main.mark_dirty()
main.undo_redo._end_edit()
_check(sword.page == "" and main.data.book.is_empty(), "deleting a page leaves its results as plain text")
main.undo_redo.undo()
await _frames()
_check(main.data.book.size() == 1, "undo brings the page back")
func _test_pictures() -> void:
var img := Image.create(900, 600, false, Image.FORMAT_RGBA8)
img.fill(Color.MEDIUM_PURPLE)
var r := BoardImages.from_image(img)
_check(r.has("id") and not r.has("error"), "a picture is stored")
main.data.images[r["id"]] = r["data"]
var tex := main.data.picture(r["id"])
_check(tex != null and maxi(tex.get_width(), tex.get_height()) == BoardImages.MAX_SIDE, "and shrunk to %d px" % BoardImages.MAX_SIDE)
main.data.images["img_unused"] = r["data"]
var e := main.data.get_table("weapons").entries[0]
e.image = r["id"]
var d := main.data.to_dict()
_check((d.get("images", {}) as Dictionary).has(r["id"]) and not (d["images"] as Dictionary).has("img_unused"), "only used pictures are saved")
var back := TowerBoard.new()
back.load_dict(d)
_check(back.picture(back.get_table("weapons").entries[0].image) != null, "pictures load with the spread")
var p := main.data.add_page("Pic page")
p.image = r["id"]
var e2 := main.data.get_table("weapons").entries[2]
main.data.link_page(e2, p.id)
_check(e2.image == r["id"], "a page's picture comes with it")
# Everything new survives an export and import of the spread file.
var t := main.data.get_table("weapons")
t.color = "#2f8a4f"
t.width = 300
t.roll_floor = "2"
e2.cost_value = "@gold"
e2.cost_amount = "3"
e2.add_pipe("loot")
e2.pipe_combine["loot"] = "max"
e2.pipe_pause["loot"] = true
e2.pipe_color["loot"] = "#c04a86"
var g := main.data.add_group("Outer", [])
var g2 := main.data.add_group("Inner", [])
g2.parent = g.id
var canon := JsonIO.canonical(JSON.parse_string(JSON.stringify(main.data.to_dict())))
var b2 := TowerBoard.new()
b2.load_dict(canon)
var t2 := b2.get_table("weapons")
var e3 := t2.entries[2]
_check(t2.color == "#2f8a4f" and t2.width == 300.0 and t2.roll_floor == "2", "card colour, size and limits import")
_check(e3.page == p.id and e3.image == r["id"] and e3.cost_amount == "3", "page links, pictures and costs import")
_check(e3.combine_for("loot") == "max" and e3.pipe_pause.has("loot") and e3.pipe_color.get("loot") == "#c04a86", "thread options import")
_check(b2.get_group(g2.id).parent == g.id and b2.book.size() == main.data.book.size() and b2.images.has(r["id"]), "nesting, the Book and pictures import")

1
tests/test_book.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://cadxlxxgym4mh

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for Builder (docs/PLAIN.md §2): effect and condition models
## that round-trip exactly with the stored text, the cases that don't fit a
## builder (ok: false), and known_values().
## Run: godot --headless --path . -s res://tests/test_builder.gd
var _failures := 0
func _init() -> void:
_test_parse_effect()
@ -15,21 +13,9 @@ func _init() -> void:
_test_condition_round_trips()
_test_condition_not_ok()
_test_known_values()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _eq(got: Variant, want: Variant, what: String) -> void:
if typeof(got) != typeof(want) or got != want:
_failures += 1
print(" ✗ %s: got %s, want %s" % [what, JSON.stringify(got), JSON.stringify(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
# ---------------------------------------------------------------- effects
@ -195,18 +181,18 @@ func _test_known_values() -> void:
order.append(v["name"])
for k in ["name", "label", "kind", "source"]:
_check(v.has(k), "%s has %s" % [v.get("name"), k])
_eq(order.slice(0, 3), ["@luck", "@town", "@skill_*"], "variable cards first, then collections")
_eq(order.slice(0, 3), ["@luck", "@town", "@skill_*"], "variable cards first, then spreads")
_eq(by["@luck"], {"name": "@luck", "label": "Luck", "kind": "number", "source": "variable", "table_id": "v_luck"}, "a variable card")
_eq(by["@town"]["kind"], "text", "text variable")
_eq(by["@town"]["label"], "Home Town", "label from the card")
_eq(by["@skill_*"]["kind"], "collection", "collection kind")
_eq(by["@skill_*"]["label"], "Skills", "collection label")
_eq(by["@skill_*"]["kind"], "collection", "spread kind")
_eq(by["@skill_*"]["label"], "Skills", "spread label")
_eq(by["@skill_pilot"]["label"], "Pilot", "member label")
_eq(by["@skill_pilot"]["collection"], "@skill_*", "member knows its collection")
_eq(by["@skill_pilot"]["collection"], "@skill_*", "member knows its spread")
_eq(by["@skill_pilot"]["source"], "effect", "effect target")
_eq(by["@traits"]["kind"], "list", "append makes a list")
_eq(by["@credits"]["kind"], "number", "number effect")
_eq(by["@weapon"]["source"], "save_as", "pipe save_as")
_eq(by["@weapon"]["source"], "save_as", "thread save_as")
_eq(by["hero"]["source"], "save_as", "[[ -> hero]] save")
_eq(by["@terms"]["kind"], "number", "number choice save_as")
_eq(by["tier"]["source"], "input", "card input")
@ -217,4 +203,4 @@ func _test_known_values() -> void:
_check(by.has("nat") and by.has("total") and by.has("effect"), "check chain names")
_check(not by.has("i") and not by.has("option"), "no loop, no dynamic pick")
_check(not by.has("@[option]") and not by.has("@x_*"), "no indirect or prefix targets")
_eq(Builder.known_values(null), [] as Array[Dictionary], "null board")
_eq(Builder.known_values(null), [] as Array[Dictionary], "null spread")

88
tests/test_card_size.gd Normal file
View file

@ -0,0 +1,88 @@
extends TestBase
## Resizable cards: the grip's corner hit area, a dragged width and list
## height (the list scrolls), saving them, and double-click back to automatic.
## Run: godot --headless --path . -s res://tests/test_card_size.gd -- --sample
func _init() -> void:
if not await start_main():
return
await _test_resize()
await _test_compact()
await _test_play_drag_selects()
finish()
func _test_resize() -> void:
var t := main.data.get_table("road")
var card := main.card_for("road")
var grip := card.grip
_check(grip != null and grip.get_index() == card.get_child_count() - 2 and card.shield.get_index() == card.get_child_count() - 1, "the grip, then the shield, are the card's last children")
_check(grip._has_point(grip.size - Vector2(4, 4)) and not grip._has_point(Vector2(4, 4)), "only the corner takes the mouse")
_check(not grip._has_point(grip.size + Vector2(5, 5)) and not grip._has_point(grip.size + Vector2(300, -4)) and not grip._has_point(Vector2(grip.size.x - 4, grip.size.y + 200)), "nothing outside the card is the resize corner")
var auto_w := card.size.x
card.set_user_size(380.0, 120.0)
await _frames()
_check(is_equal_approx(card.size.x, 380.0 + card.extra_width()), "the card takes the dragged width")
_check(card.list_scroll != null and is_equal_approx(card.list_scroll.size.y, 120.0), "a set height makes the results scroll")
_check(card.grip.get_index() == card.get_child_count() - 2, "the grip stays on top after a rebuild")
var d := t.to_dict()
_check(d.get("w") == 380 and d.get("list_h") == 120, "the size is saved")
var back := RollTable.from_dict(d)
_check(back.width == 380.0 and back.list_height == 120.0, "and loaded")
card.set_user_size(0.0, 0.0)
await _frames()
_check(is_equal_approx(card.size.x, auto_w) and card.list_scroll == null, "back to automatic")
## Zoomed out, cards take only drag, right-click and (in Play) a click to roll.
func _test_compact() -> void:
main.board.set_zoom(0.3)
await _frames()
var card := main.card_for("road")
_check(main.board.compact and card.shield.visible, "zoomed out, the shield covers the card")
_check(card.shield.tooltip_text.begins_with("Road Encounter") and card.shield.tooltip_text.contains("Click to roll"), "its name is a tooltip: " + card.shield.tooltip_text)
var click := InputEventMouseButton.new()
click.button_index = MOUSE_BUTTON_LEFT
click.pressed = true
click.global_position = Vector2(10, 10)
card.shield._gui_input(click)
var up := click.duplicate() as InputEventMouseButton
up.pressed = false
card.shield._gui_input(up)
await _frames(3)
_check(main.current.get("table_id", "") == "road" or str(main.current).contains("road"), "a click rolls it in Play")
main.board.set_zoom(1.0)
await _frames()
_check(not main.board.compact and not card.shield.visible, "zoomed in, the shield is gone")
## In Play, a left-drag on empty space draws a selection box; it doesn't pan.
func _test_play_drag_selects() -> void:
main.set_mode(Main.Mode.PLAY)
main.clear_selection()
main.board.set_zoom(0.5)
await _frames()
var card := main.card_for("road")
var r := card.get_global_rect()
var from := r.position - Vector2(20, 20) - main.board.global_position
var to := r.position + Vector2(40, 40) - main.board.global_position
var before := main.board.world.position
var press := InputEventMouseButton.new()
press.button_index = MOUSE_BUTTON_LEFT
press.pressed = true
press.position = from
main.board._gui_input(press)
var move := InputEventMouseMotion.new()
move.position = to
move.relative = to - from
main.board._gui_input(move)
var up := press.duplicate() as InputEventMouseButton
up.pressed = false
up.position = to
main.board._gui_input(up)
await _frames()
_check(main.board.world.position == before, "a left-drag doesn't pan")
_check(main.selection.has("road"), "it selects what the box touches")
main.clear_selection()

View file

@ -0,0 +1 @@
uid://bny2cvqtj0pgr

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for the new engine features of docs/PLAIN.md §3–§4: check
## cards, card inputs (pipe "with" values), collections, "nat" on roll tables,
## the why facts they record, the file format and the lint.
## Run: godot --headless --path . -s res://tests/test_check_inputs.gd
var _failures := 0
func _init() -> void:
_test_check_success_failure()
@ -24,22 +22,11 @@ func _init() -> void:
_test_nat()
_test_json()
_test_lint()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
# ---------------------------------------------------------------- helpers
func _eq(got: Variant, want: Variant, what: String) -> void:
if typeof(got) != typeof(want) or got != want:
_failures += 1
print(" ✗ %s: got %s, want %s" % [what, JSON.stringify(got), JSON.stringify(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
func _rng(seed_value: int = 1) -> RandomNumberGenerator:
@ -168,7 +155,7 @@ func _test_check_le_and_dice() -> void:
chk.entries[0].add_pipe("win")
chk.entries[1].add_pipe("lose")
b = _board([chk, _one("win", "Won with {total}"), _one("lose", "Lost")])
_eq(_texts(_roll(b, "chk")[0]), ["Success", "Won with 10"], "success pipes, total in text")
_eq(_texts(_roll(b, "chk")[0]), ["Success", "Won with 10"], "success threads, total in text")
func _test_check_errors() -> void:
@ -215,11 +202,11 @@ func _test_inputs_two_pipes() -> void:
bb.entries[0].set_pipe_with("show", {"tier": "3"})
var b := _board([start, a, bb, _show()])
var r := _roll(b, "start")
_eq(_texts(r[0]), ["go", "A", "Tier 2", "B", "Tier 3"], "two pipes pass different values")
_eq(_texts(r[0]), ["go", "A", "Tier 2", "B", "Tier 3"], "two threads pass different values")
var steps := Roller.flatten(r[0])
_eq(steps[2]["inputs"], {"tier": 2}, "step inputs")
_eq(steps[2]["why"][0], {"type": "input", "name": "tier", "value": 2, "from": "pipe"}, "input fact")
_eq(Describe.why(steps[2]["why"][0], b), "Tier was 2 (from the pipe)", "input sentence")
_eq(Describe.why(steps[2]["why"][0], b), "Tier was 2 (from the thread)", "input sentence")
_check(not (r[1] as RollContext).chain_vars.has("tier"), "tier is gone after the roll")
@ -334,7 +321,7 @@ func _test_inputs_snapshot() -> void:
func _test_inputs_loops_routers_choices_inline() -> void:
# Loop: each pass passes i.
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Loop")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Repeat")
loop.loop_expr = "3"
loop.entries[0].add_pipe("show")
loop.entries[0].set_pipe_with("show", {"tier": "i * 10"})
@ -363,15 +350,15 @@ func _test_inputs_loops_routers_choices_inline() -> void:
start.entries.append(e)
b = _board([start, router, _show()])
r = _roll(b, "start")
_eq(_texts(r[0]), ["go", "high", "Tier 200"], "router with inputs")
_eq(_texts(r[0]), ["go", "high", "Tier 200"], "branch with inputs")
var rstep: Dictionary = Roller.flatten(r[0])[1]
var types: Array = []
for f: Dictionary in rstep["why"]:
types.append(f["type"])
_eq(types, ["input", "case"], "router facts: input then case")
_eq(types, ["input", "case"], "branch facts: input then case")
_eq(Describe.why(rstep["why"][1], b), "Case 1 matched because Tier was 2 (needs 2 or more)", "case sentence with input")
e.set_pipe_with("route", {"tier": "1"})
_eq(_texts(_roll(b, "start")[0]), ["go", "low"], "router otherwise")
_eq(_texts(_roll(b, "start")[0]), ["go", "low"], "branch otherwise")
# Number choice: the Answer's pipe passes answer.
var ask := RollTable.create(RollTable.KIND_CHOICE, "ask", "Ask", "number")
ask.min_expr = "4"
@ -438,7 +425,7 @@ func _test_inputs_errors() -> void:
var r := _roll(b, "start")
_eq(_texts(r[0]), ["go", "Tier 1 extra 7"], "bad value uses the default; undeclared names still pass")
_eq(_errors(r[0]).size(), 1, "one error line")
_check(str(_errors(r[0])[0]).begins_with("Pipe input tier = 2 +"), "error names the input")
_check(str(_errors(r[0])[0]).begins_with("Thread input tier = 2 +"), "error names the input")
show.inputs = [{"name": "tier", "label": "", "default": "1 +"}]
e.set_pipe_with("show", {})
r = _roll(b, "start")
@ -450,7 +437,7 @@ func _test_inputs_errors() -> void:
func _test_collections() -> void:
var c := RollTable.create(RollTable.KIND_VARIABLE, "skills", "Skills", "collection")
_eq(c.var_type, "collection", "collection type")
_eq(c.var_type, "collection", "spread type")
_eq(c.var_name, "skill", "stem from the name")
_eq(c.initial, "", "no starting value")
_check(c.is_collection(), "is_collection")
@ -467,7 +454,7 @@ func _test_collections() -> void:
var r := _roll(b, "start", vars)
_eq(Describe.options(raise, b), "your Skills, level 1 or more", "options description")
var shown := Roller.variable_display(b, vars, c)
_check(shown["set"], "collection display is set")
_check(shown["set"], "spread display is set")
_check(str(shown["text"]).contains("Pilot") and str(shown["text"]).contains("Gun Combat"), "members listed: %s" % shown["text"])
var raised := int(_var(vars, "skill_pilot")) + int(_var(vars, "skill_gun_combat"))
_eq(raised, 4, "one member raised")
@ -478,7 +465,7 @@ func _test_collections() -> void:
fx.append(f)
_eq(fx.size(), 1, "options_where fact")
_eq(Describe.why(fx[0], b), "Offered 2 of 3 Skills (level 1 or more)", "options_where sentence")
_eq(Roller.variable_display(b, {}, c), {"text": "", "set": false, "error": ""}, "empty collection")
_eq(Roller.variable_display(b, {}, c), {"text": "", "set": false, "error": ""}, "empty spread")
# reset @skill_* still clears every member; a collection isn't declared.
var clear := _one("clear", "clear", "reset @skill_*")
b.tables.append(clear)
@ -491,7 +478,7 @@ func _test_collections() -> void:
_eq(_texts(_roll(b, "probe", v2)[0]), ["Pilot 1 / 1"], "list text and count")
# JSON.
var back := RollTable.from_dict(JSON.parse_string(JSON.stringify(c.to_dict())))
_eq(back.var_type, "collection", "collection survives JSON")
_eq(back.var_type, "collection", "spread survives JSON")
_eq(back.var_name, "skill", "stem survives JSON")
@ -572,7 +559,7 @@ func _test_json() -> void:
_eq(d["kind"], "check", "kind written")
_eq([d["check_dice"], d["check_mod"], d["check_cmp"], d["check_target"]], ["3d6", "dm(@str)", "le", "@skill"], "check keys")
_eq(d["inputs"], [{"name": "tier", "label": "Tier", "default": "1"}, {"name": "bonus"}], "inputs written without empty keys")
_eq(d["entries"][0]["pipes"], [{"table": "next", "with": {"level": "tier + 1"}}], "pipe with written")
_eq(d["entries"][0]["pipes"], [{"table": "next", "with": {"level": "tier + 1"}}], "thread with written")
var pd := plain.to_dict()
for k in ["check_dice", "check_mod", "check_cmp", "check_target", "inputs"]:
_check(not pd.has(k), "default %s left out" % k)
@ -639,9 +626,9 @@ func _test_lint() -> void:
_check(not target.is_empty() and target["level"] == "error" and target["kind"] == "check", "bad check target")
_check(not find.call("Check modifier dm(@str").is_empty(), "bad check modifier")
_check(not find.call("A check needs a Success").is_empty(), "missing Failure entry")
var bad_with: Dictionary = find.call("Pipe input tier = 2 +")
var bad_with: Dictionary = find.call("Thread input tier = 2 +")
_check(not bad_with.is_empty() and bad_with["level"] == "error" and bad_with["entry_id"] == "e1", "bad with expression is an error")
var hint: Dictionary = find.call("The pipe to Show passes extra")
var hint: Dictionary = find.call("The thread to Show passes extra")
_check(not hint.is_empty() and hint["level"] == "hint" and hint["kind"] == "inputs", "undeclared input is a hint")
_check(not find.call("Input \"Bad Name\" isn't a name").is_empty(), "bad input name")
_check(not find.call("Input Bad Name default").is_empty(), "bad input default")
@ -654,7 +641,7 @@ func _test_lint() -> void:
var hint_level := false
for p: Dictionary in probs:
kinds[p["kind"]] = true
if str(p["text"]).begins_with("The pipe to Show passes extra"):
if str(p["text"]).begins_with("The thread to Show passes extra"):
hint_level = p.get("level", "") == "hint"
_check(kinds.has("check") and kinds.has("inputs"), "static checks have check and inputs kinds: %s" % [kinds.keys()])
_check(hint_level, "static check keeps the hint level")
@ -662,4 +649,4 @@ func _test_lint() -> void:
var good := _board([RollTable.create(RollTable.KIND_CHECK, "c", "C"), _show()])
good.get_table("c").entries[0].add_pipe("show")
good.get_table("c").entries[0].set_pipe_with("show", {"tier": "total"})
_eq(BoardTester.static_checks(good), [] as Array[Dictionary], "clean board")
_eq(BoardTester.static_checks(good), [] as Array[Dictionary], "clean spread")

View file

@ -1,24 +1,10 @@
extends SceneTree
extends TestBase
## The choice pop-up's minimize pill and hover preview, and TablePreview.
## Run: godot --headless --path . -s res://tests/test_choice_dialog.gd -- --sample
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to roll.")
quit(2)
if not await start_main():
return
# Headless windows are tiny; give the app a real size.
main.set_anchors_preset(Control.PRESET_TOP_LEFT)
@ -36,8 +22,7 @@ func _init() -> void:
await _test_cancel_from_pill()
await _test_state_kept()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _add_tables() -> void:
@ -131,7 +116,7 @@ func _test_preview_content() -> void:
_check(d != null and d.kind == "pick", "the pick question opens")
if d == null:
return
_check(d.board == main.data, "the dialog finds the board")
_check(d.board == main.data, "the dialog finds the spread")
# Plain words (the default): effects and counts read as phrases.
_check(d.plain, "previews read in plain words by default")
var pp := d.preview_for_option(0)
@ -144,11 +129,11 @@ func _test_preview_content() -> void:
d.plain = false
# Option 1 pipes to a ranged table, twice.
var p := d.preview_for_option(0)
_check(p != null, "an option that pipes on has a preview")
_check(p != null, "an option that threads on has a preview")
_check(_has(p, "A **busy** place") or _has(p, "busy"), "the preview shows the option's details")
_check(_has(p, "@gold -= 5"), "the preview lists the option's effects")
_check(_has(p, "Loot") and _has(p, "d6"), "the piped table's name and dice show")
_check(_has(p, "×2"), "the pipe count shows")
_check(_has(p, "×2"), "the thread count shows")
_check(_has(p, "What the stalls sell"), "the piped table's details show")
_check(_has(p, "1–2") and _has(p, "3–5") and _has(p, "33%"), "ranged entries show their range and chance")
_check(_has(p, TablePreview.NEXT_HINT), "an entry that leads further gets a next-table hint")
@ -159,7 +144,7 @@ func _test_preview_content() -> void:
var q := d.preview_for_option(1)
_check(_has(q, "Which way?") and _has(q, "Choice card"), "a choice target shows its kind")
_check(_has(q, "Asks: Left or right?"), "a choice target shows its question")
_check(_has(q, "×@terms"), "an expression pipe count shows")
_check(_has(q, "×@terms"), "an expression thread count shows")
q.free()
_check(d.preview_for_option(2) == null, "an option with nothing to show has no preview")
main.rolling.cancel_choice()
@ -197,7 +182,7 @@ func _test_minimize() -> void:
d._input(_key(KEY_M))
_check(d.minimized and not d.card.is_visible_in_tree(), "M hides the dialog")
_check(d.pill.visible and _has(d.pill, "Question waiting: Where to?"), "the pill names the question")
_check(d.mouse_filter == Control.MOUSE_FILTER_IGNORE, "the board gets the mouse while minimized")
_check(d.mouse_filter == Control.MOUSE_FILTER_IGNORE, "the spread gets the mouse while minimized")
_check(not d._dim.visible, "the dim goes away")
_check(not d.preview_panel.visible, "the preview hides")
_check(not d.reply.finished and main.rolling.pending_choice() == d, "the question is still waiting")
@ -284,9 +269,3 @@ func _test_state_kept() -> void:
_check(not d.minimized and int(d._spin.value) == 9, "the typed value survives minimize and restore")
d.answer(null)
await process_frame
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

46
tests/test_demos.gd Normal file
View file

@ -0,0 +1,46 @@
extends TestBase
## Help's demo spreads: every demo builds and rolls cleanly, Help links to
## them, and opening one shows it unsaved with a way back.
## Run: godot --headless --path . -s res://tests/test_demos.gd -- --sample
func _init() -> void:
if not require_sample():
return
_test_builds()
if not await start_main():
return
await _test_open()
finish()
func _test_builds() -> void:
var rng := RandomNumberGenerator.new()
for key: String in DemoSpreads.TITLES:
var b := DemoSpreads.build(key)
_check(not b.tables.is_empty() and b.id == "demo-" + key, "demo %s builds" % key)
var start := b.tables[0] if b.tables[0].kind != RollTable.KIND_VARIABLE else b.tables[1]
var tree := Roller.roll(b, start.id, rng)
var bad := Roller.flatten(tree, []).filter(func(s: Dictionary) -> bool: return s.get("stop", false) and not s.get("deck_empty", false))
_check(bad.is_empty(), "demo %s rolls cleanly: %s" % [key, str(bad.map(func(s: Dictionary) -> String: return str(s.get("text", ""))))])
var book := DemoSpreads.build("book")
_check(book.page_uses("p_sword") == 2, "the Book demo links two results to its page")
var linked := book.get_table("goblin").entries[1]
book.sync_page("p_sword")
_check(linked.text.contains("Holy Light"), "and they show the page's text")
var help := FileAccess.get_file_as_string("res://help/topics.txt")
var re := RegEx.create_from_string("\\[demo\\]([a-z_]+)\\[/demo\\]")
for m in re.search_all(help):
_check(DemoSpreads.has(m.get_string(1)), "help's demo link %s exists" % m.get_string(1))
_check(HelpDialog._inline("[demo]deck[/demo]").contains("url=demo:deck"), "a demo marker becomes a link")
func _test_open() -> void:
var before := main.data.id
main.demo.open("deck")
await _frames(3)
_check(main.data.id == "demo-deck" and main.demo.active() and not main._saving_enabled, "a demo opens unsaved, with its bar")
main.demo.back()
await _frames(3)
_check(not main.demo.active() and main.data.id == before, "Back to my spread returns")

1
tests/test_demos.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://b3vsrgew5p46s

View file

@ -1,12 +1,10 @@
extends SceneTree
extends TestBase
## Headless checks for Describe (docs/PLAIN.md §1 and §3): plain phrases for
## every effect op, the condition forms, dice, dynamic options, pipes, check
## cards and why facts, with labels from variable cards, collections and card
## inputs, and the fallbacks to the original text.
## Run: godot --headless --path . -s res://tests/test_describe.gd
var _failures := 0
func _init() -> void:
_test_labels()
@ -20,22 +18,11 @@ func _init() -> void:
_test_why_from_rolls()
_test_fallbacks()
_test_rules_view()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
# ---------------------------------------------------------------- helpers
func _eq(got: Variant, want: Variant, what: String) -> void:
if typeof(got) != typeof(want) or got != want:
_failures += 1
print(" ✗ %s: got %s, want %s" % [what, JSON.stringify(got), JSON.stringify(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
func _var_card(id: String, name: String, var_name: String, type: String = "number") -> RollTable:
@ -74,25 +61,25 @@ func _board() -> TowerBoard:
func _test_labels() -> void:
var b := _board()
_eq(b.get_table("v_skills").var_name, "skill", "a collection's stem drops the final s")
_eq(b.get_table("v_skills").var_name, "skill", "a spread's stem drops the final s")
_eq(Describe.label("@str", b), "Strength", "variable card label")
_eq(Describe.label("@STR", b), "Strength", "labels ignore case")
_eq(Describe.label("@skill_gun_combat", b), "Gun Combat", "collection member label")
_eq(Describe.label("@skill_*", b), "Skills", "collection label")
_eq(Describe.label("@contact_*", b), "Contact values", "a prefix without a collection")
_eq(Describe.label("@soc_x", b), "Soc X", "no collection: pretty name")
_eq(Describe.label("@skill_gun_combat", b), "Gun Combat", "spread member label")
_eq(Describe.label("@skill_*", b), "Skills", "spread label")
_eq(Describe.label("@contact_*", b), "Contact values", "a prefix without a spread")
_eq(Describe.label("@soc_x", b), "Soc X", "no spread: pretty name")
_eq(Describe.label("@dex", b), "Dex", "unlabelled value")
_eq(Describe.label("tier", b), "Tier", "input label")
_eq(Describe.label("answer", b), "Answer", "chain label")
_eq(Describe.label("nat", b), "Natural roll", "nat label")
_eq(Describe.label("@[option]", b), "Chosen value", "indirect label")
_eq(Describe.label("@str", null), "Str", "no board")
_eq(Describe.label("@str", null), "Str", "no spread")
# The variable card wins over a collection.
b.tables.append(_var_card("v_pilot", "Piloting", "skill_pilot"))
_eq(Describe.label("@skill_pilot", b), "Piloting", "card label before collection")
_eq(Describe.label("@skill_pilot", b), "Piloting", "card label before spread")
# A collection doesn't declare its stem as a variable.
var ctx := Roller.new_context(b, RandomNumberGenerator.new(), {})
_check(ctx.declared("skill") == null, "a collection isn't a declared variable")
_check(ctx.declared("skill") == null, "a spread isn't a declared variable")
_check(ctx.declared("str") != null, "a number card is")
@ -101,7 +88,7 @@ func _test_labels() -> void:
func _test_effects() -> void:
var b := _board()
_eq(Describe.effect("@luck -= 1", b), "Luck −1", "subtract")
_eq(Describe.effect("@skill_pilot += 1", b), "Pilot +1", "add to a collection member")
_eq(Describe.effect("@skill_pilot += 1", b), "Pilot +1", "add to a spread member")
_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("@town = \"Millbrook\"", b), "Town = Millbrook", "set text")
@ -112,7 +99,7 @@ func _test_effects() -> void:
_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), "Remove Psionic from Traits", "remove")
_eq(Describe.effect("reset @skill_*", b), "Reset all Skills", "reset a collection")
_eq(Describe.effect("reset @skill_*", b), "Reset all Skills", "reset a spread")
_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 @dex", b), "Clear Dex", "reset an undeclared value")
@ -121,7 +108,7 @@ func _test_effects() -> void:
pick.options_from = "@skill_*"
_eq(Describe.effect("@[option] += 1", b, pick), "Chosen skill +1", "indirect on a skills card")
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 spread")
_eq(Describe.effect("hero = \"Bob\"", b), "Hero = Bob", "chain target")
_eq(Describe.effects("@luck -= 1; @str = 7\nreset @skill_*", b), ["Luck −1", "Strength = 7", "Reset all Skills"] as Array[String], "effects field")
@ -144,7 +131,7 @@ func _test_conditions() -> void:
_eq(Describe.condition("not @commissioned", b), "Commissioned is not set", "unset")
_eq(Describe.condition("option_value >= 1", b), "Chosen value is 1 or more", "chain value")
_eq(Describe.condition("tier = 3", b), "Tier is 3", "input")
_eq(Describe.condition("@skill_pilot >= 1", b), "Pilot is 1 or more", "collection member")
_eq(Describe.condition("@skill_pilot >= 1", b), "Pilot is 1 or more", "spread member")
_eq(Describe.condition("", b), "", "empty")
@ -171,14 +158,14 @@ func _test_options() -> void:
var t := RollTable.create(RollTable.KIND_CHOICE, "raise", "Raise", "pick")
_eq(Describe.options(t, b), "", "fixed card")
t.options_from = "@skill_*"
_eq(Describe.options(t, b), "your Skills", "collection source")
_eq(Describe.options(t, b), "your Skills", "spread source")
t.options_where = "option_value >= 1"
_eq(Describe.options(t, b), "your Skills, level 1 or more", "level filter")
t.options_where = "option != @last"
_eq(Describe.options(t, b), "your Skills, where Chosen option is not Last", "other filter")
t.options_where = ""
t.options_from = "@contact_*"
_eq(Describe.options(t, b), "your Contact values", "prefix without collection")
_eq(Describe.options(t, b), "your Contact values", "prefix without spread")
t.options_from = "@traits"
_eq(Describe.options(t, b), "your Traits", "list source")
t.options_from = "skills"
@ -191,7 +178,7 @@ func _test_pipes() -> void:
var b := _board()
var e := TableEntry.new("e1", "x")
e.add_pipe("tier3")
_eq(Describe.pipe(e, "tier3", b), "", "plain pipe")
_eq(Describe.pipe(e, "tier3", b), "", "plain thread")
e.set_pipe_with("tier3", {"tier": "3"})
e.set_pipe_when("tier3", "@luck >= 2")
_eq(Describe.pipe(e, "tier3", b), "Tier 3 · only if Luck is 2 or more", "input and condition")
@ -261,7 +248,7 @@ func _test_why_facts() -> void:
_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}), "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": "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 thread)", "input")
_eq(W.call({"type": "input", "name": "tier", "value": 1, "from": "default"}), "Tier was 1 (default)", "input default")
_eq(W.call({"type": "show_if", "hidden": 2, "chosen_hidden": false}), "2 options hidden by their conditions", "show_if")
_eq(W.call({"type": "options_where", "from": "@skill_*", "expr": "option_value >= 1", "kept": 3, "total": 5}),

View file

@ -1,9 +1,7 @@
extends SceneTree
extends TestBase
## if(condition, then, else) in expressions, and the refused inline ternary.
## Run: godot --headless --path . -s res://tests/test_expr_if.gd -- --sample
var _failures := 0
func _init() -> void:
_value("if(1 > 2, 10, 20)", 20)
@ -16,16 +14,9 @@ func _init() -> void:
_check(str(r.get("error", "")).contains("if(condition"), "\"%s\" is refused with a hint (got %s)" % [src, r])
_check(Expr.check(src) != "", "Expr.check flags \"%s\"" % src)
_check(Expr.check("if(@str > 8, 1, 0)") == "", "if() with a variable passes the check")
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _value(src: String, want: Variant) -> void:
var r := Expr.evaluate(src, null)
_check(str(r.get("error", "")) == "" and r.get("value") == want, "%s = %s (got %s)" % [src, want, r])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,23 +1,11 @@
extends SceneTree
extends TestBase
## Fast roll (Shift-click): the whole result shows at once, with no animation.
## Run: godot --headless --path . -s res://tests/test_fast_roll.gd -- --sample
## (--sample keeps the app from reading or writing saved collections.)
var _failures := 0
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return
var main: Main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to roll.")
quit(2)
if not await start_main():
return
main.rng.seed = 7
@ -27,7 +15,7 @@ func _init() -> void:
var all: Array = main.current["all"]
_check(main.current.get("done", false), "fast roll is done immediately")
_check(main.current["steps"].size() == all.size(), "fast roll shows every step at once")
_check(main.board.pipes.pulse_key == "", "fast roll sends no bead down the pipes")
_check(main.board.pipes.pulse_key == "", "fast roll sends no bead down the threads")
var lit_steps := 0
for s: Dictionary in all:
if s.has("entry_id") and not s.get("stop", false):
@ -36,7 +24,7 @@ func _init() -> void:
_check(main.lit_entries.size() == lit_steps, "only the path's results are lit")
# Chains from Wilderness Travel are a single line, so n results have n - 1 pipes.
_check(main.lit_pipes.size() == maxi(0, lit_steps - 1),
"each link in the chain lights its pipe (%d pipes, %d results)" % [main.lit_pipes.size(), lit_steps])
"each link in the chain lights its thread (%d threads, %d results)" % [main.lit_pipes.size(), lit_steps])
for c in main.cards.values():
_check(not (c as TableCard)._rolling, "no card is left tumbling")
@ -51,11 +39,4 @@ func _init() -> void:
await process_frame
_check(main.current.get("done", false) and main.current.get("fast", false), "the interrupted roll doesn't overwrite the fast result")
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
finish()

View file

@ -1,28 +1,17 @@
extends SceneTree
extends TestBase
## Group cards: the model and file format, membership, and in the app the
## frame, collapsing (hidden members, re-routed pipes, lit results, choice
## pop-ups), moving, dropping cards in and out, ungroup and delete.
## Run: godot --headless --path . -s res://tests/test_groups.gd -- --sample
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_model()
_test_json()
_test_import()
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
main.rng.seed = 5
await _load(_board_dict())
@ -30,11 +19,12 @@ func _init() -> void:
await _test_collapse()
await _test_lit_and_choice()
await _test_move()
await _test_box_select()
await _test_nested()
await _test_drop_in_and_out()
await _test_collapse_all_and_fit()
await _test_ungroup_and_delete()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
## start -> a (in G) -> b (choice, in G) -> out
@ -83,7 +73,7 @@ func _test_model() -> void:
_check(gone == ["b"] and b.get_table("b") == null and b.get_group(g.id) == null, "delete_group removes the group and its tables")
b.ungroup(h.id)
_check(b.groups.is_empty(), "ungroup removes the group")
_check(b.get_table("start").entries[0].pipes.is_empty(), "pipes into deleted tables go")
_check(b.get_table("start").entries[0].pipes.is_empty(), "threads into deleted tables go")
func _test_json() -> void:
@ -96,7 +86,7 @@ func _test_json() -> void:
g.size = Vector2(700, 300)
var text := b.to_json()
var b2 := TowerBoard.new()
_check(b2.load_json(text), "a board with groups loads")
_check(b2.load_json(text), "a spread with groups loads")
_check(b2.groups.size() == 1, "one group back")
var g2 := b2.groups[0]
_check(g2.id == g.id and g2.name == "Middle" and g2.collapsed and g2.details == g.details, "id, name, collapsed and details round-trip")
@ -106,7 +96,7 @@ func _test_json() -> void:
# Old files without groups load unchanged, and save without a groups key.
var old := TowerBoard.new()
var src := SampleBoard.create().to_dict()
_check(not src.has("groups"), "boards without groups write no groups key")
_check(not src.has("groups"), "spreads without groups write no groups key")
_check(old.load_dict(src) and old.groups.is_empty(), "an old file loads with no groups")
_check(old.to_json() == SampleBoard.create().to_json() or JSON.parse_string(old.to_json())["tables"].size() == src["tables"].size(), "an old file saves the same tables")
var v1 := TowerBoard.new()
@ -135,7 +125,7 @@ func _test_import() -> void:
_check(r["ok"] and gl[0]["members"] == ["a", "b"], "import maps members by id or name and drops unknown ones: %s" % str(gl[0]["members"]))
_check(str(r["warnings"]).contains("ghost"), "import warns about unknown members")
var b := TowerBoard.new()
_check(b.load_dict(r["collection"]) and b.groups.size() == 1 and b.groups[0].collapsed, "an imported collection keeps its groups")
_check(b.load_dict(r["collection"]) and b.groups.size() == 1 and b.groups[0].collapsed, "an imported spread keeps its groups")
var res := JsonIO.import_json(JsonIO.export_json(b.to_dict()))
_check(res["ok"] and res["collection"]["groups"][0]["members"] == ["a", "b"], "export and import round-trip groups")
@ -157,7 +147,7 @@ func _test_group_from_selection() -> void:
_check(g != null and g.members == ["a", "b"], "Group makes a group of the selection")
_check(main.selection.is_empty() and not main.editing._sel_bar.visible, "grouping clears the selection")
var node := main.group_node(g.id)
_check(node != null and node.get_parent() == main.board.groups, "an expanded group's frame sits behind the pipes")
_check(node != null and node.get_parent() == main.board.groups, "an expanded group's frame sits behind the threads")
var ra := Rect2(main.card_for("a").position, main.card_for("a").size)
var rb := Rect2(main.card_for("b").position, main.card_for("b").size)
_check(g.rect().encloses(ra) and g.rect().encloses(rb), "the frame fits around its members")
@ -178,12 +168,12 @@ func _test_collapse() -> void:
_check(main.card_for("start").visible and main.card_for("out").visible, "other cards stay")
var paths: Dictionary = main.board.pipes._paths
var into: PackedVector2Array = paths.get("start:e1>a", PackedVector2Array())
_check(not into.is_empty() and into[into.size() - 1].distance_to(node.inlet_point()) < 0.5, "a pipe into a member attaches to the group's inlet")
_check(not into.is_empty() and into[into.size() - 1].distance_to(node.inlet_point()) < 0.5, "a thread into a member attaches to the group's inlet")
var outp: PackedVector2Array = paths.get("b:e1>out", PackedVector2Array())
_check(not outp.is_empty() and is_equal_approx(outp[0].x, node.position.x + node.size.x), "a pipe out of a member leaves from the group's right edge")
_check(not outp.is_empty() and is_equal_approx(outp[0].x, node.position.x + node.size.x), "a thread out of a member leaves from the group's right edge")
_check(outp.is_empty() or outp[outp.size() - 1].distance_to(main.card_for("out").inlet_point()) < 0.5, "and still reaches its target")
_check(not paths.has("a:e1>b"), "pipes inside the collapsed group aren't drawn")
_check(main.board.pipes.pipe_at(into[into.size() / 2], 3.0) == "", "re-routed pipes can't be clicked")
_check(not paths.has("a:e1>b"), "threads inside the collapsed group aren't drawn")
_check(main.board.pipes.pipe_at(into[into.size() / 2], 3.0) == "", "re-routed threads can't be clicked")
var gp: Dictionary = main.board.pipes.group_ports
_check(not gp.is_empty(), "the group card gets an outlet port")
_check(main.data.to_dict()["groups"][0]["collapsed"] == true, "collapsed is saved")
@ -211,7 +201,7 @@ func _test_lit_and_choice() -> void:
break
_check(main.current.get("done", false), "the roll finishes after the answer")
_check(main.is_entry_lit("b", "e2") and main.is_entry_lit("out", "e1"), "the picked option and what follows are lit")
_check(main.lit_pipes.has("b:e2>out"), "the pipe out of the group is lit")
_check(main.lit_pipes.has("b:e2>out"), "the thread out of the group is lit")
node = main.group_node(g.id)
var keys := main.lit_keys_for_group(g)
_check(keys.has("b:e2") and (keys.has("a:e1") or keys.has("a:e2")), "the group knows its members' lit results: %s" % str(keys))
@ -222,7 +212,7 @@ func _test_lit_and_choice() -> void:
if row and not outp.is_empty():
var to_world := main.board.world.get_global_transform().affine_inverse()
var mid := (to_world * row.get_global_rect().get_center()).y
_check(absf(outp[0].y - mid) < 1.0, "a lit result's pipe leaves from its row on the group card")
_check(absf(outp[0].y - mid) < 1.0, "a lit result's thread leaves from its row on the group card")
main.prompt_hook = func(_req: Dictionary) -> Variant: return 0
# Fast roll: lights at once.
main.start_roll("start", true)
@ -331,7 +321,7 @@ func _test_ungroup_and_delete() -> void:
(b as Button).pressed.emit()
await process_frame
_check(main.data.groups.is_empty() and main.data.get_table("a") == null and main.data.get_table("b") == null, "deleting the group deletes its cards")
_check(main.card_for("a") == null and main.data.get_table("start").entries[0].pipes.is_empty(), "their cards and the pipes into them go")
_check(main.card_for("a") == null and main.data.get_table("start").entries[0].pipes.is_empty(), "their cards and the threads into them go")
_check(main.top_bar._toast.visible and main.top_bar._toast_undo.visible, "with an undo toast")
main.top_bar._undo()
await process_frame
@ -339,12 +329,68 @@ func _test_ungroup_and_delete() -> void:
## True when a table has a card on show (hidden members have no card at all).
## A drag box picks up a collapsed group and a card; dragging the group moves both.
func _test_box_select() -> void:
var g := _group()
var was_collapsed := g.collapsed
if not g.collapsed:
main.toggle_group(g.id)
for i in 3:
await process_frame
main.clear_selection()
var node := main.group_node(g.id)
var loose := main.card_for("loose")
main.select_in_rect(Rect2(node.position, node.size).merge(Rect2(loose.position, loose.size)))
_check(main.selecting.groups.has(g.id) and main.selection.has("loose"), "a drag box selects groups and cards")
_check(main.editing._sel_label.text.ends_with(", 1 group selected"), "the bar counts both: " + main.editing._sel_label.text)
var gp := g.position
var lp := loose.table.position
main.selecting.drag_group(g.id, Vector2(30, 10))
_check(g.position == gp + Vector2(30, 10) and loose.table.position == lp + Vector2(30, 10), "dragging a selected group moves the whole selection")
main.selecting.drag_group(g.id, Vector2(-30, -10))
main.clear_selection()
_check(main.selecting.groups.is_empty(), "clearing the selection drops the groups")
if not was_collapsed:
main.toggle_group(g.id)
for i in 3:
await process_frame
## A group inside a group: grouping a selected group, collapsing the outer one
## hides everything, moving moves all, ungrouping hands things to the outer group.
func _test_nested() -> void:
var inner := _group()
main.clear_selection()
main.selecting.set_group(inner.id, true)
main.editing.toggle_selected("loose")
var outer := main.grouping.group_selection()
await _frames(3)
_check(outer != null and inner.parent == outer.id and outer.members == ["loose"], "grouping a group puts it inside the new one")
_check(main.data.tables_in(outer.id).size() == inner.members.size() + 1, "the outer group holds every card inside")
if not outer.collapsed:
main.toggle_group(outer.id)
await _frames(3)
_check(main.group_node(inner.id) == null and main.card_for("a") == null and main.card_for("loose") == null, "collapsing the outer group hides the inner group and all cards")
_check(main.hidden_groups().get("a") == main.group_node(outer.id), "the outer group stands in for cards deep inside")
var tpl := TemplateKit.make(main.data, [], "group", "Nest", "", [outer.id])
_check((tpl["groups"] as Array).size() == 2 and (tpl["groups"][1] as Dictionary).get("parent_at") == 0, "a group template keeps the inner group")
var r := TemplateKit.instantiate(tpl, {}, main.data, Vector2(3000, 0))
_check((r["groups"][1] as TableGroup).parent == (r["groups"][0] as TableGroup).id, "and inserting it nests again")
main.toggle_group(outer.id)
await _frames(3)
var before := inner.position
main.move_group(outer.id, Vector2(10, 0))
_check(inner.position == before + Vector2(10, 0), "moving the outer group moves the inner one")
main.move_group(outer.id, Vector2(-10, 0))
main.ungroup(outer.id)
await _frames(3)
_check(inner.parent == "" and main.data.group_of("loose") == null, "ungrouping hands the contents back to the spread")
var d := main.data.to_dict()
var back := TowerBoard.new()
back.load_dict(d)
_check(back.groups.size() == main.data.groups.size(), "groups survive saving")
func _shown(tid: String) -> bool:
var c := main.card_for(tid)
return c != null and c.visible
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print("FAIL ", what)

View file

@ -1,27 +1,15 @@
extends SceneTree
extends TestBase
## 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 _failures := 0
var main: Main
var insp: Inspector
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
main.size = Vector2(1440, 900)
@ -43,25 +31,9 @@ func _init() -> void:
await _test_dirty_and_save()
await _test_other_cards()
await _test_add_kinds()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _check(ok: bool, what: String) -> void:
if ok:
print(" ok %s" % what)
else:
_failures += 1
print(" FAIL %s" % what)
func _eq(a: Variant, b: Variant, what: String) -> void:
_check(a == b, "%s (got %s, want %s)" % [what, JSON.stringify(a), JSON.stringify(b)])
func _frames(n: int = 2) -> void:
for i in n:
await process_frame
func _board_dict() -> Dictionary:
@ -83,7 +55,7 @@ func _board_dict() -> Dictionary:
{"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": []},
{"id": "rt", "name": "Router", "kind": "router", "x": 1000, "y": 40, "entries": [
{"id": "rt", "name": "Branch", "kind": "router", "x": 1000, "y": 40, "entries": [
{"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"}]},
@ -114,21 +86,21 @@ 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")
_check(_has_text(insp, "Select a card, a result or a pipe to edit it."), "the empty state says how to select")
_check(_has_text(insp, "Select a card, a result or a thread to edit it."), "the empty state says how to select")
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")
_check(insp.effects != null and insp.pipe_parts.has("loot") and insp.pipe_parts.has("curios"), "a result shows its effects and both pipes")
_check(insp.effects != null and insp.pipe_parts.has("loot") and insp.pipe_parts.has("curios"), "a result shows its effects and both threads")
main.inspecting.select_pipe("beyond:e2>loot")
_eq(insp.selection.get("to"), "loot", "select_pipe")
_eq(insp.pipe_parts.keys(), ["loot"], "a pipe shows only its own box")
_eq(main.board.pipes.select_key, "beyond:e2>loot", "the selected pipe is highlighted on the board")
_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")
main.clear_inspector()
_check(insp.selection.is_empty(), "clear_inspector")
main.open_pipe_options("beyond:e2>curios", Vector2(10, 10))
_eq(insp.selection.get("to"), "curios", "clicking a pipe in Build selects it in the inspector")
_eq(insp.selection.get("to"), "curios", "clicking a thread in Build selects it in the inspector")
main.request_table_settings("loot")
_eq(insp.selection, {"kind": "card", "tid": "loot"}, "Table settings… selects the card")
main.select_result("beyond", "nope")
@ -274,7 +246,7 @@ func _test_otherwise() -> void:
main.select_result("beyond", "e2")
var loot_other: CheckBox = insp.pipe_parts["loot"]["otherwise"]
var cur_other: CheckBox = insp.pipe_parts["curios"]["otherwise"]
_check(cur_other.button_pressed and not cur_other.disabled, "the otherwise pipe is ticked")
_check(cur_other.button_pressed and not cur_other.disabled, "the otherwise thread is ticked")
_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")
@ -300,7 +272,7 @@ func _test_otherwise() -> void:
func _test_pipe_inputs() -> void:
print("Pipe inputs")
print("Thread inputs")
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")
@ -360,13 +332,13 @@ func _test_check() -> void:
func _test_collection() -> void:
print("Collection members")
print("Spread members")
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")
_eq(main.persistent_vars.get("skill_new", {}).get("value"), 0, "it's the board value @skill_new = 0")
_eq(main.persistent_vars.get("skill_new", {}).get("value"), 0, "it's the spread value @skill_new = 0")
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")
@ -377,7 +349,7 @@ func _test_collection() -> void:
_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")
_eq(Describe.label("@skill_pilot", main.data), "Pilot", "(members are labelled through the collection)")
_eq(Describe.label("@skill_pilot", main.data), "Pilot", "(members are labelled through the spread)")
await _frames()
@ -387,15 +359,15 @@ func _test_options() -> void:
var t := _t("learn")
_check(not t.is_dynamic(), "a fixed list at first")
var err := InspectorCard.set_options(insp, "@skill_*", "")
_eq(err, "", "From a collection")
_eq(err, "", "From a spread")
_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"]
_eq(picker.value, "@skill_*", "the source picker shows the collection")
_check(picker.items().any(func(it: Dictionary) -> bool: return it["name"] == "@skill_*"), "it offers collections")
_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")
_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")
@ -407,14 +379,14 @@ func _test_value_picker() -> void:
var p := ValuePicker.new(main, "")
root.add_child(p)
var names := p.items().map(func(it: Dictionary) -> String: return it["name"])
_check(names.has("@luck") and names.has("@str"), "it lists the board's values")
_check(names.has("@luck") and names.has("@str"), "it lists the spread's values")
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")
_check(names.has("@skill_pilot"), "collection members with values are offered")
_check(not names.has("@skill_*"), "collection patterns only where they fit")
_check(names.has("@skill_pilot"), "spread members with values are offered")
_check(not names.has("@skill_*"), "spread patterns only where they fit")
p.allow_patterns = true
_check(p.items().any(func(it: Dictionary) -> bool: return it["name"] == "@skill_*" and it["group"] == "Collections"), "grouped under Collections")
_check(p.items().any(func(it: Dictionary) -> bool: return it["name"] == "@skill_*" and it["group"] == "Collections"), "grouped under Spreads")
_eq(p.filtered("lu").map(func(it: Dictionary) -> String: return it["name"]), ["@luck"], "search by label")
p.open_menu()
await _frames()
@ -428,12 +400,12 @@ func _test_value_picker() -> void:
var n := p.create_value("Fame", true)
_eq(n, "@fame", "+ New value… names it")
var card := main.variable_card("fame")
_check(card != null and card.name == "Fame", "Show on the board adds a variable card")
_check(card != null and card.name == "Fame", "Show on the spread adds a variable card")
_eq(got.back(), "@fame", "and picks it")
var steps := main.undo_redo.edits.undo_stack.size()
n = p.create_value("Mood", false)
_eq(n, "@mood", "without a card")
_check(main.variable_card("mood") == null and main.undo_redo.edits.undo_stack.size() == steps, "no card, no board change")
_check(main.variable_card("mood") == null and main.undo_redo.edits.undo_stack.size() == steps, "no card, no spread change")
p.queue_free()
await _frames()
@ -499,7 +471,7 @@ func _test_dirty_and_save() -> void:
main._saving_enabled = true
main._save_timer.stop()
insp.apply_settings({"tags": "loot, treasure"})
_check(main.edit_rev > rev, "an inspector edit marks the board dirty")
_check(main.edit_rev > rev, "an inspector edit marks the spread dirty")
_check(not main._save_timer.is_stopped(), "and schedules a save")
main._save_timer.stop()
main._saving_enabled = false
@ -507,7 +479,7 @@ func _test_dirty_and_save() -> void:
var copy := TowerBoard.new()
copy.load_dict(main.data.to_dict())
_eq(copy.get_table("loot").tags, ["loot", "treasure"], "the saved form has it")
_eq(copy.get_table("beyond").find_entry("e2").with_for("loot"), {"tier": "3"}, "pipe inputs are saved")
_eq(copy.get_table("beyond").find_entry("e2").with_for("loot"), {"tier": "3"}, "thread inputs are saved")
main.undo_redo._commit_edits()
_check(main.undo_redo.can_undo(), "and it's an undo step")
await _frames()
@ -533,7 +505,7 @@ func _test_other_cards() -> void:
_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")
_eq(Roller.lint_router(rt), [], "the router is fine")
_eq(Roller.lint_router(rt), [], "the branch is fine")
# 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")
@ -557,13 +529,13 @@ func _test_add_kinds() -> void:
print("+ Card ▾")
var labels: Array = main.editing.ADD_KINDS.map(func(k: Array) -> String: return k[0])
_check(labels.any(func(s: String) -> bool: return s.begins_with("Check")), "Check card is in the menu")
_check(labels.any(func(s: String) -> bool: return s.begins_with("Collection")), "Collection is in the menu")
_check(labels.any(func(s: String) -> bool: return s.begins_with("Collection")), "Spread is in the menu")
_eq(main.editing._add_menu.text, "+ Card ▾", "the button reads + Card ▾")
var c := main.editing.add_table(RollTable.KIND_CHECK)
_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")
var col := main.editing.add_table(RollTable.KIND_VARIABLE, RollTable.VAR_COLLECTION)
_check(col.is_collection() and col.name == "Skills" and col.var_name == "skill_2", "adding a collection (%s, @%s)" % [col.name, col.var_name])
_check(col.is_collection() and col.name == "Skills" and col.var_name == "skill_2", "adding a spread (%s, @%s)" % [col.name, col.var_name])
var v := main.editing.add_table(RollTable.KIND_VARIABLE, "number")
_eq(v.name, "New variable", "a plain variable keeps its name")
await _frames()

View file

@ -1,10 +1,8 @@
extends SceneTree
extends TestBase
## Headless checks for the roller working with RollContext, TextExpander,
## pipes that save variables, card decks and StateStore.
## Run: godot --headless --path . -s res://tests/test_integration.gd
var _failures := 0
func _init() -> void:
_test_refs_and_vars()
@ -14,8 +12,7 @@ func _init() -> void:
_test_missing_and_unset()
_test_decks_through_state()
_test_lit_and_steps()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _entry(id: String, text: String, weight: int = 1) -> TableEntry:
@ -87,11 +84,11 @@ func _test_pipe_save() -> void:
var ctx := Roller.new_context(b, _rng(3), store, {})
var n := Roller.roll(b, "src", ctx.rng, 0, {}, ctx)
# Text is expanded before pipes roll, so {foe} isn't set yet in the same entry.
_check((n["summary"] as String).contains("{foe?}"), "pipes roll after the entry's text")
_eq(ctx.lookup("foe"), "[b]Ogre[/b]", "pipe save_as stores the export BBCode in a chain var")
_check((n["summary"] as String).contains("{foe?}"), "threads roll after the entry's text")
_eq(ctx.lookup("foe"), "[b]Ogre[/b]", "thread save_as stores the export BBCode in a chain var")
_check(not (ctx.lookup("foe") as String).contains("url="), "saved value has no internal markers")
_check(store.has("pal") and store["pal"]["value"] == "Mira" and store["pal"]["source"] == "pals", "@ save goes to persistent vars with source: %s" % str(store))
_check(ctx.persistent_changed, "persistent_changed after a pipe save")
_check(ctx.persistent_changed, "persistent_changed after a thread save")
# A later table in the same chain sees the chain var.
var a := _table("a", "A", ["start"])
var c := _table("c", "C", ["uses {foe}"])
@ -100,7 +97,7 @@ func _test_pipe_save() -> void:
var b2 := _board([a, c, dst])
var n2 := Roller.roll(b2, "a", _rng(4))
var used: String = (n2["children"] as Array)[1]["summary"]
_eq(used, "uses [url=var:foe][b]Ogre[/b][/url]", "chain var from a pipe is used by a later pipe")
_eq(used, "uses [url=var:foe][b]Ogre[/b][/url]", "chain var from a thread is used by a later thread")
func _test_persistent_across_rolls() -> void:
@ -162,7 +159,7 @@ func _test_depth_limit() -> void:
for s in Roller.flatten(n2, []):
if s.get("inline", false):
inline += 1
_check(inline <= Roller.MAX_DEPTH and worst <= 2 * Roller.MAX_DEPTH + 1, "mixed pipes and refs stop at the reference limit (%d refs, depth %d)" % [inline, worst])
_check(inline <= Roller.MAX_DEPTH and worst <= 2 * Roller.MAX_DEPTH + 1, "mixed threads and refs stop at the reference limit (%d refs, depth %d)" % [inline, worst])
func _test_missing_and_unset() -> void:
@ -215,8 +212,8 @@ func _test_lit_and_steps() -> void:
var lp := {}
var lt := {}
Roller.collect_lit(n, le, lp, lt)
_check(lp.has(Roller.ref_key("quest", "quest0", "names")), "reference pipe is lit")
_check(lp.has(Roller.pipe_key("quest", "quest0", "names")), "real pipe is lit too")
_check(lp.has(Roller.ref_key("quest", "quest0", "names")), "reference thread is lit")
_check(lp.has(Roller.pipe_key("quest", "quest0", "names")), "real thread is lit too")
_check(Roller.is_ref_key(Roller.ref_key("a", "b", "c")) and not Roller.is_ref_key(Roller.pipe_key("a", "b", "c")), "ref keys are told apart")
_check((lt[Roller.entry_key("quest", "quest0")] as String).contains("Aldric"), "lit texts hold the expanded text")
# Steps survive JSON (history is saved as JSON).
@ -224,12 +221,3 @@ func _test_lit_and_steps() -> void:
var back: Variant = JSON.parse_string(JSON.stringify(steps))
_check(back is Array and (back as Array).size() == steps.size() and back[0]["text"] == steps[0]["text"], "steps round-trip through JSON")
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(got == want, "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for the import/export converters.
## Run: godot --headless --path . -s res://tests/test_io.gd
const TMP_DIR := "user://test_io_tmp/"
var _failures := 0
func _init() -> void:
DirAccess.make_dir_recursive_absolute(TMP_DIR)
@ -15,8 +13,7 @@ func _init() -> void:
_test_mermaid_dot()
_test_graphml()
_cleanup()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
## Two tables with weights, ranges, count/save_as pipes, an inline reference, a
@ -57,12 +54,12 @@ func _test_json() -> void:
var small := _small()
var res2 := JsonIO.import_json(JsonIO.export_json(small))
_check(res2["ok"] and res2["collection"] == JsonIO.canonical(small), "small collection round-trips exactly")
_check(res2["ok"] and res2["collection"] == JsonIO.canonical(small), "small spread round-trips exactly")
_check(not JsonIO.export_json({"tables": [], "state": {"draws": 1}}).contains("state"), "export drops unknown/local keys")
# Legacy keys: triggers, die, collection name.
var legacy := JsonIO.import_json('{"format_version":1,"collection":"Old","tables":[{"id":"a","name":"A","die":20,"entries":[{"text":"x","triggers":["a"]}]}]}')
_check(legacy["ok"] and legacy["collection"]["name"] == "Old", "legacy collection key becomes name")
_check(legacy["ok"] and legacy["collection"]["name"] == "Old", "legacy spread key becomes name")
var lt: Dictionary = legacy["collection"]["tables"][0]
_check(lt["dice"] == "1d20" and lt["entries"][0]["pipes"] == ["a"] and lt["entries"][0]["id"] == "e1", "legacy die/triggers/missing entry id handled")
@ -81,8 +78,8 @@ func _test_json() -> void:
_check(ids.size() == 3, "table ids are unique after import")
_check(dt[0]["id"] == "t" and dt[1]["id"] != "t" and dt[2]["id"] == "third_table", "first keeps id, others get fresh ones")
_check(dt[0]["entries"][0]["id"] != dt[0]["entries"][1]["id"], "duplicate entry ids are fixed")
_check(dt[1]["entries"][0]["pipes"] == ["t"], "pipe by table name is resolved to the id")
_check(dt[2]["entries"][0]["pipes"] == ["t"], "pipe to the original id keeps pointing at the first table")
_check(dt[1]["entries"][0]["pipes"] == ["t"], "thread by table name is resolved to the id")
_check(dt[2]["entries"][0]["pipes"] == ["t"], "thread to the original id keeps pointing at the first table")
# Validation.
_check(not JsonIO.import_json("not json")["ok"], "garbage is rejected")
@ -119,13 +116,13 @@ func _test_canvas() -> void:
for e in doc["edges"]:
labels.append(str(e.get("label", "")))
_check(labels.has("×2 → weapon") and labels.has("ref → w2"), "canvas edge labels (%s)" % str(labels))
_check(doc["edges"].size() == 3, "canvas edges: 2 pipes + 1 ref (missing target skipped), got %d" % doc["edges"].size())
_check(doc["edges"].size() == 3, "canvas edges: 2 threads + 1 ref (missing target skipped), got %d" % doc["edges"].size())
var res := CanvasIO.import_canvas(text)
_check(res["ok"], "canvas imports")
var want := JsonIO.canonical(small)
var got: Dictionary = res["collection"]
_check(got["tables"] == want["tables"], "canvas round trip keeps every field")
_check(got["id"] == "demo" and got["name"] == small["name"], "canvas round trip keeps collection id and name")
_check(got["id"] == "demo" and got["name"] == small["name"], "canvas round trip keeps spread id and name")
# Group sizing: entries sit inside their group.
var ok_inside := true
@ -146,7 +143,7 @@ func _test_canvas() -> void:
var sample := SampleBoard.create().to_dict()
var big := CanvasIO.import_canvas(CanvasIO.export_canvas(sample))
_check(big["ok"] and _plain_tables(big["collection"]["tables"], sample) == _plain_tables(JsonIO.canonical(sample)["tables"], sample),
"sample board's roll tables survive a canvas round trip (logic keys are JSON-only)")
"sample spread's roll tables survive a canvas round trip (logic keys are JSON-only)")
func _test_canvas_stripped() -> void:
@ -172,8 +169,8 @@ func _test_canvas_stripped() -> void:
_check(loot["entries"][1]["text"] == "Melee weapon \"sharp\" [1]", "stripped: BBCode is gone from visible text")
var pipe: Variant = loot["entries"][1].get("pipes", [])[0]
_check(pipe is Dictionary and pipe["table"] == weapons["id"] and pipe["count"] == 2 and pipe["save_as"] == "weapon", "stripped: count and save_as parsed from edge label")
_check(weapons["entries"][1].get("pipes", []) == [loot["id"]], "stripped: plain pipe becomes a table id")
_check(not loot["entries"][2].has("pipes"), "stripped: reference edges do not become pipes")
_check(weapons["entries"][1].get("pipes", []) == [loot["id"]], "stripped: plain thread becomes a table id")
_check(not loot["entries"][2].has("pipes"), "stripped: reference edges do not become threads")
var found := false
for g in res["guesses"]:
found = found or (g as String).contains("1d6")
@ -194,9 +191,9 @@ func _test_mermaid_dot() -> void:
var m := MermaidExporter.export_mermaid(small)
_check(m.begins_with("graph LR"), "mermaid starts with graph LR")
_check(m.contains("t0[\"Loot\"]") and m.contains("t1[\"Weapons (1d6)\"]"), "mermaid nodes, dice in label")
_check(m.contains("t0 -->|\"") and m.contains("×2 → weapon") and m.contains("| t1"), "mermaid pipe edge with count and save_as")
_check(m.contains("t0 -->|\"") and m.contains("×2 → weapon") and m.contains("| t1"), "mermaid thread edge with count and save_as")
_check(m.contains("t0 -.->|\"") , "mermaid dashed edge for reference")
_check(m.contains("t1 -->|\"Sword") and m.contains("| t0"), "mermaid pipe back to Loot")
_check(m.contains("t1 -->|\"Sword") and m.contains("| t0"), "mermaid thread back to Loot")
_check(m.contains("missing: ghost") and m.contains(":::missing"), "mermaid marks the missing target")
_check(not m.contains("[b]") and not m.contains("[/b]"), "mermaid strips BBCode")
_check(m.contains("#quot;sharp#quot;") and m.contains("#91;1#93;"), "mermaid escapes quotes and brackets")
@ -209,9 +206,9 @@ func _test_mermaid_dot() -> void:
var d := DotExporter.export_dot(small)
_check(d.begins_with("digraph TableTower {") and d.strip_edges().ends_with("}"), "dot has a digraph wrapper")
_check(d.contains("Weapons (1d6)") and d.contains("PORT=\"e1\""), "dot table labels and entry ports")
_check(d.contains("t0:e1:e -> t1:head:w [label=\"×2 → weapon\"]"), "dot pipe edge from entry port to table")
_check(d.contains("t0:e1:e -> t1:head:w [label=\"×2 → weapon\"]"), "dot thread edge from entry port to table")
_check(d.contains("t0:e2:e -> t1:head:w [label=\"ref → w2\", style=dashed]"), "dot dashed reference edge")
_check(d.contains("t1:e1:e -> t0:head:w;"), "dot plain pipe edge")
_check(d.contains("t1:e1:e -> t0:head:w;"), "dot plain thread edge")
_check(d.contains("missing: ghost") and d.contains("color=red"), "dot marks the missing target")
_check(d.contains("&quot;sharp&quot;") and not d.contains("[b]"), "dot escapes quotes in HTML labels and strips BBCode")
_check(d.contains("label=\"Demo \\\"Set\\\"\""), "dot escapes quotes in strings")
@ -221,7 +218,7 @@ func _test_mermaid_dot() -> void:
# Big tables don't explode.
var sm := MermaidExporter.export_mermaid(SampleBoard.create().to_dict())
var sd := DotExporter.export_dot(SampleBoard.create().to_dict())
_check(sm.contains("graph LR") and sd.contains("more"), "sample board exports to mermaid and dot")
_check(sm.contains("graph LR") and sd.contains("more"), "sample spread exports to mermaid and dot")
func _test_graphml() -> void:
@ -245,13 +242,13 @@ func _test_graphml() -> void:
var sample := SampleBoard.create().to_dict()
var big := GraphMLIO.import_graphml(GraphMLIO.export_graphml(sample))
_check(big["ok"] and _plain_tables(big["collection"]["tables"], sample) == _plain_tables(JsonIO.canonical(sample)["tables"], sample),
"sample board's roll tables survive a graphml round trip (logic keys are JSON-only)")
"sample spread's roll tables survive a graphml round trip (logic keys are JSON-only)")
# Foreign GraphML: nodes become tables, edges entries.
var foreign := '<?xml version="1.0"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns"><key id="d0" for="node" attr.name="name" attr.type="string"/><graph edgedefault="directed"><node id="a"><data key="d0">Alpha</data></node><node id="b"><data key="d0">Beta</data></node><edge source="a" target="b"/></graph></graphml>'
var fres := GraphMLIO.import_graphml(foreign)
_check(fres["ok"] and fres["collection"]["tables"].size() == 2 and not (fres["guesses"] as Array).is_empty(), "foreign graphml imports with guesses")
_check(fres["collection"]["tables"][0]["entries"][0]["pipes"] == ["beta"], "foreign graphml edge becomes a pipe")
_check(fres["collection"]["tables"][0]["entries"][0]["pipes"] == ["beta"], "foreign graphml edge becomes a thread")
_check(not GraphMLIO.import_graphml("<nope/>")["ok"], "non-graphml is rejected")
# Write a file once to make sure the text survives disk.
@ -281,9 +278,3 @@ func _plain_tables(tables: Array, sample: Dictionary) -> Array:
if not logic:
plain[t["id"]] = true
return tables.filter(func(t: Dictionary) -> bool: return plain.has(t["id"]))
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

70
tests/test_list_view.gd Normal file
View file

@ -0,0 +1,70 @@
extends TestBase
## List view: rows for every card with thread counts and Roll, search, new
## folders, and drag-and-drop moves (reorder, into a folder, folder in folder).
## Run: godot --headless --path . -s res://tests/test_list_view.gd -- --sample
func _init() -> void:
if not await start_main():
return
await _test_rows()
await _test_moves()
finish()
func _rows(it: TreeItem, out: Array) -> Array:
var c := it.get_first_child()
while c:
out.append(c)
_rows(c, out)
c = c.get_next()
return out
func _find(id: String) -> TreeItem:
for it: TreeItem in _rows(main.list_view.tree.get_root(), []):
if ListTree._meta(it).get("id") == id:
return it
return null
func _test_rows() -> void:
var lv := main.list_view
_check(not lv.visible, "the list starts hidden")
lv.set_shown(true)
await _frames(2)
var rows := _rows(lv.tree.get_root(), [])
_check(rows.size() == main.data.tables.size(), "a row per card (%d)" % rows.size())
var road := _find("road")
_check(road != null and road.get_text(ListTree.COL_THREADS).contains("←1") and road.get_text(ListTree.COL_ROLL) == "Roll", "a row shows its threads and Roll: " + (road.get_text(ListTree.COL_THREADS) if road else ""))
_check(road.get_tooltip_text(ListTree.COL_THREADS).contains("from Wilderness Travel"), "the thread tooltip says where they come from")
lv._search.text = "weapon"
lv._search.text_changed.emit("weapon")
await _frames()
var hits := _rows(lv.tree.get_root(), [])
_check(hits.size() >= 1 and hits.size() < rows.size(), "search narrows the list (%d rows)" % hits.size())
lv._search.text = ""
lv._search.text_changed.emit("")
func _test_moves() -> void:
var lv := main.list_view
var n := main.data.groups.size()
lv.new_folder()
await _frames(2)
_check(main.data.groups.size() == n + 1, "+ Folder adds an empty group")
var g := main.data.groups[main.data.groups.size() - 1]
ListOrder.move(main, {"kind": "card", "id": "towns"}, {"kind": "group", "id": g.id}, 0)
await _frames(2)
_check(main.data.group_of("towns") == g, "dropping a card on a folder moves it in")
var f2 := main.data.add_group("Inner", [])
ListOrder.move(main, {"kind": "group", "id": f2.id}, {"kind": "group", "id": g.id}, 0)
_check(f2.parent == g.id, "a folder dropped on a folder goes inside it")
ListOrder.move(main, {"kind": "group", "id": g.id}, {"kind": "group", "id": f2.id}, 0)
_check(g.parent == "", "a folder can't go inside its own inner folder")
var ids := main.data.tables.map(func(t: RollTable) -> String: return t.id)
ListOrder.move(main, {"kind": "card", "id": ids[3]}, {"kind": "card", "id": ids[0]}, -1)
_check(main.data.tables[0].id == ids[3], "dropping above a card reorders the spread's list")
main.undo_redo.undo()
_check(main.data.tables[0].id == ids[0], "and undo puts it back")

View file

@ -0,0 +1 @@
uid://cm6sju33r5taq

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for logic cards (docs/LOGIC.md): expressions, effects,
## variables, choice / loop / variable / sheet cards, the action limit, long
## chains and the file format.
## Run: godot --headless --path . -s res://tests/test_logic.gd
var _failures := 0
func _init() -> void:
_test_expressions()
@ -20,8 +18,7 @@ func _init() -> void:
_test_sheet()
_test_json()
await _test_character()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
# ---------------------------------------------------------------- helpers
@ -299,7 +296,7 @@ func _test_choices() -> void:
_check(n.get("picked", false) and (n["entry"] as TableEntry).text == "Army" and n.get("kind") == "choice", "picked entry is the node's entry")
_eq(_var(vars, "branch"), "ground", "picked entry's effects run")
_eq(_var(vars, "career"), "Army", "save_as gets the picked text")
_check((n["children"] as Array).size() == 1 and Formatter.strip_tags((n["children"] as Array)[0]["summary"]) == "Then Army", "picked entry's pipes follow")
_check((n["children"] as Array).size() == 1 and Formatter.strip_tags((n["children"] as Array)[0]["summary"]) == "Then Army", "picked entry's threads follow")
_check(not n.has("value"), "a picked entry has no die value")
# pick: Random.
var randoms := {}
@ -323,7 +320,7 @@ func _test_choices() -> void:
_check(_var(vars, "terms") is int, "...as an int")
_eq(ctx.chain_vars.get("answer"), 4, "chain variable answer")
_eq(_var(vars, "total"), 14, "the Answer entry's effects see answer")
_eq((n["children"] as Array).size(), 4, "the Answer entry's pipe count can be an expression")
_eq((n["children"] as Array).size(), 4, "the Answer entry's thread count can be an expression")
_check(n.has("effects") and Effects.log_text(n["effects"]) == PackedStringArray(["Total +4 → 14"]), "effects log on the node: %s" % str(n.get("effects")))
var steps := Roller.flatten(n, [])
_check(steps[0].get("answer") == 4 and steps[0].get("kind") == "choice" and steps[0].has("effects"), "steps carry kind, answer and effects")
@ -382,7 +379,7 @@ func _test_choices() -> void:
func _test_loops() -> void:
# times
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Loop", "times")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Repeat", "times")
loop.loop_expr = "3"
loop.entries[0].effects = "@sum += i"
loop.entries[0].text = "Pass {i}"
@ -396,13 +393,13 @@ func _test_loops() -> void:
_eq(n.get("summary"), "Repeated 3 times", "loop node text")
_eq(_var(vars, "sum"), 6, "i is 1, 2, 3")
_eq(_texts(Roller.flatten(n, [])), ["Repeated 3 times", "Pass 1", "Pass 2", "Pass 3", "Afterwards", "Done after 6"], "loop steps")
_check(not ctx.chain_vars.has("i"), "i is gone after the loop")
_check(not ctx.chain_vars.has("i"), "i is gone after the repeat")
var steps := Roller.flatten(n, [])
_check(steps[1].get("pass") == 1 and steps[1]["num"] == "1" and steps[4].get("after", false) and steps[0].get("passes") == 3, "pass and Afterwards steps are marked")
var le := {}
var lp := {}
Roller.collect_lit(n, le, lp)
_check(lp.has(Roller.pipe_key("loop", "e2", "done")) and not lp.has(Roller.pipe_key("loop", "e1", "loop")), "passes light no pipe; Afterwards' pipe is lit")
_check(lp.has(Roller.pipe_key("loop", "e2", "done")) and not lp.has(Roller.pipe_key("loop", "e1", "loop")), "passes light no thread; Afterwards' thread is lit")
loop.loop_expr = "0"
n = Roller.roll(b, "loop", _rng(2))
_check(n.get("passes") == 0 and (n["children"] as Array).size() == 1, "times 0 runs only Afterwards")
@ -447,7 +444,7 @@ func _test_loop_from_answer() -> void:
var q := RollTable.create(RollTable.KIND_CHOICE, "q", "How many?", "number")
q.max_expr = "10"
q.entries[0].add_pipe("loop")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Loop", "times")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Repeat", "times")
loop.loop_expr = "answer"
loop.entries[0].effects = "@count += 1"
var b := _board([q, loop])
@ -488,7 +485,7 @@ func _test_cycles() -> void:
_check(steps.back().get("stop", false) and steps.back().get("limit", false), "the marker is a stop step")
_eq(ctx.halted, "Stopped after 10,000 actions", "ctx.halted")
_check(ms < 15000, "the endless cycle stops in reasonable time (%d ms)" % ms)
_eq(Roller.endless_cycles(b2), ["loop"] as Array[String], "a plain self-pipe is still flagged")
_eq(Roller.endless_cycles(b2), ["loop"] as Array[String], "a plain self-thread is still flagged")
# Mixed with inline references.
var r := _table("r", ["[[Loop]] and on"])
b2.tables.append(r)
@ -601,7 +598,7 @@ func _test_json() -> void:
num.min_expr = "1"
num.max_expr = "@max"
var txt := RollTable.create(RollTable.KIND_CHOICE, "txt", "Txt", "text")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Loop", "until")
var loop := RollTable.create(RollTable.KIND_LOOP, "loop", "Repeat", "until")
var vcard := RollTable.create(RollTable.KIND_VARIABLE, "var", "STR", "list")
vcard.initial = "\"a, b\""
var sheet := RollTable.create(RollTable.KIND_SHEET, "sheet", "Sheet")
@ -622,12 +619,12 @@ func _test_json() -> void:
_check(not plain["entries"][0].has("effects"), "an entry without effects has no effects key")
var d := num.to_dict()
_check(d["kind"] == "choice" and d["choice"] == "number" and d["min"] == "1" and d["max"] == "@max" and not d.has("save_as"), "choice keys: %s" % str(d))
_eq(roll.to_dict()["entries"][0]["pipes"], [{"table": "loop", "count": "@terms"}], "an expression pipe count")
_eq(roll.to_dict()["entries"][0]["pipes"], [{"table": "loop", "count": "@terms"}], "an expression thread count")
# RollTable round trip through JSON text.
var text := b.to_json()
var b2 := TowerBoard.new()
_check(b2.load_json(text), "board JSON loads")
_eq(b2.to_json(), text, "board JSON round-trips unchanged")
_check(b2.load_json(text), "spread JSON loads")
_eq(b2.to_json(), text, "spread JSON round-trips unchanged")
_eq(b2.get_table("roll").entries[0].count_expr("loop"), "@terms", "expression count survives")
# JsonIO canonical/import keep every new key.
var exported := JsonIO.export_json(b.to_dict())
@ -643,7 +640,7 @@ func _test_json() -> void:
var ct: Dictionary = canon["tables"][0]
_check(ct["kind"] == "choice" and ct["min"] == "2" and not ct.has("max"), "canonical keeps kind keys, numbers as text, drops defaults: %s" % str(ct))
_check(ct["entries"][0]["effects"] == "@a += 1" and ct["entries"][0]["pipes"] == [{"table": "y", "count": "@n"}, {"table": "z", "count": 3}], "canonical keeps effects and counts: %s" % str(ct["entries"][0]))
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "count": "@n"})), "×@n", "pipe label for an expression count")
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "count": "@n"})), "×@n", "thread label for an expression count")
# ---------------------------------------------------------------- scenario
@ -720,11 +717,3 @@ func _test_character() -> void:
# ---------------------------------------------------------------- checks
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(typeof(got) == typeof(want) and got == want or (got is Array and want is Array and str(got) == str(want)), "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## Logic cards in the app: the choice pop-up, progress while it's open,
## cancelling, a new roll replacing an open question, live variable and sheet
## cards, the long-chain tray and the Build-mode settings rules.
@ -7,22 +7,9 @@ extends SceneTree
const DEMO := "res://examples/logic_demo.json"
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to roll.")
quit(2)
if not await start_main():
return
main.rng.seed = 11
@ -40,8 +27,7 @@ func _init() -> void:
await _test_long_chain()
await _test_action_limit()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _load_demo() -> void:
@ -85,9 +71,9 @@ func _var(name: String) -> Variant:
func _test_demo_file() -> void:
var text := FileAccess.get_file_as_string(DEMO)
var r := IoMenu.parse_import(text, IoMenu.detect_format("logic_demo.json", text))
_check(r["ok"] and (r["errors"] as Array).is_empty(), "the demo imports through Board ▾ → Import: %s" % str(r["errors"]))
_check(r["ok"] and (r["errors"] as Array).is_empty(), "the demo imports through Spread ▾ → Import: %s" % str(r["errors"]))
var b := TowerBoard.new()
_check(b.load_json(text), "the demo loads as a board")
_check(b.load_json(text), "the demo loads as a spread")
var kinds := {}
for t in b.tables:
kinds[t.kind + ("/" + t.choice if t.kind == "choice" else "")] = true
@ -110,7 +96,7 @@ func _test_cards() -> void:
var loop := main.card_for("explore")
_check(loop.rows.size() == 2 and loop.anchor_for("e1").size() > 0 and loop.anchor_for("e2").size() > 0,
"a loop card has Each time and Afterwards rows with outlets")
_eq(TableCard.loop_rule(loop.table), "× @rooms", "the loop rule reads × @rooms")
_eq(TableCard.loop_rule(loop.table), "× @rooms", "the repeat rule reads × @rooms")
var hp := main.card_for("v_hp")
_check(hp.rows.is_empty() and hp.anchor_for("x").is_empty(), "a variable card has no outlets")
var sheet := main.card_for("report")
@ -137,7 +123,7 @@ func _test_scripted() -> void:
for s: Dictionary in main.current["all"]:
if s.has("pass"):
passes += 1
_eq(passes, 3, "the number answer drives the loop")
_eq(passes, 3, "the number answer drives the repeat")
var last: Dictionary = (main.current["all"] as Array).back()
_eq(last.get("table_id"), "report", "the chain ends at the sheet")
_check(main.tray._headline.visible and Formatter.strip_tags(main.tray._headline_text.text).begins_with("Brin the delver"),
@ -186,7 +172,7 @@ func _test_dialog_answers() -> void:
_check(d != null and d.kind == "pick" and d._options.size() == 3, "then the pick pop-up with three options")
if d == null:
return
_check(main.is_entry_lit("explore", "e1") and main.is_entry_lit("explore", "e2"), "the loop's steps are lit before the pick")
_check(main.is_entry_lit("explore", "e1") and main.is_entry_lit("explore", "e2"), "the repeat's steps are lit before the pick")
d.answer(-1)
await process_frame
_check(main.rolling.pending_choice() == null and main.current.get("done", false), "Random finishes the roll")
@ -311,7 +297,7 @@ func _test_live_edits() -> void:
for c in main.tray._vars._list.get_children():
if c is HBoxContainer:
rows += 1
_check(rows >= 4, "the Variables tab lists every board variable, numbers included (%d rows)" % rows)
_check(rows >= 4, "the Variables tab lists every spread variable, numbers included (%d rows)" % rows)
var dlg := main.tray._vars.confirm_reset_all()
_check(dlg != null and dlg.is_inside_tree(), "Reset all asks first, in the app")
dlg.close()
@ -331,7 +317,7 @@ func _test_settings_rules() -> void:
c.entries[0].add_pipe("x")
var r := TableSettingsDialog.apply_settings(c, {"name": "C", "choice": "number", "min": "1", "max": "@top", "prompt": "How many?", "save_as": "@n"})
_check(r["ok"] and c.choice == "number" and c.entries.size() == 1 and c.entries[0].text == "Answer", "pick → number keeps one Answer row")
_check(Array(c.entries[0].pipes) == ["x"] and c.entries[0].effects == "@a = 1", "…with the first option's pipes and effects")
_check(Array(c.entries[0].pipes) == ["x"] and c.entries[0].effects == "@a = 1", "…with the first option's threads and effects")
_check(c.max_expr == "@top" and c.save_as == "@n", "min/max and save as applied")
var bad := TableSettingsDialog.apply_settings(c, {"name": "C", "choice": "number", "min": "1 +", "max": "5"})
_check(not bad["ok"] and c.min_expr == "1", "a bad min is refused and nothing changes")
@ -349,11 +335,11 @@ func _test_settings_rules() -> void:
var s := RollTable.create(RollTable.KIND_SHEET, "s", "S")
TableSettingsDialog.apply_settings(s, {"template": "HP {@hp}"})
_eq(s.entries[0].text, "HP {@hp}", "sheet template applied")
_eq(PipePopover._count_error("@terms"), "", "pipe counts take expressions")
_check(PipePopover._count_error("@terms +") != "", "bad pipe counts are flagged")
_eq(PipePopover._count_error("@terms"), "", "thread counts take expressions")
_check(PipePopover._count_error("@terms +") != "", "bad thread counts are flagged")
var e := TableEntry.new("e", "x")
e.set_pipe_count("y", "@terms")
_eq(PipeLayer._pipe_tag(e, "y"), "×@terms", "expression counts show on the pipe")
_eq(PipeLayer._pipe_tag(e, "y"), "×@terms", "expression counts show on the thread")
# Previews.
var pv := RichText.preview("{@skill_*} and {= dm(@str)} and {= 1 +}", main.data)
_check(pv.contains("{@skill_*}") and pv.contains("{= dm(@str)}"), "previews show {@x_*} and {= expr} readably")
@ -443,13 +429,3 @@ func _test_action_limit() -> void:
# ---------------------------------------------------------------- checks
func _eq(got: Variant, want: Variant, what: String) -> void:
if typeof(got) != typeof(want) or got != want:
_failures += 1
print(" ✗ %s (got %s, want %s)" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

60
tests/test_mobile.gd Normal file
View file

@ -0,0 +1,60 @@
extends TestBase
## The phone layout (List fills the screen, Spread/List swap, slim bar and
## tray, View/Help/Play-Build in ☰) and touch gestures (pinch zoom, a long
## press timing out into a right-click).
## Run: godot --headless --path . -s res://tests/test_mobile.gd -- --sample
func _init() -> void:
if not await start_main():
return
await _test_layout()
await _test_touch()
finish()
func _test_layout() -> void:
main.mobile = MobileLayout.new(main)
main.mobile.apply()
await _frames()
_check(main.list_view.visible and not main.board.visible, "the list fills the screen")
_check(not main.top_bar.view_menu.visible and not main.top_bar.help_menu.visible and not main.tray.side_panel.visible, "the bar and tray slim down")
main.mobile.swap.pressed.emit()
_check(main.board.visible and not main.list_view.visible and main.mobile.swap.text == "List", "Spread/List swaps to the spread")
main.mobile.swap.pressed.emit()
var texts: Array = Actions.background(main, Vector2.ZERO).map(func(a: Dictionary) -> String: return str(a.get("text", "")))
_check(texts.has("Switch to Build") and texts.has("Help…"), "☰ carries Play/Build and Help: %s" % str(texts))
main.mobile.show_list(false)
func _test_touch() -> void:
var touch: TouchInput = null
for c in main.get_children():
if c is TouchInput:
touch = c
_check(touch != null, "touch gestures are on")
var z := main.board.zoom
touch._input(_tap(0, Vector2(100, 300), true))
touch._input(_tap(1, Vector2(200, 300), true))
var d := InputEventScreenDrag.new()
d.index = 1
d.position = Vector2(300, 300)
touch._input(d)
_check(main.board.zoom > z * 1.5, "two fingers spreading apart zoom in (%.2f → %.2f)" % [z, main.board.zoom])
touch._input(_tap(1, Vector2(300, 300), false))
touch._input(_tap(0, Vector2(100, 300), false))
touch._input(_tap(0, Vector2(120, 320), true))
touch._process(0.3)
_check(touch._hold_t > 0.0, "a held finger counts toward a long press")
touch._process(0.3)
_check(touch._hold_t < 0.0, "after half a second it fires (as a right-click)")
touch._input(_tap(0, Vector2(120, 320), false))
func _tap(i: int, at: Vector2, down: bool) -> InputEventScreenTouch:
var t := InputEventScreenTouch.new()
t.index = i
t.position = at
t.pressed = down
return t

1
tests/test_mobile.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dgu87qrdhygdr

View file

@ -1,9 +1,7 @@
extends SceneTree
extends TestBase
## Headless checks for dice, weights, pipe options, card mode and JSON.
## Run: godot --headless --path . -s res://tests/test_model.gd
var _failures := 0
func _init() -> void:
_test_dice()
@ -15,8 +13,7 @@ func _init() -> void:
_test_seed()
_test_json()
_test_sample()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _entry(id: String, text: String, weight: int = 1) -> TableEntry:
@ -149,7 +146,7 @@ func _test_pipes() -> void:
e.add_pipe("other")
e.add_pipe("dst", 3, "foe")
src.entries.append(e)
_check(e.pipes.size() == 2, "pipe targets stay unique")
_check(e.pipes.size() == 2, "thread targets stay unique")
var dst := RollTable.new("dst", "Dst")
dst.entries.append(_entry("d1", "Thing"))
var other := RollTable.new("other", "Other")
@ -157,19 +154,19 @@ func _test_pipes() -> void:
var b := _board([src, dst, other])
var n := Roller.roll(b, "src", _rng(1))
var kids: Array = n["children"]
_check(kids.size() == 4, "count 3 plus one plain pipe gives 4 children (got %d)" % kids.size())
_check(kids.size() == 4, "count 3 plus one plain thread gives 4 children (got %d)" % kids.size())
var saved := 0
for c: Dictionary in kids:
if c.get("save_as", "") == "foe":
saved += 1
_check(saved == 3, "save_as is set on the 3 counted children")
_check(not (kids[3] as Dictionary).has("save_as"), "plain pipe has no save_as")
_check(not (kids[3] as Dictionary).has("save_as"), "plain thread has no save_as")
_check(not n.has("save_as"), "root node has no save_as")
_check(Roller.flatten(n, []).size() == 5, "flatten walks counted children")
var lit_e := {}
var lit_p := {}
Roller.collect_lit(n, lit_e, lit_p)
_check(lit_p.has(Roller.pipe_key("src", "e1", "dst")), "counted pipe is lit")
_check(lit_p.has(Roller.pipe_key("src", "e1", "dst")), "counted thread is lit")
e.remove_pipe("dst")
_check(e.pipes == ["other"] and e.pipe_count.is_empty() and e.pipe_save.is_empty(), "remove_pipe clears options")
@ -177,7 +174,7 @@ func _test_pipes() -> void:
e.set_pipe_count("other", 0)
_check(e.count_for("other") == 1, "count below 1 clamps to 1")
e.set_pipe_save("other", "@loot")
_check(e.to_dict()["pipes"] == [{"table": "other", "save_as": "@loot"}], "save-only pipe serializes as object")
_check(e.to_dict()["pipes"] == [{"table": "other", "save_as": "@loot"}], "save-only thread serializes as object")
func _test_cards() -> void:
@ -213,7 +210,7 @@ func _test_cards() -> void:
for i in 4:
Roller.roll(b, "deck", r, 0, d2)
var stopped := Roller.roll(b, "deck", r, 0, d2)
_check(stopped.get("stop", "") == "Deck empty", "stop mode returns Deck empty")
_check(stopped.get("stop", "") == "Empty" and stopped.get("deck_empty", false), "a deck that waits for Shuffle gives its Empty result")
(d2["deck"] as DeckState).reshuffle()
_check(not Roller.roll(b, "deck", r, 0, d2).has("stop"), "manual reshuffle deals again")
@ -263,7 +260,7 @@ func _test_cycles() -> void:
var board := _board([a, bt])
_check(Roller.endless_cycles(board) == ["a", "b"], "two-table loop is endless")
bt.entries.append(_entry("eb2", "exit"))
_check(Roller.endless_cycles(board).is_empty(), "an exit entry fixes the loop")
_check(Roller.endless_cycles(board).is_empty(), "an exit entry fixes the repeat")
bt.entries[1].weight = 0
_check(Roller.endless_cycles(board).size() == 2, "a zero-weight exit does not count")
bt.entries[1].weight = 1
@ -271,9 +268,9 @@ func _test_cycles() -> void:
var es := _entry("es", "again")
es.add_pipe("s")
self_t.entries.append(es)
_check(Roller.endless_cycles(_board([self_t])) == ["s"], "sole self-pipe is endless")
_check(Roller.endless_cycles(_board([self_t])) == ["s"], "sole self-thread is endless")
self_t.entries.append(_entry("es2", "done"))
_check(Roller.endless_cycles(_board([self_t])).is_empty(), "self-pipe on some entries is fine")
_check(Roller.endless_cycles(_board([self_t])).is_empty(), "self-thread on some entries is fine")
# An entry that pipes into a cycle and a fine table is still stuck.
var ok := RollTable.new("ok", "Ok")
ok.entries.append(_entry("k", "fine"))
@ -283,7 +280,7 @@ func _test_cycles() -> void:
em.add_pipe("mix")
mix.entries.append(em)
_check(Roller.endless_cycles(_board([ok, mix])) == ["mix"], "entry needing a cycle blocks its table")
_check(Roller.endless_cycles(SampleBoard.create()).is_empty(), "sample board has no endless cycles")
_check(Roller.endless_cycles(SampleBoard.create()).is_empty(), "sample spread has no endless cycles")
func _test_seed() -> void:
@ -313,17 +310,17 @@ func _test_json() -> void:
{"id": "e1", "text": "Low", "range": [1, 10], "pipes": ["x", {"table": "y", "count": 2, "save_as": "@pal"}]},
{"id": "e2", "text": "High", "range": [11, 20], "weight": 4, "details": "[b]hi[/b]"}]}]}
var b := TowerBoard.new()
_check(b.load_json(JSON.stringify(legacy)), "legacy board loads")
_check(b.load_json(JSON.stringify(legacy)), "legacy spread loads")
var t := b.get_table("old")
_check(t.dice == "1d20" and t.die_size() == 20 and t.dice_label() == "d20", "legacy die 20 becomes 1d20")
var e := t.entries[0]
_check(e.pipes == ["x", "y"] and e.count_for("y") == 2 and e.save_for("y") == "@pal" and e.count_for("x") == 1, "mixed string/object pipes load")
_check(e.pipes == ["x", "y"] and e.count_for("y") == 2 and e.save_for("y") == "@pal" and e.count_for("x") == 1, "mixed string/object threads load")
_check(t.entries[1].weight == 4 and t.entries[1].details == "[b]hi[/b]", "weight and entry details load")
var d := t.to_dict()
_check(not d.has("die") and d["dice"] == "1d20", "die is no longer written")
var ed: Dictionary = d["entries"][0]
_check(ed["pipes"] == ["x", {"table": "y", "count": 2, "save_as": "@pal"}], "pipes save in contract form")
_check(not (d["entries"][1] as Dictionary).has("pipes"), "empty pipes omitted")
_check(ed["pipes"] == ["x", {"table": "y", "count": 2, "save_as": "@pal"}], "threads save in contract form")
_check(not (d["entries"][1] as Dictionary).has("pipes"), "empty threads omitted")
var plain := RollTable.new("p", "P")
plain.entries.append(_entry("e", "x"))
@ -338,12 +335,12 @@ func _test_json() -> void:
plain.card_mode = true
plain.deck_empty = "stop"
var back := RollTable.from_dict(JSON.parse_string(JSON.stringify(plain.to_dict())))
_check(back.details == "Hello" and back.tags == ["a", "b"] and back.card_mode and back.deck_empty == "stop", "details, tags, card mode round-trip")
_check(back.details == "Hello" and back.tags == ["a", "b"] and back.card_mode and back.deck_empty == "stop", "details, tags, deck mode round-trip")
_check(back.to_dict() == plain.to_dict(), "table dict round-trips")
var sample := SampleBoard.create()
var copy := TowerBoard.new()
_check(copy.load_json(sample.to_json()) and copy.to_json() == sample.to_json(), "sample board JSON round-trips")
_check(copy.load_json(sample.to_json()) and copy.to_json() == sample.to_json(), "sample spread JSON round-trips")
func _test_sample() -> void:
@ -357,7 +354,7 @@ func _test_sample() -> void:
_check(not eids.has(e.id), "unique entry ids in %s" % t.id)
eids[e.id] = true
for p in e.pipes:
_check(s.get_table(p) != null, "pipe target %s exists" % p)
_check(s.get_table(p) != null, "thread target %s exists" % p)
var loot := s.get_table("loot")
_check(loot.entries[0].weight == 3 and absf(loot.chance(loot.entries[0]) - 3.0 / 8.0) < 1e-9, "gold weight 3 of 8")
var roles := s.get_table("party_roles")
@ -375,9 +372,3 @@ func _test_sample() -> void:
_check(ruins.dice_mod == "@luck" and ruins.range_problems() == "", "Search the Ruins is 1d6 + Luck with clean ranges")
var reach: Array = ruins.entries.map(func(e: TableEntry) -> bool: return RollRange.natural_reach(ruins, e))
_check(reach == [false, true, true, true, false], "only a modifier reaches its first and last results: %s" % str(reach))
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,12 +1,10 @@
extends SceneTree
extends TestBase
## Headless checks for the roll modifier on ranged roll tables (dice_mod,
## RollRange): results past the dice, using the nearest result past the ends,
## chances with a modifier, the file format, plain words and the Why line,
## and the ModifierEditor's plain forms.
## Run: godot --headless --path . -s res://tests/test_modifier.gd
var _failures := 0
func _init() -> void:
_test_model()
@ -16,21 +14,9 @@ func _init() -> void:
_test_words()
_test_problems()
_test_editor_forms()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _eq(got: Variant, want: Variant, what: String) -> void:
if typeof(got) != typeof(want) or got != want:
_failures += 1
print(" ✗ %s: got %s, want %s" % [what, JSON.stringify(got), JSON.stringify(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
## A 1d20 + @luck event table with results from -3 to 24:
## -3 Disaster · -2–5 Bad · 6–15 Quiet · 16–23 Good · 24 Windfall.

View file

@ -1,27 +1,16 @@
extends SceneTree
extends TestBase
## Navigation on big boards: search (BoardSearch and the panel), focus_table,
## the minimap, Pack collapsed groups (and making room when a packed group
## expands), lazily built cards for collapsed groups, and the resizable tray
## and inspector.
## Run: godot --headless --path . -s res://tests/test_navigation.gd -- --sample
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_fold_and_layout()
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
# The headless window is tiny; give the app a real screen's worth of room.
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
@ -36,8 +25,7 @@ func _init() -> void:
await _test_pack()
await _test_zoom_range()
await _test_panels()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
## start -> agent (in Careers, 30 results); careers and skills groups
@ -104,9 +92,9 @@ func _test_lazy_cards() -> void:
var paths: Dictionary = main.board.pipes._paths
var gn := main.group_node("careers")
var into: PackedVector2Array = paths.get("start:e1>agent", PackedVector2Array())
_check(not into.is_empty() and into[into.size() - 1].distance_to(gn.inlet_point()) < 0.5, "a pipe into a hidden member still routes to its group")
_check(not into.is_empty() and into[into.size() - 1].distance_to(gn.inlet_point()) < 0.5, "a thread into a hidden member still routes to its group")
var out: PackedVector2Array = paths.get("skill:e1>gems", PackedVector2Array())
_check(out.is_empty(), "pipes inside one collapsed group aren't drawn")
_check(out.is_empty(), "threads inside one collapsed group aren't drawn")
main.toggle_group("careers")
await process_frame
_check(main.card_for("agent") != null and main.card_for("army") != null, "expanding the group builds its cards")
@ -122,10 +110,10 @@ func _test_lazy_cards() -> void:
var rev := main.board.geometry_rev
for i in 5:
await process_frame
_check(main.board.geometry_rev == rev, "nothing redraws while the board is idle")
_check(main.board.geometry_rev == rev, "nothing redraws while the spread is idle")
main.board.world.position += Vector2(30, 10)
await process_frame
_check(main.board.geometry_rev == rev, "panning doesn't redraw the pipe, port or card layers")
_check(main.board.geometry_rev == rev, "panning doesn't redraw the thread, port or card layers")
func _test_search() -> void:
@ -244,7 +232,7 @@ func _test_minimap() -> void:
main.top_bar.view_menu.sync()
var view_pm := main.top_bar.view_menu.get_popup()
_check(mm.visible and view_pm.is_item_checked(view_pm.get_item_index(ViewMenu.ID_MINIMAP)), "the minimap shows, and View ▾ has it checked")
_check(mm.position.x + mm.size.x <= main.board.size.x and mm.position.y + mm.size.y <= main.board.size.y, "in the board's bottom-right corner")
_check(mm.position.x + mm.size.x <= main.board.size.x and mm.position.y + mm.size.y <= main.board.size.y, "in the spread's bottom-right corner")
mm.set_world(Rect2(-100, -100, 4000, 2000))
var p := Vector2(1234, 567)
_check(mm.map_to_world(mm.world_to_map(p)).distance_to(p) < 0.01, "map and world coordinates round-trip")
@ -252,7 +240,7 @@ func _test_minimap() -> void:
main.board.center_on(Vector2(1900, 900))
var v := main.board.view_rect()
var vm := mm.view_rect_on_map()
_check(vm.position.distance_to(mm.world_to_map(v.position)) < 0.01 and absf(vm.size.x - v.size.x * mm._scale) < 0.01, "the view rect is the board's view, scaled")
_check(vm.position.distance_to(mm.world_to_map(v.position)) < 0.01 and absf(vm.size.x - v.size.x * mm._scale) < 0.01, "the view rect is the spread's view, scaled")
var target := mm.world_to_map(Vector2(500, 300))
mm.pan_to_map_point(target)
_check(main.board.view_rect().get_center().distance_to(Vector2(500, 300)) < 1.0, "clicking the map pans there")
@ -294,7 +282,7 @@ func _test_pack() -> void:
"reading order holds along the top row")
_check(after["end"].position.y > after["start"].position.y and after["pick"].position.x > after["end"].position.x, "and in the row below")
var bounds1 := main.board.content_bounds()
_check(bounds1.size.x < bounds0.size.x * 0.5 and bounds1.size.y < bounds0.size.y, "the board gets much smaller: %s -> %s" % [str(bounds0.size), str(bounds1.size)])
_check(bounds1.size.x < bounds0.size.x * 0.5 and bounds1.size.y < bounds0.size.y, "the spread gets much smaller: %s -> %s" % [str(bounds0.size), str(bounds1.size)])
var agent := main.data.get_table("agent")
_check(agent.position - main.data.get_group("careers").position == Vector2(22, 68), "members move with their group")
_check(main.top_bar._toast.visible and main.top_bar._toast_undo.visible, "with an undo toast")
@ -320,7 +308,7 @@ func _test_zoom_range() -> void:
main.board.set_zoom(0.01)
_check(is_equal_approx(main.board.zoom, BoardView.MIN_ZOOM) and BoardView.MIN_ZOOM <= 0.1, "zoom goes down to about 0.1")
main.board.fit()
_check(main.board.zoom < 0.35, "Fit can zoom below the old minimum for a wide board: %.2f" % main.board.zoom)
_check(main.board.zoom < 0.35, "Fit can zoom below the old minimum for a wide spread: %.2f" % main.board.zoom)
## Rects of the blocks Pack works on: groups (compact or frame) and loose cards.
@ -339,12 +327,6 @@ func _overlaps(rects: Array) -> bool:
return false
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print("FAIL ", what)
func _test_panels() -> void:
print("Resizable tray and inspector")
var foot: PanelSplitter = null
@ -393,11 +375,3 @@ func _test_panels() -> void:
_check(not side.visible, "no handle in Play mode")
main.history.clear()
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(typeof(got) == typeof(want) and got == want, "%s: got %s, want %s" % [what, str(got), str(want)])
func _frames(n: int = 4) -> void:
for i in n:
await process_frame

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## Headless checks for dynamic pick options (options_from / options_where),
## conditional options (show_if) and indirect variable names (@[expr]), as in
## docs/LOGIC.md §2a: candidates, labels and values, fixed extras, Random,
@ -6,13 +6,9 @@ extends SceneTree
## already have" board and the choice pop-up's rendering.
## Run: godot --headless --path . -s res://tests/test_options.gd -- --sample
var _failures := 0
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_prefix_options()
_test_list_options()
@ -28,8 +24,7 @@ func _init() -> void:
await _test_dialog()
_test_settings()
await _test_card()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
# ---------------------------------------------------------------- helpers
@ -344,7 +339,7 @@ func _test_json() -> void:
_check(not plain.has("options_from") and not plain.has("options_where"), "a fixed pick card has no options keys")
var col := {"format_version": 2, "id": "c", "name": "C", "tables": [d]}
var res := JsonIO.import_json(JsonIO.export_json(col))
_check(res["ok"], "the collection imports")
_check(res["ok"], "the spread imports")
var td: Dictionary = (res["collection"]["tables"] as Array)[0]
_check(str(td.get("options_from", "")) == "@skill_*" and str(td.get("options_where", "")) == "option_value >= 1" \
and str((td["entries"][1] as Dictionary).get("show_if", "")) == "@terms > 2", "export and import keep them")
@ -433,7 +428,7 @@ func _test_tester() -> void:
spend.entries.append(TableEntry.new("keep", "Keep it all"))
var b := _board([start, spend])
var report: Dictionary = await BoardTester.simulate(b, "start", {"runs": 100, "seed": 4})
_check(BoardTester.is_clean(report), "the simulator runs a dynamic board cleanly")
_check(BoardTester.is_clean(report), "the simulator runs a dynamic spread cleanly")
_check(not (report["unchosen"] as Dictionary).has("spend"), "both the Chosen entry and the fixed extra get chosen")
@ -471,7 +466,7 @@ func _test_dialog() -> void:
pp.free()
d.plain = false
var p := d.preview_for_option(1)
_check(p != null and _has(p, "@[option] += 1") and _has(p, "Next step"), "a dynamic option's preview shows the Chosen entry's effects and pipes")
_check(p != null and _has(p, "@[option] += 1") and _has(p, "Next step"), "a dynamic option's preview shows the Chosen entry's effects and threads")
_check(_has(p, "skill_gun_combat"), "the preview names the variable behind the option")
p.free()
# Key 3 answers the third option (Pilot).
@ -617,9 +612,3 @@ func _has(n: Node, needle: String) -> bool:
if s.contains(needle):
return true
return false
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## The display side of Plain Build (docs/PLAIN.md §6): plain chips and lines
## on cards and their text-mode twins, the switch refreshing them, pipe
## labels, check / collection / inputs visuals, "Why this?" sentences and the
@ -9,8 +9,6 @@ extends SceneTree
## (rules_plain(), rules_view_changed, select_result(), select_card()), so the
## display can be tested on its own.
var _failures := 0
var main: Main
const FAKE_MAIN := """extends Main
%s
@ -56,19 +54,11 @@ const BOARD := {
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_why_sentences()
_test_rules_view_helpers()
main = _make_main()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to roll.")
quit(2)
if not await start_main():
return
main.rng.seed = 7
main.data.load_json(JSON.stringify(BOARD))
@ -88,13 +78,12 @@ func _init() -> void:
await _test_roll_why()
await _test_build_rows()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
## Main with the inspector's hooks (only the signal is skipped when Main
## already declares it).
func _make_main() -> Main:
func _create_main() -> Main:
var has_signal := false
for s: Dictionary in (load("res://ui/main.gd") as Script).get_script_signal_list():
if str(s["name"]) == "rules_view_changed":
@ -150,17 +139,6 @@ func _chips(card: TableCard) -> PackedStringArray:
return out
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
func _eq(got: Variant, want: Variant, what: String) -> void:
if got != want:
_failures += 1
print(" ✗ %s: got %s, want %s" % [what, var_to_str(got), var_to_str(want)])
# ---------------------------------------------------------------- pure parts
@ -184,7 +162,7 @@ func _test_why_sentences() -> void:
_eq(Describe.why(other, b), "Took Learn from it because no condition was true", "otherwise fact")
_eq(Describe.why(case_f, b), "Case 1 didn't match because Strength was 9 (needs 10 or more)", "case fact")
_eq(Describe.why(eff, b), "Luck went from 2 to 1", "effect fact")
_eq(Describe.why(inp, b), "Tier was 3 (from the pipe)", "input fact")
_eq(Describe.why(inp, b), "Tier was 3 (from the thread)", "input fact")
_check(Describe.why(when_f, b, false).contains("@luck >= 2"), "text mode keeps the rule as written")
# A step's reasons: the parent's pipe choices aimed at it, the parent's
# effects on the values they read, then its own facts.
@ -241,35 +219,35 @@ func _test_switch() -> void:
await process_frame
var beyond := main.card_for("beyond")
_check(_chips(beyond).has("@luck -= 1"), "Text view: the chip shows the stored statement")
_check(_has(main.card_for("rounds"), "while @luck > 0"), "Text view: the loop rule as written")
_check(_has(main.card_for("rounds"), "while @luck > 0"), "Text view: the repeat rule as written")
_check(_has(main.card_for("learn"), "Options from @skill_* · where option_value >= 1"), "Text view: the options source as written")
_check(_has(main.card_for("loot"), "input tier · default 1"), "Text view: inputs by name")
main.board.pipes._process(0.0)
_check(main.board.pipes._drawn_state.back() == false, "the pipe layer redraws for the Text view")
_check(main.board.pipes._drawn_state.back() == false, "the thread layer redraws for the Text view")
_set_plain(true)
await process_frame
_check(_chips(main.card_for("beyond")).has("Luck −1"), "switching back refreshes the chips")
main.board.pipes._process(0.0)
_check(main.board.pipes._drawn_state.back() == true, "and the pipes")
_check(main.board.pipes._drawn_state.back() == true, "and the threads")
func _test_pipe_labels() -> void:
var b := main.data
var vault := b.get_table("beyond").entries[1]
_eq(RulesView.pipe_label(vault, "loot", b, true), "Tier 3 · only if Luck is 2 or more", "plain pipe label")
_eq(RulesView.pipe_label(vault, "loot", b, true), "Tier 3 · only if Luck is 2 or more", "plain thread label")
_eq(RulesView.pipe_label(vault, "learn", b, true), "otherwise", "otherwise label")
_eq(RulesView.pipe_label(vault, "loot", b, false), "tier=3 if @luck >= 2", "text pipe label")
_eq(RulesView.pipe_label(b.get_table("gate").entries[0], "beyond", b, true), "", "a plain pipe has no label")
_eq(RulesView.pipe_label(vault, "loot", b, false), "tier=3 if @luck >= 2", "text thread label")
_eq(RulesView.pipe_label(b.get_table("gate").entries[0], "beyond", b, true), "", "a plain thread has no label")
func _test_router_and_choice() -> void:
var climb := main.card_for("climb")
_check(_has(climb, "if Strength is 10 or more"), "a router case reads in words")
_check(_has(climb, "if Strength is 10 or more"), "a branch case reads in words")
_check(_has(climb, "Otherwise"), "the last case reads Otherwise")
var learn := main.card_for("learn")
_check(_has(learn, "Options: your Skills, level 1 or more"), "a choice's options source reads in words")
_check(_has(learn, "only if Luck is at most 1"), "show_if reads only if …")
_check(_chips(learn).has("Chosen skill +1"), "the Chosen row's effect names the collection's member")
_check(_chips(learn).has("Chosen skill +1"), "the Chosen row's effect names the spread's member")
func _test_check_card() -> void:
@ -280,7 +258,7 @@ func _test_check_card() -> void:
_check(_has(gate, "8+") and _has(gate, "≤7"), "outlet ranges")
await process_frame
for eid in ["ok", "no"]:
_check(not gate.anchor_for(eid).is_empty(), "the %s outlet has a pipe anchor" % eid)
_check(not gate.anchor_for(eid).is_empty(), "the %s outlet has a thread anchor" % eid)
var ok_y: float = gate.anchor_for("ok").get("pos", Vector2.ZERO).y
var no_y: float = gate.anchor_for("no").get("pos", Vector2.ZERO).y
_check(no_y > ok_y, "Failure sits below Success")
@ -297,7 +275,7 @@ func _test_collection_and_inputs() -> void:
names.append(str(m.get_meta("member")))
_eq(names, ["@skill_athletics", "@skill_mechanic", "@skill_recon"], "members: set ones by label, then ones the rules name")
_check(_has(skills, "Mechanic") and _has(skills, "2") and _has(skills, "—"), "members show live values")
_check(_has(skills, "Collection · kept between rolls"), "the collection's kind line")
_check(_has(skills, "Collection · kept between rolls"), "the spread's kind line")
main.persistent_vars["skill_mechanic"] = {"value": 3, "source": ""}
main.refresh_live()
_check(_has(skills, "3"), "values refresh live")
@ -382,7 +360,7 @@ func _test_build_rows() -> void:
_check(not _has(beyond, "ƒ") and not _has(beyond, "Details"), "the inline effects / details editors are gone")
_check(_with_meta(beyond, "effects_chip").size() == 1, "one chip for the one entry with effects")
var climb := main.card_for("climb")
_check(not _with_meta(climb, "case_line").is_empty() and _has(climb, "if Strength is 10 or more"), "a Build router case shows its condition in words")
_check(not _with_meta(climb, "case_line").is_empty() and _has(climb, "if Strength is 10 or more"), "a Build branch case shows its condition in words")
var row: Control = beyond.rows["e2"]
var ev := InputEventMouseButton.new()
ev.button_index = MOUSE_BUTTON_LEFT
@ -391,7 +369,7 @@ func _test_build_rows() -> void:
_eq(main.get("picked").back(), ["beyond", "e2"], "clicking a result row calls select_result")
_eq(beyond.selected_entry(), "e2", "the row is selected")
var sb := row.get_theme_stylebox("panel") as StyleBoxFlat
_check(sb != null and sb.border_width_left == 3 and sb.border_color == Style.COPPER, "the selected row has a copper bar")
_check(sb != null and sb.border_width_left == 3 and sb.border_color == Style.TRIM, "the selected row has a copper bar")
var gate := main.card_for("gate")
(gate.rows["ok"] as Control).emit_signal("gui_input", ev)
_eq(beyond.selected_entry(), "", "selecting on another card clears this one")
@ -399,7 +377,7 @@ func _test_build_rows() -> void:
gate.set_selected_entry("no")
_eq(gate.selected_entry(), "no", "the inspector can set the selection directly")
var adds := _with_meta(main.card_for("skills"), "collection_add")
_check(adds.size() == 1 and (adds[0] as Button).text == "+ Add skill", "the collection card has + Add skill in Build")
_check(adds.size() == 1 and (adds[0] as Button).text == "+ Add skill", "the spread card has + Add skill in Build")
if adds.size() == 1:
(adds[0] as Button).emit_signal("pressed")
_eq(main.get("picked").back(), ["card", "skills"], "+ Add selects the card for the inspector")

185
tests/test_roll_features.gd Normal file
View file

@ -0,0 +1,185 @@
extends TestBase
## Roll features in the engine: combining a thread's repeated rolls (add,
## highest, lowest, choose), saving the combined value, and only the kept roll
## following its threads.
## Run: godot --headless --path . -s res://tests/test_roll_features.gd
func _init() -> void:
_test_combine()
await _test_choose()
await _test_pause()
await _test_costs()
_test_limits()
finish()
## Start → Gold ×3; Gold's results are numbers, and each pipes on to Note.
func _board(mode: String) -> TowerBoard:
var b := TowerBoard.new()
var start := RollTable.new("start", "Start")
var e := TableEntry.new("e1", "Treasure")
e.add_pipe("gold", 3, "loot")
if mode != "all":
e.pipe_combine["gold"] = mode
start.entries.append(e)
var gold := RollTable.new("gold", "Gold")
for i in 6:
var g := TableEntry.new("g%d" % i, str((i + 1) * 10))
g.add_pipe("note")
gold.entries.append(g)
var note := RollTable.new("note", "Note")
note.entries.append(TableEntry.new("n1", "Noted"))
for t in [start, gold, note]:
b.tables.append(t)
return b
func _kids(tree: Dictionary, tid: String) -> Array:
return (tree["children"] as Array).filter(func(k: Dictionary) -> bool: return (k["table"] as RollTable).id == tid)
func _test_combine() -> void:
var rng := RandomNumberGenerator.new()
rng.seed = 7
var tree := Roller.roll(_board("all"), "start", rng)
_check(_kids(tree, "gold").size() == 3, "keep every roll: three Gold results")
_check((_kids(tree, "gold")[0]["children"] as Array).size() == 1, "and each follows its own thread")
var b := _board("sum")
var ctx := Roller.new_context(b, rng)
tree = Roller.roll(b, "start", rng, 0, {}, ctx)
var golds := _kids(tree, "gold")
var total := 0
for k: Dictionary in golds:
if not k.has("combined"):
total += int(str(k["summary"]))
_check(k.get("dropped", false) and (k["children"] as Array).is_empty(), "added rolls don't follow their threads")
var sum: Dictionary = golds[golds.size() - 1]
_check(sum.get("combined") == "sum" and int(str(sum["summary"])) == total, "add together: a total of %d" % total)
_check(int(ctx.lookup("loot")) == total, "save as keeps the total")
b = _board("max")
tree = Roller.roll(b, "start", rng)
golds = _kids(tree, "gold")
var best: Dictionary = {}
for k: Dictionary in golds:
if not k.get("dropped", false):
best = k
var top := 0
for k: Dictionary in golds:
top = maxi(top, int(str(k["summary"])))
_check(best.get("kept") == "max" and int(str(best["summary"])) == top, "keep the highest keeps %d" % top)
_check((best["children"] as Array).size() == 1, "the kept roll follows its thread")
var flat := Roller.flatten(tree, [])
_check(flat.any(func(s: Dictionary) -> bool: return s.get("dropped", false)), "set-aside rolls are marked in the steps")
var back := TableEntry.from_dict(b.get_table("start").entries[0].to_dict())
_check(back.combine_for("gold") == "max", "the combine mode is saved")
func _test_choose() -> void:
var b := _board("choose")
var rng := RandomNumberGenerator.new()
rng.seed = 3
var ctx := Roller.new_context(b, rng)
var asked: Array = []
ctx.prompt = func(req: Dictionary) -> Variant:
asked.append(req)
return 1
var tree: Dictionary = await Roller.roll_async(b, "start", ctx)
var golds := _kids(tree, "gold")
_check(asked.size() == 1 and (asked[0]["options"] as Array).size() == 3, "let me choose asks once, with the three rolls")
_check(golds[1].get("kept") == "choose" and golds[0].get("dropped", false), "the picked roll is kept")
func _test_pause() -> void:
var b := _board("all")
b.get_table("start").entries[0].pipe_pause["gold"] = true
var rng := RandomNumberGenerator.new()
var tree := Roller.roll(b, "start", rng)
_check(_kids(tree, "gold").size() == 3, "headless rolls continue past a pause")
var ctx := Roller.new_context(b, rng)
var asked: Array = []
ctx.prompt = func(req: Dictionary) -> Variant:
asked.append(req)
return false
tree = await Roller.roll_async(b, "start", ctx)
_check(asked.size() == 1 and asked[0]["kind"] == "pause", "a paused thread asks once")
_check(_kids(tree, "gold").is_empty() and tree.get("stopped_before") == "gold", "Stop here ends the roll before the thread")
var back := TableEntry.from_dict(b.get_table("start").entries[0].to_dict())
_check(back.pipe_pause.has("gold"), "the pause is saved")
## A pick card whose "Reroll" option costs 1 point.
func _test_costs() -> void:
var b := TowerBoard.new()
var pick := RollTable.create(RollTable.KIND_CHOICE, "pick", "Spend?", "pick")
pick.entries.clear()
var keep := TableEntry.new("k", "Keep it")
var again := TableEntry.new("r", "Reroll")
again.cost_value = "@points"
again.cost_amount = "1"
pick.entries.append(keep)
pick.entries.append(again)
b.tables.append(pick)
var rng := RandomNumberGenerator.new()
var ctx := Roller.new_context(b, rng, {"points": 1})
var req := RollChoice.request_for(pick, ctx)
var o: Dictionary = (req["options"] as Array)[1]
_check(o.get("cost") == "Costs 1 points" or str(o.get("cost", "")).begins_with("Costs 1"), "the option says what it costs: %s" % str(o.get("cost")))
_check(not o.has("disabled"), "with a point it can be picked")
ctx.prompt = func(_r: Dictionary) -> Variant: return 1
await Roller.roll_async(b, "pick", ctx)
_check(int(ctx.lookup("@points")) == 0, "picking it pays the point")
req = RollChoice.request_for(pick, ctx)
o = (req["options"] as Array)[1]
_check(str(o.get("disabled", "")).contains("you have 0"), "with none left it's greyed out: %s" % str(o.get("disabled", "")))
var tree: Dictionary = await Roller.roll_async(b, "pick", ctx)
_check((tree["entry"] as TableEntry).id == "k", "a greyed-out option can't be picked; the reply falls back")
for i in 20:
var t2 := Roller.roll(b, "pick", rng, 0, {}, ctx)
if (t2["entry"] as TableEntry).id == "r":
_check(false, "Random never picks an option you can't afford")
break
var back := TableEntry.from_dict(again.to_dict())
_check(back.cost_value == "@points" and back.cost_amount == "1", "the cost is saved")
## An earlier result sets @atmo_min; the later Atmosphere card never rolls below it.
func _test_limits() -> void:
var b := TowerBoard.new()
var feature := RollTable.new("feature", "Feature")
var e := TableEntry.new("f", "Thick haze")
e.effects = "@atmo_min = 7"
e.add_pipe("atmo")
feature.entries.append(e)
var atmo := RollTable.new("atmo", "Atmosphere")
atmo.dice = "2d6"
for i in range(2, 13):
var a := TableEntry.new("a%d" % i, "Atmo %d" % i)
a.has_range = true
a.range_lo = i
a.range_hi = i
atmo.entries.append(a)
atmo.roll_floor = "@atmo_min"
b.tables.append(feature)
b.tables.append(atmo)
var rng := RandomNumberGenerator.new()
var low := 99
for i in 60:
var ctx := Roller.new_context(b, rng)
var tree := Roller.roll(b, "feature", rng, 0, {}, ctx)
var child: Dictionary = tree["children"][0]
low = mini(low, int(child["value"]))
_check(low == 7, "the earlier result's floor holds: lowest roll %d" % low)
var ctx2 := Roller.new_context(b, rng)
var r := RollRange.limit(atmo, 3, ctx2)
_check(r["value"] == 3 and not r.has("limited"), "an unset value doesn't limit the roll")
Effects.run("@atmo_min = 7", ctx2, "feature")
r = RollRange.limit(atmo, 3, ctx2)
_check(r["value"] == 7 and r["limited"] == "floor", "below the floor is raised to it")
var why := Describe.why({"type": "roll", "pick": "dice", "dice": "2d6", "faces": [1, 2], "total": 7, "raw": 3, "limited": "floor", "limit_expr": "@atmo_min"}, b, true)
_check(why.contains("raised to 7"), "Why says it was raised: " + why)
var back := RollTable.from_dict(atmo.to_dict())
_check(back.roll_floor == "@atmo_min", "the floor is saved")

View file

@ -0,0 +1 @@
uid://bg7ass7t6g5tu

View file

@ -1,9 +1,7 @@
extends SceneTree
extends TestBase
## Headless checks for the data model and roller.
## Run: godot --headless --path . -s res://tests/test_roller.gd
var _failures := 0
func _init() -> void:
var board := SampleBoard.create()
@ -25,7 +23,7 @@ func _init() -> void:
_check(wild.range_problems() == "", "wilderness ranges have no gaps or overlaps")
_check(wild.num_label(wild.entries[5], 5) == "96–00", "last range reads 96–00")
for e in wild.entries:
_check(e.pipes.size() == 1, "range %s has exactly one pipe" % e.text)
_check(e.pipes.size() == 1, "range %s has exactly one thread" % e.text)
# Range weighting: 01–30 should come up about 30% of the time.
var counts := {}
@ -69,19 +67,19 @@ func _init() -> void:
_check(stops > 50 and stops < 150, "rolls into a gap stop with a message (%d/200)" % stops)
# A self-pipe stops at the action limit (docs/LOGIC.md §7) instead of looping forever.
var loop := RollTable.new("loop", "Loop")
var loop := RollTable.new("loop", "Repeat")
var again := TableEntry.new("e1", "Again")
again.pipes.append("loop")
loop.entries.append(again)
var b3 := TowerBoard.new()
b3.tables.append(loop)
var steps := Roller.flatten(Roller.roll(b3, "loop", rng), [])
_check(steps.size() == Roller.MAX_ACTIONS + 1 and str(steps[steps.size() - 1]["text"]) == Roller.limit_text(), "self-pipe stops at the action limit (%d steps)" % steps.size())
_check(steps.size() == Roller.MAX_ACTIONS + 1 and str(steps[steps.size() - 1]["text"]) == Roller.limit_text(), "self-thread stops at the action limit (%d steps)" % steps.size())
# JSON round trip keeps everything.
var copy := TowerBoard.new()
_check(copy.load_json(board.to_json()), "board JSON loads back")
_check(copy.to_json() == board.to_json(), "board JSON round-trips unchanged")
_check(copy.load_json(board.to_json()), "spread JSON loads back")
_check(copy.to_json() == board.to_json(), "spread JSON round-trips unchanged")
_check(copy.get_table("trinkets").collapsed, "collapsed state is saved")
# Removing a table removes pipes into it.
@ -91,13 +89,6 @@ func _init() -> void:
for e in t.entries:
if e.pipes.has("loot"):
dangling = true
_check(not dangling and copy.get_table("loot") == null, "removing a table removes pipes into it")
_check(not dangling and copy.get_table("loot") == null, "removing a table removes threads into it")
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)
finish()

View file

@ -1,12 +1,10 @@
extends SceneTree
extends TestBase
## Headless checks for conditional pipes and router cards (docs/LOGIC.md §3a
## and §3b): when / otherwise selection, the snapshot rule, expression errors,
## first-match routing, "No case matched", the file format, lint_pipes() and a
## small board where a router replaces a chain-variable workaround.
## Run: godot --headless --path . -s res://tests/test_router.gd
var _failures := 0
func _init() -> void:
_test_when_otherwise()
@ -19,8 +17,7 @@ func _init() -> void:
_test_cycles()
await _test_mini_board()
_test_ui_helpers()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
# ---------------------------------------------------------------- helpers
@ -93,13 +90,13 @@ func _branch_board(str_value: int) -> TowerBoard:
func _test_when_otherwise() -> void:
_eq(_ids(_roll(_branch_board(10), "start")), ["start", "strong", "after"], "a true condition runs its pipe; otherwise is skipped")
_eq(_ids(_roll(_branch_board(10), "start")), ["start", "strong", "after"], "a true condition runs its thread; otherwise is skipped")
_eq(_ids(_roll(_branch_board(2), "start")), ["start", "weak", "after"], "the second condition can be the true one")
_eq(_ids(_roll(_branch_board(6), "start")), ["start", "plain", "after"], "no condition true: the otherwise pipe runs")
_eq(_ids(_roll(_branch_board(6), "start")), ["start", "plain", "after"], "no condition true: the otherwise thread runs")
# Two true conditions both run (pipes aren't else-if; use a router for that).
var b := _branch_board(10)
b.get_table("start").entries[0].set_pipe_when("weak", "@str > 1")
_eq(_ids(_roll(b, "start")), ["start", "strong", "weak", "after"], "every true condition runs, in pipe order")
_eq(_ids(_roll(b, "start")), ["start", "strong", "weak", "after"], "every true condition runs, in thread order")
# A condition clears otherwise, and otherwise can't be set while there's a condition.
var e := TableEntry.new("e1", "x")
e.add_pipe("y")
@ -115,8 +112,8 @@ func _test_when_otherwise() -> void:
var lit_e := {}
var lit_p := {}
Roller.collect_lit(_roll(_branch_board(10), "start"), lit_e, lit_p)
_check(lit_p.has(Roller.pipe_key("start", "e1", "strong")) and lit_p.has(Roller.pipe_key("start", "e1", "after")), "taken pipes light")
_check(not lit_p.has(Roller.pipe_key("start", "e1", "weak")) and not lit_p.has(Roller.pipe_key("start", "e1", "plain")), "skipped pipes stay dark")
_check(lit_p.has(Roller.pipe_key("start", "e1", "strong")) and lit_p.has(Roller.pipe_key("start", "e1", "after")), "taken threads light")
_check(not lit_p.has(Roller.pipe_key("start", "e1", "weak")) and not lit_p.has(Roller.pipe_key("start", "e1", "plain")), "skipped threads stay dark")
# ---------------------------------------------------------------- snapshot
@ -139,7 +136,7 @@ func _test_snapshot() -> void:
var vars := {}
var ids := _ids(_roll(b, "start", vars))
_eq(ids, ["start", "first", "second", "third"], "conditions and counts come from the snapshot, not the changed variables")
_eq(_var(vars, "x"), 1, "the first pipe's subtree did change @x")
_eq(_var(vars, "x"), 1, "the first thread's subtree did change @x")
# An otherwise pipe doesn't fire because a when pipe's subtree made the
# conditions false afterwards.
_check(not ids.has("fallback"), "otherwise reads the snapshot too")
@ -149,7 +146,7 @@ func _test_snapshot() -> void:
link.entries[0].add_pipe("link")
link.entries[0].set_pipe_when("link", "@k < 5")
var v2 := {}
_eq(_ids(_roll(_board([link]), "link", v2)).size(), 5, "a conditional self-pipe stops when its condition turns false")
_eq(_ids(_roll(_board([link]), "link", v2)).size(), 5, "a conditional self-thread stops when its condition turns false")
_eq(_var(v2, "k"), 5, "it ran five times")
@ -165,7 +162,7 @@ func _test_errors() -> void:
var tree := _roll(_board([start, _one("bad", "Bad"), _one("other", "Other")]), "start")
_eq(_ids(tree), ["start", "other"], "a condition that errors counts as false (so otherwise runs)")
var errs := _errors(tree)
_check(errs.size() == 1 and str(errs[0]).begins_with("Pipe condition @x + * 2"), "the error shows as an error line on the node: %s" % str(errs))
_check(errs.size() == 1 and str(errs[0]).begins_with("Thread condition @x + * 2"), "the error shows as an error line on the node: %s" % str(errs))
var step: Dictionary = Roller.flatten(tree)[0]
_check((step.get("effects", []) as Array).size() == 1, "the error line is in the step's effects")
@ -186,9 +183,9 @@ func _router_board() -> TowerBoard:
func _test_router() -> void:
var t := RollTable.create(RollTable.KIND_ROUTER, "r", "Router")
_eq(t.kind, "router", "create makes a router")
_eq(t.entries.size(), 2, "a new router has two cases")
var t := RollTable.create(RollTable.KIND_ROUTER, "r", "Branch")
_eq(t.kind, "router", "create makes a branch")
_eq(t.entries.size(), 2, "a new branch has two cases")
_eq(t.entries[0].text, "if …", "its first case")
_check(t.entries[0].when != "" and Expr.check(t.entries[0].when) == "", "the first case has a valid condition")
_check(t.entries[1].text == "Otherwise" and t.entries[1].when == "", "the second is Otherwise")
@ -197,7 +194,7 @@ func _test_router() -> void:
var vars := {"species": {"value": "Aslan", "source": ""}, "str": {"value": 10, "source": ""}}
var tree := _roll(b, "route", vars)
_eq(_ids(tree), ["route", "aslan"], "the first true case wins, even when a later one is true too")
_eq(str(tree.get("kind", "")), "router", "the node's kind is router")
_eq(str(tree.get("kind", "")), "router", "the node's kind is branch")
_eq(tree.get("case"), 0, "the node's case index")
_eq(_var(vars, "took"), "aslan", "the case's effects ran")
_eq(Formatter.strip_tags(str(tree["summary"])), "Aslan path", "the case's text is the summary")
@ -209,13 +206,13 @@ func _test_router() -> void:
# One action per router.
var ctx := Roller.new_context(b, _rng(), {})
Roller.roll(b, "route", ctx.rng, 0, {}, ctx)
_eq(ctx.actions, 2, "a router is one action (plus the table it pipes to)")
_eq(ctx.actions, 2, "a branch is one action (plus the table it threads to)")
# A case condition with an error counts as false and is reported.
b.get_table("route").entries[0].when = "@species = = 3 +"
var t3 := _roll(b, "route", {})
_eq(_ids(t3), ["route", "plain"], "an erroring case is skipped")
var errs := _errors(t3)
_check(errs.size() == 1 and str(errs[0]).begins_with("Case "), "the case error is on the router node: %s" % str(errs))
_check(errs.size() == 1 and str(errs[0]).begins_with("Case "), "the case error is on the branch node: %s" % str(errs))
# Lighting: the matched case is lit.
var le := {}
var lp := {}
@ -229,13 +226,13 @@ func _test_no_case() -> void:
r.entries.remove_at(2) # no Otherwise
var tree := _roll(b, "route", {})
_check(tree.has("stop") and str(tree["summary"]) == Roller.NO_CASE, "nothing matched: the node stops with \"No case matched\"")
_eq(str(tree.get("kind", "")), "router", "the stop node is a router node")
_eq(str(tree.get("kind", "")), "router", "the stop node is a branch node")
_eq(_ids(tree), ["route"], "nothing follows")
var step: Dictionary = Roller.flatten(tree)[0]
_check(step.get("stop", false) and str(step["text"]) == "No case matched", "the step shows it")
# A router with no cases at all.
r.entries.clear()
_check(_roll(b, "route", {}).has("stop"), "an empty router stops")
_check(_roll(b, "route", {}).has("stop"), "an empty branch stops")
# ---------------------------------------------------------------- file format
@ -253,9 +250,9 @@ func _test_json() -> void:
_eq(str(ed.get("when", "")), "@str >= 8", "an entry's when is written")
_check(not (d["entries"][2] as Dictionary).has("when"), "the Otherwise case has no when")
var pipes: Array = ed["pipes"]
_eq(pipes[1], {"table": "aslan", "count": 2, "save_as": "who", "when": "@str > 9"}, "a pipe's when is written with its other options")
_eq(pipes[2], {"table": "plain", "otherwise": true}, "an otherwise pipe")
_eq(pipes[0], "strong", "a plain pipe stays a bare id")
_eq(pipes[1], {"table": "aslan", "count": 2, "save_as": "who", "when": "@str > 9"}, "a thread's when is written with its other options")
_eq(pipes[2], {"table": "plain", "otherwise": true}, "an otherwise thread")
_eq(pipes[0], "strong", "a plain thread stays a bare id")
var back := RollTable.from_dict(d)
var be := back.entries[1]
_check(back.kind == "router" and be.when == "@str >= 8" and be.when_for("aslan") == "@str > 9" and be.is_otherwise("plain") and be.count_for("aslan") == 2 and be.save_for("aslan") == "who", "the table round-trips")
@ -266,10 +263,10 @@ func _test_json() -> void:
{"id": "b", "text": "B", "when": ""}]}]}
var c := JsonIO.canonical(raw)
var ce: Dictionary = c["tables"][0]["entries"][0]
_eq(str(c["tables"][0].get("kind", "")), "router", "canonical keeps kind router")
_eq(str(c["tables"][0].get("kind", "")), "router", "canonical keeps kind branch")
_eq(str(ce.get("when", "")), "@a = 1", "canonical keeps (trimmed) entry when")
_check(not (c["tables"][0]["entries"][1] as Dictionary).has("when"), "canonical drops an empty when")
_eq(ce["pipes"], [{"table": "y", "when": "@b"}, {"table": "z", "otherwise": true}, {"table": "w"}, {"table": "v"}], "canonical pipe conditions")
_eq(ce["pipes"], [{"table": "y", "when": "@b"}, {"table": "z", "otherwise": true}, {"table": "w"}, {"table": "v"}], "canonical thread conditions")
var text := JsonIO.export_json(b.to_dict())
var imp := JsonIO.import_json(text)
_check(imp["ok"], "the export imports")
@ -277,14 +274,14 @@ func _test_json() -> void:
b2.load_dict(imp["collection"])
var e2 := b2.get_table("route").entries[1]
_check(e2.when == "@str >= 8" and e2.when_for("aslan") == "@str > 9" and e2.is_otherwise("plain"), "a JSON export round-trips conditions")
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "when": "@str >= 8", "count": 2, "save_as": "w"})), "if @str >= 8 ×2 → w", "edge label for a conditional pipe")
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "otherwise": true})), "otherwise", "edge label for an otherwise pipe")
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "when": "@str >= 8", "count": 2, "save_as": "w"})), "if @str >= 8 ×2 → w", "edge label for a conditional thread")
_eq(JsonIO.pipe_label(JsonIO.pipe_info({"table": "y", "otherwise": true})), "otherwise", "edge label for an otherwise thread")
# ---------------------------------------------------------------- lint
func _test_lint() -> void:
_eq(Roller.lint_pipes(_router_board()), [] as Array[Dictionary], "a clean board has no lint")
_eq(Roller.lint_pipes(_router_board()), [] as Array[Dictionary], "a clean spread has no lint")
var b := _router_board()
var r := b.get_table("route")
# Otherwise first: the cases after it can't be chosen.
@ -311,9 +308,9 @@ func _test_lint() -> void:
msgs["%s:%s" % [item["table_id"], item["entry_id"]]] = str(msgs.get("%s:%s" % [item["table_id"], item["entry_id"]], "")) + str(item["message"]) + "|"
_check(str(msgs.get("route:c3", "")).contains("Otherwise case isn't last"), "Otherwise case not last: %s" % str(lint))
_check(str(msgs.get("route:c1", "")).begins_with("Case @str >= = 8"), "a bad case condition: %s" % str(lint))
_check(str(msgs.get("start:e1", "")).contains("Pipe condition (((") and str(msgs.get("start:e1", "")).contains("comes before a conditional pipe"), "a bad pipe condition, and otherwise before when: %s" % str(lint))
_check(str(msgs.get("lonely:e1", "")).contains("always runs"), "otherwise with no conditional pipe: %s" % str(lint))
_check(str(msgs.get("empty:", "")).contains("no cases"), "a router with no cases: %s" % str(lint))
_check(str(msgs.get("start:e1", "")).contains("Thread condition (((") and str(msgs.get("start:e1", "")).contains("comes before a conditional thread"), "a bad thread condition, and otherwise before when: %s" % str(lint))
_check(str(msgs.get("lonely:e1", "")).contains("always runs"), "otherwise with no conditional thread: %s" % str(lint))
_check(str(msgs.get("empty:", "")).contains("no cases"), "a branch with no cases: %s" % str(lint))
_eq(lint.size(), 6, "six lint items")
@ -322,12 +319,12 @@ func _test_cycles() -> void:
var link := _one("link", "Link", "@k += 1")
link.entries[0].add_pipe("link")
link.entries[0].set_pipe_when("link", "@k < 3")
_eq(Roller.endless_cycles(_board([link])), [] as Array[String], "a conditional self-pipe is not an endless cycle")
_eq(Roller.endless_cycles(_board([link])), [] as Array[String], "a conditional self-thread is not an endless cycle")
var r := RollTable.create(RollTable.KIND_ROUTER, "r", "R")
r.entries[0].add_pipe("r")
_eq(Roller.endless_cycles(_board([r])), [] as Array[String], "a router with a case that finishes is fine")
_eq(Roller.endless_cycles(_board([r])), [] as Array[String], "a branch with a case that finishes is fine")
r.entries[1].add_pipe("r")
_eq(Roller.endless_cycles(_board([r])), ["r"] as Array[String], "a router whose every case loops back is endless")
_eq(Roller.endless_cycles(_board([r])), ["r"] as Array[String], "a branch whose every case loops back is endless")
# ---------------------------------------------------------------- mini board
@ -390,9 +387,9 @@ func _test_mini_board() -> void:
_eq(_var(vars, "path"), "aslan" if pick == 0 else "human", "%s: @path" % label)
_check(_errors(tree).is_empty(), "%s: no errors" % label)
if use_router:
_check(ids.has("route") and ids.has("sheet"), "%s: through the router to the sheet" % label)
_check(ids.has("route") and ids.has("sheet"), "%s: through the branch to the sheet" % label)
# The router version lints clean and has no cycles.
_eq(Roller.lint_pipes(_species_board(true)), [] as Array[Dictionary], "the router board lints clean")
_eq(Roller.lint_pipes(_species_board(true)), [] as Array[Dictionary], "the branch spread lints clean")
# ---------------------------------------------------------------- UI helpers
@ -407,18 +404,10 @@ func _test_ui_helpers() -> void:
var bad := TableSettingsDialog.apply_settings(r, {"name": "R", "cases": ["@a = = 1", ""]})
_check(not bad["ok"] and str(bad["error"]).begins_with("Case 1"), "settings refuse a bad case: %s" % str(bad))
var ok := TableSettingsDialog.apply_settings(r, {"name": "R", "cases": ["@a = 1", ""], "card_mode": true, "ranged": true})
_check(ok["ok"] and r.entries[0].when == "@a = 1" and not r.card_mode and not r.is_ranged(), "settings set case conditions; no card mode or ranges: %s" % str(ok))
_check(TableSettingsRules.router_hint(["", "@a"]) != "" and TableSettingsRules.router_hint(["@a", ""]) == "", "router order hint")
_eq(TablePreview.kind_line(r), "Router · if / else if / otherwise", "preview kind line")
_check(ok["ok"] and r.entries[0].when == "@a = 1" and not r.card_mode and not r.is_ranged(), "settings set case conditions; no deck mode or ranges: %s" % str(ok))
_check(TableSettingsRules.router_hint(["", "@a"]) != "" and TableSettingsRules.router_hint(["@a", ""]) == "", "branch order hint")
_eq(TablePreview.kind_line(r), "Branch · if / else if / otherwise", "preview kind line")
# ---------------------------------------------------------------- checks
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(typeof(got) == typeof(want) and got == want or (got is Array and want is Array and str(got) == str(want)), "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for the app-shell logic: table settings, collections, import.
## Run: godot --headless --path . -s res://tests/test_shell.gd
const ROOT := "user://test_shell_tmp"
var _failures := 0
func _init() -> void:
_wipe(ROOT)
@ -16,8 +14,7 @@ func _init() -> void:
_test_import()
_test_export()
_wipe(ROOT)
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _plain_table(n: int = 4) -> RollTable:
@ -34,8 +31,8 @@ func _test_settings() -> void:
_check(r["ok"], "plain settings apply")
_check(t.name == "Gems" and t.details == "[b]x[/b]", "name trimmed, details kept")
_check(t.tags == ["a", "b"], "tags split and de-duplicated")
_check(t.card_mode and t.deck_empty == "stop", "card mode and deck_empty set")
_check(r["deck_reset"], "card mode change resets the deck")
_check(t.card_mode and t.deck_empty == "stop", "deck mode and deck_empty set")
_check(r["deck_reset"], "deck mode change resets the deck")
var bad := TableSettingsDialog.apply_settings(t, {"ranged": true, "dice": "banana", "name": "Changed"})
_check(not bad["ok"] and t.name == "Gems" and not t.is_ranged(), "invalid dice changes nothing")
@ -79,7 +76,7 @@ func _test_ranges() -> void:
z.entries[1].weight = 0
z.entries[0].pipes = ["a", "b"] as Array[String]
TableSettingsRules.assign_ranges(z)
_check(not z.entries[1].has_range and z.entries[0].pipes.size() == 1, "weight 0 skipped, extra pipe dropped")
_check(not z.entries[1].has_range and z.entries[0].pipes.size() == 1, "weight 0 skipped, extra thread dropped")
_check(z.entries[2].range_hi == 100, "last live entry reaches the top")
@ -96,10 +93,10 @@ func _test_collections() -> void:
var a := CollectionSwitcher.create_collection(lib, null, "Alpha")
a.tables.append(_plain_table())
var b := CollectionSwitcher.create_collection(lib, a, "Beta")
_check(lib.list().size() == 2, "two collections after create")
_check(lib.load_collection(a.id).tables.size() == 1, "creating saves the current collection first")
_check(lib.list().size() == 2, "two spreads after create")
_check(lib.load_collection(a.id).tables.size() == 1, "creating saves the current spread first")
var back := CollectionSwitcher.switch_collection(lib, b, a.id)
_check(back != null and back.id == a.id and back.tables.size() == 1, "switch loads the other collection")
_check(back != null and back.id == a.id and back.tables.size() == 1, "switch loads the other spread")
_check(CollectionSwitcher.switch_collection(lib, a, "missing") == null, "switch to a missing id is null")
_check(not CollectionSwitcher.rename_collection(lib, a, " "), "blank rename refused")
_check(CollectionSwitcher.rename_collection(lib, a, "Alpha Prime"), "rename works")
@ -108,12 +105,12 @@ func _test_collections() -> void:
_check(copy != null and copy.id != a.id and copy.tables.size() == 1, "duplicate copies the tables")
state.set_variable(a.id, "x", "1")
var next := CollectionSwitcher.delete_collection(lib, copy)
_check(next != null and next.id != copy.id and not lib.exists(copy.id), "delete returns another collection")
_check(state.get_variables(a.id).has("x"), "delete leaves other collections' state")
_check(next != null and next.id != copy.id and not lib.exists(copy.id), "delete returns another spread")
_check(state.get_variables(a.id).has("x"), "delete leaves other spreads' state")
for e in lib.list():
var c := lib.load_collection(str(e["id"]))
CollectionSwitcher.delete_collection(lib, c)
_check(lib.list().size() == 1, "deleting the last collection leaves a fresh empty one")
_check(lib.list().size() == 1, "deleting the last spread leaves a fresh empty one")
func _test_import() -> void:
@ -130,7 +127,7 @@ func _test_import() -> void:
var r := IoMenu.import_as_collection(lib, canvas, "loot.canvas")
_check(r["ok"], "canvas import ok: %s" % str(r["errors"]))
var b: TowerBoard = r["board"]
_check(b != null and lib.list().size() == before + 1 and lib.exists(b.id), "import adds a new collection")
_check(b != null and lib.list().size() == before + 1 and lib.exists(b.id), "import adds a new spread")
var all := ""
for t in b.tables:
all += t.name + "|"
@ -139,7 +136,7 @@ func _test_import() -> void:
_check(not all.contains("[url") and not all.contains("[img") and not all.contains("res://"), "import is sanitized: " + all)
_check(all.contains("[b]bold[/b]") and all.contains("[color=red]gem[/color]"), "safe tags survive: " + all)
var r2 := IoMenu.import_as_collection(lib, canvas, "loot.canvas")
_check(r2["ok"] and r2["board"].id != b.id, "importing twice makes two collections")
_check(r2["ok"] and r2["board"].id != b.id, "importing twice makes two spreads")
var bad := IoMenu.import_as_collection(lib, "{not json", "x.json")
_check(not bad["ok"] and not (bad["errors"] as Array).is_empty() and lib.list().size() == before + 2, "bad file adds nothing")
_check(IoMenu.detect_format("a.canvas", "") == "canvas" and IoMenu.detect_format("a", "<graphml/>") == "graphml", "format detection")
@ -166,9 +163,3 @@ func _wipe(path: String) -> void:
for f in d.get_files():
DirAccess.remove_absolute(abs.path_join(f))
DirAccess.remove_absolute(abs)
func _check(cond: bool, msg: String) -> void:
if not cond:
_failures += 1
print("FAIL: ", msg)

View file

@ -1,10 +1,8 @@
extends SceneTree
extends TestBase
## Keeps the simulator (BoardTester, and its CLI tools/simulate_board.gd) working: runs it on a small inline board with
## a choice, a loop, a check, a bad effect, an unreachable table and a sheet.
## Run: godot --headless --path . -s res://tests/test_simulate.gd
var _failures := 0
func _init() -> void:
var b := _board()
@ -36,14 +34,13 @@ func _init() -> void:
# A preference picks the matching option every time.
var r2: Dictionary = await BoardTester.simulate(b, "start", {"runs": 20, "seed": 4, "prefer": "^Mine$"})
_check((r2["unchosen"] as Dictionary).has("pick"), "--prefer always picks the matching option")
_check(int((r2["table_hits"] as Dictionary).get("mine", 0)) == 20 * 3, "the preferred option's pipe ran on every pass")
_check(int((r2["table_hits"] as Dictionary).get("mine", 0)) == 20 * 3, "the preferred option's thread ran on every pass")
# The action limit is reported as a halt reason.
var r3: Dictionary = await BoardTester.simulate(b, "start", {"runs": 5, "seed": 5, "max_actions": 4})
_eq((r3["halted"] as Dictionary).get("Action limit", 0), 5, "the action limit is a halt reason")
var text := BoardTester.format_report(r)
_check(text.contains("Runs: 60") and text.contains("Tables never reached: 1") and text.contains("Sample final sheet") and text.contains("@gold: min"), "the report prints:\n%s" % text)
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _board() -> TowerBoard:
@ -87,12 +84,3 @@ func _board() -> TowerBoard:
b.tables.append(t)
return b
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(str(got) == str(want), "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

162
tests/test_small_ui.gd Normal file
View file

@ -0,0 +1,162 @@
extends TestBase
## Small UI items: backwards ranges warn and block rolling (no auto-swap), the
## inspector's thread lists, replacing a template, the tray chip's bold source
## name, and the export menu's Other formats.
## Run: godot --headless --path . -s res://tests/test_small_ui.gd -- --sample
func _init() -> void:
if not await start_main():
return
await _test_backwards_range()
await _test_thread_lists()
_test_template_replace()
await _test_chip_and_export()
await _test_deck_mode()
await _test_batch()
await _test_pause_aside()
_test_sheet_export()
finish()
func _test_backwards_range() -> void:
var t := main.data.get_table("wilderness")
var e := t.entries[0]
e.range_lo = 40
e.range_hi = 10
var card := main.card_for("wilderness")
card.update_warning()
_check(e.range_lo == 40 and e.range_hi == 10, "the ends aren't swapped")
_check(RollRange.backwards(t) != "" and t.range_problems().contains("runs backwards"), "a warning says the range runs backwards")
_check(card.header_ui.roll_button.disabled, "the die button is greyed out")
main.rolling.start_roll("wilderness")
await _frames()
_check(not str(main.current).contains("wilderness") or main.current.is_empty() or main.current.get("table_id", "") != "wilderness", "it can't be rolled")
e.range_lo = 1
e.range_hi = 30
card.update_warning()
_check(not card.header_ui.roll_button.disabled, "fixing it enables the die again")
func _test_thread_lists() -> void:
main.set_mode(Main.Mode.BUILD)
await _frames()
main.select_card("road")
await _frames(3)
var texts: Array[String] = []
for b in main.inspector.find_children("*", "Button", true, false):
texts.append((b as Button).text)
var heads: Array[String] = []
for l in main.inspector.find_children("*", "Label", true, false):
heads.append((l as Label).text)
_check(heads.any(func(s: String) -> bool: return s.begins_with("THREADS IN (")), "the card inspector lists threads in")
_check(texts.any(func(s: String) -> bool: return s.begins_with("Wilderness Travel · ")), "a thread in names its card and result: %s" % str(texts.slice(0, 6)))
_check(texts.any(func(s: String) -> bool: return s.contains(" → ")), "threads out name where they go")
func _test_template_replace() -> void:
var lib := main.templating.templates()
var tpl := TemplateKit.make(main.data, ["road"], "card", "Road")
var id := lib.add(tpl)
var changed := tpl.duplicate(true)
changed["name"] = "Road, revised"
changed["replace_id"] = id
main.templating.store_template(changed)
_check(lib.get_template(id).get("name") == "Road, revised", "Replace saves over the same template")
_check(not lib.get_template(id).has("replace_id"), "without the replace marker")
var count := lib.list().size()
main.templating.store_template(tpl.duplicate(true))
_check(lib.list().size() == count + 1, "a plain save still adds a new one")
func _test_chip_and_export() -> void:
main.set_mode(Main.Mode.PLAY)
main.rolling.start_roll("road", true)
await _frames(4)
var bold := false
for l in main.tray.find_children("*", "Label", true, false):
var lab := l as Label
if lab.text == "Road Encounter" and lab.get_theme_font("font") == Style.body_bold():
bold = true
_check(bold, "the chip names its card in bold")
var pm := main.top_bar._board_menu.get_popup()
var subs := pm.find_children("*", "PopupMenu", false, false)
_check(subs.size() == 1 and (subs[0] as PopupMenu).item_count == IoMenu.EXPORTS.size() - 1, "rare formats sit under Other formats")
## Deck mode: drawn results fade, an empty deck that waits for Shuffle gives
## its Empty result, and Shuffle all puts everything back.
func _test_deck_mode() -> void:
var t := main.data.get_table("party_roles")
_check(t != null and t.card_mode, "the sample's Party Roles is a deck")
t.deck_empty = "stop"
t.deck_empty_text = "No roles left"
for i in t.entries.size():
main.rolling.start_roll("party_roles", true)
await _frames(2)
var card := main.card_for("party_roles")
var faded := 0
for e in t.entries:
if card.rows.has(e.id) and (card.rows[e.id] as Control).modulate.a < 0.5:
faded += 1
_check(faded == t.entries.size(), "every drawn result is faded (%d of %d)" % [faded, t.entries.size()])
main.rolling.start_roll("party_roles", true)
await _frames(2)
var steps: Array = main.current.get("steps", [])
var last: Dictionary = steps[steps.size() - 1] if not steps.is_empty() else {}
_check(str(last.get("text", "")) == "No roles left" and last.get("deck_empty", false), "an empty deck gives its Empty result: %s" % str(last.get("text", "")))
main.local_state.reshuffle_all()
await _frames()
_check((card.rows[t.entries[0].id] as Control).modulate.a == 1.0, "Shuffle all brings them back")
func _test_batch() -> void:
var texts: Array[String] = await BatchRoll.run(main, "road", 4)
_check(texts.size() == 4 and texts[0].contains("Road Encounter"), "a batch gives every result: %d" % texts.size())
var dialogs := main.find_children("*", "ModalCard", true, false)
_check(not dialogs.is_empty() and (dialogs[dialogs.size() - 1] as ModalCard).title_label.text == "Road Encounter × 4", "and shows them together")
(dialogs[dialogs.size() - 1] as ModalCard).close()
## A paused roll waits in the tray; another roll sets it aside; Continue
## brings it back and finishes it.
func _test_pause_aside() -> void:
var road := main.data.get_table("road")
for e in road.entries:
for to in e.pipes:
e.pipe_pause[to] = true
var bandit := road.entries[0]
var tid := bandit.pipes[0] if not bandit.pipes.is_empty() else ""
var weights := []
for e in road.entries:
weights.append(e.weight)
e.weight = 0
bandit.weight = 1
main.rolling.start_roll("road", true)
await _frames(3)
var pauses: RollPauses = main.rolling.pauses
_check(pauses.has_waiting() and main.tray._pause_box.get_child_count() > 0, "the roll waits with Continue in the tray")
main.rolling.start_roll("weather", true)
await _frames(3)
_check(pauses.has_waiting() and str(main.current.get("root", "")) == "weather", "another roll sets the paused one aside")
pauses.answer(0, true)
await _frames(4)
_check(not pauses.has_waiting() and str(main.current.get("root", "")) == "road", "Continue makes it current again")
var reached := (main.current.get("all", []) as Array).any(func(s: Dictionary) -> bool: return str(s.get("table_id", "")) == tid)
_check(tid == "" or reached, "and it goes on past the pause")
for i in road.entries.size():
road.entries[i].weight = weights[i]
road.entries[i].pipe_pause.clear()
func _test_sheet_export() -> void:
var b := "[b]Name:[/b] [color=#aa0000]Ash[/color] & co\n[i]Brave[/i]"
var md := SheetExport.as_format(b, "Hero", "md")
_check(md.begins_with("# Hero") and md.contains("**Name:**") and md.contains("*Brave*") and not md.contains("[color"), "Markdown: " + md)
var html := SheetExport.as_format(b, "Hero", "html")
_check(html.contains("<b>Name:</b>") and html.contains("color:#aa0000") and html.contains("&amp; co") and html.contains("<br>"), "HTML keeps bold and colour")
var txt := SheetExport.as_format(b, "Hero", "txt")
_check(txt.contains("Name: Ash & co") and not txt.contains("["), "Text strips the formatting")
main.rolling.start_roll("road", true)
_check(SheetExport.document(main, "txt").contains("Road Encounter"), "the current roll becomes a document")

View file

@ -0,0 +1 @@
uid://bom7e8k2tk2mn

View file

@ -1,11 +1,9 @@
extends SceneTree
extends TestBase
## Headless checks for collections, LibraryStore and StateStore.
## Run: godot --headless --path . -s res://tests/test_storage.gd
const ROOT := "user://test_storage_tmp"
var _failures := 0
func _init() -> void:
_wipe(ROOT)
@ -15,8 +13,7 @@ func _init() -> void:
_test_corrupt()
_test_state()
_wipe(ROOT)
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _test_versions() -> void:
@ -85,7 +82,7 @@ func _test_library() -> void:
_check(lib.state.get_history("fantasy-loot").is_empty() and lib.state.get_history().size() == 1, "delete drops only its history")
_check(lib.state.get_setting("last_collection") == null, "delete clears last_collection if it pointed there")
_check(not lib.delete("fantasy-loot"), "deleting twice returns false")
_check(lib.load_collection("fantasy-loot") == null, "loading a missing collection returns null")
_check(lib.load_collection("fantasy-loot") == null, "loading a missing spread returns null")
func _test_migration() -> void:
@ -98,7 +95,7 @@ func _test_migration() -> void:
f.close()
var lib := LibraryStore.new(root)
var b := lib.migrate_legacy()
_check(b != null and b.name == "My Tables" and b.id == "my-tables", "legacy board imported as My Tables")
_check(b != null and b.name == "My Tables" and b.id == "my-tables", "legacy spread imported as My Tables")
_check(lib.load_collection("my-tables").tables.size() == sample.tables.size(), "imported tables are saved")
_check(not FileAccess.file_exists(legacy) and FileAccess.file_exists(legacy + ".bak"), "old file renamed to .bak")
_check(lib.migrate_legacy() == null, "migration is a no-op once done")
@ -107,7 +104,7 @@ func _test_migration() -> void:
var f2 := FileAccess.open(legacy, FileAccess.WRITE)
f2.store_string(JSON.stringify({"format_version": 1, "tables": sample.to_dict()["tables"]}))
f2.close()
_check(lib.migrate_legacy() == null and FileAccess.file_exists(legacy), "no migration when collections exist")
_check(lib.migrate_legacy() == null and FileAccess.file_exists(legacy), "no migration when spreads exist")
func _test_corrupt() -> void:
@ -120,7 +117,7 @@ func _test_corrupt() -> void:
var f2 := FileAccess.open(lib.path_for("wrongshape"), FileAccess.WRITE)
f2.store_string("[1, 2, 3]")
f2.close()
_check(lib.load_collection("broken") == null, "corrupt collection loads as null")
_check(lib.load_collection("broken") == null, "corrupt spread loads as null")
var ids: Array = []
for e in lib.list():
ids.append(e["id"])
@ -196,9 +193,3 @@ func _wipe(path: String) -> void:
for f in DirAccess.get_files_at(path):
DirAccess.remove_absolute(path.path_join(f))
DirAccess.remove_absolute(path)
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## Templates: saving (placeholder detection, relative positions, pipes kept or
## recorded by name), inserting (substitution, fresh ids, internal pipes kept,
## outside pipes relinked or reported), the library and the built-in
@ -7,14 +7,9 @@ extends SceneTree
const TMP_ROOT := "user://test_templates_tmp"
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_make()
_test_insert()
@ -22,17 +17,10 @@ func _init() -> void:
_test_library_memory()
_test_library_files()
_test_builtins()
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
await _test_app()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
## A check table and its outcome table, piping to "Wounds" outside.
@ -61,8 +49,8 @@ func _test_make() -> void:
var t0: Dictionary = tpl["tables"][0]
var t1: Dictionary = tpl["tables"][1]
_check(t0["x"] == 0 and t0["y"] == 0 and t1["x"] == 300 and t1["y"] == 60, "positions are relative to the top-left: %s %s" % [str(t0["x"]), str(t1["x"])])
_check(t0["entries"][1]["pipes"] == [{"table": "outcome", "count": "{$n}", "save_as": "{$skill}_result"}], "internal pipes keep their target and options: %s" % str(t0["entries"][1]["pipes"]))
_check(t0["entries"][0]["pipes"] == [{"table": "Wounds", "outside": true}], "an outside pipe is recorded by name: %s" % str(t0["entries"][0]["pipes"]))
_check(t0["entries"][1]["pipes"] == [{"table": "outcome", "count": "{$n}", "save_as": "{$skill}_result"}], "internal threads keep their target and options: %s" % str(t0["entries"][1]["pipes"]))
_check(t0["entries"][0]["pipes"] == [{"table": "Wounds", "outside": true}], "an outside thread is recorded by name: %s" % str(t0["entries"][0]["pipes"]))
_check(not JSON.stringify(tpl).contains("\"wounds\""), "the outside table itself isn't in the template")
_check(TemplateKit.summary(tpl) == "2 cards: roll, choice", "summary: %s" % TemplateKit.summary(tpl))
# A group template keeps its group, relative to the frame's corner.
@ -94,16 +82,16 @@ func _test_insert() -> void:
_check(chk.id != "chk" and oc.id != "outcome" and chk.id != oc.id, "fresh table ids")
_check(chk.entries[0].id != "e1" and chk.entries[0].id != chk.entries[1].id, "fresh entry ids")
_check(chk.position == Vector2(1000, 500) and oc.position == Vector2(1300, 560), "placed at the origin, keeping the layout")
_check(chk.entries[1].pipes == [oc.id] and chk.entries[1].count_expr(oc.id) == "" and chk.entries[1].count_for(oc.id) == 2, "internal pipes follow the new ids, with their count")
_check(chk.entries[1].pipes == [oc.id] and chk.entries[1].count_expr(oc.id) == "" and chk.entries[1].count_for(oc.id) == 2, "internal threads follow the new ids, with their count")
_check(chk.entries[1].save_for(oc.id) == "pilot_result", "and their save_as, substituted")
_check(chk.entries[0].pipes == ["w1"] and oc.entries[1].pipes == ["w1"], "outside pipes relink to the table with that name (any case)")
_check((r["relinked"] as Array).size() == 2 and (r["dropped"] as Array).is_empty(), "relinked pipes are reported: %s" % str(r["relinked"]))
_check(chk.entries[0].pipes == ["w1"] and oc.entries[1].pipes == ["w1"], "outside threads relink to the table with that name (any case)")
_check((r["relinked"] as Array).size() == 2 and (r["dropped"] as Array).is_empty(), "relinked threads are reported: %s" % str(r["relinked"]))
var again := TemplateKit.insert(tpl, {}, b, Vector2.ZERO)
_check((again["tables"][0] as RollTable).id != chk.id, "a second insert gets new ids again")
_check((again["tables"][0] as RollTable).name == "{$skill} check", "missing values without a default stay as typed")
var empty := TowerBoard.new()
var r2 := TemplateKit.insert(tpl, {"skill": "a", "target": "1", "n": "1"}, empty, Vector2.ZERO)
_check((r2["dropped"] as Array).size() == 2 and (r2["tables"][0] as RollTable).entries[0].pipes.is_empty(), "outside pipes with no table of that name are dropped and listed: %s" % str(r2["dropped"]))
_check((r2["dropped"] as Array).size() == 2 and (r2["tables"][0] as RollTable).entries[0].pipes.is_empty(), "outside threads with no table of that name are dropped and listed: %s" % str(r2["dropped"]))
# Group templates make the group.
var gsrc := _board()
var g := gsrc.add_group("{$skill} block", ["chk", "outcome"])
@ -182,7 +170,7 @@ func _test_builtins() -> void:
var r := TemplateKit.insert(tpl, {}, b, Vector2(50, 50))
var text := b.to_json()
_check(not text.contains("{$"), "%s: defaults fill every placeholder" % row["id"])
_check((r["dropped"] as Array).is_empty(), "%s: no pipes lead outside" % row["id"])
_check((r["dropped"] as Array).is_empty(), "%s: no threads lead outside" % row["id"])
var declared := TemplateKit.detect_params(tpl)
for p: Dictionary in tpl["params"]:
_check(declared.has(str(p["name"])), "%s: param %s is used" % [row["id"], p["name"]])
@ -263,17 +251,17 @@ func _test_app() -> void:
for t in main.data.tables:
if t.kind == RollTable.KIND_VARIABLE and t.var_name == "counter":
var_card = t
_check(var_card != null and main.card_for(var_card.id) != null, "its variable card is on the board")
_check(var_card != null and main.card_for(var_card.id) != null, "its variable card is on the spread")
# Insert with values and an outside pipe that relinks.
var tpl := TemplateKit.make(_board(), ["chk", "outcome"], "selection", "Check")
var r := main.templating.insert_template(tpl, {"skill": "stealth", "target": "9", "n": "1"})
await process_frame
var chk: RollTable = r["tables"][0]
_check(main.card_for(chk.id) != null and chk.name == "stealth check", "the inserted cards appear")
_check(chk.entries[0].pipes == ["wounds"], "an outside pipe relinks to Wounds on this board")
_check(chk.entries[0].pipes == ["wounds"], "an outside thread relinks to Wounds on this spread")
var center := main.board.screen_to_world(main.board.size / 2.0)
var ext := TemplateKit.extent(tpl)
_check(chk.position.distance_to((center - ext / 2.0).round().max(Vector2(20, 20 + TableGroup.TITLE_H))) < 2.0, "placed around the view centre")
_check(chk.position.distance_to((center - ext / 2.0).round()) < 2.0, "placed around the view centre")
_check(main.top_bar._toast.visible and main.top_bar._toast_undo.visible, "an undo toast follows")
main.top_bar._undo()
await process_frame
@ -284,7 +272,7 @@ func _test_app() -> void:
main.templating.insert_template(tpl, {"skill": "x", "target": "1", "n": "1"})
await process_frame
var rep := _top_modal()
_check(rep != null and rep.title_label.text.begins_with("Inserted"), "pipes that can't relink are listed in a report")
_check(rep != null and rep.title_label.text.begins_with("Inserted"), "threads that can't relink are listed in a report")
if rep:
rep.close()
# The card settings dialog offers Save as template.
@ -327,9 +315,3 @@ func _wipe(dir: String) -> void:
DirAccess.remove_absolute(tdir)
if DirAccess.dir_exists_absolute(dir):
DirAccess.remove_absolute(dir)
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print("FAIL ", what)

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## Headless checks for RollContext, TextExpander and Formatter.
## Run: godot --headless --path . -s res://tests/test_text.gd
@ -17,7 +17,6 @@ const RESULTS := {
"bold": ["[b]heavy"],
}
var _failures := 0
var _ctx: RollContext
var _rolls: Dictionary = {}
@ -25,8 +24,7 @@ var _rolls: Dictionary = {}
func _init() -> void:
_test_expander()
_test_formatter()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _new_ctx(persistent: Dictionary = {}) -> RollContext:
@ -208,12 +206,3 @@ func _test_formatter() -> void:
_eq(RollContext.normalize_name(" [b]Gems[/b] "), "gems", "normalize_name")
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(got == want, "%s\n got: %s\n want: %s" % [what, got, want])
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print(" ✗ ", what)

100
tests/test_theme.gd Normal file
View file

@ -0,0 +1,100 @@
extends TestBase
## Theme sets: applying built-ins sets Style tokens and fills, saving and
## deleting a user set, and the Theme dialog building its editors.
## Run: godot --headless --path . -s res://tests/test_theme.gd -- --sample
func _init() -> void:
if not require_sample():
return
ThemeStore.DIR = OS.get_temp_dir().path_join("tt_theme_test_%d/" % OS.get_process_id())
if not await start_main():
return
_test_apply()
_test_save_delete()
await _test_dialog()
_test_own_colours()
await _test_sparkles()
finish()
func _test_apply() -> void:
_check(ThemeStore.current.get("id") == "tarot", "Tarot is the default set")
_check(Style.BG == Color("#2c0744"), "Tarot sets the background colour")
_check(Style.fill_texture(Style.BG_FILL) != null, "Tarot's background is a gradient")
_check(BoardView.pattern_texture("stars") != null and BoardView.pattern_texture("none") == null, "patterns build")
ThemeStore.apply(BuiltinThemes.FELT)
_check(Style.BG == Color("#1f4a39"), "Felt falls back to the original colours")
_check(Style.PATTERN == "dots", "Felt uses dots")
_check(Style.panel_box() is StyleBoxFlat, "a solid panel fill is a flat box")
ThemeStore.apply(BuiltinThemes.TAROT)
_check(Style.panel_box() is StyleBoxTexture, "a gradient panel fill is a texture box")
var cols := ThemeStore.resolved_colors(BuiltinThemes.FELT)
_check(cols.size() == ThemeStore.TOKENS.size(), "resolved colours cover every token")
func _test_save_delete() -> void:
var t := BuiltinThemes.TAROT.duplicate(true)
t["name"] = "Night Sky"
var id := ThemeStore.save(t)
_check(id != "tarot", "saving a built-in makes a new id: " + id)
_check(ThemeStore.find(id).get("name") == "Night Sky", "the saved set is found")
_check(ThemeStore.all().size() == BuiltinThemes.all().size() + 1, "the saved set is listed")
ThemeStore.delete("tarot")
_check(ThemeStore.find("tarot").get("builtin", false), "built-ins can't be deleted")
ThemeStore.delete(id)
_check(ThemeStore.all().size() == BuiltinThemes.all().size(), "the user set is deleted")
func _test_dialog() -> void:
var d := ThemeDialog.new(main)
main.add_child(d)
await _frames()
_check(d._content.find_children("*", "FillEditor", true, false).size() == 2, "background and panel fill editors")
var basic := d._content.find_children("*", "ColorPickerButton", true, false).size()
d._more = true
d._rebuild()
await _frames()
var all := d._content.find_children("*", "ColorPickerButton", true, false).size()
_check(all > basic, "More colours shows more swatches (%d > %d)" % [all, basic])
var fe := d._content.find_children("*", "FillEditor", true, false)[0] as FillEditor
fe._set_kind(1)
_check((fe.fill["colors"] as Array).size() >= 2 and d._dirty, "a gradient gets two colours and marks the set changed")
d.close()
await _frames()
func _test_own_colours() -> void:
var t := RollTable.new()
t.id = "a"
t.color = "#2f8a4f"
var e := TableEntry.new("e1", "x")
e.add_pipe("b")
e.pipe_color["b"] = "#c04a86"
t.entries.append(e)
var back := RollTable.from_dict(t.to_dict())
_check(back.color == "#2f8a4f", "a card's colour survives saving")
_check(back.entries[0].pipe_color.get("b") == "#c04a86", "a thread's colour survives saving")
back.entries[0].remove_pipe("b")
_check(back.entries[0].pipe_color.is_empty(), "deleting a thread drops its colour")
var card := main.card_for(main.data.tables[0].id)
if card and card.frame:
main.data.get_table(card.table.id).color = "#b8382c"
card.rebuild()
_check(card.frame.material == CardFrame.material_for(Color("#b8382c")), "the frame takes the card's colour")
func _test_sparkles() -> void:
var card := main.card_for(main.data.tables[0].id)
var layer := card.get_parent()
var before := layer.find_children("*", "CPUParticles2D", false, false).size()
card.sparkle(card.table.entries[0].id)
_check(layer.find_children("*", "CPUParticles2D", false, false).size() == before + 1, "a landing result bursts sparkles")
var pipes := main.board.pipes
pipes.pulse_key = pipes._paths.keys()[0] if not pipes._paths.is_empty() else ""
await _frames()
_check(pipes._trail != null and pipes._trail.emitting, "the pulse trails sparkles")
pipes.pulse_key = ""
await _frames()
_check(not pipes._trail.emitting, "the trail stops with the pulse")

1
tests/test_theme.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://nfq0rycxflhw

View file

@ -1,24 +1,12 @@
extends SceneTree
extends TestBase
## The top bar's menus (View ▾, the zoom control, Board ▾ with Pack, Help ▾),
## striped result rows, the Build card's ⋯ menu and the row × that shows on
## hover or selection, and the Help window's topics and links.
## Run: godot --headless --path . -s res://tests/test_top_bar.gd -- --sample
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
await _frames(5)
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
main.size = Vector2(1440, 900)
@ -28,8 +16,7 @@ func _init() -> void:
await _test_stripes()
await _test_card_menu()
await _test_help()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
finish()
func _test_bar() -> void:
@ -40,7 +27,7 @@ func _test_bar() -> void:
texts.append((n as Button).text)
_check(not texts.has("Arrange ▾"), "Arrange ▾ is gone from the Build tools: %s" % str(texts))
var pm := bar._board_menu.get_popup()
_check(pm.get_item_index(IoMenu.ID_PACK) >= 0, "Board ▾ has Pack collapsed groups")
_check(pm.get_item_index(IoMenu.ID_PACK) >= 0, "Spread ▾ has Pack collapsed groups")
_check(main.nav._search_button.text == "", "Search is an icon button")
@ -54,7 +41,7 @@ func _test_zoom() -> void:
await _frames()
_eq(z.menu.text, "50% ▾", "and follows zoom changes from elsewhere")
z.activate(ZoomControl.ID_FIT)
_check(main.board.zoom != 0.5, "Fit board changes the zoom")
_check(main.board.zoom != 0.5, "Fit spread changes the zoom")
func _test_view_menu() -> void:
@ -120,7 +107,7 @@ func _test_card_menu() -> void:
_eq(del.modulate.a, 0.0, "and hides it again when deselected")
var pm := (menus[0] as MenuButton).get_popup()
pm.id_pressed.emit(TableCardEditing.MENU_DELETE)
_check(Actions.press(pm, "Delete table"), "⋯ has Delete table")
await _frames()
_check(main.data.get_table("loot") == null, "⋯ → Delete table deletes it")
main.undo_redo.undo()
@ -132,7 +119,7 @@ func _test_card_menu() -> void:
func _test_help() -> void:
var titles := HelpDialog.titles()
_check(titles.size() >= 10 and titles.has("Card mode") and titles.has("Roll modifiers"), "help has its topics: %s" % str(titles))
_check(titles.size() >= 10 and titles.has("Deck mode") and titles.has("Roll modifiers"), "help has its topics: %s" % str(titles))
var src := FileAccess.get_file_as_string(HelpDialog.PATH)
var re := RegEx.create_from_string("\\[topic\\](.+?)\\[/topic\\]")
for m in re.search_all(src):
@ -141,26 +128,11 @@ func _test_help() -> void:
_check(str(t["body"]).length() > 80, "“%s” has text" % t["title"])
_check(HelpDialog._inline("`[[Loot]]`").contains("[lb][lb]Loot[rb][rb]"), "code spans keep their brackets")
var d := main.top_bar.help_menu.open("card MODE")
var d := main.top_bar.help_menu.open("deck MODE")
await _frames()
_eq(d.current, "Card mode", "Help opens at the asked topic, any case")
_eq(d.current, "Deck mode", "Help opens at the asked topic, any case")
d._on_meta("topic:Roll modifiers")
_eq(d.current, "Roll modifiers", "a topic link switches topics")
_check(d.text.get_parsed_text().contains("Luck"), "and shows its text")
d.close()
await _frames()
func _frames(n: int = 2) -> void:
for i in n:
await process_frame
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print("FAIL ", what)
func _eq(got: Variant, want: Variant, what: String) -> void:
_check(got == want, "%s: got %s, want %s" % [what, str(got), str(want)])

View file

@ -1,4 +1,4 @@
extends SceneTree
extends TestBase
## Undo and redo of Build edits (EditHistory and Main's "Undo and redo"):
## every kind of edit, coalescing, redo being cleared, the cap, per-collection
## histories, labels, view and lit state, the toast's Undo, lazily built cards,
@ -7,23 +7,12 @@ extends SceneTree
## [--big-board=<collection.json>] times a real board instead of a made-up
## 800-card one.
var _failures := 0
var main: Main
func _init() -> void:
if not OS.get_cmdline_user_args().has("--sample"):
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
if not require_sample():
return
_test_history_unit()
main = load("res://ui/main.tscn").instantiate()
root.add_child(main)
for i in 5:
await process_frame
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
if not await start_main():
return
main.set_anchors_and_offsets_preset(Control.PRESET_TOP_LEFT)
main.size = Vector2(1440, 900)
@ -46,16 +35,7 @@ func _init() -> void:
await _test_play_mode()
await _test_collections()
await _test_big_board()
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)
func _check(ok: bool, what: String) -> void:
if ok:
print(" ok %s" % what)
else:
_failures += 1
print(" FAIL %s" % what)
finish()
## Loot (two results, one piping to Gems), Gems, Weapons and Armor in the
@ -83,11 +63,6 @@ func _load(d: Dictionary = {}) -> void:
await process_frame
func _frames(n: int = 2) -> void:
for i in n:
await process_frame
func _t(id: String) -> RollTable:
return main.data.get_table(id)
@ -250,20 +225,20 @@ func _test_results_and_tables() -> void:
_check(_label() == "Delete table Gems" and _t("a").entries[0].pipes.is_empty(), "deleting a table: %s" % _label())
main.undo_redo.undo()
await _frames()
_check(_t("b") != null and main.card_for("b") != null and _t("a").entries[0].pipes == ["b"], "undo brings the table, its card and the pipe into it back")
_check(_t("b") != null and main.card_for("b") != null and _t("a").entries[0].pipes == ["b"], "undo brings the table, its card and the thread into it back")
func _test_pipes() -> void:
print("Pipes")
print("Threads")
main.undo_redo._begin_edit()
_t("a").entries[1].pipes.append("c")
main.mark_dirty()
await _frames()
_check(_label() == "Add pipe Loot → Weapons", "laying a pipe: %s" % _label())
_check(_label() == "Add thread Loot → Weapons", "laying a thread: %s" % _label())
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 thread away")
main.remove_pipe("a:e1>b")
_check(_label() == "Delete pipe Loot → Gems" and main.top_bar._toast_undo.visible, "removing a pipe, with an undo toast: %s" % _label())
_check(_label() == "Delete thread Loot → Gems" and main.top_bar._toast_undo.visible, "removing a thread, with an undo toast: %s" % _label())
main.undo_redo.undo()
_check(_t("a").entries[0].pipes == ["b"], "undo lays it again")
var e := _t("a").entries[0]
@ -275,7 +250,7 @@ func _test_pipes() -> void:
e.set_pipe_count("b", 4)
main.mark_dirty()
await _frames()
_check(_steps() == n0 + 1 and _label() == "Edit pipe Loot → Gems", "nudging a pipe's count twice is one step: %s" % _label())
_check(_steps() == n0 + 1 and _label() == "Edit thread Loot → Gems", "nudging a thread's count twice is one step: %s" % _label())
await create_timer(EditHistory.COALESCE_SECS + 0.1).timeout
e.set_pipe_save("b", "gem")
main.mark_dirty()
@ -394,7 +369,7 @@ func _test_template_and_reset() -> void:
_check(_label() == "Reset sample" and _t("a") == null, "Reset sample is a step: %s" % _label())
main.undo_redo.undo()
await _frames()
_check(_t("a") != null and _t("a").name == "Loot" and main.data.get_group("g1") != null, "undo brings the board back")
_check(_t("a") != null and _t("a").name == "Loot" and main.data.get_group("g1") != null, "undo brings the spread back")
func _test_pack() -> void:
@ -558,7 +533,7 @@ func _test_play_mode() -> void:
func _test_collections() -> void:
print("Per-collection history")
print("Per-spread history")
main.add_entry("a")
var first := main.data
var h := main.undo_redo.edits
@ -566,7 +541,7 @@ func _test_collections() -> void:
other.load_dict({"format_version": 2, "id": "other", "name": "Other", "tables": [
{"id": "x", "name": "X", "x": 0, "y": 0, "entries": [{"id": "e1", "text": "x"}]}]})
await main.collections._show_collection(other)
_check(main.undo_redo.edits != h and not main.undo_redo.edits.can_undo(), "another collection has its own, empty history")
_check(main.undo_redo.edits != h and not main.undo_redo.edits.can_undo(), "another spread has its own, empty history")
main.add_entry("x")
_check(main.undo_redo.edits.undo_label() == "Add result to X", "edits there go to its history")
await main.collections._show_collection(first)
@ -577,12 +552,12 @@ func _test_collections() -> void:
func _test_big_board() -> void:
print("Big board")
print("Big spread")
var d: Dictionary = {}
var path := ""
for a in OS.get_cmdline_user_args():
if a.begins_with("--big-board="):
path = a.trim_prefix("--big-board=")
if a.begins_with("--big-spread="):
path = a.trim_prefix("--big-spread=")
if path != "" and FileAccess.file_exists(path):
d = JSON.parse_string(FileAccess.get_file_as_string(path))
else:
@ -630,13 +605,13 @@ func _test_big_board() -> void:
var t5 := Time.get_ticks_usec()
main.undo_redo.undo()
var undo_del_ms := (Time.get_ticks_usec() - t5) / 1000.0
_check(_t(u.id) != null, "undoing a deletion on the big board brings the card back")
print(" TIMING %d cards: one committed edit %.1f ms (snapshot %.1f ms); keystroke %.2f ms, of which mark_dirty's existing refresh %.2f ms; undo of an edit %.1f ms (board update %.1f ms); undo of a deletion %.1f ms; board %d chars, later step %d bytes" % [
_check(_t(u.id) != null, "undoing a deletion on the big spread brings the card back")
print(" TIMING %d cards: one committed edit %.1f ms (snapshot %.1f ms); keystroke %.2f ms, of which mark_dirty's existing refresh %.2f ms; undo of an edit %.1f ms (spread update %.1f ms); undo of a deletion %.1f ms; spread %d chars, later step %d bytes" % [
n, commit_ms, cap_ms, key_ms, base_ms, undo_ms, undo_one_ms, undo_del_ms, full, step_bytes])
_check(commit_ms < 250.0, "committing one edit stays quick: %.1f ms" % commit_ms)
_check(key_ms - base_ms < 1.0, "a keystroke doesn't snapshot the board: %.2f ms over %.2f ms" % [key_ms, base_ms])
_check(key_ms - base_ms < 1.0, "a keystroke doesn't snapshot the spread: %.2f ms over %.2f ms" % [key_ms, base_ms])
_check(step_bytes < full / 10, "a later step stores only the changed cards: %d of %d" % [step_bytes, full])
_check(_t(t.id).name.ends_with("(edited)") and not _t(t.id).name.ends_with("x"), "undo works on the big board")
_check(_t(t.id).name.ends_with("(edited)") and not _t(t.id).name.ends_with("x"), "undo works on the big spread")
func _synthetic_board(n: int) -> Dictionary:

63
tests/testbase.gd Normal file
View file

@ -0,0 +1,63 @@
class_name TestBase
extends SceneTree
## Shared boilerplate for the headless suites: the --sample guard, loading the
## app, frame waiting, the check helpers and the PASS/FAIL summary the runner
## (tools/run_tests.sh) looks for. A suite extends this and calls
## `if not await start_main(): return` first when it needs the app.
var _failures := 0
var main: Main
## Returns false (after quitting with 2) unless the suite was started with
## `-- --sample`, so a test can't touch saved data.
func require_sample() -> bool:
if OS.get_cmdline_user_args().has("--sample"):
return true
print("Run with -- --sample so the test can't touch saved data.")
quit(2)
return false
## Hook: suites that need a customised Main override this.
func _create_main() -> Main:
return load("res://ui/main.tscn").instantiate()
## Guard, then loads the app under root and waits for it. Returns false (after
## quitting) if the guard fails or the app would save.
func start_main() -> bool:
if not require_sample():
return false
main = _create_main()
root.add_child(main)
await _frames(5)
if main._saving_enabled:
print("Saving is enabled; refusing to run.")
quit(2)
return false
return true
func _frames(n: int = 2) -> void:
for i in n:
await process_frame
func _check(ok: bool, what: String) -> void:
if not ok:
_failures += 1
print("FAIL ", what)
func _eq(got: Variant, want: Variant, what: String) -> void:
var same: bool = typeof(got) == typeof(want) and got == want
if not same and got is Array and want is Array:
same = str(got) == str(want)
_check(same, "%s\n got: %s\n want: %s" % [what, str(got), str(want)])
## Prints the summary line the runner greps for, then quits.
func finish() -> void:
print("%s: %d failure(s)" % ["PASS" if _failures == 0 else "FAIL", _failures])
quit(1 if _failures else 0)

1
tests/testbase.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://qgpdvh5r3t5i

Some files were not shown because too many files have changed in this diff Show more