@gameslate/sdk 0.3.12 → 0.3.13
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/lib/catalogue.d.ts +40 -10
- package/lib/catalogue.js +33 -16
- package/lib/chips.d.ts +2 -2
- package/lib/chips.js +12 -4
- package/lib/pack.d.ts +21 -7
- package/lib/sandbox-protocol.d.ts +27 -9
- package/lib/status.d.ts +9 -1
- package/lib/status.js +26 -0
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +46 -0
package/lib/catalogue.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare const ItemSchema: z.ZodObject<{
|
|
|
10
10
|
short: z.ZodOptional<z.ZodString>;
|
|
11
11
|
/** where/how it's obtained, spoiler-light */
|
|
12
12
|
source: z.ZodOptional<z.ZodString>;
|
|
13
|
+
/** a counter holding how many the player holds (potions in a pouch): its slot shows ×N */
|
|
14
|
+
count: z.ZodOptional<z.ZodString>;
|
|
13
15
|
}, "strict", z.ZodTypeAny, {
|
|
14
16
|
label: string;
|
|
15
17
|
id: string;
|
|
@@ -17,6 +19,7 @@ export declare const ItemSchema: z.ZodObject<{
|
|
|
17
19
|
source?: string | undefined;
|
|
18
20
|
category?: string | undefined;
|
|
19
21
|
short?: string | undefined;
|
|
22
|
+
count?: string | undefined;
|
|
20
23
|
}, {
|
|
21
24
|
label: string;
|
|
22
25
|
id: string;
|
|
@@ -24,6 +27,7 @@ export declare const ItemSchema: z.ZodObject<{
|
|
|
24
27
|
source?: string | undefined;
|
|
25
28
|
category?: string | undefined;
|
|
26
29
|
short?: string | undefined;
|
|
30
|
+
count?: string | undefined;
|
|
27
31
|
}>;
|
|
28
32
|
export type CatalogueItem = z.infer<typeof ItemSchema>;
|
|
29
33
|
export declare const CounterSchema: z.ZodObject<{
|
|
@@ -36,14 +40,16 @@ export declare const CounterSchema: z.ZodObject<{
|
|
|
36
40
|
display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
41
|
/** what core features know it as: the AI's health and magic, the "no small key" chip */
|
|
38
42
|
role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
|
|
39
|
-
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage
|
|
40
|
-
|
|
43
|
+
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage. `duration`: whole
|
|
44
|
+
* milliseconds, shown as 1'23"456 (also in chips); any other value reads as unknown, and
|
|
45
|
+
* `display` doesn't apply */
|
|
46
|
+
format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
|
|
41
47
|
}, "strict", z.ZodTypeAny, {
|
|
42
48
|
label: string;
|
|
43
49
|
id: string;
|
|
44
50
|
icon?: string | undefined;
|
|
45
51
|
max?: string | number | undefined;
|
|
46
|
-
format?: "number" | "percent" | undefined;
|
|
52
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
47
53
|
display?: Record<string, string> | undefined;
|
|
48
54
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
49
55
|
}, {
|
|
@@ -51,7 +57,7 @@ export declare const CounterSchema: z.ZodObject<{
|
|
|
51
57
|
id: string;
|
|
52
58
|
icon?: string | undefined;
|
|
53
59
|
max?: string | number | undefined;
|
|
54
|
-
format?: "number" | "percent" | undefined;
|
|
60
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
55
61
|
display?: Record<string, string> | undefined;
|
|
56
62
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
57
63
|
}>;
|
|
@@ -96,16 +102,23 @@ export declare const LayoutSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<
|
|
|
96
102
|
id: z.ZodString;
|
|
97
103
|
title: z.ZodString;
|
|
98
104
|
counters: z.ZodArray<z.ZodString, "many">;
|
|
105
|
+
/** leave out a counter the state doesn't have rather than show it as unknown (per-player
|
|
106
|
+
* counters a one-player game has no value for); a layout left empty is left out. A
|
|
107
|
+
* counter the decoder failed to read is hidden too, so use it only where absence means
|
|
108
|
+
* "doesn't apply" */
|
|
109
|
+
hideMissing: z.ZodOptional<z.ZodBoolean>;
|
|
99
110
|
}, "strict", z.ZodTypeAny, {
|
|
100
111
|
id: string;
|
|
101
112
|
title: string;
|
|
102
113
|
counters: string[];
|
|
103
114
|
kind: "counters";
|
|
115
|
+
hideMissing?: boolean | undefined;
|
|
104
116
|
}, {
|
|
105
117
|
id: string;
|
|
106
118
|
title: string;
|
|
107
119
|
counters: string[];
|
|
108
120
|
kind: "counters";
|
|
121
|
+
hideMissing?: boolean | undefined;
|
|
109
122
|
}>]>;
|
|
110
123
|
export type CatalogueLayout = z.infer<typeof LayoutSchema>;
|
|
111
124
|
export declare const MissionStepSchema: z.ZodObject<{
|
|
@@ -581,6 +594,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
581
594
|
short: z.ZodOptional<z.ZodString>;
|
|
582
595
|
/** where/how it's obtained, spoiler-light */
|
|
583
596
|
source: z.ZodOptional<z.ZodString>;
|
|
597
|
+
/** a counter holding how many the player holds (potions in a pouch): its slot shows ×N */
|
|
598
|
+
count: z.ZodOptional<z.ZodString>;
|
|
584
599
|
}, "strict", z.ZodTypeAny, {
|
|
585
600
|
label: string;
|
|
586
601
|
id: string;
|
|
@@ -588,6 +603,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
588
603
|
source?: string | undefined;
|
|
589
604
|
category?: string | undefined;
|
|
590
605
|
short?: string | undefined;
|
|
606
|
+
count?: string | undefined;
|
|
591
607
|
}, {
|
|
592
608
|
label: string;
|
|
593
609
|
id: string;
|
|
@@ -595,6 +611,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
595
611
|
source?: string | undefined;
|
|
596
612
|
category?: string | undefined;
|
|
597
613
|
short?: string | undefined;
|
|
614
|
+
count?: string | undefined;
|
|
598
615
|
}>, "many">;
|
|
599
616
|
counters: z.ZodArray<z.ZodObject<{
|
|
600
617
|
id: z.ZodString;
|
|
@@ -606,14 +623,16 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
606
623
|
display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
607
624
|
/** what core features know it as: the AI's health and magic, the "no small key" chip */
|
|
608
625
|
role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
|
|
609
|
-
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage
|
|
610
|
-
|
|
626
|
+
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage. `duration`: whole
|
|
627
|
+
* milliseconds, shown as 1'23"456 (also in chips); any other value reads as unknown, and
|
|
628
|
+
* `display` doesn't apply */
|
|
629
|
+
format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
|
|
611
630
|
}, "strict", z.ZodTypeAny, {
|
|
612
631
|
label: string;
|
|
613
632
|
id: string;
|
|
614
633
|
icon?: string | undefined;
|
|
615
634
|
max?: string | number | undefined;
|
|
616
|
-
format?: "number" | "percent" | undefined;
|
|
635
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
617
636
|
display?: Record<string, string> | undefined;
|
|
618
637
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
619
638
|
}, {
|
|
@@ -621,7 +640,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
621
640
|
id: string;
|
|
622
641
|
icon?: string | undefined;
|
|
623
642
|
max?: string | number | undefined;
|
|
624
|
-
format?: "number" | "percent" | undefined;
|
|
643
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
625
644
|
display?: Record<string, string> | undefined;
|
|
626
645
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
627
646
|
}>, "many">;
|
|
@@ -651,16 +670,23 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
651
670
|
id: z.ZodString;
|
|
652
671
|
title: z.ZodString;
|
|
653
672
|
counters: z.ZodArray<z.ZodString, "many">;
|
|
673
|
+
/** leave out a counter the state doesn't have rather than show it as unknown (per-player
|
|
674
|
+
* counters a one-player game has no value for); a layout left empty is left out. A
|
|
675
|
+
* counter the decoder failed to read is hidden too, so use it only where absence means
|
|
676
|
+
* "doesn't apply" */
|
|
677
|
+
hideMissing: z.ZodOptional<z.ZodBoolean>;
|
|
654
678
|
}, "strict", z.ZodTypeAny, {
|
|
655
679
|
id: string;
|
|
656
680
|
title: string;
|
|
657
681
|
counters: string[];
|
|
658
682
|
kind: "counters";
|
|
683
|
+
hideMissing?: boolean | undefined;
|
|
659
684
|
}, {
|
|
660
685
|
id: string;
|
|
661
686
|
title: string;
|
|
662
687
|
counters: string[];
|
|
663
688
|
kind: "counters";
|
|
689
|
+
hideMissing?: boolean | undefined;
|
|
664
690
|
}>]>, "many">;
|
|
665
691
|
missions: z.ZodArray<z.ZodObject<{
|
|
666
692
|
id: z.ZodString;
|
|
@@ -1048,7 +1074,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1048
1074
|
id: string;
|
|
1049
1075
|
icon?: string | undefined;
|
|
1050
1076
|
max?: string | number | undefined;
|
|
1051
|
-
format?: "number" | "percent" | undefined;
|
|
1077
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1052
1078
|
display?: Record<string, string> | undefined;
|
|
1053
1079
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1054
1080
|
}[];
|
|
@@ -1060,6 +1086,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1060
1086
|
source?: string | undefined;
|
|
1061
1087
|
category?: string | undefined;
|
|
1062
1088
|
short?: string | undefined;
|
|
1089
|
+
count?: string | undefined;
|
|
1063
1090
|
}[];
|
|
1064
1091
|
chips: {
|
|
1065
1092
|
label: string;
|
|
@@ -1078,6 +1105,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1078
1105
|
title: string;
|
|
1079
1106
|
counters: string[];
|
|
1080
1107
|
kind: "counters";
|
|
1108
|
+
hideMissing?: boolean | undefined;
|
|
1081
1109
|
})[];
|
|
1082
1110
|
missions: {
|
|
1083
1111
|
id: string;
|
|
@@ -1167,7 +1195,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1167
1195
|
id: string;
|
|
1168
1196
|
icon?: string | undefined;
|
|
1169
1197
|
max?: string | number | undefined;
|
|
1170
|
-
format?: "number" | "percent" | undefined;
|
|
1198
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1171
1199
|
display?: Record<string, string> | undefined;
|
|
1172
1200
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1173
1201
|
}[];
|
|
@@ -1179,6 +1207,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1179
1207
|
source?: string | undefined;
|
|
1180
1208
|
category?: string | undefined;
|
|
1181
1209
|
short?: string | undefined;
|
|
1210
|
+
count?: string | undefined;
|
|
1182
1211
|
}[];
|
|
1183
1212
|
chips: {
|
|
1184
1213
|
label: string;
|
|
@@ -1197,6 +1226,7 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1197
1226
|
title: string;
|
|
1198
1227
|
counters: string[];
|
|
1199
1228
|
kind: "counters";
|
|
1229
|
+
hideMissing?: boolean | undefined;
|
|
1200
1230
|
})[];
|
|
1201
1231
|
missions: {
|
|
1202
1232
|
id: string;
|
package/lib/catalogue.js
CHANGED
|
@@ -17,6 +17,8 @@ export const ItemSchema = z
|
|
|
17
17
|
short: z.string().optional(),
|
|
18
18
|
/** where/how it's obtained, spoiler-light */
|
|
19
19
|
source: z.string().optional(),
|
|
20
|
+
/** a counter holding how many the player holds (potions in a pouch): its slot shows ×N */
|
|
21
|
+
count: Id.optional(),
|
|
20
22
|
})
|
|
21
23
|
.strict();
|
|
22
24
|
export const CounterSchema = z
|
|
@@ -30,8 +32,10 @@ export const CounterSchema = z
|
|
|
30
32
|
display: z.record(z.string(), z.string()).optional(),
|
|
31
33
|
/** what core features know it as: the AI's health and magic, the "no small key" chip */
|
|
32
34
|
role: z.enum(['health', 'magic', 'armor', 'keys']).optional(),
|
|
33
|
-
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage
|
|
34
|
-
|
|
35
|
+
/** `percent`: a 0..max bar (max defaults to 1), shown as a percentage. `duration`: whole
|
|
36
|
+
* milliseconds, shown as 1'23"456 (also in chips); any other value reads as unknown, and
|
|
37
|
+
* `display` doesn't apply */
|
|
38
|
+
format: z.enum(['number', 'percent', 'duration']).optional(),
|
|
35
39
|
})
|
|
36
40
|
.strict();
|
|
37
41
|
/** A variant of the game the decoder can report (`state.variant`). */
|
|
@@ -60,6 +64,11 @@ export const LayoutSchema = z.discriminatedUnion('kind', [
|
|
|
60
64
|
id: Id,
|
|
61
65
|
title: z.string(),
|
|
62
66
|
counters: z.array(Id).min(1),
|
|
67
|
+
/** leave out a counter the state doesn't have rather than show it as unknown (per-player
|
|
68
|
+
* counters a one-player game has no value for); a layout left empty is left out. A
|
|
69
|
+
* counter the decoder failed to read is hidden too, so use it only where absence means
|
|
70
|
+
* "doesn't apply" */
|
|
71
|
+
hideMissing: z.boolean().optional(),
|
|
63
72
|
})
|
|
64
73
|
.strict(),
|
|
65
74
|
]);
|
|
@@ -272,19 +281,32 @@ function checkDuplicateIds(cat) {
|
|
|
272
281
|
];
|
|
273
282
|
return groups.flatMap(([what, ids]) => duplicates(ids).map(d => `duplicate ${what} id "${d}"`));
|
|
274
283
|
}
|
|
284
|
+
/* every place a catalogue names a counter by id, with where it says so */
|
|
285
|
+
function counterReferences(cat) {
|
|
286
|
+
const refs = [
|
|
287
|
+
...cat.missions.map((m) => [
|
|
288
|
+
`mission ${m.id}.progress`,
|
|
289
|
+
m.progress?.counter,
|
|
290
|
+
]),
|
|
291
|
+
...cat.collectibles.map((c) => [
|
|
292
|
+
`collectibles ${c.id}.counter`,
|
|
293
|
+
c.counter,
|
|
294
|
+
]),
|
|
295
|
+
...cat.items.map((i) => [`item ${i.id}.count`, i.count]),
|
|
296
|
+
...cat.counters.map((c) => [
|
|
297
|
+
`counter ${c.id}.max`,
|
|
298
|
+
typeof c.max === 'string' ? c.max : undefined,
|
|
299
|
+
]),
|
|
300
|
+
];
|
|
301
|
+
return refs.flatMap(([where, id]) => (id === undefined ? [] : [[where, id]]));
|
|
302
|
+
}
|
|
275
303
|
function checkStructure(cat, known) {
|
|
276
|
-
const problems =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
problems.push(`mission ${m.id}.progress: unknown counter "${m.progress.counter}"`);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
304
|
+
const problems = counterReferences(cat)
|
|
305
|
+
.filter(([, id]) => !known.counters.has(id))
|
|
306
|
+
.map(([where, id]) => `${where}: unknown counter "${id}"`);
|
|
282
307
|
for (const set of cat.collectibles) {
|
|
283
308
|
if (!set.entries && !set.localSource)
|
|
284
309
|
problems.push(`collectibles ${set.id}: needs entries or a localSource`);
|
|
285
|
-
if (set.counter && !known.counters.has(set.counter)) {
|
|
286
|
-
problems.push(`collectibles ${set.id}.counter: unknown counter "${set.counter}"`);
|
|
287
|
-
}
|
|
288
310
|
}
|
|
289
311
|
for (const layout of cat.inventoryLayouts) {
|
|
290
312
|
const [ids, pool, noun] = layout.kind === 'slotGrid'
|
|
@@ -293,11 +315,6 @@ function checkStructure(cat, known) {
|
|
|
293
315
|
for (const id of ids.filter(x => !pool.has(x)))
|
|
294
316
|
problems.push(`layout ${layout.id}: unknown ${noun} "${id}"`);
|
|
295
317
|
}
|
|
296
|
-
for (const c of cat.counters) {
|
|
297
|
-
if (typeof c.max === 'string' && !known.counters.has(c.max)) {
|
|
298
|
-
problems.push(`counter ${c.id}.max: unknown counter "${c.max}"`);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
318
|
return problems;
|
|
302
319
|
}
|
|
303
320
|
/**
|
package/lib/chips.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Catalogue } from './catalogue.js';
|
|
1
|
+
import type { Catalogue, CatalogueCounter } from './catalogue.js';
|
|
2
2
|
import type { EvaluationContext } from './condition.js';
|
|
3
3
|
import type { GameState } from './types.js';
|
|
4
4
|
/** Values a chip's label and prompt may reference: `{location}`, `{difficulty}`, `{counter:id}`. */
|
|
@@ -8,7 +8,7 @@ export interface ChipVars {
|
|
|
8
8
|
}
|
|
9
9
|
/** null when a referenced value isn't available, so the caller drops the chip instead of
|
|
10
10
|
* showing "{difficulty}" or "undefined" to the player. */
|
|
11
|
-
export declare function fillChipText(text: string, vars: ChipVars, state: GameState): string | null;
|
|
11
|
+
export declare function fillChipText(text: string, vars: ChipVars, state: GameState, counters?: readonly CatalogueCounter[]): string | null;
|
|
12
12
|
export interface FilledChip {
|
|
13
13
|
id: string;
|
|
14
14
|
label: string;
|
package/lib/chips.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { evaluate, readCounter } from './condition.js';
|
|
2
|
+
import { getCounterView } from './status.js';
|
|
2
3
|
const PLACEHOLDER_RE = /\{(location|difficulty|counter:[A-Za-z0-9_:.-]+)\}/g;
|
|
4
|
+
/* a duration reads as a time (1'23"456), as its card shows it; other counters as their number */
|
|
5
|
+
function counterText(id, state, counters) {
|
|
6
|
+
const counter = counters.find(c => c.id === id);
|
|
7
|
+
if (counter?.format === 'duration')
|
|
8
|
+
return getCounterView(counter, state)?.text;
|
|
9
|
+
return readCounter(state, id)?.toString();
|
|
10
|
+
}
|
|
3
11
|
/** null when a referenced value isn't available, so the caller drops the chip instead of
|
|
4
12
|
* showing "{difficulty}" or "undefined" to the player. */
|
|
5
|
-
export function fillChipText(text, vars, state) {
|
|
13
|
+
export function fillChipText(text, vars, state, counters = []) {
|
|
6
14
|
let missing = false;
|
|
7
15
|
const out = text.replace(PLACEHOLDER_RE, (_m, key) => {
|
|
8
16
|
const value = key.startsWith('counter:')
|
|
9
|
-
?
|
|
17
|
+
? counterText(key.slice('counter:'.length), state, counters)
|
|
10
18
|
: key === 'location'
|
|
11
19
|
? vars.location
|
|
12
20
|
: vars.difficulty;
|
|
@@ -21,8 +29,8 @@ export function getActiveChips(catalogue, state, vars, ctx = {}) {
|
|
|
21
29
|
return catalogue.chips.flatMap((chip) => {
|
|
22
30
|
if (chip.when && evaluate(chip.when, state, ctx) !== 'met')
|
|
23
31
|
return [];
|
|
24
|
-
const label = fillChipText(chip.label, vars, state);
|
|
25
|
-
const prompt = fillChipText(chip.prompt, vars, state);
|
|
32
|
+
const label = fillChipText(chip.label, vars, state, catalogue.counters);
|
|
33
|
+
const prompt = fillChipText(chip.prompt, vars, state, catalogue.counters);
|
|
26
34
|
return label && prompt ? [{ id: chip.id, label, prompt }] : [];
|
|
27
35
|
});
|
|
28
36
|
}
|
package/lib/pack.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
16
16
|
category: z.ZodOptional<z.ZodString>;
|
|
17
17
|
short: z.ZodOptional<z.ZodString>;
|
|
18
18
|
source: z.ZodOptional<z.ZodString>;
|
|
19
|
+
count: z.ZodOptional<z.ZodString>;
|
|
19
20
|
}, "strict", z.ZodTypeAny, {
|
|
20
21
|
label: string;
|
|
21
22
|
id: string;
|
|
@@ -23,6 +24,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
23
24
|
source?: string | undefined;
|
|
24
25
|
category?: string | undefined;
|
|
25
26
|
short?: string | undefined;
|
|
27
|
+
count?: string | undefined;
|
|
26
28
|
}, {
|
|
27
29
|
label: string;
|
|
28
30
|
id: string;
|
|
@@ -30,6 +32,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
30
32
|
source?: string | undefined;
|
|
31
33
|
category?: string | undefined;
|
|
32
34
|
short?: string | undefined;
|
|
35
|
+
count?: string | undefined;
|
|
33
36
|
}>, "many">;
|
|
34
37
|
counters: z.ZodArray<z.ZodObject<{
|
|
35
38
|
id: z.ZodString;
|
|
@@ -38,13 +41,13 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
38
41
|
max: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
39
42
|
display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
40
43
|
role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
|
|
41
|
-
format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
|
|
44
|
+
format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
|
|
42
45
|
}, "strict", z.ZodTypeAny, {
|
|
43
46
|
label: string;
|
|
44
47
|
id: string;
|
|
45
48
|
icon?: string | undefined;
|
|
46
49
|
max?: string | number | undefined;
|
|
47
|
-
format?: "number" | "percent" | undefined;
|
|
50
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
48
51
|
display?: Record<string, string> | undefined;
|
|
49
52
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
50
53
|
}, {
|
|
@@ -52,7 +55,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
52
55
|
id: string;
|
|
53
56
|
icon?: string | undefined;
|
|
54
57
|
max?: string | number | undefined;
|
|
55
|
-
format?: "number" | "percent" | undefined;
|
|
58
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
56
59
|
display?: Record<string, string> | undefined;
|
|
57
60
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
58
61
|
}>, "many">;
|
|
@@ -80,16 +83,19 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
80
83
|
id: z.ZodString;
|
|
81
84
|
title: z.ZodString;
|
|
82
85
|
counters: z.ZodArray<z.ZodString, "many">;
|
|
86
|
+
hideMissing: z.ZodOptional<z.ZodBoolean>;
|
|
83
87
|
}, "strict", z.ZodTypeAny, {
|
|
84
88
|
id: string;
|
|
85
89
|
title: string;
|
|
86
90
|
counters: string[];
|
|
87
91
|
kind: "counters";
|
|
92
|
+
hideMissing?: boolean | undefined;
|
|
88
93
|
}, {
|
|
89
94
|
id: string;
|
|
90
95
|
title: string;
|
|
91
96
|
counters: string[];
|
|
92
97
|
kind: "counters";
|
|
98
|
+
hideMissing?: boolean | undefined;
|
|
93
99
|
}>]>, "many">;
|
|
94
100
|
missions: z.ZodArray<z.ZodObject<{
|
|
95
101
|
id: z.ZodString;
|
|
@@ -459,7 +465,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
459
465
|
id: string;
|
|
460
466
|
icon?: string | undefined;
|
|
461
467
|
max?: string | number | undefined;
|
|
462
|
-
format?: "number" | "percent" | undefined;
|
|
468
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
463
469
|
display?: Record<string, string> | undefined;
|
|
464
470
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
465
471
|
}[];
|
|
@@ -471,6 +477,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
471
477
|
source?: string | undefined;
|
|
472
478
|
category?: string | undefined;
|
|
473
479
|
short?: string | undefined;
|
|
480
|
+
count?: string | undefined;
|
|
474
481
|
}[];
|
|
475
482
|
chips: {
|
|
476
483
|
label: string;
|
|
@@ -489,6 +496,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
489
496
|
title: string;
|
|
490
497
|
counters: string[];
|
|
491
498
|
kind: "counters";
|
|
499
|
+
hideMissing?: boolean | undefined;
|
|
492
500
|
})[];
|
|
493
501
|
missions: {
|
|
494
502
|
id: string;
|
|
@@ -578,7 +586,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
578
586
|
id: string;
|
|
579
587
|
icon?: string | undefined;
|
|
580
588
|
max?: string | number | undefined;
|
|
581
|
-
format?: "number" | "percent" | undefined;
|
|
589
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
582
590
|
display?: Record<string, string> | undefined;
|
|
583
591
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
584
592
|
}[];
|
|
@@ -590,6 +598,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
590
598
|
source?: string | undefined;
|
|
591
599
|
category?: string | undefined;
|
|
592
600
|
short?: string | undefined;
|
|
601
|
+
count?: string | undefined;
|
|
593
602
|
}[];
|
|
594
603
|
chips: {
|
|
595
604
|
label: string;
|
|
@@ -608,6 +617,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
608
617
|
title: string;
|
|
609
618
|
counters: string[];
|
|
610
619
|
kind: "counters";
|
|
620
|
+
hideMissing?: boolean | undefined;
|
|
611
621
|
})[];
|
|
612
622
|
missions: {
|
|
613
623
|
id: string;
|
|
@@ -726,7 +736,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
726
736
|
id: string;
|
|
727
737
|
icon?: string | undefined;
|
|
728
738
|
max?: string | number | undefined;
|
|
729
|
-
format?: "number" | "percent" | undefined;
|
|
739
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
730
740
|
display?: Record<string, string> | undefined;
|
|
731
741
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
732
742
|
}[];
|
|
@@ -738,6 +748,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
738
748
|
source?: string | undefined;
|
|
739
749
|
category?: string | undefined;
|
|
740
750
|
short?: string | undefined;
|
|
751
|
+
count?: string | undefined;
|
|
741
752
|
}[];
|
|
742
753
|
chips: {
|
|
743
754
|
label: string;
|
|
@@ -756,6 +767,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
756
767
|
title: string;
|
|
757
768
|
counters: string[];
|
|
758
769
|
kind: "counters";
|
|
770
|
+
hideMissing?: boolean | undefined;
|
|
759
771
|
})[];
|
|
760
772
|
missions: {
|
|
761
773
|
id: string;
|
|
@@ -856,7 +868,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
856
868
|
id: string;
|
|
857
869
|
icon?: string | undefined;
|
|
858
870
|
max?: string | number | undefined;
|
|
859
|
-
format?: "number" | "percent" | undefined;
|
|
871
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
860
872
|
display?: Record<string, string> | undefined;
|
|
861
873
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
862
874
|
}[];
|
|
@@ -868,6 +880,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
868
880
|
source?: string | undefined;
|
|
869
881
|
category?: string | undefined;
|
|
870
882
|
short?: string | undefined;
|
|
883
|
+
count?: string | undefined;
|
|
871
884
|
}[];
|
|
872
885
|
chips: {
|
|
873
886
|
label: string;
|
|
@@ -886,6 +899,7 @@ export declare const PackDataSchema: z.ZodObject<{
|
|
|
886
899
|
title: string;
|
|
887
900
|
counters: string[];
|
|
888
901
|
kind: "counters";
|
|
902
|
+
hideMissing?: boolean | undefined;
|
|
889
903
|
})[];
|
|
890
904
|
missions: {
|
|
891
905
|
id: string;
|
|
@@ -64,6 +64,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
64
64
|
category: z.ZodOptional<z.ZodString>;
|
|
65
65
|
short: z.ZodOptional<z.ZodString>;
|
|
66
66
|
source: z.ZodOptional<z.ZodString>;
|
|
67
|
+
count: z.ZodOptional<z.ZodString>;
|
|
67
68
|
}, "strict", z.ZodTypeAny, {
|
|
68
69
|
label: string;
|
|
69
70
|
id: string;
|
|
@@ -71,6 +72,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
71
72
|
source?: string | undefined;
|
|
72
73
|
category?: string | undefined;
|
|
73
74
|
short?: string | undefined;
|
|
75
|
+
count?: string | undefined;
|
|
74
76
|
}, {
|
|
75
77
|
label: string;
|
|
76
78
|
id: string;
|
|
@@ -78,6 +80,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
78
80
|
source?: string | undefined;
|
|
79
81
|
category?: string | undefined;
|
|
80
82
|
short?: string | undefined;
|
|
83
|
+
count?: string | undefined;
|
|
81
84
|
}>, "many">;
|
|
82
85
|
counters: z.ZodArray<z.ZodObject<{
|
|
83
86
|
id: z.ZodString;
|
|
@@ -86,13 +89,13 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
86
89
|
max: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
87
90
|
display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
88
91
|
role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
|
|
89
|
-
format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
|
|
92
|
+
format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
|
|
90
93
|
}, "strict", z.ZodTypeAny, {
|
|
91
94
|
label: string;
|
|
92
95
|
id: string;
|
|
93
96
|
icon?: string | undefined;
|
|
94
97
|
max?: string | number | undefined;
|
|
95
|
-
format?: "number" | "percent" | undefined;
|
|
98
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
96
99
|
display?: Record<string, string> | undefined;
|
|
97
100
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
98
101
|
}, {
|
|
@@ -100,7 +103,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
100
103
|
id: string;
|
|
101
104
|
icon?: string | undefined;
|
|
102
105
|
max?: string | number | undefined;
|
|
103
|
-
format?: "number" | "percent" | undefined;
|
|
106
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
104
107
|
display?: Record<string, string> | undefined;
|
|
105
108
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
106
109
|
}>, "many">;
|
|
@@ -128,16 +131,19 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
128
131
|
id: z.ZodString;
|
|
129
132
|
title: z.ZodString;
|
|
130
133
|
counters: z.ZodArray<z.ZodString, "many">;
|
|
134
|
+
hideMissing: z.ZodOptional<z.ZodBoolean>;
|
|
131
135
|
}, "strict", z.ZodTypeAny, {
|
|
132
136
|
id: string;
|
|
133
137
|
title: string;
|
|
134
138
|
counters: string[];
|
|
135
139
|
kind: "counters";
|
|
140
|
+
hideMissing?: boolean | undefined;
|
|
136
141
|
}, {
|
|
137
142
|
id: string;
|
|
138
143
|
title: string;
|
|
139
144
|
counters: string[];
|
|
140
145
|
kind: "counters";
|
|
146
|
+
hideMissing?: boolean | undefined;
|
|
141
147
|
}>]>, "many">;
|
|
142
148
|
missions: z.ZodArray<z.ZodObject<{
|
|
143
149
|
id: z.ZodString;
|
|
@@ -507,7 +513,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
507
513
|
id: string;
|
|
508
514
|
icon?: string | undefined;
|
|
509
515
|
max?: string | number | undefined;
|
|
510
|
-
format?: "number" | "percent" | undefined;
|
|
516
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
511
517
|
display?: Record<string, string> | undefined;
|
|
512
518
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
513
519
|
}[];
|
|
@@ -519,6 +525,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
519
525
|
source?: string | undefined;
|
|
520
526
|
category?: string | undefined;
|
|
521
527
|
short?: string | undefined;
|
|
528
|
+
count?: string | undefined;
|
|
522
529
|
}[];
|
|
523
530
|
chips: {
|
|
524
531
|
label: string;
|
|
@@ -537,6 +544,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
537
544
|
title: string;
|
|
538
545
|
counters: string[];
|
|
539
546
|
kind: "counters";
|
|
547
|
+
hideMissing?: boolean | undefined;
|
|
540
548
|
})[];
|
|
541
549
|
missions: {
|
|
542
550
|
id: string;
|
|
@@ -626,7 +634,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
626
634
|
id: string;
|
|
627
635
|
icon?: string | undefined;
|
|
628
636
|
max?: string | number | undefined;
|
|
629
|
-
format?: "number" | "percent" | undefined;
|
|
637
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
630
638
|
display?: Record<string, string> | undefined;
|
|
631
639
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
632
640
|
}[];
|
|
@@ -638,6 +646,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
638
646
|
source?: string | undefined;
|
|
639
647
|
category?: string | undefined;
|
|
640
648
|
short?: string | undefined;
|
|
649
|
+
count?: string | undefined;
|
|
641
650
|
}[];
|
|
642
651
|
chips: {
|
|
643
652
|
label: string;
|
|
@@ -656,6 +665,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
656
665
|
title: string;
|
|
657
666
|
counters: string[];
|
|
658
667
|
kind: "counters";
|
|
668
|
+
hideMissing?: boolean | undefined;
|
|
659
669
|
})[];
|
|
660
670
|
missions: {
|
|
661
671
|
id: string;
|
|
@@ -770,7 +780,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
770
780
|
id: string;
|
|
771
781
|
icon?: string | undefined;
|
|
772
782
|
max?: string | number | undefined;
|
|
773
|
-
format?: "number" | "percent" | undefined;
|
|
783
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
774
784
|
display?: Record<string, string> | undefined;
|
|
775
785
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
776
786
|
}[];
|
|
@@ -782,6 +792,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
782
792
|
source?: string | undefined;
|
|
783
793
|
category?: string | undefined;
|
|
784
794
|
short?: string | undefined;
|
|
795
|
+
count?: string | undefined;
|
|
785
796
|
}[];
|
|
786
797
|
chips: {
|
|
787
798
|
label: string;
|
|
@@ -800,6 +811,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
800
811
|
title: string;
|
|
801
812
|
counters: string[];
|
|
802
813
|
kind: "counters";
|
|
814
|
+
hideMissing?: boolean | undefined;
|
|
803
815
|
})[];
|
|
804
816
|
missions: {
|
|
805
817
|
id: string;
|
|
@@ -900,7 +912,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
900
912
|
id: string;
|
|
901
913
|
icon?: string | undefined;
|
|
902
914
|
max?: string | number | undefined;
|
|
903
|
-
format?: "number" | "percent" | undefined;
|
|
915
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
904
916
|
display?: Record<string, string> | undefined;
|
|
905
917
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
906
918
|
}[];
|
|
@@ -912,6 +924,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
912
924
|
source?: string | undefined;
|
|
913
925
|
category?: string | undefined;
|
|
914
926
|
short?: string | undefined;
|
|
927
|
+
count?: string | undefined;
|
|
915
928
|
}[];
|
|
916
929
|
chips: {
|
|
917
930
|
label: string;
|
|
@@ -930,6 +943,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
930
943
|
title: string;
|
|
931
944
|
counters: string[];
|
|
932
945
|
kind: "counters";
|
|
946
|
+
hideMissing?: boolean | undefined;
|
|
933
947
|
})[];
|
|
934
948
|
missions: {
|
|
935
949
|
id: string;
|
|
@@ -1083,7 +1097,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1083
1097
|
id: string;
|
|
1084
1098
|
icon?: string | undefined;
|
|
1085
1099
|
max?: string | number | undefined;
|
|
1086
|
-
format?: "number" | "percent" | undefined;
|
|
1100
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1087
1101
|
display?: Record<string, string> | undefined;
|
|
1088
1102
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1089
1103
|
}[];
|
|
@@ -1095,6 +1109,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1095
1109
|
source?: string | undefined;
|
|
1096
1110
|
category?: string | undefined;
|
|
1097
1111
|
short?: string | undefined;
|
|
1112
|
+
count?: string | undefined;
|
|
1098
1113
|
}[];
|
|
1099
1114
|
chips: {
|
|
1100
1115
|
label: string;
|
|
@@ -1113,6 +1128,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1113
1128
|
title: string;
|
|
1114
1129
|
counters: string[];
|
|
1115
1130
|
kind: "counters";
|
|
1131
|
+
hideMissing?: boolean | undefined;
|
|
1116
1132
|
})[];
|
|
1117
1133
|
missions: {
|
|
1118
1134
|
id: string;
|
|
@@ -1230,7 +1246,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1230
1246
|
id: string;
|
|
1231
1247
|
icon?: string | undefined;
|
|
1232
1248
|
max?: string | number | undefined;
|
|
1233
|
-
format?: "number" | "percent" | undefined;
|
|
1249
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1234
1250
|
display?: Record<string, string> | undefined;
|
|
1235
1251
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1236
1252
|
}[];
|
|
@@ -1242,6 +1258,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1242
1258
|
source?: string | undefined;
|
|
1243
1259
|
category?: string | undefined;
|
|
1244
1260
|
short?: string | undefined;
|
|
1261
|
+
count?: string | undefined;
|
|
1245
1262
|
}[];
|
|
1246
1263
|
chips: {
|
|
1247
1264
|
label: string;
|
|
@@ -1260,6 +1277,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
|
|
|
1260
1277
|
title: string;
|
|
1261
1278
|
counters: string[];
|
|
1262
1279
|
kind: "counters";
|
|
1280
|
+
hideMissing?: boolean | undefined;
|
|
1263
1281
|
})[];
|
|
1264
1282
|
missions: {
|
|
1265
1283
|
id: string;
|
package/lib/status.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Catalogue, CatalogueCounter, CounterRole, CatalogueMission, CollectibleEntry, ReferenceEntry } from './catalogue.js';
|
|
1
|
+
import type { Catalogue, CatalogueCounter, CatalogueItem, CatalogueLayout, CounterRole, CatalogueMission, CollectibleEntry, ReferenceEntry } from './catalogue.js';
|
|
2
2
|
import type { EvaluationContext } from './condition.js';
|
|
3
3
|
import type { GameState } from './types.js';
|
|
4
4
|
/** Context whose `{ mission }` conditions resolve against this catalogue (cycles → unknown). */
|
|
@@ -22,6 +22,14 @@ export interface CounterView {
|
|
|
22
22
|
}
|
|
23
23
|
/** Counter value + display text; null when the counter isn't streamed (unknown, not zero). */
|
|
24
24
|
export declare function getCounterView(counter: CatalogueCounter, state: GameState): CounterView | null;
|
|
25
|
+
/** Milliseconds as a race time: 83456 → 1'23"456. */
|
|
26
|
+
export declare function formatDuration(ms: number): string;
|
|
27
|
+
/** The counters a `counters` layout shows now: all of them, or with `hideMissing` those the state has. */
|
|
28
|
+
export declare function layoutCounterIds(layout: Extract<CatalogueLayout, {
|
|
29
|
+
kind: 'counters';
|
|
30
|
+
}>, state: GameState): string[];
|
|
31
|
+
/** How many of an item the player holds, when the pack counts it and the state has the count. */
|
|
32
|
+
export declare function findItemCount(item: CatalogueItem, state: GameState): number | undefined;
|
|
25
33
|
/** The pack's counter with this role and its value now, or undefined (no such counter, or unread). */
|
|
26
34
|
export declare function counterByRole(catalogue: Catalogue | undefined, state: GameState, role: CounterRole): (CounterView & {
|
|
27
35
|
counter: CatalogueCounter;
|
package/lib/status.js
CHANGED
|
@@ -69,6 +69,11 @@ export function getCounterView(counter, state) {
|
|
|
69
69
|
: counter.max
|
|
70
70
|
? (readCounter(state, counter.max) ?? null)
|
|
71
71
|
: null;
|
|
72
|
+
if (counter.format === 'duration') {
|
|
73
|
+
/* a value that isn't whole milliseconds can't be shown as a time: unknown, not a crash
|
|
74
|
+
* mid-render (plugin state isn't schema-checked at the daemon, boundaries.ts) */
|
|
75
|
+
return isDuration(value) ? { value, text: formatDuration(value), max } : null;
|
|
76
|
+
}
|
|
72
77
|
if (counter.format === 'percent') {
|
|
73
78
|
/* no max declared: the value is already a 0..1 share. A declared max that's unread or
|
|
74
79
|
* not positive leaves the share unknown, so the counter isn't shown. */
|
|
@@ -81,6 +86,27 @@ export function getCounterView(counter, state) {
|
|
|
81
86
|
const text = mapped ?? (max !== null ? `${value}/${max}` : String(value));
|
|
82
87
|
return { value, text, max };
|
|
83
88
|
}
|
|
89
|
+
const MS_PER_MINUTE = 60_000;
|
|
90
|
+
const MS_PER_SECOND = 1000;
|
|
91
|
+
const isDuration = (ms) => Number.isInteger(ms) && ms >= 0;
|
|
92
|
+
/** Milliseconds as a race time: 83456 → 1'23"456. */
|
|
93
|
+
export function formatDuration(ms) {
|
|
94
|
+
if (!Number.isInteger(ms) || ms < 0)
|
|
95
|
+
throw new Error(`${ms} isn't a duration in whole milliseconds`);
|
|
96
|
+
const minutes = Math.floor(ms / MS_PER_MINUTE);
|
|
97
|
+
const seconds = Math.floor((ms % MS_PER_MINUTE) / MS_PER_SECOND);
|
|
98
|
+
return `${minutes}'${String(seconds).padStart(2, '0')}"${String(ms % MS_PER_SECOND).padStart(3, '0')}`;
|
|
99
|
+
}
|
|
100
|
+
/** The counters a `counters` layout shows now: all of them, or with `hideMissing` those the state has. */
|
|
101
|
+
export function layoutCounterIds(layout, state) {
|
|
102
|
+
if (!layout.hideMissing)
|
|
103
|
+
return layout.counters;
|
|
104
|
+
return layout.counters.filter(id => readCounter(state, id) !== undefined);
|
|
105
|
+
}
|
|
106
|
+
/** How many of an item the player holds, when the pack counts it and the state has the count. */
|
|
107
|
+
export function findItemCount(item, state) {
|
|
108
|
+
return item.count === undefined ? undefined : readCounter(state, item.count);
|
|
109
|
+
}
|
|
84
110
|
/** The pack's counter with this role and its value now, or undefined (no such counter, or unread). */
|
|
85
111
|
export function counterByRole(catalogue, state, role) {
|
|
86
112
|
const counter = catalogue?.counters.find(c => c.role === role);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gameslate/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -74,6 +74,9 @@ evaluator in the SDK decides "done", "collected" and "available". Rules:
|
|
|
74
74
|
counter out of `counters` rather than reporting 0.
|
|
75
75
|
- Give counters a `role` (`health`, `magic`, `armor`, `keys`) so shared UI finds them.
|
|
76
76
|
- Use `format: 'percent'` with a `max` for meters.
|
|
77
|
+
- Use `format: 'duration'` for times kept in milliseconds (shown as 1'23"456), give an item
|
|
78
|
+
`count` (a counter id) when the player holds several, and set `hideMissing` on a `counters`
|
|
79
|
+
layout whose counters exist only in some modes (Dr. Mario's other bottles). Needs sdk 0.3.13.
|
|
77
80
|
|
|
78
81
|
**What to put in a pack** (Mario Kart 64 and Star Fox 64 in gameslate-n64 are worked examples):
|
|
79
82
|
|
|
@@ -215,6 +218,13 @@ or store each (docs/emulator-driving.md, "Finding an address from snapshots"). T
|
|
|
215
218
|
values pin a count; a 0/1 flag needs the whole series. A hit is a lead: read those functions and
|
|
216
219
|
confirm the width and sign there, as with any lead.
|
|
217
220
|
|
|
221
|
+
**No movie, but a table the boot loads (save records, defaults):** copy any N64 `.bk2` made on the
|
|
222
|
+
same BizHawk, set `GameName` and `SHA1` in its `Header.txt` to your ROM's, and replace its `Input
|
|
223
|
+
Log.txt` with the `LogKey` lines, N neutral frames and `[/Input]`. `drive tas` boots it on an
|
|
224
|
+
empty save, and the snapshots show the table holding its init values at every entry (F-Zero X's
|
|
225
|
+
24 course records all read `MAX_TIMER` from frame 60, 2026-12-04). That pins the address and the
|
|
226
|
+
stride, not a set value: say so, and leave the set case to synthetic memory and a live check.
|
|
227
|
+
|
|
218
228
|
**A game with no decomp (Castlevania: Legacy of Darkness is the worked example):** the leads and
|
|
219
229
|
the screen are all the evidence there is, so `addresses.ts` is hand-written with each address's
|
|
220
230
|
frames and what the screen showed.
|
|
@@ -436,6 +446,26 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
|
|
|
436
446
|
game could repeat, add it here (in `@gameslate/sdk`'s `template/claude/skills`, then copy it into
|
|
437
447
|
the plugin repos) in the same change as the fix. The next game should not have to find it again.
|
|
438
448
|
|
|
449
|
+
- **Run the support check in `check` once the repo has a support table.** Add `"support":
|
|
450
|
+
"gameslate-plugin support plugin --built dist/<id>"` and `&& yarn support` to `check`. Without
|
|
451
|
+
it, gameslate-n64's README frontmatter said Harvest Moon 64 had no missions for a release after
|
|
452
|
+
it gained 16, and three hand-edited table rows drifted from what the generator writes (2026-12-04).
|
|
453
|
+
Change a pack's missions, items or map, then rerun it with `--write`.
|
|
454
|
+
- **A save table copied at boot can be read half-copied.** The daemon reads memory between the
|
|
455
|
+
game's own steps, so a poll can land in the middle of a loop like F-Zero X's `Save_Load`. If
|
|
456
|
+
the copy runs in order, read "copied, then not yet" as still loading. Throw only on a shape no
|
|
457
|
+
copy leaves, such as a loaded entry after an unloaded one (2026-12-04 review).
|
|
458
|
+
- **Read a round's fields only once the round is up.** Mario Golf's course select runs
|
|
459
|
+
`holeIndex--` and wraps the hole only at the end of the function, so a poll in the menus can see
|
|
460
|
+
hole -1. Its first cut range-checked the hole on every poll, so it could throw in a menu that
|
|
461
|
+
never shows one. Read the scene first, and read and check the round's fields only in a round
|
|
462
|
+
scene (2026-12-04 review).
|
|
463
|
+
- **Follow the game's own lookup, not the field's name.** Mario Golf's Ring Shot reuses
|
|
464
|
+
`GameState.holeIndex` as a stage number. The game maps the stage through `f_RingShotHoles` in
|
|
465
|
+
`GetHoleRecordIndex`, and the driving range always uses hole 0. Before indexing a table by a
|
|
466
|
+
field, grep for the functions that read that field, and mirror their branches. Read the game's
|
|
467
|
+
tables from RAM rather than copying them. A file-static goes under the spec's `statics`; when
|
|
468
|
+
the decomp also builds with GCC, `nm` on its ELF confirms the offset.
|
|
439
469
|
- **Write a different value at each address in a poll test.** Bomberman Hero's poll test wrote 3
|
|
440
470
|
to both bombs and fire, so a swap of the two in `readRaw` still passed. Take a snapshot where
|
|
441
471
|
the fields differ (frame 15000 had bombs 4 and fire 3 on the HUD).
|
|
@@ -454,6 +484,22 @@ the plugin repos) in the same change as the fix. The next game should not have t
|
|
|
454
484
|
games shipped map extractors and `map_2d` in `gameslate-registry` while omitting `'map_2d'` from
|
|
455
485
|
`source.capabilities` in `source.ts`. `gameslate-plugin support` cross-checks `map.status`
|
|
456
486
|
against `source.capabilities` so the two cannot drift.
|
|
487
|
+
- **An unnamed id in a header can still be written: find every writer before you throw on it.**
|
|
488
|
+
Harvest Moon 64's rucksack loops run 9 times over 8-byte arrays, so its ninth slot is
|
|
489
|
+
`heldItem`, whatever Pete holds: a tavern beer (122, set in `shop.c`), a fox facing east (an id
|
|
490
|
+
inside an 8-wide block `items.h` names only by its first). Reading it as a rucksack slot and
|
|
491
|
+
throwing on unnamed ids would have dropped the whole state the moment he picked one up. Grep the
|
|
492
|
+
assignments (`= ` on the field, `SET_` in cutscene bytecode) and the flag table that limits what
|
|
493
|
+
a slot may hold (`itemFlags`' `ITEM_RUCKSACK_STORABLE`) before calling an id impossible.
|
|
494
|
+
- **A bit that marks a mission done must never be cleared.** Check `clear…Bit` calls in C *and*
|
|
495
|
+
the cutscene bytecode's `CLEAR_SPECIAL_BIT n, array[w]` (numeric, so grep the word and bit, not
|
|
496
|
+
the name). HM64's `HAVE_GREENHOUSE` is cleared by a typhoon and `WON_VEGETABLE_FESTIVAL` after
|
|
497
|
+
Basil's visit, so neither can be a mission. Read where a bit is set, too: `HAVE_STABLE` reads like
|
|
498
|
+
a house extension but is a Horse Race medal prize.
|
|
499
|
+
- **Use the item-name table the menu itself reads.** Quest 64's decomp leaves item ids unnamed;
|
|
500
|
+
disassembling the inventory menu's draw (`names[gInventory[i]]`, a pointer table in a
|
|
501
|
+
decompressed data blob) gave the id → name map and the empty value from the init loop. Pin the
|
|
502
|
+
names with a ROM-gated test that decodes the table, so a wrong index fails.
|
|
457
503
|
- **A table the decomp hasn't split is still in the ROM.** Quest 64's `gBossData` (8 bosses,
|
|
458
504
|
0x18 bytes each) lives in an unsplit data blob. Scanning the ROM for the struct's shape found
|
|
459
505
|
it at 0xD873A0: plausible map ids, zero padding, RAM pointers, and a `bossNumber` that is a
|