rpg-engine 0.17.1 → 0.18.1
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/commands/change/change.d.ts +1 -0
- package/dist/commands/change/recipe-pace.d.ts +5 -0
- package/dist/commands/change/recipe-pace.js +20 -1
- package/dist/commands/change/recipe.d.ts +4 -0
- package/dist/commands/change/recipe.js +9 -5
- package/dist/commands/reveal.d.ts +2 -0
- package/dist/commands/reveal.js +22 -3
- package/dist/commands/scene/close.js +3 -1
- package/dist/commands/scene/open.js +1 -1
- package/dist/commands/scene/scene.js +3 -2
- package/dist/commands/shared/packages/updates.d.ts +6 -0
- package/dist/commands/shared/packages/updates.js +114 -0
- package/dist/commands/shared/scene/scene.js +4 -0
- package/dist/commands/shared/time/recipes.d.ts +5 -0
- package/dist/commands/shared/time/recipes.js +19 -1
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +5 -0
- package/dist/commands/travel/travel.js +1 -0
- package/dist/commands/view/place.d.ts +6 -0
- package/dist/commands/view/place.js +37 -13
- package/dist/commands/view/result.d.ts +2 -0
- package/dist/commands/view/view.d.ts +1 -0
- package/dist/commands/view/view.js +34 -11
- package/dist/core/context.d.ts +5 -0
- package/dist/dashboard/app.js +1 -1
- package/dist/dashboard/dice/tray.js +7 -5
- package/dist/dashboard/parts/labels.js +26 -4
- package/dist/dashboard/parts/widgets.js +1 -1
- package/dist/dashboard/play/rolls.js +3 -3
- package/dist/dashboard/settings/setup.js +30 -13
- package/dist/dashboard/shell/table.js +7 -3
- package/dist/packages/npm.js +32 -7
- package/dist/pages/index.d.ts +1 -1
- package/dist/pages/index.js +1 -1
- package/dist/scene/scene.d.ts +4 -1
- package/instructions/combat.md +2 -2
- package/instructions/core.md +2 -2
- package/instructions/play.md +4 -4
- package/package.json +1 -1
|
@@ -32,8 +32,10 @@ export function shownPlace(sight) {
|
|
|
32
32
|
.map(({ entry, place: holder }) => ({ name: entry.name, value: inKnownWords(world, knowledge, entry.value), ...placed(holder) })),
|
|
33
33
|
...placesAround(world, place).flatMap((holder) => effectsOf(holder).map((effect) => ({ effect: effect.name, ...(effect.end === undefined ? {} : { end: effect.end }), ...placed(holder) }))),
|
|
34
34
|
];
|
|
35
|
+
const scene = readOpenScene(sight.root).scene;
|
|
36
|
+
// One the open scene gives by what the character sees of them is there in the scene alone, as one it does not know (D-568).
|
|
35
37
|
const present = world.pages.filter((page) => page.type === "character" && page.fields.status !== "dead" && locate(world, page).chain[0] === place
|
|
36
|
-
&& (sight.party.includes(page) || knowsPage(knowledge, page)));
|
|
38
|
+
&& (sight.party.includes(page) || (knowsPage(knowledge, page) && !seenInScene(world, sight.party, scene, page.name))));
|
|
37
39
|
const image = picture(sight, place);
|
|
38
40
|
const grid = placeGrid(place)?.grid;
|
|
39
41
|
const text = knownText(world, knowledge, place);
|
|
@@ -49,7 +51,7 @@ export function shownPlace(sight) {
|
|
|
49
51
|
// The party first, the player character in the foreground at its head (VIEW-12).
|
|
50
52
|
here: [...partyFirst(sight).filter((page) => present.includes(page)), ...present.filter((page) => !sight.party.includes(page))].map((page) => ({
|
|
51
53
|
...person(sight, page),
|
|
52
|
-
...hostileMark(
|
|
54
|
+
...hostileMark(scene, page.name),
|
|
53
55
|
...stateOf(sight, page),
|
|
54
56
|
})),
|
|
55
57
|
...(grid === undefined ? {} : { map: shownGrid(sight, place, grid) }),
|
|
@@ -64,7 +66,7 @@ export function shownScene(sight) {
|
|
|
64
66
|
const place = knownPage(sight, scene.place);
|
|
65
67
|
const characters = scene.with.map((link) => {
|
|
66
68
|
const name = parsePageReference(link).name;
|
|
67
|
-
const page =
|
|
69
|
+
const page = knownInScene(sight, scene, link);
|
|
68
70
|
const hostile = hostileMark(scene, name);
|
|
69
71
|
const written = pagesWithName(sight.world, name)[0];
|
|
70
72
|
const state = written === undefined ? {} : strangerState(sight, scene, written);
|
|
@@ -75,7 +77,7 @@ export function shownScene(sight) {
|
|
|
75
77
|
});
|
|
76
78
|
const creatures = [...new Set(Object.values(scene.copies).map((copy) => copy.creature))].map((creature) => {
|
|
77
79
|
const count = Object.values(scene.copies).filter((copy) => copy.creature === creature).length;
|
|
78
|
-
const page =
|
|
80
|
+
const page = knownInScene(sight, scene, creature);
|
|
79
81
|
// A kind the character does not know by the letter its copies have in the scene, as creature B, with more kinds (D-331).
|
|
80
82
|
const first = Object.keys(scene.copies).find((copy) => scene.copies[copy].creature === creature);
|
|
81
83
|
const name = first === undefined ? "creature" : strangerName(scene, first).replace(/\s*\d+$/, "");
|
|
@@ -132,7 +134,7 @@ export function seenEffect(sight, effect) {
|
|
|
132
134
|
if (end === undefined || !("turn" in end)) {
|
|
133
135
|
return effectParts(sight.world, system, effect, sight.words);
|
|
134
136
|
}
|
|
135
|
-
const scene = readOpenScene(sight.root).scene ?? { copies: {} };
|
|
137
|
+
const scene = readOpenScene(sight.root).scene ?? { with: [], copies: {} };
|
|
136
138
|
return effectParts(sight.world, system, { ...effect, end: { ...end, turn: shownTurn(sight, scene, end.turn) } }, sight.words);
|
|
137
139
|
}
|
|
138
140
|
/** The picture of one the character does not know, as strangerPicture gives it, for the scene and for the rolls (D-420, D-421). */
|
|
@@ -144,6 +146,21 @@ export function strangerImage(root, context, world, name) {
|
|
|
144
146
|
const hidden = file === undefined ? undefined : hiddenImageName(file);
|
|
145
147
|
return file === undefined || hidden === undefined ? undefined : { file: hidden, version: Math.trunc(files().modified(file) ?? 0) };
|
|
146
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Whether the open scene gives someone by what the character sees of them (D-568), by their name, a copy's or its creature's: one in the scene the master gave
|
|
151
|
+
* seen for, known by name or not, while the scene keeps them; never one of the party.
|
|
152
|
+
*/
|
|
153
|
+
export function seenInScene(world, party, scene, name) {
|
|
154
|
+
if (scene === undefined) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const copies = { ...scene.gone, ...scene.copies };
|
|
158
|
+
const copy = Object.keys(copies).find((copyName) => comparableText(copyName) === comparableText(name));
|
|
159
|
+
const key = parsePageReference(copy === undefined ? name : copies[copy].creature).name;
|
|
160
|
+
const inScene = [...scene.with, ...Object.values(copies).map((one) => one.creature)].some((link) => comparableText(parsePageReference(link).name) === comparableText(key));
|
|
161
|
+
const page = pagesWithName(world, key)[0];
|
|
162
|
+
return inScene && seenOf(scene, key) !== undefined && (page === undefined || !party.includes(page));
|
|
163
|
+
}
|
|
147
164
|
/**
|
|
148
165
|
* A place's map as the player sees it (GRD-6): who stands where, the party and the characters the character knows by name, the others of the open scene as
|
|
149
166
|
* someone, its copies as the scene names them; a character it does not know outside the scene is not shown, as in VIEW-6.
|
|
@@ -169,7 +186,7 @@ function shownGrid(sight, place, written) {
|
|
|
169
186
|
const measured = { square, ...(system?.grid === undefined ? {} : measuredFrom(sight, system.grid, measures, here, self, one)) };
|
|
170
187
|
if (one.copy !== undefined && here !== undefined) {
|
|
171
188
|
const copy = here.copies[one.copy];
|
|
172
|
-
const creature =
|
|
189
|
+
const creature = knownInScene(sight, here, copy?.creature);
|
|
173
190
|
const image = creature === undefined ? strangerPicture(sight, copy?.creature) : picture(sight, creature);
|
|
174
191
|
const state = copy === undefined ? {} : stateOf(sight, copyPage(one.copy, copy));
|
|
175
192
|
return [
|
|
@@ -182,7 +199,7 @@ function shownGrid(sight, place, written) {
|
|
|
182
199
|
if (page === undefined || page.type !== "character" || page.fields.status === "dead") {
|
|
183
200
|
return [];
|
|
184
201
|
}
|
|
185
|
-
if (sight.party.includes(page) ||
|
|
202
|
+
if (sight.party.includes(page) || knownInScene(sight, here, page.name) !== undefined) {
|
|
186
203
|
return [{ ...person(sight, page), ...hostileMark(here, page.name), ...stateOf(sight, page), ...measured }];
|
|
187
204
|
}
|
|
188
205
|
const image = strangerPicture(sight, page.name);
|
|
@@ -246,9 +263,9 @@ function fighterOf(sight, scene, name) {
|
|
|
246
263
|
return undefined;
|
|
247
264
|
}
|
|
248
265
|
const party = sight.party.includes(page);
|
|
249
|
-
// A copy is named when the character knows its creature; a character when it knows them.
|
|
250
|
-
const creature = copy === undefined ? undefined :
|
|
251
|
-
const stranger = copy === undefined ? !party &&
|
|
266
|
+
// A copy is named when the character knows its creature; a character when it knows them; neither while the scene gives them by what is seen (D-568).
|
|
267
|
+
const creature = copy === undefined ? undefined : knownInScene(sight, scene, copy[1].creature);
|
|
268
|
+
const stranger = copy === undefined ? !party && knownInScene(sight, scene, page.name) === undefined : creature === undefined;
|
|
252
269
|
const shown = !stranger ? page.name : copy === undefined ? seenName(scene, page.name) : strangerName(scene, copy[0]);
|
|
253
270
|
const image = stranger ? strangerPicture(sight, copy === undefined ? page.name : copy[1].creature) : picture(sight, creature ?? page);
|
|
254
271
|
const effects = shownEffects(sight, system, page, party);
|
|
@@ -376,13 +393,20 @@ function knownPage(sight, name) {
|
|
|
376
393
|
const page = pagesWithName(sight.world, parsePageReference(name).name)[0];
|
|
377
394
|
return page !== undefined && knowsPage(sight.knowledge, page) ? page : undefined;
|
|
378
395
|
}
|
|
379
|
-
/**
|
|
396
|
+
/**
|
|
397
|
+
* Whose turn it is, as the character knows them: a character it knows by name, a copy by its own name when it knows the creature, else creature and its number;
|
|
398
|
+
* by what is seen while the scene gives them so (D-568).
|
|
399
|
+
*/
|
|
380
400
|
function shownTurn(sight, scene, name) {
|
|
381
401
|
const copy = Object.entries(scene.copies).find(([copyName]) => comparableText(copyName) === comparableText(name));
|
|
382
402
|
if (copy === undefined) {
|
|
383
|
-
return
|
|
403
|
+
return knownInScene(sight, scene, name)?.name ?? seenName(scene, name);
|
|
384
404
|
}
|
|
385
|
-
return
|
|
405
|
+
return knownInScene(sight, scene, copy[1].creature) === undefined ? strangerName(scene, copy[0]) : copy[0];
|
|
406
|
+
}
|
|
407
|
+
/** The page the character knows by a name in the open scene: none while the scene gives them by what is seen (D-568), known or not. */
|
|
408
|
+
function knownInScene(sight, scene, name) {
|
|
409
|
+
return name === undefined || seenInScene(sight.world, sight.party, scene, name) ? undefined : knownPage(sight, name);
|
|
386
410
|
}
|
|
387
411
|
/**
|
|
388
412
|
* The name the player hears for a copy of a creature its character does not know (D-325, D-331, D-416): what the master said the character sees of its kind and
|
|
@@ -18,6 +18,8 @@ import type { KnownEntry, ShownCalendar, ShownDocument } from "./world.ts";
|
|
|
18
18
|
export type ViewResult = {
|
|
19
19
|
kind: "none";
|
|
20
20
|
language?: string;
|
|
21
|
+
/** The game system's words in the campaign's language, as in play: they name the system's own questions of the setup (D-403). */
|
|
22
|
+
words?: SystemWords;
|
|
21
23
|
importing?: ShownImport;
|
|
22
24
|
} | {
|
|
23
25
|
kind: "overview";
|
|
@@ -32,7 +32,7 @@ import { shownLayers } from "./layers.js";
|
|
|
32
32
|
import { mapText, shownMap } from "./map.js";
|
|
33
33
|
import { characterNamed, memoryOf, memoryText } from "./memory.js";
|
|
34
34
|
import { knownNamedPage, knownPage, lineValues, placeLook, shownName, shownPage, valueCoins } from "./page.js";
|
|
35
|
-
import { isDown, sceneLine, seenEffect, shownPlace, shownScene, strangerImage } from "./place.js";
|
|
35
|
+
import { isDown, sceneLine, seenEffect, seenInScene, shownPlace, shownScene, strangerImage } from "./place.js";
|
|
36
36
|
import { shownSaves } from "./saves.js";
|
|
37
37
|
import { diaryCount, diaryLine, diaryLines, isCopyName, rollCount, rollsShown, seenByRoll, shownRoll, storyFact } from "./story.js";
|
|
38
38
|
import { knownDocuments, knownEntries, knownEntryText, shownCalendar } from "./world.js";
|
|
@@ -105,9 +105,11 @@ export const view = defineCommand({
|
|
|
105
105
|
const knowledge = input.as === undefined ? playerKnowledge(root, world, input.focus) : knowledgeOf(root, world, characterNamed(world, input.as));
|
|
106
106
|
// An import under way, which the dashboard tells the player (D-491 (11)); never the character agent.
|
|
107
107
|
const importing = input.as === undefined ? importShown(root) : undefined;
|
|
108
|
+
// Before a player character, as in the setup, the system's words still name its own questions, as its Outcomes.
|
|
108
109
|
if (knowledge === undefined) {
|
|
109
110
|
const language = readSettings(root).language;
|
|
110
|
-
|
|
111
|
+
const words = shownWords(root, context, world, language);
|
|
112
|
+
return { kind: "none", ...(language === undefined ? {} : { language }), ...(words === undefined ? {} : { words }), ...(importing === undefined ? {} : { importing }) };
|
|
111
113
|
}
|
|
112
114
|
const pc = knowledge.pc;
|
|
113
115
|
// Who of the party the view gives: the player characters, the living first, or the one whose view it is for a character agent, and the companions (VIEW-12).
|
|
@@ -133,10 +135,11 @@ export const view = defineCommand({
|
|
|
133
135
|
}
|
|
134
136
|
const present = readPresent(root).date;
|
|
135
137
|
const known = (name) => shownName(world, knowledge, name);
|
|
138
|
+
const lineNamed = namedInLines(root, readLog(root), world, [...players, ...companionsOf(world)], known);
|
|
136
139
|
return {
|
|
137
140
|
kind: "journal",
|
|
138
141
|
...(present === undefined ? {} : { now: formatGameDate(present) }),
|
|
139
|
-
...shownJournal(root, world, knowledge, present, (entry) => storyFact(world, entry,
|
|
142
|
+
...shownJournal(root, world, knowledge, present, (entry) => storyFact(world, entry, lineNamed(entry)), known, (name) => placeLook(root, context, world, knowledge, name)),
|
|
140
143
|
// The diaries the player reads, the last line first: never a hidden line, as another character's (DIA-4).
|
|
141
144
|
thoughts: thoughtsIn(root, world).filter((one) => !one.hidden).reverse().map((one) => ({ who: known(one.page.name) ?? "someone", ...(one.date === undefined ? {} : { date: one.date }), text: one.text })),
|
|
142
145
|
};
|
|
@@ -177,7 +180,7 @@ export const view = defineCommand({
|
|
|
177
180
|
const { coins } = campaignCoins(root, context);
|
|
178
181
|
const system = campaignSystem(root, context);
|
|
179
182
|
const open = readJourney(root)?.at !== undefined;
|
|
180
|
-
const companions = world
|
|
183
|
+
const companions = companionsOf(world);
|
|
181
184
|
const language = readSettings(root).language;
|
|
182
185
|
const memberWords = system === undefined || language === undefined ? undefined : systemWordsOf(root, system, language, context);
|
|
183
186
|
const sight = { root, context, world, knowledge, party: [...players, ...companions], ...(memberWords === undefined ? {} : { words: memberWords.words }) };
|
|
@@ -217,27 +220,27 @@ export const view = defineCommand({
|
|
|
217
220
|
};
|
|
218
221
|
const now = readPresent(root).date;
|
|
219
222
|
const named = (name) => shownName(world, knowledge, name);
|
|
223
|
+
const log = readLog(root);
|
|
224
|
+
const lineNamed = namedInLines(root, log, world, sight.party, named);
|
|
220
225
|
// The picture of someone the log names, as the player character knows them; of a stranger, as the scene shows them, a copy by its creature (D-420, D-421).
|
|
221
|
-
const picture = (name) => {
|
|
222
|
-
const page = knownNamedPage(world, knowledge, name);
|
|
226
|
+
const picture = (name, known = named) => {
|
|
227
|
+
const page = known(name) === undefined ? undefined : knownNamedPage(world, knowledge, name);
|
|
223
228
|
const who = String(name ?? "").trim();
|
|
224
229
|
return page !== undefined
|
|
225
230
|
? shownImage(root, context, world, page, (base) => knowsPage(knowledge, base))
|
|
226
231
|
: strangerImage(root, context, world, isCopyName(world, who) ? who.replace(/ \d+$/, "") : who);
|
|
227
232
|
};
|
|
228
|
-
const log = readLog(root);
|
|
229
233
|
const seenAt = seenByRoll(log, readOpenScene(root).scene?.seen);
|
|
230
234
|
const shownLines = log.filter((entry) => entry.visibility === "public");
|
|
231
235
|
const moment = lastMoment(shownLines);
|
|
232
|
-
const diary = shownLines.flatMap((entry) => diaryLine(world, entry,
|
|
236
|
+
const diary = shownLines.flatMap((entry) => diaryLine(world, entry, lineNamed(entry)));
|
|
233
237
|
const shown = input.diary?.trim().toLowerCase() === "all" ? diary.length : diaryCount(input.diary);
|
|
234
238
|
const shownRolls = shownLines.filter((entry) => entry.type === "roll");
|
|
235
239
|
const place = shownPlace(sight);
|
|
236
240
|
const openScene = shownScene(sight);
|
|
237
241
|
const settings = readSettings(root);
|
|
238
242
|
const today = now === undefined ? undefined : calendarDayOf(root, context, now.day);
|
|
239
|
-
const
|
|
240
|
-
const titled = withPageTitles(words, world);
|
|
243
|
+
const titled = shownWords(root, context, world, settings.language);
|
|
241
244
|
// The system's pages of the party's sheets, in the campaign's language where the system has no translation (D-539).
|
|
242
245
|
wantTexts(root, context, world, [...players, ...companions]);
|
|
243
246
|
const textsTranslating = translatingTexts(context, world);
|
|
@@ -261,7 +264,7 @@ export const view = defineCommand({
|
|
|
261
264
|
scene: sceneLine(sight, named),
|
|
262
265
|
diary: diary.slice(Math.max(0, diary.length - shown)),
|
|
263
266
|
total: diary.length,
|
|
264
|
-
rolls: shownRolls.slice(-rollCount(input.rolls)).map((entry) => shownRoll(world, entry,
|
|
267
|
+
rolls: shownRolls.slice(-rollCount(input.rolls)).map((entry) => shownRoll(world, entry, lineNamed(entry), (name) => picture(name, lineNamed(entry)), seenAt.get(entry.id))),
|
|
265
268
|
rollsTotal: shownRolls.length,
|
|
266
269
|
problems: campaignProblems(root, world, context).length,
|
|
267
270
|
...(importing === undefined ? {} : { importing }),
|
|
@@ -325,6 +328,26 @@ export const view = defineCommand({
|
|
|
325
328
|
}
|
|
326
329
|
},
|
|
327
330
|
});
|
|
331
|
+
function companionsOf(world) {
|
|
332
|
+
return world.pages.filter((page) => page.type === "character" && page.fields.role === "companion");
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* How each line of the log names people: those of the open scene name one it gives by what the character sees of them as one it does not know, while it keeps
|
|
336
|
+
* them (D-568); the lines before it as the character knows them.
|
|
337
|
+
*/
|
|
338
|
+
function namedInLines(root, log, world, party, named) {
|
|
339
|
+
const scene = readOpenScene(root).scene;
|
|
340
|
+
const opened = scene === undefined ? -1 : log.findLastIndex((entry) => entry.type === "scene-opened");
|
|
341
|
+
const inScene = new Set(opened < 0 ? [] : log.slice(opened + 1).map((entry) => entry.id));
|
|
342
|
+
const hiding = (name) => (typeof name === "string" && seenInScene(world, party, scene, name) ? undefined : named(name));
|
|
343
|
+
return (entry) => (inScene.has(entry.id) ? hiding : named);
|
|
344
|
+
}
|
|
345
|
+
/** The game system's words in the campaign's language, with its pages' titles, for the dashboard (D-403); none when it has neither. */
|
|
346
|
+
function shownWords(root, context, world, language) {
|
|
347
|
+
const system = campaignSystem(root, context);
|
|
348
|
+
const words = system === undefined || language === undefined ? undefined : systemWordsOf(root, system, language, context);
|
|
349
|
+
return withPageTitles(words, world);
|
|
350
|
+
}
|
|
328
351
|
/**
|
|
329
352
|
* The system's words for the page, with the names its translation gives its pages, as Palla di fuoco for Fireball, where its words do not name them (D-542):
|
|
330
353
|
* those translated on this computer too, where the system has no words in the language (D-539).
|
package/dist/core/context.d.ts
CHANGED
|
@@ -158,6 +158,11 @@ export interface PackageManager {
|
|
|
158
158
|
search(): Promise<PackageInfo[] | {
|
|
159
159
|
failed: string;
|
|
160
160
|
}>;
|
|
161
|
+
/**
|
|
162
|
+
* The newest version of a package npm's registry has that this engine reads (D-569), asked within a few seconds; undefined when the registry does not
|
|
163
|
+
* answer in time, or has none. Missing where npm is not asked, as in most tests.
|
|
164
|
+
*/
|
|
165
|
+
newest?(name: string): Promise<string | undefined>;
|
|
161
166
|
}
|
|
162
167
|
/** How this rpg-engine is installed (D-515 (3)): globally by npm, which updates it; as npm link of a folder in development; or any other way, from that folder. */
|
|
163
168
|
export type EngineInstall = {
|
package/dist/dashboard/app.js
CHANGED
|
@@ -189,7 +189,7 @@ function App() {
|
|
|
189
189
|
if (number !== reading.current) {
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
setSystemWords(overview.kind === "overview" ? overview.words : undefined);
|
|
192
|
+
setSystemWords(overview.kind === "overview" || overview.kind === "none" ? overview.words : undefined);
|
|
193
193
|
setSystemVerbs(overview.kind === "overview" ? overview.verbs : undefined);
|
|
194
194
|
setChangedPages(overview.kind === "overview" ? overview.layers : undefined);
|
|
195
195
|
if (number === reading.current) {
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
|
|
|
8
8
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
9
9
|
import { CoinFace, CoinFaces, DiceFaces, tossWords } from "../parts/faces.js";
|
|
10
10
|
import { DieIcon, Icon } from "../parts/icons.js";
|
|
11
|
-
import {
|
|
11
|
+
import { rollModifier, rollText, shownText, signed } from "../parts/labels.js";
|
|
12
12
|
import { trayCheck, useRequested } from "../play/requested.js";
|
|
13
13
|
import { Token } from "../sheet/party.js";
|
|
14
14
|
import { soundPref, useChoice, usePref } from "../shell/prefs.js";
|
|
@@ -193,20 +193,22 @@ export function DiceTray({ requested, sheetThrow, party, campaign, onLanded, onS
|
|
|
193
193
|
useEffect(() => {
|
|
194
194
|
if (requested !== undefined) {
|
|
195
195
|
const toss = requested.toss;
|
|
196
|
-
|
|
196
|
+
// The master's notation may name a field, as 1d20+stealth: in the system's words.
|
|
197
|
+
const written = rollText(requested.notation);
|
|
198
|
+
const title = requested.check ?? (toss === undefined ? written : t("Coins"));
|
|
197
199
|
// A check's is the player's character's when it names no one; the master's own is no one's.
|
|
198
200
|
const member = party.find((candidate) => candidate.name === requested.who) ?? (requested.by === "player" && toss === undefined ? party.find((candidate) => candidate.role === "pc") : undefined);
|
|
199
201
|
void throwAndShow({
|
|
200
202
|
free: false,
|
|
201
203
|
title,
|
|
202
|
-
...(title ===
|
|
204
|
+
...(title === written || toss !== undefined ? {} : { notation: written }),
|
|
203
205
|
dice: requested.dice,
|
|
204
|
-
modifier:
|
|
206
|
+
modifier: rollModifier(requested),
|
|
205
207
|
total: requested.total,
|
|
206
208
|
...(requested.says === undefined ? {} : { says: requested.says }),
|
|
207
209
|
...(requested.tones === undefined ? {} : { tones: requested.tones }),
|
|
208
210
|
...(toss === undefined ? {} : { toss, says: capitalized(tossWords(toss)) }),
|
|
209
|
-
text: toss === undefined ? requested.text : tossWords(toss),
|
|
211
|
+
text: toss === undefined ? rollText(requested.text) : tossWords(toss),
|
|
210
212
|
...(member === undefined ? {} : { member }),
|
|
211
213
|
roll: requested.id,
|
|
212
214
|
}, lingers.asked, mastersDice(requested, party, campaign));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { isolated, numberText, pageLocale, systemWord, t, timeText } from "../text.js";
|
|
1
|
+
import { isolated, numberText, pageLocale, systemWord, systemWordAnyCase, t, timeText } from "../text.js";
|
|
3
2
|
// The dice the page has a picture of: the d% as 100, the coin as 2.
|
|
4
3
|
const drawnDice = [2, 4, 6, 8, 10, 12, 20, 100];
|
|
5
4
|
/** A field's name as a label: its words apart, in capitals the short names, as ac, hp, or str which the system names Strength; age stays a word. */
|
|
@@ -51,10 +50,17 @@ export function drawnDiceOf(notation) {
|
|
|
51
50
|
const oneOfTwo = count === 2 && /\d*d(?:\d+|%|F)(?:k[hl]1|d[hl]1)(?![\d])/i.test(notation);
|
|
52
51
|
return count <= 2 ? { sides: Array.from({ length: count }, () => sides), ...(oneOfTwo ? { faded: true } : {}) } : { sides: [sides], count };
|
|
53
52
|
}
|
|
54
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* An item of a list as the page shows it: in the system's words, a name and its number too, as Cleric 3 (playtest 19); a short name in capitals, as WIS; any other
|
|
55
|
+
* with its first letter a capital, as Light hammer.
|
|
56
|
+
*/
|
|
55
57
|
export function itemLabel(item, fields = new Set()) {
|
|
56
58
|
const word = item.trim();
|
|
57
|
-
|
|
59
|
+
const counted = /^(.*\D)\s+(\d+)$/.exec(word);
|
|
60
|
+
const countedWord = counted === null ? undefined : systemWord("words", counted[1]);
|
|
61
|
+
// A sheet's value as the master wrote it, «Dice set», finds the system's word in any case, «dice set».
|
|
62
|
+
return systemWord("words", word) ?? systemWord("fields", word) ?? systemWordAnyCase("words", word) ?? (counted === null || countedWord === undefined ? undefined : `${countedWord} ${counted[2]}`)
|
|
63
|
+
?? (isShortName(word.toLowerCase(), fields) ? word.toUpperCase() : phraseLabel(word));
|
|
58
64
|
}
|
|
59
65
|
/** A label of a sheet's line as a phrase, its first letter a capital: "sleight of hand" reads "Sleight of hand"; "STR save" stays as it is. */
|
|
60
66
|
export function phraseLabel(label) {
|
|
@@ -88,6 +94,22 @@ export function notationModifier(notation) {
|
|
|
88
94
|
const match = /([+-]\d+)$/.exec(notation.replace(/\s+/g, ""));
|
|
89
95
|
return match === null ? 0 : Number(match[1]);
|
|
90
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The number a roll adds to its dice: its notation's, as the 5 of 2d20kh1+5; with a field's name in it, as the master's 1d20+stealth, what its total adds to the
|
|
99
|
+
* dice kept, as the notation tells no number (playtest 19). A pool that counts successes adds none of its own.
|
|
100
|
+
*/
|
|
101
|
+
export function rollModifier(roll) {
|
|
102
|
+
const terms = roll.notation.replace(/\s+/g, "").split(/[+-]/);
|
|
103
|
+
const named = terms.some((term) => /^[a-z]/i.test(term) && !/^d(?:\d|%|F)/i.test(term));
|
|
104
|
+
if (!named || roll.dice.length === 0 || roll.dice.some((die) => die.success !== undefined)) {
|
|
105
|
+
return notationModifier(roll.notation);
|
|
106
|
+
}
|
|
107
|
+
return roll.total - roll.dice.reduce((sum, die) => (die.dropped === true ? sum : sum + die.value), 0);
|
|
108
|
+
}
|
|
109
|
+
/** A roll's notation or text with the fields it adds in the system's words: 1d20+stealth = 22 [15] + 7 (stealth +7) reads Furtività for stealth in Italian. */
|
|
110
|
+
export function rollText(text) {
|
|
111
|
+
return text.replace(/(?<![\w%-])[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\w-])/g, (name) => systemWord("fields", name) ?? name);
|
|
112
|
+
}
|
|
91
113
|
/**
|
|
92
114
|
* A number as it reads in the page's language: −1 with a minus sign rather than a hyphen, 4,2 m with the Italian comma; a field whose kind is duration, as 3m
|
|
93
115
|
* of the engine, in words: 3 minuti.
|
|
@@ -58,7 +58,7 @@ export function Track({ value, label }) {
|
|
|
58
58
|
}
|
|
59
59
|
/** A list as chips, or as lines when it is of sentences; what the character's parts add to it apart, with where it comes from (PRO-7). */
|
|
60
60
|
export function Chips({ value, fields }) {
|
|
61
|
-
return (_jsxs("span", { class: "chips-block", children: [_jsx(Items, { items: value.items ?? [], field: value.field, fields: fields }), value.always && (_jsxs("span", { class: "always", children: [_jsx("span", { class: "always-from", children: t("Always, from {sources}", { sources: value.always.from.join(` ${t("and")} `) }) }), _jsx(Items, { items: value.always.items, field: value.field, fields: fields })] }))] }));
|
|
61
|
+
return (_jsxs("span", { class: "chips-block", children: [_jsx(Items, { items: value.items ?? [], field: value.field, fields: fields }), value.always && (_jsxs("span", { class: "always", children: [_jsx("span", { class: "always-from", children: t("Always, from {sources}", { sources: value.always.from.map((source) => itemLabel(source)).join(` ${t("and")} `) }) }), _jsx(Items, { items: value.always.items, field: value.field, fields: fields })] }))] }));
|
|
62
62
|
}
|
|
63
63
|
/** A list's items, each a button that acts when the system names verbs for its field (D-495). */
|
|
64
64
|
function Items({ items, field, fields }) {
|
|
@@ -9,7 +9,7 @@ import { CardHeader, useOpen } from "../parts/card.js";
|
|
|
9
9
|
import { CoinFaces, DiceFaces, tossWords } from "../parts/faces.js";
|
|
10
10
|
import { gameDateLabel, notationLabel } from "../parts/game-words.js";
|
|
11
11
|
import { cardIcons, Icon } from "../parts/icons.js";
|
|
12
|
-
import {
|
|
12
|
+
import { rollModifier, rollText, strangerLabel } from "../parts/labels.js";
|
|
13
13
|
import { rollWindow } from "../parts/layout.js";
|
|
14
14
|
import { Token } from "../sheet/party.js";
|
|
15
15
|
import { capitalized, pageLocale, t } from "../text.js";
|
|
@@ -79,7 +79,7 @@ function RollRow({ roll, name, token, coins, fresh, greeted, several }) {
|
|
|
79
79
|
const free = "free" in roll;
|
|
80
80
|
// The whole roll, which the lines may cut: whom and what, the dice as the chat writes them, the notation in words, and when (D-299); a toss's coins in words.
|
|
81
81
|
const toss = roll.toss === undefined ? undefined : tossWords(roll.toss);
|
|
82
|
-
const said = [roll.check === undefined ? name : `${name} · ${roll.check}`, toss ?? roll.text, toss === undefined ? notationLabel(roll.words) : undefined, rolledWhen(roll), free ? t("Free roll · not logged") : undefined]
|
|
82
|
+
const said = [roll.check === undefined ? name : `${name} · ${roll.check}`, toss ?? rollText(roll.text), toss === undefined ? notationLabel(roll.words) : undefined, rolledWhen(roll), free ? t("Free roll · not logged") : undefined]
|
|
83
83
|
.filter((line) => line !== undefined && line !== "")
|
|
84
84
|
.join("\n");
|
|
85
85
|
return (_jsxs("li", { class: ["roll", player ? "by-player" : "by-master", free ? "free" : "", entering ? "entering" : ""].filter((part) => part !== "").join(" "), "data-roll": roll.id, title: said, children: [marked && _jsx("span", { class: "roll-flag", "aria-hidden": "true", children: "!" }), token === undefined
|
|
@@ -91,7 +91,7 @@ function RollRow({ roll, name, token, coins, fresh, greeted, several }) {
|
|
|
91
91
|
: roll.says === undefined
|
|
92
92
|
? _jsx("span", { class: "roll-total num", children: roll.total })
|
|
93
93
|
: _jsx("span", { class: "roll-total roll-says", children: roll.says }), _jsx("span", { class: "roll-dice", children: toss === undefined
|
|
94
|
-
? (_jsxs(_Fragment, { children: [_jsx(DiceFaces, { dice: roll.dice, modifier:
|
|
94
|
+
? (_jsxs(_Fragment, { children: [_jsx(DiceFaces, { dice: roll.dice, modifier: rollModifier(roll), tones: roll.tones }), _jsx("span", { class: "visually-hidden", children: rollText(roll.text) })] }))
|
|
95
95
|
: _jsx("span", { class: "roll-toss", children: capitalized(toss) }) })] }));
|
|
96
96
|
}
|
|
97
97
|
/** What a roll's faces mean in place of its total: the coins of a toss in the page's language, or what an extension's roll says. */
|
|
@@ -29,36 +29,44 @@ export function SetupView({ setup }) {
|
|
|
29
29
|
// The choices left to the master, as the game keeps them until the master makes them, and those just left here.
|
|
30
30
|
const [leftHere, setLeftHere] = useState(new Set());
|
|
31
31
|
const left = new Set([...(setup.left ?? []), ...leftHere].filter((name) => questions.some((question) => question.name === name && !answered(question))));
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
// Until the player uses the page, the card follows the chat: the first question still open, as the master fills them from what the player says there
|
|
33
|
+
// (playtest 01); with none, the last card. Once the player chooses or moves here, the card is theirs.
|
|
34
|
+
const [own, setOwn] = useState(false);
|
|
35
|
+
const [at, setAt] = useState(0);
|
|
36
|
+
const current = own ? at : firstOpen(questions, setup.left ?? []);
|
|
37
37
|
// Whether the player moved among the cards: then the new card's title takes the focus, never at the first reading.
|
|
38
38
|
const [moved, setMoved] = useState(false);
|
|
39
39
|
const [said, setSaid] = useState();
|
|
40
|
-
const done =
|
|
41
|
-
const question = questions[Math.min(
|
|
40
|
+
const done = current >= questions.length;
|
|
41
|
+
const question = questions[Math.min(current, questions.length - 1)];
|
|
42
42
|
const step = steps.indexOf(setup.mode);
|
|
43
43
|
const go = (index) => {
|
|
44
|
+
setOwn(true);
|
|
44
45
|
setMoved(true);
|
|
45
46
|
setAt(index);
|
|
46
47
|
};
|
|
48
|
+
// A choice made here keeps the card where it is, as the player made it.
|
|
49
|
+
const touch = () => {
|
|
50
|
+
if (!own) {
|
|
51
|
+
setOwn(true);
|
|
52
|
+
setAt(current);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
47
55
|
const leave = async (name) => {
|
|
48
56
|
const refused = await sendSetupWord({ leave: name });
|
|
49
57
|
setSaid(refused);
|
|
50
58
|
if (refused === undefined) {
|
|
51
59
|
setLeftHere((before) => new Set([...before, name]));
|
|
52
|
-
go(
|
|
60
|
+
go(current + 1);
|
|
53
61
|
}
|
|
54
62
|
};
|
|
55
|
-
return (_jsxs("section", { class: "setup", "aria-labelledby": "setup-title", children: [_jsx("div", { class: "setup-host", children: _jsx(Master, { mood: "happy" }) }), _jsx(CampaignName, { name: setup.name }), _jsx("h1", { id: "setup-title", class: "visually-hidden", children: t("Setting up {campaign}", { campaign: setup.name }) }), _jsx("ol", { class: "setup-steps", "aria-label": t("Steps"), children: steps.map((one, index) => (_jsxs("li", { class: index < step ? "done" : index === step ? "now" : undefined, "aria-current": index === step ? "step" : undefined, children: [_jsx("span", { class: "setup-step-dot", "aria-hidden": "true", children: index < step ? "✓" : index + 1 }), stepName(one)] }, one))) }), said !== undefined && _jsx("p", { class: "setup-problem", role: "alert", children: said }), !done && question !== undefined && (_jsx(Question, { question: question, count: t("{value} of {max}", { value:
|
|
63
|
+
return (_jsxs("section", { class: "setup", "aria-labelledby": "setup-title", children: [_jsx("div", { class: "setup-host", children: _jsx(Master, { mood: "happy" }) }), _jsx(CampaignName, { name: setup.name }), _jsx("h1", { id: "setup-title", class: "visually-hidden", children: t("Setting up {campaign}", { campaign: setup.name }) }), _jsx("ol", { class: "setup-steps", "aria-label": t("Steps"), children: steps.map((one, index) => (_jsxs("li", { class: index < step ? "done" : index === step ? "now" : undefined, "aria-current": index === step ? "step" : undefined, children: [_jsx("span", { class: "setup-step-dot", "aria-hidden": "true", children: index < step ? "✓" : index + 1 }), stepName(one)] }, one))) }), said !== undefined && _jsx("p", { class: "setup-problem", role: "alert", children: said }), !done && question !== undefined && (_jsx(Question, { question: question, count: t("{value} of {max}", { value: current + 1, max: questions.length }), left: left.has(question.name), focus: moved, onBack: current > 0 ? () => go(current - 1) : undefined, onNext: () => go(current + 1), onLeave: () => void leave(question.name), onTouch: touch, onProblem: setSaid }, question.name)), done && _jsx(Ready, { setup: setup, left: left, focus: moved, onGo: go, onProblem: setSaid }), _jsx("ol", { class: "setup-dots", "aria-label": t("Questions"), style: { "--count": String(questions.length) }, children: questions.map((one, index) => (_jsx("li", { children: _jsx("button", { type: "button", class: [answered(one) ? "answered" : left.has(one.name) ? "left" : "", index === current ? "here" : ""].filter((name) => name !== "").join(" "), "aria-label": answered(one) ? t("{setting}: answered", { setting: settingLabel(one.name) }) : left.has(one.name) ? t("{setting}: left to the master", { setting: settingLabel(one.name) }) : settingLabel(one.name), "aria-current": index === current ? "step" : undefined, onClick: () => go(index) }) }, one.name))) }), _jsx("p", { class: "setup-chat", children: t("You can also tell the master in the chat: they hear what you choose here.") })] }));
|
|
56
64
|
}
|
|
57
65
|
/**
|
|
58
66
|
* One question as its card shows it: what it is, its choices large with what each means and the one the game suggests, or a list's items; back, next, or left
|
|
59
67
|
* to the master. Its title takes the focus when the player moved to it.
|
|
60
68
|
*/
|
|
61
|
-
function Question({ question, count, left, focus, onBack, onNext, onLeave, onProblem }) {
|
|
69
|
+
function Question({ question, count, left, focus, onBack, onNext, onLeave, onTouch, onProblem }) {
|
|
62
70
|
const [picked, setPicked] = useState();
|
|
63
71
|
const resting = useRef(undefined);
|
|
64
72
|
const heading = useRef(null);
|
|
@@ -81,6 +89,7 @@ function Question({ question, count, left, focus, onBack, onNext, onLeave, onPro
|
|
|
81
89
|
}, []);
|
|
82
90
|
// A click chooses at once; the arrows show each choice and send the one they rest on.
|
|
83
91
|
const pick = (choice, byKey) => {
|
|
92
|
+
onTouch();
|
|
84
93
|
setPicked(choice);
|
|
85
94
|
clearTimeout(resting.current?.timer);
|
|
86
95
|
resting.current = undefined;
|
|
@@ -94,7 +103,7 @@ function Question({ question, count, left, focus, onBack, onNext, onLeave, onPro
|
|
|
94
103
|
}, keyRest);
|
|
95
104
|
resting.current = { choice, timer };
|
|
96
105
|
};
|
|
97
|
-
return (_jsxs("article", { class: "setup-card", "aria-labelledby": id, children: [_jsx("p", { class: "eyebrow setup-count", children: count }), _jsx("h2", { id: id, ref: heading, tabIndex: -1, children: title }), _jsx("p", { class: "setup-about", children: phraseLabel(t(question.about)) }), question.choices !== undefined && _jsx(Choices, { question: question, value: value, labelledBy: id, onPick: pick }), isList && _jsx(ListQuestion, { question: question, onProblem: onProblem }), left && value === undefined && _jsx("p", { class: "setup-left", children: t("Left to the master: they choose, and tell you.") }), _jsxs("div", { class: "setup-moves", children: [onBack !== undefined && _jsx("button", { type: "button", class: "button setup-back", onClick: onBack, children: t("Back") }), open && !isList && _jsx("button", { type: "button", class: "button quiet", onClick: onLeave, children: t("You decide") }), _jsxs("button", { type: "button", class: open ? "button quiet" : "button gold", onClick: onNext, children: [open ? t("Skip") : t("Next"), " ", _jsx(Icon, { name: "send" })] })] })] }));
|
|
106
|
+
return (_jsxs("article", { class: "setup-card", "aria-labelledby": id, onFocusIn: onTouch, children: [_jsx("p", { class: "eyebrow setup-count", children: count }), _jsx("h2", { id: id, ref: heading, tabIndex: -1, children: title }), _jsx("p", { class: "setup-about", children: phraseLabel(t(question.about)) }), question.choices !== undefined && _jsx(Choices, { question: question, value: value, labelledBy: id, onPick: pick }), isList && _jsx(ListQuestion, { question: question, onTouch: onTouch, onProblem: onProblem }), left && value === undefined && _jsx("p", { class: "setup-left", children: t("Left to the master: they choose, and tell you.") }), _jsxs("div", { class: "setup-moves", children: [onBack !== undefined && _jsx("button", { type: "button", class: "button setup-back", onClick: onBack, children: t("Back") }), open && !isList && _jsx("button", { type: "button", class: "button quiet", onClick: onLeave, children: t("You decide") }), _jsxs("button", { type: "button", class: open ? "button quiet" : "button gold", onClick: onNext, children: [open ? t("Skip") : t("Next"), " ", _jsx(Icon, { name: "send" })] })] })] }));
|
|
98
107
|
}
|
|
99
108
|
/** A question's choices as a radio group: one stop of Tab, the arrows move among them and choose; each with what it means, the suggested one marked. */
|
|
100
109
|
function Choices({ question, value, labelledBy, onPick }) {
|
|
@@ -116,10 +125,13 @@ function Choices({ question, value, labelledBy, onPick }) {
|
|
|
116
125
|
return (_jsx("div", { class: "setup-choices", role: "radiogroup", "aria-labelledby": labelledBy, onKeyDown: move, children: choices.map((choice, index) => (_jsxs("button", { type: "button", role: "radio", "aria-checked": value === choice.value, tabIndex: index === stop ? 0 : -1, class: "setup-choice", onClick: () => onPick(choice.value, false), children: [_jsxs("strong", { children: [choice.label === undefined ? valueLabel(choice.value) : phraseLabel(t(choice.label)), choice.value === question.suggested && _jsx("span", { class: "setup-suggested", children: choice.value === question.last ? t("Like last time") : t("Suggested") })] }), choice.means !== undefined && _jsx("span", { children: phraseLabel(t(choice.means)) })] }, choice.value))) }));
|
|
117
126
|
}
|
|
118
127
|
/** A list of the setup, lines or veils: its items to take off, a field to add one, and None for a player who wants none. */
|
|
119
|
-
function ListQuestion({ question, onProblem }) {
|
|
128
|
+
function ListQuestion({ question, onTouch, onProblem }) {
|
|
120
129
|
const [item, setItem] = useState("");
|
|
121
130
|
const field = useRef(null);
|
|
122
|
-
const send = (change) =>
|
|
131
|
+
const send = (change) => {
|
|
132
|
+
onTouch();
|
|
133
|
+
void changeSetting(change).then(onProblem);
|
|
134
|
+
};
|
|
123
135
|
return (_jsxs("div", { class: "setup-list", children: [(question.items ?? []).length > 0 && (_jsx("ul", { children: (question.items ?? []).map((one) => (_jsxs("li", { children: [one, _jsx("button", { type: "button", class: "icon-button", "aria-label": t("Take {item} off", { item: one }), onClick: () => {
|
|
124
136
|
send({ setting: question.name, remove: one });
|
|
125
137
|
field.current?.focus();
|
|
@@ -185,6 +197,11 @@ function CampaignName({ name }) {
|
|
|
185
197
|
}
|
|
186
198
|
} }), _jsx("button", { type: "submit", class: "button gold", children: t("Save") })] }));
|
|
187
199
|
}
|
|
200
|
+
/** Where the questions stand: the first still open, neither answered nor left to the master; with none, past the last. */
|
|
201
|
+
function firstOpen(questions, left) {
|
|
202
|
+
const first = questions.findIndex((question) => !answered(question) && !left.includes(question.name));
|
|
203
|
+
return first < 0 ? questions.length : first;
|
|
204
|
+
}
|
|
188
205
|
/** Whether a question is answered: a value chosen, or a list given, even with none. */
|
|
189
206
|
function answered(question) {
|
|
190
207
|
return question.value !== undefined || question.items !== undefined;
|
|
@@ -73,7 +73,7 @@ function TabMark({ path }) {
|
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* The table's measures, taken only when it or the window changes size, never as the page scrolls. The rolls' list grows with its rolls up to twelve, as tall as
|
|
76
|
-
*
|
|
76
|
+
* the first one that has opened draws, then scrolls inside. The table stays at the top while it fits the window; taller, its top goes up so that it scrolls with the page until
|
|
77
77
|
* its foot reaches the window's and stays there, the end of the rolls always in reach.
|
|
78
78
|
*/
|
|
79
79
|
function useTableFit(track) {
|
|
@@ -88,8 +88,10 @@ function useTableFit(track) {
|
|
|
88
88
|
if (stick === null) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
+
// A new roll opens its place from nothing: measured then, a pixel high, it would leave the list room for one (playtest 19). The first row that has
|
|
92
|
+
// opened gives the measure; while none has, the list keeps the room it had.
|
|
91
93
|
const rows = stick.querySelector(".roll-list");
|
|
92
|
-
const first = rows?.
|
|
94
|
+
const first = [...(rows?.children ?? [])].find((row) => row.getAnimations().every((animation) => animation.playState !== "running"));
|
|
93
95
|
if (rows !== null && first instanceof HTMLElement) {
|
|
94
96
|
const gap = Number.parseFloat(getComputedStyle(rows).rowGap) || 0;
|
|
95
97
|
track.style.setProperty("--list-room", `${Math.ceil(mostRolls * first.offsetHeight + (mostRolls - 1) * gap)}px`);
|
|
@@ -114,14 +116,16 @@ function useTableFit(track) {
|
|
|
114
116
|
sizes.observe(stick);
|
|
115
117
|
}
|
|
116
118
|
window.addEventListener("resize", update);
|
|
117
|
-
// The table's top changes as the page's top or what the master asks come and go.
|
|
119
|
+
// The table's top changes as the page's top or what the master asks come and go; a roll has its height once it has opened.
|
|
118
120
|
track.addEventListener("transitionend", update);
|
|
121
|
+
track.addEventListener("animationend", update);
|
|
119
122
|
update();
|
|
120
123
|
return () => {
|
|
121
124
|
cancelAnimationFrame(asked);
|
|
122
125
|
sizes.disconnect();
|
|
123
126
|
window.removeEventListener("resize", update);
|
|
124
127
|
track.removeEventListener("transitionend", update);
|
|
128
|
+
track.removeEventListener("animationend", update);
|
|
125
129
|
track.style.removeProperty("--list-room");
|
|
126
130
|
track.style.removeProperty("--table-top");
|
|
127
131
|
};
|