rpg-engine 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adventures/source.js +6 -5
- package/dist/commands/package.d.ts +3 -3
- package/dist/commands/package.js +72 -35
- package/dist/commands/shared/adventures.js +20 -11
- package/dist/commands/shared/library.js +13 -5
- package/dist/commands/shared/packages/catalog.d.ts +2 -0
- package/dist/commands/shared/packages/catalog.js +1 -0
- package/dist/commands/view/place.d.ts +2 -0
- package/dist/commands/view/place.js +8 -2
- package/dist/core/context.d.ts +2 -0
- package/dist/core/refusal.d.ts +12 -0
- package/dist/core/refusal.js +17 -0
- package/dist/dashboard/api.js +37 -81
- package/dist/dashboard/app.js +10 -3
- package/dist/dashboard/asked.js +6 -3
- package/dist/dashboard/assets/master.svg +1 -2
- package/dist/dashboard/card.js +1 -1
- package/dist/dashboard/dice/load.js +6 -1
- package/dist/dashboard/dice/throw.js +5 -1
- package/dist/dashboard/dice/tray.js +5 -1
- package/dist/dashboard/footer.js +2 -2
- package/dist/dashboard/game-words.js +32 -32
- package/dist/dashboard/guide/ar.md +5 -5
- package/dist/dashboard/guide/cs.md +7 -7
- package/dist/dashboard/guide/da.md +5 -5
- package/dist/dashboard/guide/de.md +5 -5
- package/dist/dashboard/guide/el.md +7 -7
- package/dist/dashboard/guide/en.md +2 -2
- package/dist/dashboard/guide/es.md +6 -6
- package/dist/dashboard/guide/fi.md +5 -5
- package/dist/dashboard/guide/fr.md +6 -6
- package/dist/dashboard/guide/he.md +7 -7
- package/dist/dashboard/guide/hi.md +6 -6
- package/dist/dashboard/guide/hu.md +7 -7
- package/dist/dashboard/guide/is.md +7 -7
- package/dist/dashboard/guide/it.md +5 -5
- package/dist/dashboard/guide/ja.md +7 -7
- package/dist/dashboard/guide/ko.md +9 -9
- package/dist/dashboard/guide/nb.md +6 -6
- package/dist/dashboard/guide/nl.md +7 -7
- package/dist/dashboard/guide/pl.md +7 -7
- package/dist/dashboard/guide/pt.md +5 -5
- package/dist/dashboard/guide/ro.md +8 -8
- package/dist/dashboard/guide/ru.md +7 -7
- package/dist/dashboard/guide/sv.md +6 -6
- package/dist/dashboard/guide/tr.md +8 -8
- package/dist/dashboard/guide/uk.md +6 -6
- package/dist/dashboard/guide/zh.md +8 -8
- package/dist/dashboard/help/blocks.js +6 -0
- package/dist/dashboard/help/help.js +15 -3
- package/dist/dashboard/help/markdown.js +2 -1
- package/dist/dashboard/i18n/ar.json +53 -1
- package/dist/dashboard/i18n/cs.json +53 -1
- package/dist/dashboard/i18n/da.json +53 -1
- package/dist/dashboard/i18n/de.json +53 -1
- package/dist/dashboard/i18n/el.json +53 -1
- package/dist/dashboard/i18n/es.json +53 -1
- package/dist/dashboard/i18n/fi.json +53 -1
- package/dist/dashboard/i18n/fr.json +53 -1
- package/dist/dashboard/i18n/he.json +53 -1
- package/dist/dashboard/i18n/hi.json +53 -1
- package/dist/dashboard/i18n/hu.json +53 -1
- package/dist/dashboard/i18n/is.json +53 -1
- package/dist/dashboard/i18n/it.json +56 -4
- package/dist/dashboard/i18n/ja.json +53 -1
- package/dist/dashboard/i18n/ko.json +53 -1
- package/dist/dashboard/i18n/nb.json +53 -1
- package/dist/dashboard/i18n/nl.json +53 -1
- package/dist/dashboard/i18n/pl.json +53 -1
- package/dist/dashboard/i18n/pt.json +53 -1
- package/dist/dashboard/i18n/ro.json +53 -1
- package/dist/dashboard/i18n/ru.json +53 -1
- package/dist/dashboard/i18n/sv.json +53 -1
- package/dist/dashboard/i18n/tr.json +53 -1
- package/dist/dashboard/i18n/uk.json +53 -1
- package/dist/dashboard/i18n/zh.json +53 -1
- package/dist/dashboard/icons.js +2 -2
- package/dist/dashboard/journal.js +9 -4
- package/dist/dashboard/labels.js +5 -4
- package/dist/dashboard/language-choice.js +3 -3
- package/dist/dashboard/markdown.js +11 -4
- package/dist/dashboard/notes.js +4 -2
- package/dist/dashboard/notices.js +2 -2
- package/dist/dashboard/packages/ask-card.js +1 -1
- package/dist/dashboard/packages/packages.js +14 -10
- package/dist/dashboard/packages/page-code.js +11 -3
- package/dist/dashboard/packages/widgets.js +5 -5
- package/dist/dashboard/pages.js +3 -3
- package/dist/dashboard/place/map-sheet.js +4 -3
- package/dist/dashboard/place/map-view.js +17 -5
- package/dist/dashboard/refusals.js +61 -0
- package/dist/dashboard/rolls.js +3 -3
- package/dist/dashboard/settings.js +19 -5
- package/dist/dashboard/sheet.js +26 -7
- package/dist/dashboard/status.js +19 -13
- package/dist/dashboard/style.css +113 -16
- package/dist/dashboard/text.js +6 -2
- package/dist/dashboard/top.js +7 -9
- package/dist/dashboard/turns.js +7 -2
- package/dist/dashboard/world/lore.js +16 -15
- package/dist/dashboard/world/map.js +43 -1
- package/dist/dashboard/world/world.js +50 -15
- package/dist/extensions/extension.js +4 -1
- package/dist/packages/npm.js +4 -2
- package/dist/packages/tarball.js +8 -4
- package/dist/server/dashboard/writes.js +22 -13
- package/dist/systems/system-code.js +5 -0
- package/package.json +1 -1
package/dist/dashboard/style.css
CHANGED
|
@@ -286,7 +286,8 @@
|
|
|
286
286
|
outline-offset: 1px !important;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
/* A control without words says its name when hovered, after a moment, or reached by the keyboard; never at a touch, where it would stay lit.
|
|
289
|
+
/* A control without words says its name when hovered, after a moment, or reached by the keyboard; never at a touch, where it would stay lit. A name of
|
|
290
|
+
several things, as a gathered spark's, has a line for each. */
|
|
290
291
|
[data-tip]::before {
|
|
291
292
|
content: attr(data-tip) !important;
|
|
292
293
|
position: absolute !important;
|
|
@@ -300,7 +301,7 @@
|
|
|
300
301
|
font: 400 0.8rem/1.2 system-ui, -apple-system, "Segoe UI", sans-serif !important;
|
|
301
302
|
letter-spacing: 0 !important;
|
|
302
303
|
text-transform: none !important;
|
|
303
|
-
white-space:
|
|
304
|
+
white-space: pre !important;
|
|
304
305
|
opacity: 0 !important;
|
|
305
306
|
translate: -50% 4px !important;
|
|
306
307
|
pointer-events: none !important;
|
|
@@ -1007,6 +1008,8 @@
|
|
|
1007
1008
|
.top > .status-chips {
|
|
1008
1009
|
grid-area: chips;
|
|
1009
1010
|
margin: 0;
|
|
1011
|
+
/* Clear of the theme's corner, whose button is wider than its triangle. */
|
|
1012
|
+
margin-inline-end: 40px;
|
|
1010
1013
|
}
|
|
1011
1014
|
|
|
1012
1015
|
.top > .nav-row {
|
|
@@ -1281,6 +1284,14 @@
|
|
|
1281
1284
|
white-space: nowrap;
|
|
1282
1285
|
}
|
|
1283
1286
|
|
|
1287
|
+
.product-time {
|
|
1288
|
+
display: none;
|
|
1289
|
+
margin: 4px 0 0;
|
|
1290
|
+
color: var(--muted);
|
|
1291
|
+
font-size: 0.8rem;
|
|
1292
|
+
white-space: nowrap;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1284
1295
|
.product {
|
|
1285
1296
|
margin: 4px 0 0;
|
|
1286
1297
|
unicode-bidi: isolate;
|
|
@@ -1566,6 +1577,14 @@
|
|
|
1566
1577
|
letter-spacing: var(--title-spacing, 0.01em);
|
|
1567
1578
|
}
|
|
1568
1579
|
|
|
1580
|
+
.top:not(.compact) .product {
|
|
1581
|
+
display: none;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
.top:not(.compact) .product-time {
|
|
1585
|
+
display: block;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1569
1588
|
.top {
|
|
1570
1589
|
gap: 12px;
|
|
1571
1590
|
}
|
|
@@ -2628,6 +2647,15 @@
|
|
|
2628
2647
|
justify-self: center;
|
|
2629
2648
|
}
|
|
2630
2649
|
|
|
2650
|
+
/* A figure no taller than an icon takes the icon's place, beside the words. */
|
|
2651
|
+
.widget-lead.figured:has(> .ext-figure.small) {
|
|
2652
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
.widget-lead.figured > .ext-figure.small {
|
|
2656
|
+
grid-column: auto;
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2631
2659
|
.widget-lead-icon {
|
|
2632
2660
|
width: 40px;
|
|
2633
2661
|
height: 40px;
|
|
@@ -3072,6 +3100,21 @@
|
|
|
3072
3100
|
color: var(--accent);
|
|
3073
3101
|
}
|
|
3074
3102
|
|
|
3103
|
+
.status-count {
|
|
3104
|
+
position: absolute;
|
|
3105
|
+
inset-block-end: -3px;
|
|
3106
|
+
inset-inline-end: -3px;
|
|
3107
|
+
min-width: 14px;
|
|
3108
|
+
padding: 0 3px;
|
|
3109
|
+
border-radius: 7px;
|
|
3110
|
+
background: var(--accent);
|
|
3111
|
+
color: var(--paper);
|
|
3112
|
+
font-size: 0.72rem;
|
|
3113
|
+
font-weight: 700;
|
|
3114
|
+
line-height: 14px;
|
|
3115
|
+
text-align: center;
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3075
3118
|
.status-icon svg {
|
|
3076
3119
|
width: 18px;
|
|
3077
3120
|
height: 18px;
|
|
@@ -8150,10 +8193,13 @@
|
|
|
8150
8193
|
min-height: 84px;
|
|
8151
8194
|
}
|
|
8152
8195
|
|
|
8196
|
+
/* Within the picture, wrapping rather than over the save's title. */
|
|
8153
8197
|
.save-badge {
|
|
8154
8198
|
top: 6px;
|
|
8155
8199
|
inset-inline-start: 6px;
|
|
8156
|
-
|
|
8200
|
+
inset-inline-end: 6px;
|
|
8201
|
+
white-space: normal;
|
|
8202
|
+
font-size: 0.72rem;
|
|
8157
8203
|
}
|
|
8158
8204
|
|
|
8159
8205
|
.save-what {
|
|
@@ -10438,6 +10484,13 @@
|
|
|
10438
10484
|
.guide blockquote p {
|
|
10439
10485
|
margin-bottom: 4px;
|
|
10440
10486
|
}
|
|
10487
|
+
|
|
10488
|
+
/* On a phone the folded cards are the index. */
|
|
10489
|
+
@media (max-width: 600px) {
|
|
10490
|
+
.help-index {
|
|
10491
|
+
display: none;
|
|
10492
|
+
}
|
|
10493
|
+
}
|
|
10441
10494
|
}
|
|
10442
10495
|
/* About. */
|
|
10443
10496
|
@layer pages {
|
|
@@ -10559,19 +10612,6 @@
|
|
|
10559
10612
|
font-size: 0.85rem;
|
|
10560
10613
|
}
|
|
10561
10614
|
|
|
10562
|
-
.about-fine {
|
|
10563
|
-
padding-top: 14px;
|
|
10564
|
-
border-top: 1px solid var(--rule);
|
|
10565
|
-
color: var(--muted);
|
|
10566
|
-
font-size: 0.8rem;
|
|
10567
|
-
line-height: 1.45;
|
|
10568
|
-
}
|
|
10569
|
-
|
|
10570
|
-
.about-fine p {
|
|
10571
|
-
max-width: 90ch;
|
|
10572
|
-
margin: 0 0 8px;
|
|
10573
|
-
}
|
|
10574
|
-
|
|
10575
10615
|
/* On a phone the robot over the words, the links under them the whole width. */
|
|
10576
10616
|
@media (max-width: 600px) {
|
|
10577
10617
|
.about-hero {
|
|
@@ -11748,6 +11788,18 @@
|
|
|
11748
11788
|
height: 22px;
|
|
11749
11789
|
}
|
|
11750
11790
|
|
|
11791
|
+
.turn-notice-round,
|
|
11792
|
+
.turn-notice-go {
|
|
11793
|
+
white-space: nowrap;
|
|
11794
|
+
}
|
|
11795
|
+
|
|
11796
|
+
/* On a phone the notice says whose turn alone: the round is on the Scene. */
|
|
11797
|
+
@media (max-width: 600px) {
|
|
11798
|
+
.turn-notice-round {
|
|
11799
|
+
display: none;
|
|
11800
|
+
}
|
|
11801
|
+
}
|
|
11802
|
+
|
|
11751
11803
|
.turn-notice-go {
|
|
11752
11804
|
margin-inline-start: auto;
|
|
11753
11805
|
padding: 4px 12px;
|
|
@@ -12124,6 +12176,13 @@
|
|
|
12124
12176
|
stroke: #2f5b80;
|
|
12125
12177
|
}
|
|
12126
12178
|
|
|
12179
|
+
/* A region chosen, as from the Lore's Show on the map: its ink in gold. */
|
|
12180
|
+
.region-edge.selected {
|
|
12181
|
+
stroke: var(--gold);
|
|
12182
|
+
stroke-width: 3.5;
|
|
12183
|
+
stroke-opacity: 1;
|
|
12184
|
+
}
|
|
12185
|
+
|
|
12127
12186
|
/* The paper aged at its edges. */
|
|
12128
12187
|
.map-age {
|
|
12129
12188
|
pointer-events: none;
|
|
@@ -12201,6 +12260,15 @@
|
|
|
12201
12260
|
stroke-linejoin: round;
|
|
12202
12261
|
}
|
|
12203
12262
|
|
|
12263
|
+
.chosen-way {
|
|
12264
|
+
fill: none;
|
|
12265
|
+
stroke: var(--gold);
|
|
12266
|
+
stroke-opacity: 0.6;
|
|
12267
|
+
stroke-width: 10;
|
|
12268
|
+
stroke-linecap: round;
|
|
12269
|
+
stroke-linejoin: round;
|
|
12270
|
+
}
|
|
12271
|
+
|
|
12204
12272
|
.key-way .trail {
|
|
12205
12273
|
stroke-width: 8;
|
|
12206
12274
|
}
|
|
@@ -12773,6 +12841,24 @@
|
|
|
12773
12841
|
max-width: none;
|
|
12774
12842
|
}
|
|
12775
12843
|
|
|
12844
|
+
/* On a phone, squares of 32 px at least, of the 40 the map is drawn in: the map scrolls aside rather than shrinking past reading (D-547). */
|
|
12845
|
+
@media (max-width: 600px) {
|
|
12846
|
+
/* The card keeps the column's width, whatever the map's: the map alone scrolls. */
|
|
12847
|
+
.lm {
|
|
12848
|
+
min-width: 0;
|
|
12849
|
+
max-width: 100%;
|
|
12850
|
+
}
|
|
12851
|
+
|
|
12852
|
+
.lm-frame {
|
|
12853
|
+
max-width: 100%;
|
|
12854
|
+
overflow-x: auto;
|
|
12855
|
+
}
|
|
12856
|
+
|
|
12857
|
+
.lm-frame:not(.panned) .lm-svg {
|
|
12858
|
+
min-width: calc(var(--map-width) * 0.8px);
|
|
12859
|
+
}
|
|
12860
|
+
}
|
|
12861
|
+
|
|
12776
12862
|
.lm.lm-full {
|
|
12777
12863
|
position: fixed;
|
|
12778
12864
|
inset: 0;
|
|
@@ -13278,6 +13364,12 @@
|
|
|
13278
13364
|
font-size: 1.1rem;
|
|
13279
13365
|
}
|
|
13280
13366
|
|
|
13367
|
+
/* The player's own sentence, not the story's voice: the page's letters. */
|
|
13368
|
+
.act-sheet .map-sheet-head h2 {
|
|
13369
|
+
font-family: inherit;
|
|
13370
|
+
font-size: 1.25rem;
|
|
13371
|
+
}
|
|
13372
|
+
|
|
13281
13373
|
.map-sheet-body {
|
|
13282
13374
|
overflow: auto;
|
|
13283
13375
|
padding: 12px 0;
|
|
@@ -13968,6 +14060,10 @@
|
|
|
13968
14060
|
border-top: 1px solid var(--rule);
|
|
13969
14061
|
}
|
|
13970
14062
|
|
|
14063
|
+
.package-note + .package-add {
|
|
14064
|
+
margin-top: 14px;
|
|
14065
|
+
}
|
|
14066
|
+
|
|
13971
14067
|
/* The catalog: its heading and search, the chips of the kinds, the rows, then the others on asking. */
|
|
13972
14068
|
.package-catalog-head {
|
|
13973
14069
|
display: flex;
|
|
@@ -14527,6 +14623,7 @@
|
|
|
14527
14623
|
.package-tile {
|
|
14528
14624
|
width: 32px;
|
|
14529
14625
|
height: 32px;
|
|
14626
|
+
align-self: start;
|
|
14530
14627
|
}
|
|
14531
14628
|
|
|
14532
14629
|
.package-tile svg.icon {
|
package/dist/dashboard/text.js
CHANGED
|
@@ -104,7 +104,7 @@ export function systemWordAnyCase(kind, english) {
|
|
|
104
104
|
* language written from right to left each value is isolated, so that a name, a number or a notation keeps its own order: +2, 1d20+5.
|
|
105
105
|
*/
|
|
106
106
|
export function t(phrase, values = {}) {
|
|
107
|
-
const own = phrases[phrase] ?? systemWord("words", phrase);
|
|
107
|
+
const own = (Object.hasOwn(phrases, phrase) ? phrases[phrase] : undefined) ?? systemWord("words", phrase);
|
|
108
108
|
if (own === undefined) {
|
|
109
109
|
askFirst(phrase);
|
|
110
110
|
}
|
|
@@ -133,7 +133,11 @@ export function capitalized(text) {
|
|
|
133
133
|
}
|
|
134
134
|
/** Which way the page's language is written: right to left for Arabic and Hebrew, left to right for the others. */
|
|
135
135
|
export function pageDirection() {
|
|
136
|
-
return rightToLeft.includes(current) ? "rtl" : "ltr";
|
|
136
|
+
return rightToLeft.includes(current.split("-")[0]) ? "rtl" : "ltr";
|
|
137
|
+
}
|
|
138
|
+
/** The language the page writes in now, for Intl's dates, lists and numbers: English while a language translated on the fly has no phrases yet. */
|
|
139
|
+
export function pageLocale() {
|
|
140
|
+
return current;
|
|
137
141
|
}
|
|
138
142
|
/** A phrase of the page with things put in its {names}, such as links: its pieces in order, the words as strings; for a sentence whose order each language keeps. */
|
|
139
143
|
export function tParts(phrase, parts) {
|
package/dist/dashboard/top.js
CHANGED
|
@@ -13,7 +13,7 @@ import { Master } from "./master.js";
|
|
|
13
13
|
import { ownKey } from "./packages/page-code.js";
|
|
14
14
|
import { Drawn, WidgetChips } from "./packages/widgets.js";
|
|
15
15
|
import { usePrefChange } from "./prefs.js";
|
|
16
|
-
import { t } from "./text.js";
|
|
16
|
+
import { listText, t } from "./text.js";
|
|
17
17
|
import { pickTheme, shownTheme } from "./theme.js";
|
|
18
18
|
// What the row of the sections leaves between a link and the next, between the sections and the pages after them, and for the menu's button.
|
|
19
19
|
const linkGap = 2;
|
|
@@ -30,7 +30,7 @@ export function Top(top) {
|
|
|
30
30
|
setPoke({ id: String(Date.now()), mood: pokedMoods[Date.now() % pokedMoods.length] ?? "happy" });
|
|
31
31
|
};
|
|
32
32
|
const title = top.campaign ?? top.product;
|
|
33
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { children: _jsx("a", { class: "title-home", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] }))] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName, ownPages: top.ownPages ?? [], ownShown: top.ownShown }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: room, class: "top-room", children: [_jsx("span", { class: "top-mark far", "aria-hidden": "true" }), _jsx("span", { class: "top-mark near", "aria-hidden": "true" })] }), _jsxs("header", { ref: header, class: compact ? "top compact" : "top", children: [_jsx(MasterHome, { top: top, poke: poke, onHome: home }), _jsxs("div", { class: "titles", children: [_jsx("h1", { dir: "auto", children: _jsx("a", { class: "title-home", dir: "auto", href: sectionAddress("party"), onClick: home, children: title }) }), top.campaign !== undefined && (_jsxs("p", { class: "product", children: [top.product, top.system && _jsx("span", { class: "system-chip", children: top.system })] })), top.campaign !== undefined && top.now !== undefined && _jsx("p", { class: "product-time", children: gameDateLabel(top.now) })] }), _jsx(StatusChips, { now: top.now, calendar: top.calendar, live: top.live }), _jsx(Navigation, { current: top.section, fight: top.fight, yourTurn: top.yourTurn, turnName: top.turnName, ownPages: top.ownPages ?? [], ownShown: top.ownShown }), top.path !== undefined && top.path.length > 0 && _jsx(PlacePath, { path: top.path })] }), _jsx(ThemeCorner, {})] }));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* The sections, each a link to its address (D-276, D-309), the one shown marked, then the packages' pages that are tabs (D-512); then the saves, Help, the
|
|
@@ -50,7 +50,9 @@ function Navigation({ current, fight, yourTurn, turnName, ownPages, ownShown })
|
|
|
50
50
|
return (_jsxs("div", { ref: row, class: "nav-row", children: [_jsxs("nav", { class: "sections main-nav", "aria-label": t("Sections"), children: [tabs.map((tab) => {
|
|
51
51
|
const gone = awayTabs.includes(tab);
|
|
52
52
|
const kinds = [tab.key === "scene" && turns ? (turn ? "your-turn" : "in-turns") : "", tab.own ? "own-tab" : "", gone ? "away" : ""];
|
|
53
|
-
|
|
53
|
+
// The scene's whole name for a screen reader in a turn: Scene, your turn.
|
|
54
|
+
const named = tab.key === "scene" && turn ? `${tab.label}, ${turnName === undefined ? t("your turn") : t("It's {name}'s turn", { name: turnName })}` : undefined;
|
|
55
|
+
return (_jsxs("a", { href: tab.href, class: kinds.filter((kind) => kind !== "").join(" ") || undefined, "aria-label": named, "aria-current": tab.current ? "page" : undefined, "aria-hidden": gone ? true : undefined, tabIndex: gone ? -1 : undefined, children: [_jsx("span", { class: "section-mark", children: tab.icon }), _jsx("span", { class: "section-name", dir: "auto", children: tab.label })] }, tab.key));
|
|
54
56
|
}), menuPages.map((page, index) => {
|
|
55
57
|
const gone = !fitting.pages;
|
|
56
58
|
const kinds = ["page-link tip-below", index === 0 ? "pages-start" : "", gone ? "away" : ""].filter((kind) => kind !== "").join(" ");
|
|
@@ -77,7 +79,7 @@ function PackagesMenu({ pages, current, ownShown, kinds, gone }) {
|
|
|
77
79
|
const [open, setOpen] = useState(false);
|
|
78
80
|
const holder = useRef(null);
|
|
79
81
|
const shown = current === "packages" || pages.some((page) => ownKey(page) === ownShown);
|
|
80
|
-
const label = t("Menu: {pages}", { pages:
|
|
82
|
+
const label = t("Menu: {pages}", { pages: listText([...pages.map((page) => page.title), sectionLabel("packages")]) });
|
|
81
83
|
useClosing(holder, open, setOpen);
|
|
82
84
|
return (_jsxs("div", { ref: holder, class: `packages-menu ${kinds}`, "aria-hidden": gone ? true : undefined, children: [_jsx("button", { type: "button", class: shown ? "packages-menu-button shown" : "packages-menu-button", "aria-label": label, "data-tip": label, "aria-expanded": open, tabIndex: gone ? -1 : undefined, onClick: () => setOpen(!open), children: _jsx("span", { class: "section-mark", children: _jsx(Icon, { name: "packages" }) }) }), open && (_jsxs("div", { class: "menu-pop", children: [_jsx(OwnPageLinks, { pages: pages, ownShown: ownShown, onPick: () => setOpen(false) }), _jsxs("a", { class: "menu-manage", href: sectionAddress("packages"), "aria-current": current === "packages" ? "page" : undefined, onClick: () => setOpen(false), children: [_jsx(Icon, { name: "packages" }), sectionLabel("packages")] })] }))] }));
|
|
83
85
|
}
|
|
@@ -169,7 +171,7 @@ function Menu({ current, awayTabs, awayPages, ownMenu, ownShown }) {
|
|
|
169
171
|
if (awayTabs.length + awayPages.length === 0) {
|
|
170
172
|
return null;
|
|
171
173
|
}
|
|
172
|
-
const names =
|
|
174
|
+
const names = listText([...awayTabs.map((tab) => tab.label), ...awayPages.map(sectionLabel)]);
|
|
173
175
|
return (_jsxs("div", { class: "menu", ref: holder, children: [_jsx("button", { type: "button", class: "icon-button tonal menu-button tip-left", "aria-label": t("Menu: {pages}", { pages: names }), "data-tip": t("Menu: {pages}", { pages: names }), "aria-expanded": open, onClick: () => setOpen(!open), children: _jsx(Icon, { name: "menu" }) }), open && (_jsxs("div", { class: "menu-pop", children: [awayTabs.map((tab) => (_jsxs("a", { href: tab.href, "aria-current": tab.current ? "page" : undefined, dir: "auto", onClick: () => setOpen(false), children: [tab.icon, tab.label] }, tab.key))), awayPages.map((page) => (_jsxs(Fragment, { children: [_jsxs("a", { href: sectionAddress(page), "aria-current": page === current ? "page" : undefined, onClick: () => setOpen(false), children: [_jsx(Icon, { name: page }), sectionLabel(page)] }), page === "packages" && ownMenu.length > 0 && (_jsx("div", { class: "menu-sub", children: _jsx(OwnPageLinks, { pages: ownMenu, ownShown: ownShown, onPick: () => setOpen(false) }) }))] }, page))), _jsxs("button", { type: "button", class: "menu-theme", onClick: flip, children: [_jsx(Icon, { name: theme.next === "dark" ? "moon" : "sun" }), theme.name] })] }))] }));
|
|
174
176
|
}
|
|
175
177
|
/** A touch outside an open menu, or Escape, closes it; Escape gives the focus back to its button. */
|
|
@@ -260,7 +262,3 @@ function useWrapped(row) {
|
|
|
260
262
|
};
|
|
261
263
|
}, []);
|
|
262
264
|
}
|
|
263
|
-
/** Names as a list in the page's language: Rules, Saves and Settings; ルール、セーブ、設定. */
|
|
264
|
-
function listOf(names) {
|
|
265
|
-
return new Intl.ListFormat(document.documentElement.lang || "en", { type: "conjunction" }).format(names);
|
|
266
|
-
}
|
package/dist/dashboard/turns.js
CHANGED
|
@@ -30,7 +30,7 @@ export function turnWords(name) {
|
|
|
30
30
|
*/
|
|
31
31
|
export function TurnBand({ scene, several = false, motion }) {
|
|
32
32
|
const fighters = scene.fighters;
|
|
33
|
-
const acting = fighters
|
|
33
|
+
const acting = actingIndex(fighters, scene.turn);
|
|
34
34
|
const next = acting < 0 || fighters.length < 2 ? undefined : fighters[(acting + 1) % fighters.length];
|
|
35
35
|
const mine = acting >= 0 && fighters[acting].role === "pc";
|
|
36
36
|
const kinds = ["turn-band", mine ? "mine" : acting < 0 ? "" : fighters[acting].role, motion === undefined ? "" : `band-${motion}`];
|
|
@@ -87,7 +87,7 @@ export function TurnsCard({ scene, party, several = false, beside = false }) {
|
|
|
87
87
|
const list = useRef(null);
|
|
88
88
|
const [open, toggle] = useOpen("Turns");
|
|
89
89
|
const fighters = scene?.fighters ?? [];
|
|
90
|
-
const acting = fighters
|
|
90
|
+
const acting = actingIndex(fighters, scene?.turn);
|
|
91
91
|
// As the turn passes, the list that scrolls brings whoever acts into its sight, the page left where it is.
|
|
92
92
|
useEffect(() => {
|
|
93
93
|
const element = list.current;
|
|
@@ -169,3 +169,8 @@ function fighterStatus(fighter, widgets) {
|
|
|
169
169
|
function shownName(fighter) {
|
|
170
170
|
return fighter.stranger ? strangerLabel(fighter.name) : fighter.name;
|
|
171
171
|
}
|
|
172
|
+
/** Where in the order who acts stands: the one the view marks, then by name, as from a server older than the page. */
|
|
173
|
+
function actingIndex(fighters, turn) {
|
|
174
|
+
const marked = fighters.findIndex((fighter) => fighter.acting === true);
|
|
175
|
+
return marked >= 0 ? marked : fighters.findIndex((fighter) => fighter.name === turn);
|
|
176
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
3
|
import { sectionAddress } from "../address.js";
|
|
4
4
|
import { pictureAddress, readView } from "../api.js";
|
|
@@ -16,7 +16,7 @@ const wide = "(min-width: 900px)";
|
|
|
16
16
|
* place on the world map, or of the nearest that holds it. With more than one player character (`players`), a chip for each among the kinds shows what that
|
|
17
17
|
* one knows (D-480 (7)).
|
|
18
18
|
*/
|
|
19
|
-
export function LoreTab({ world, version, open, onMap, players = [] }) {
|
|
19
|
+
export function LoreTab({ world, version, open, onMap, players = [], kinds = new Map() }) {
|
|
20
20
|
const [search, setSearch] = useState("");
|
|
21
21
|
// A kind of page, or a player character's name after "@".
|
|
22
22
|
const [filter, setFilter] = useState();
|
|
@@ -37,7 +37,7 @@ export function LoreTab({ world, version, open, onMap, players = [] }) {
|
|
|
37
37
|
return (_jsxs(Browse, { open: entry?.name, explicit: asked !== undefined, back: sectionAddress("world", "lore"), backLabel: t("All you know"), children: [_jsxs("div", { class: "browse-list", children: [open !== undefined && asked === undefined && _jsx("p", { class: "browse-none", role: "status", children: t("Your character knows nothing called “{name}”.", { name: open }) }), _jsx("div", { class: "browse-find", children: _jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: search, placeholder: t("Search"), "aria-label": t("Search what your character knows"), onInput: (event) => setSearch(event.currentTarget.value) })] }) }), (groupedLore(world.known).length > 1 || each.length > 0) && (_jsx(FilterChips, { label: t("Kinds"), chosen: shownFilter, onChoose: setFilter, all: found.length, options: [
|
|
38
38
|
...groupedLore(found).map((part) => ({ key: part.group, name: groupLabel(part.group), count: part.entries.length })),
|
|
39
39
|
...each.map((member) => ({ key: `@${member.name}`, name: member.name, count: found.filter((entry) => knownTo(entry, member.name)).length, member })),
|
|
40
|
-
] })), found.length === 0 && (_jsxs("p", { class: "browse-none", role: "status", children: [t("Nothing your character knows matches “{search}”.", { search }), " ", _jsx("button", { type: "button", class: "button quiet", onClick: () => setSearch(""), children: t("Clear the search") })] })), groups.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `lore-${part.group}`, children: [_jsxs("h3", { class: "eyebrow", id: `lore-${part.group}`, children: [groupLabel(part.group), _jsx("span", { class: "browse-count num", children: part.entries.length })] }), _jsx("ul", { class: "browse-rows", children: part.entries.map((one, index) => (_jsx("li", { children: _jsxs("a", { class: "browse-row", href: sectionAddress("world", "lore", one.name), "aria-current": one.name === entry?.name ? "true" : undefined, "aria-describedby": `lore-${part.group}-${index}`, "data-name": one.name, children: [_jsx(LoreThumb, { entry: one }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", children: one.name }), _jsx("span", { class: "browse-meta", id: `lore-${part.group}-${index}`, children:
|
|
40
|
+
] })), found.length === 0 && (_jsxs("p", { class: "browse-none", role: "status", children: [t("Nothing your character knows matches “{search}”.", { search }), " ", _jsx("button", { type: "button", class: "button quiet", onClick: () => setSearch(""), children: t("Clear the search") })] })), groups.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `lore-${part.group}`, children: [_jsxs("h3", { class: "eyebrow", id: `lore-${part.group}`, children: [groupLabel(part.group), _jsx("span", { class: "browse-count num", children: part.entries.length })] }), _jsx("ul", { class: "browse-rows", children: part.entries.map((one, index) => (_jsx("li", { children: _jsxs("a", { class: "browse-row", href: sectionAddress("world", "lore", one.name), "aria-current": one.name === entry?.name ? "true" : undefined, "aria-labelledby": `lore-name-${part.group}-${index}`, "aria-describedby": `lore-${part.group}-${index}`, "data-name": one.name, children: [_jsx(LoreThumb, { entry: one }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", id: `lore-name-${part.group}-${index}`, children: one.name }), _jsx("span", { class: "browse-meta", id: `lore-${part.group}-${index}`, children: _jsx(MetaLine, { kind: entryKind(one, kinds), text: plainLine(one.summary) ?? one.within?.[0] }) })] })] }) }, one.name))) })] }, part.group)))] }), entry !== undefined && (_jsx(LoreReader, { entry: entry, version: version, link: link, several: each.length > 0, kinds: kinds, onMap: entry.type === "place" ? onMap([entry.name, ...entry.within ?? []]) : undefined, focus: asked !== undefined }, entry.name))] }));
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* The documents the character has or read: those it carries, then the others; the one open on its paper, as what it is. With more than one player character
|
|
@@ -58,7 +58,7 @@ export function DocumentsTab({ world, open, players = [] }) {
|
|
|
58
58
|
{ key: "carried", name: t("With you"), documents: world.documents.filter((one) => one.carried && (one.carrier === undefined || !carriers.includes(one.carrier))) },
|
|
59
59
|
{ key: "read", name: t("Read elsewhere"), documents: world.documents.filter((one) => !one.carried) },
|
|
60
60
|
].filter((part) => part.documents.length > 0);
|
|
61
|
-
return (_jsxs(Browse, { open: document?.name, explicit: asked !== undefined, back: sectionAddress("world", "documents"), backLabel: t("All documents"), children: [_jsxs("div", { class: "browse-list", children: [open !== undefined && asked === undefined && _jsx("p", { class: "browse-none", role: "status", children: t("Your character has no document called “{name}”.", { name: open }) }), parts.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `documents-${part.key}`, children: [_jsxs("h3", { class: "eyebrow", id: `documents-${part.key}`, children: [part.name, _jsx("span", { class: "browse-count num", children: part.documents.length })] }), _jsx("ul", { class: "browse-rows", children: part.documents.map((one, index) => (_jsx("li", { children: _jsxs("a", { class: "browse-row", href: sectionAddress("world", "documents", one.name), "aria-current": one.name === document?.name ? "true" : undefined, "aria-describedby": `documents-${part.key}-${index}`, "data-name": one.name, children: [_jsx("span", { class: `browse-thumb paper-thumb look-${documentLook(one.document)}`, "aria-hidden": "true", children: _jsx(DocumentGlyph, { look: documentLook(one.document) }) }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", children: one.name }), _jsx("span", { class: "browse-meta", id: `documents-${part.key}-${index}`, children:
|
|
61
|
+
return (_jsxs(Browse, { open: document?.name, explicit: asked !== undefined, back: sectionAddress("world", "documents"), backLabel: t("All documents"), children: [_jsxs("div", { class: "browse-list", children: [open !== undefined && asked === undefined && _jsx("p", { class: "browse-none", role: "status", children: t("Your character has no document called “{name}”.", { name: open }) }), parts.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `documents-${part.key}`, children: [_jsxs("h3", { class: "eyebrow", id: `documents-${part.key}`, children: [part.name, _jsx("span", { class: "browse-count num", children: part.documents.length })] }), _jsx("ul", { class: "browse-rows", children: part.documents.map((one, index) => (_jsx("li", { children: _jsxs("a", { class: "browse-row", href: sectionAddress("world", "documents", one.name), "aria-current": one.name === document?.name ? "true" : undefined, "aria-labelledby": `documents-name-${part.key}-${index}`, "aria-describedby": `documents-${part.key}-${index}`, "data-name": one.name, children: [_jsx("span", { class: `browse-thumb paper-thumb look-${documentLook(one.document)}`, "aria-hidden": "true", children: _jsx(DocumentGlyph, { look: documentLook(one.document) }) }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", id: `documents-name-${part.key}-${index}`, children: one.name }), _jsx("span", { class: "browse-meta", id: `documents-${part.key}-${index}`, children: _jsx(MetaLine, { kind: documentLabel(one.document), text: plainLine(one.text) }) })] })] }) }, one.name))) })] }, part.key)))] }), document !== undefined && _jsx(DocumentReader, { document: document, link: link, focus: asked !== undefined, several: several }, document.name)] }));
|
|
62
62
|
}
|
|
63
63
|
/** Whether a document is carried, in words: by the player's character, or with more than one by the one named, as its group says; nothing of one read elsewhere. */
|
|
64
64
|
function carriedWords(document, several) {
|
|
@@ -75,6 +75,7 @@ function documentLabel(document) {
|
|
|
75
75
|
notice: t("Notice"),
|
|
76
76
|
page: t("Page"),
|
|
77
77
|
book: t("Book"),
|
|
78
|
+
tome: t("Book"),
|
|
78
79
|
diary: t("Diary"),
|
|
79
80
|
journal: t("Diary"),
|
|
80
81
|
map: t("Map"),
|
|
@@ -82,7 +83,8 @@ function documentLabel(document) {
|
|
|
82
83
|
inscription: t("Inscription"),
|
|
83
84
|
};
|
|
84
85
|
const word = document.trim();
|
|
85
|
-
|
|
86
|
+
// A kind the page has no word for, as a poster, by the look it shares: a poster is a notice.
|
|
87
|
+
return labels[word.toLowerCase()] ?? labels[documentLook(word)] ?? capitalized(word);
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* The list and its reader: side by side on a wide screen; under it the reader in the list's place once a page is open, with the way back at its top. Back from
|
|
@@ -106,7 +108,7 @@ function Browse({ open, explicit, back, backLabel, children }) {
|
|
|
106
108
|
return (_jsxs("div", { class: explicit ? "browse open" : "browse", ref: box, children: [explicit && (_jsxs("a", { class: "browse-back button quiet", href: back, children: [_jsx(Icon, { name: "fold" }), backLabel] })), children] }));
|
|
107
109
|
}
|
|
108
110
|
/** A page the character knows, read whole as it knows it: its picture, what it is and where, its text with its links, and where it leads on the page. */
|
|
109
|
-
function LoreReader({ entry, version, link, onMap, focus, several }) {
|
|
111
|
+
function LoreReader({ entry, version, link, onMap, focus, several, kinds }) {
|
|
110
112
|
const [text, setText] = useState();
|
|
111
113
|
// Who knows each secret, when not all the player characters do: said after its title, the one place the page names them (D-480 (7)).
|
|
112
114
|
const [knowers, setKnowers] = useState([]);
|
|
@@ -127,7 +129,7 @@ function LoreReader({ entry, version, link, onMap, focus, several }) {
|
|
|
127
129
|
useOpened(title, focus);
|
|
128
130
|
const person = entry.type === "character" || entry.type === "creature";
|
|
129
131
|
const banner = entry.picture !== undefined && !person;
|
|
130
|
-
return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [banner && _jsx("img", { class: "reader-banner", src: pictureAddress(entry.picture), alt: "" }), _jsxs("header", { class: "reader-head", children: [person && _jsx(Token, { member: { name: entry.name, image: entry.picture, role: entry.companion ? "companion" : "other" }, large: true, ...(entry.companion ? { side: "ally" } : {}) }), _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: entryKind(entry) }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: entry.name }), entry.within !== undefined && (_jsxs("p", { class: "reader-where", children: [_jsx(Icon, { name: "place" }), _jsx("span", { class: "reader-path", children: entry.within.toReversed().map((place, index) => (_jsxs("span", { children: [index > 0 && _jsx("span", { class: "reader-step", "aria-hidden": "true" }), _jsx("a", { class: "md-link", href: sectionAddress("world", "lore", place), children: place })] }, place))) })] }))] })] }), (onMap !== undefined || entry.companion) && (_jsxs("p", { class: "reader-actions", children: [onMap !== undefined && (_jsxs("a", { class: "button package-button", href: onMap, children: [_jsx(Icon, { name: "world" }), t("Show on the map")] })), entry.companion && (_jsxs("a", { class: "button package-button", href: `#/party/${encodeURIComponent(entry.name)}`, children: [_jsx(Icon, { name: "party" }), t("Open the sheet")] }))] })), _jsxs("div", { class: "reader-text", children: [text === undefined && !problem && entry.summary !== "" && _jsx(Markdown, { text: entry.summary, link: link }), text !== undefined && text.trim() !== "" && _jsx(Markdown, { text: text, link: link, secretKnowers: several ? knowersOf(knowers) : undefined }), ((text !== undefined && text.trim() === "") || (text === undefined && entry.summary === "")) && !problem && (_jsx("p", { class: "browse-none", children: text === undefined ? t("Reading…") : t("Your character knows its name, and nothing more yet.") })), problem && _jsx("p", { class: "browse-none", children: t("This page could not be read now: try again in a moment.") })] })] }));
|
|
132
|
+
return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [banner && _jsx("img", { class: "reader-banner", src: pictureAddress(entry.picture), alt: "" }), _jsxs("header", { class: "reader-head", children: [person && _jsx(Token, { member: { name: entry.name, image: entry.picture, role: entry.companion ? "companion" : "other" }, large: true, ...(entry.companion ? { side: "ally" } : {}) }), _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: entryKind(entry, kinds) }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: entry.name }), entry.within !== undefined && (_jsxs("p", { class: "reader-where", children: [_jsx(Icon, { name: "place" }), _jsx("span", { class: "reader-path", children: entry.within.toReversed().map((place, index) => (_jsxs("span", { children: [index > 0 && _jsx("span", { class: "reader-step", "aria-hidden": "true" }), _jsx("a", { class: "md-link", href: sectionAddress("world", "lore", place), children: place })] }, place))) })] }))] })] }), (onMap !== undefined || entry.companion) && (_jsxs("p", { class: "reader-actions", children: [onMap !== undefined && (_jsxs("a", { class: "button package-button", href: onMap, children: [_jsx(Icon, { name: "world" }), t("Show on the map")] })), entry.companion && (_jsxs("a", { class: "button package-button", href: `#/party/${encodeURIComponent(entry.name)}`, children: [_jsx(Icon, { name: "party" }), t("Open the sheet")] }))] })), _jsxs("div", { class: "reader-text", children: [text === undefined && !problem && entry.summary !== "" && _jsx(Markdown, { text: entry.summary, link: link }), text !== undefined && text.trim() !== "" && _jsx(Markdown, { text: text, link: link, secretKnowers: several ? knowersOf(knowers) : undefined }), ((text !== undefined && text.trim() === "") || (text === undefined && entry.summary === "")) && !problem && (_jsx("p", { class: "browse-none", children: text === undefined ? t("Reading…") : t("Your character knows its name, and nothing more yet.") })), problem && _jsx("p", { class: "browse-none", children: t("This page could not be read now: try again in a moment.") })] })] }));
|
|
131
133
|
}
|
|
132
134
|
/** A document on its paper, as what it is: a letter, a notice, a torn page; its picture first, larger at a click, for a map above all. */
|
|
133
135
|
function DocumentReader({ document, link, focus, several }) {
|
|
@@ -203,18 +205,17 @@ function linksOf(world) {
|
|
|
203
205
|
};
|
|
204
206
|
}
|
|
205
207
|
/** What a page is, in the reader's eyebrow: a companion, a person, the kind of a place, a faction… */
|
|
206
|
-
function entryKind(entry) {
|
|
208
|
+
function entryKind(entry, kinds) {
|
|
207
209
|
if (entry.companion) {
|
|
208
210
|
return t("Companion");
|
|
209
211
|
}
|
|
210
|
-
const
|
|
211
|
-
return entry.type === "place" ? placeKindLabel(entry.kind) ?? t("Place") :
|
|
212
|
+
const types = { character: t("Person"), faction: t("Faction"), creature: t("Creature"), item: t("Item"), event: t("Event"), topic: t("Topic") };
|
|
213
|
+
return entry.type === "place" ? kinds.get(entry.name) ?? placeKindLabel(entry.kind) ?? t("Place") : types[entry.type] ?? capitalized(entry.type);
|
|
212
214
|
}
|
|
213
|
-
/** A row's
|
|
214
|
-
function
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
return [entryKind(entry), opening ?? where].filter((part) => part !== undefined && part !== "").join(" · ");
|
|
215
|
+
/** A row's meta: what it is in the page's language, then its own words isolated in their direction, as Italian words in an Arabic page. */
|
|
216
|
+
function MetaLine({ kind, text }) {
|
|
217
|
+
const words = text === undefined || text === "" ? undefined : _jsx("bdi", { children: text });
|
|
218
|
+
return kind === undefined ? (words ?? null) : _jsxs(_Fragment, { children: [kind, words && _jsxs(_Fragment, { children: [" · ", words] })] });
|
|
218
219
|
}
|
|
219
220
|
/** A group of the list in the page's language. */
|
|
220
221
|
function groupLabel(group) {
|
|
@@ -172,7 +172,7 @@ export function hexesOf(view, width, height, lifted, regions) {
|
|
|
172
172
|
for (let row = firstRow; row <= lastRow; row++) {
|
|
173
173
|
const centre = hexCentre(column, row, across);
|
|
174
174
|
const lit = lifted.circles.some((circle) => Math.hypot(centre.x - circle.x, centre.y - circle.y) <= Math.max(circle.r, radius))
|
|
175
|
-
||
|
|
175
|
+
|| nearSegment(segmentGrid(lifted), centre, Math.max(lineReach, radius * 0.9));
|
|
176
176
|
const region = smallestFirst.find((candidate) => Math.hypot(centre.x - candidate.x, centre.y - candidate.y) <= candidate.radius);
|
|
177
177
|
hexes.push({ ...centre, lit, ...(region === undefined ? {} : { region: region.name }), ...(region?.biome === undefined ? {} : { biome: region.biome }), tone: toneOf(column, row) });
|
|
178
178
|
}
|
|
@@ -516,6 +516,48 @@ function lengthOf(points) {
|
|
|
516
516
|
return points.reduce((sum, point, index) => (index === 0 ? 0 : sum + Math.hypot(point.x - points[index - 1].x, point.y - points[index - 1].y)), 0);
|
|
517
517
|
}
|
|
518
518
|
/** How far a point is from a segment, in km. */
|
|
519
|
+
// The segments of the known ways in square cells, built once for each lifting: a hex looks only at the cells near it, however many ways the world has.
|
|
520
|
+
const segmentCell = 10;
|
|
521
|
+
const segmentGrids = new WeakMap();
|
|
522
|
+
function segmentGrid(lifted) {
|
|
523
|
+
const known = segmentGrids.get(lifted);
|
|
524
|
+
if (known !== undefined) {
|
|
525
|
+
return known;
|
|
526
|
+
}
|
|
527
|
+
const grid = new Map();
|
|
528
|
+
for (const line of lifted.lines) {
|
|
529
|
+
for (let index = 1; index < line.length; index++) {
|
|
530
|
+
const [from, to] = [line[index - 1], line[index]];
|
|
531
|
+
for (let column = Math.floor(Math.min(from.x, to.x) / segmentCell); column <= Math.floor(Math.max(from.x, to.x) / segmentCell); column++) {
|
|
532
|
+
for (let row = Math.floor(Math.min(from.y, to.y) / segmentCell); row <= Math.floor(Math.max(from.y, to.y) / segmentCell); row++) {
|
|
533
|
+
const key = `${column} ${row}`;
|
|
534
|
+
const cell = grid.get(key);
|
|
535
|
+
if (cell === undefined) {
|
|
536
|
+
grid.set(key, [[from, to]]);
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
cell.push([from, to]);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
segmentGrids.set(lifted, grid);
|
|
546
|
+
return grid;
|
|
547
|
+
}
|
|
548
|
+
/** Whether a segment of the grid passes within `reach` of a point: the same answer as looking at every segment. */
|
|
549
|
+
function nearSegment(grid, point, reach) {
|
|
550
|
+
const [firstColumn, lastColumn] = [Math.floor((point.x - reach) / segmentCell), Math.floor((point.x + reach) / segmentCell)];
|
|
551
|
+
const [firstRow, lastRow] = [Math.floor((point.y - reach) / segmentCell), Math.floor((point.y + reach) / segmentCell)];
|
|
552
|
+
for (let column = firstColumn; column <= lastColumn; column++) {
|
|
553
|
+
for (let row = firstRow; row <= lastRow; row++) {
|
|
554
|
+
if ((grid.get(`${column} ${row}`) ?? []).some(([from, to]) => toSegment(point, from, to) <= reach)) {
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
519
561
|
function toSegment(point, from, to) {
|
|
520
562
|
const [dx, dy] = [to.x - from.x, to.y - from.y];
|
|
521
563
|
const share = Math.max(0, Math.min(1, ((point.x - from.x) * dx + (point.y - from.y) * dy) / (dx * dx + dy * dy || 1)));
|