@gameslate/sdk 0.3.12 → 0.3.14

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.
@@ -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
- format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
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
- format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
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
- format: z.enum(['number', 'percent']).optional(),
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
- for (const m of cat.missions) {
278
- if (m.progress && !known.counters.has(m.progress.counter)) {
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
- ? readCounter(state, key.slice('counter:'.length))?.toString()
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;
@@ -27,14 +27,28 @@ export interface GameMemory {
27
27
  */
28
28
  log?(message: string): void;
29
29
  }
30
+ /**
31
+ * N64 only: code from the ROM that stays in RAM at a fixed address while the game runs, for a game
32
+ * whose boot code doesn't (Mario Tennis boots a decompressor at 0x80300000, then draws over it).
33
+ * The core searches for these 64 bytes, after the boot code, to find the console's RAM.
34
+ */
35
+ export interface N64RamAnchor {
36
+ /** where the bytes start in the ROM, word-aligned */
37
+ romOffset: number;
38
+ /** the KSEG0 address (0x80…) they sit at in RAM */
39
+ ramAddress: number;
40
+ }
41
+ /** A build a source reads: where it's from, and (N64) how its RAM is found if the usual way fails. */
42
+ export interface BuildSupport {
43
+ region: string;
44
+ ramAnchor?: N64RamAnchor;
45
+ }
30
46
  /** A memory-read state source for one game. Packs export theirs from games/<id>/source.ts. */
31
47
  export interface GamePlugin {
32
48
  readonly gameId: string;
33
49
  readonly stateSchemaVersion: number;
34
50
  readonly capabilities: GameCapability[];
35
- readonly supportedBuildIds: ReadonlyMap<string, {
36
- region: string;
37
- }>;
51
+ readonly supportedBuildIds: ReadonlyMap<string, BuildSupport>;
38
52
  readonly executableHints: readonly string[];
39
53
  /**
40
54
  * Stats a launch wrapper from an older bundle may not send. While any is missing, the daemon
@@ -6,10 +6,28 @@ export declare const SandboxSourceSchema: z.ZodObject<{
6
6
  capabilities: z.ZodArray<z.ZodEnum<["location", "map_2d", "objectives", "inventory", "stats", "chat_chips"]>, "many">;
7
7
  supportedBuildIds: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodObject<{
8
8
  region: z.ZodString;
9
+ ramAnchor: z.ZodOptional<z.ZodObject<{
10
+ romOffset: z.ZodNumber;
11
+ ramAddress: z.ZodNumber;
12
+ }, "strip", z.ZodTypeAny, {
13
+ romOffset: number;
14
+ ramAddress: number;
15
+ }, {
16
+ romOffset: number;
17
+ ramAddress: number;
18
+ }>>;
9
19
  }, "strip", z.ZodTypeAny, {
10
20
  region: string;
21
+ ramAnchor?: {
22
+ romOffset: number;
23
+ ramAddress: number;
24
+ } | undefined;
11
25
  }, {
12
26
  region: string;
27
+ ramAnchor?: {
28
+ romOffset: number;
29
+ ramAddress: number;
30
+ } | undefined;
13
31
  }>], null>, "many">;
14
32
  executableHints: z.ZodArray<z.ZodString, "many">;
15
33
  wrapperMayOmitStats: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -29,6 +47,10 @@ export declare const SandboxSourceSchema: z.ZodObject<{
29
47
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
30
48
  supportedBuildIds: [string, {
31
49
  region: string;
50
+ ramAnchor?: {
51
+ romOffset: number;
52
+ ramAddress: number;
53
+ } | undefined;
32
54
  }][];
33
55
  executableHints: string[];
34
56
  wrapperMayOmitStats?: string[] | undefined;
@@ -42,6 +64,10 @@ export declare const SandboxSourceSchema: z.ZodObject<{
42
64
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
43
65
  supportedBuildIds: [string, {
44
66
  region: string;
67
+ ramAnchor?: {
68
+ romOffset: number;
69
+ ramAddress: number;
70
+ } | undefined;
45
71
  }][];
46
72
  executableHints: string[];
47
73
  wrapperMayOmitStats?: string[] | undefined;
@@ -64,6 +90,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
64
90
  category: z.ZodOptional<z.ZodString>;
65
91
  short: z.ZodOptional<z.ZodString>;
66
92
  source: z.ZodOptional<z.ZodString>;
93
+ count: z.ZodOptional<z.ZodString>;
67
94
  }, "strict", z.ZodTypeAny, {
68
95
  label: string;
69
96
  id: string;
@@ -71,6 +98,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
71
98
  source?: string | undefined;
72
99
  category?: string | undefined;
73
100
  short?: string | undefined;
101
+ count?: string | undefined;
74
102
  }, {
75
103
  label: string;
76
104
  id: string;
@@ -78,6 +106,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
78
106
  source?: string | undefined;
79
107
  category?: string | undefined;
80
108
  short?: string | undefined;
109
+ count?: string | undefined;
81
110
  }>, "many">;
82
111
  counters: z.ZodArray<z.ZodObject<{
83
112
  id: z.ZodString;
@@ -86,13 +115,13 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
86
115
  max: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
87
116
  display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
88
117
  role: z.ZodOptional<z.ZodEnum<["health", "magic", "armor", "keys"]>>;
89
- format: z.ZodOptional<z.ZodEnum<["number", "percent"]>>;
118
+ format: z.ZodOptional<z.ZodEnum<["number", "percent", "duration"]>>;
90
119
  }, "strict", z.ZodTypeAny, {
91
120
  label: string;
92
121
  id: string;
93
122
  icon?: string | undefined;
94
123
  max?: string | number | undefined;
95
- format?: "number" | "percent" | undefined;
124
+ format?: "number" | "duration" | "percent" | undefined;
96
125
  display?: Record<string, string> | undefined;
97
126
  role?: "keys" | "health" | "magic" | "armor" | undefined;
98
127
  }, {
@@ -100,7 +129,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
100
129
  id: string;
101
130
  icon?: string | undefined;
102
131
  max?: string | number | undefined;
103
- format?: "number" | "percent" | undefined;
132
+ format?: "number" | "duration" | "percent" | undefined;
104
133
  display?: Record<string, string> | undefined;
105
134
  role?: "keys" | "health" | "magic" | "armor" | undefined;
106
135
  }>, "many">;
@@ -128,16 +157,19 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
128
157
  id: z.ZodString;
129
158
  title: z.ZodString;
130
159
  counters: z.ZodArray<z.ZodString, "many">;
160
+ hideMissing: z.ZodOptional<z.ZodBoolean>;
131
161
  }, "strict", z.ZodTypeAny, {
132
162
  id: string;
133
163
  title: string;
134
164
  counters: string[];
135
165
  kind: "counters";
166
+ hideMissing?: boolean | undefined;
136
167
  }, {
137
168
  id: string;
138
169
  title: string;
139
170
  counters: string[];
140
171
  kind: "counters";
172
+ hideMissing?: boolean | undefined;
141
173
  }>]>, "many">;
142
174
  missions: z.ZodArray<z.ZodObject<{
143
175
  id: z.ZodString;
@@ -507,7 +539,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
507
539
  id: string;
508
540
  icon?: string | undefined;
509
541
  max?: string | number | undefined;
510
- format?: "number" | "percent" | undefined;
542
+ format?: "number" | "duration" | "percent" | undefined;
511
543
  display?: Record<string, string> | undefined;
512
544
  role?: "keys" | "health" | "magic" | "armor" | undefined;
513
545
  }[];
@@ -519,6 +551,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
519
551
  source?: string | undefined;
520
552
  category?: string | undefined;
521
553
  short?: string | undefined;
554
+ count?: string | undefined;
522
555
  }[];
523
556
  chips: {
524
557
  label: string;
@@ -537,6 +570,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
537
570
  title: string;
538
571
  counters: string[];
539
572
  kind: "counters";
573
+ hideMissing?: boolean | undefined;
540
574
  })[];
541
575
  missions: {
542
576
  id: string;
@@ -626,7 +660,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
626
660
  id: string;
627
661
  icon?: string | undefined;
628
662
  max?: string | number | undefined;
629
- format?: "number" | "percent" | undefined;
663
+ format?: "number" | "duration" | "percent" | undefined;
630
664
  display?: Record<string, string> | undefined;
631
665
  role?: "keys" | "health" | "magic" | "armor" | undefined;
632
666
  }[];
@@ -638,6 +672,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
638
672
  source?: string | undefined;
639
673
  category?: string | undefined;
640
674
  short?: string | undefined;
675
+ count?: string | undefined;
641
676
  }[];
642
677
  chips: {
643
678
  label: string;
@@ -656,6 +691,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
656
691
  title: string;
657
692
  counters: string[];
658
693
  kind: "counters";
694
+ hideMissing?: boolean | undefined;
659
695
  })[];
660
696
  missions: {
661
697
  id: string;
@@ -770,7 +806,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
770
806
  id: string;
771
807
  icon?: string | undefined;
772
808
  max?: string | number | undefined;
773
- format?: "number" | "percent" | undefined;
809
+ format?: "number" | "duration" | "percent" | undefined;
774
810
  display?: Record<string, string> | undefined;
775
811
  role?: "keys" | "health" | "magic" | "armor" | undefined;
776
812
  }[];
@@ -782,6 +818,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
782
818
  source?: string | undefined;
783
819
  category?: string | undefined;
784
820
  short?: string | undefined;
821
+ count?: string | undefined;
785
822
  }[];
786
823
  chips: {
787
824
  label: string;
@@ -800,6 +837,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
800
837
  title: string;
801
838
  counters: string[];
802
839
  kind: "counters";
840
+ hideMissing?: boolean | undefined;
803
841
  })[];
804
842
  missions: {
805
843
  id: string;
@@ -900,7 +938,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
900
938
  id: string;
901
939
  icon?: string | undefined;
902
940
  max?: string | number | undefined;
903
- format?: "number" | "percent" | undefined;
941
+ format?: "number" | "duration" | "percent" | undefined;
904
942
  display?: Record<string, string> | undefined;
905
943
  role?: "keys" | "health" | "magic" | "armor" | undefined;
906
944
  }[];
@@ -912,6 +950,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
912
950
  source?: string | undefined;
913
951
  category?: string | undefined;
914
952
  short?: string | undefined;
953
+ count?: string | undefined;
915
954
  }[];
916
955
  chips: {
917
956
  label: string;
@@ -930,6 +969,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
930
969
  title: string;
931
970
  counters: string[];
932
971
  kind: "counters";
972
+ hideMissing?: boolean | undefined;
933
973
  })[];
934
974
  missions: {
935
975
  id: string;
@@ -1024,10 +1064,28 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1024
1064
  capabilities: z.ZodArray<z.ZodEnum<["location", "map_2d", "objectives", "inventory", "stats", "chat_chips"]>, "many">;
1025
1065
  supportedBuildIds: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodObject<{
1026
1066
  region: z.ZodString;
1067
+ ramAnchor: z.ZodOptional<z.ZodObject<{
1068
+ romOffset: z.ZodNumber;
1069
+ ramAddress: z.ZodNumber;
1070
+ }, "strip", z.ZodTypeAny, {
1071
+ romOffset: number;
1072
+ ramAddress: number;
1073
+ }, {
1074
+ romOffset: number;
1075
+ ramAddress: number;
1076
+ }>>;
1027
1077
  }, "strip", z.ZodTypeAny, {
1028
1078
  region: string;
1079
+ ramAnchor?: {
1080
+ romOffset: number;
1081
+ ramAddress: number;
1082
+ } | undefined;
1029
1083
  }, {
1030
1084
  region: string;
1085
+ ramAnchor?: {
1086
+ romOffset: number;
1087
+ ramAddress: number;
1088
+ } | undefined;
1031
1089
  }>], null>, "many">;
1032
1090
  executableHints: z.ZodArray<z.ZodString, "many">;
1033
1091
  wrapperMayOmitStats: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -1047,6 +1105,10 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1047
1105
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
1048
1106
  supportedBuildIds: [string, {
1049
1107
  region: string;
1108
+ ramAnchor?: {
1109
+ romOffset: number;
1110
+ ramAddress: number;
1111
+ } | undefined;
1050
1112
  }][];
1051
1113
  executableHints: string[];
1052
1114
  wrapperMayOmitStats?: string[] | undefined;
@@ -1060,6 +1122,10 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1060
1122
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
1061
1123
  supportedBuildIds: [string, {
1062
1124
  region: string;
1125
+ ramAnchor?: {
1126
+ romOffset: number;
1127
+ ramAddress: number;
1128
+ } | undefined;
1063
1129
  }][];
1064
1130
  executableHints: string[];
1065
1131
  wrapperMayOmitStats?: string[] | undefined;
@@ -1083,7 +1149,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1083
1149
  id: string;
1084
1150
  icon?: string | undefined;
1085
1151
  max?: string | number | undefined;
1086
- format?: "number" | "percent" | undefined;
1152
+ format?: "number" | "duration" | "percent" | undefined;
1087
1153
  display?: Record<string, string> | undefined;
1088
1154
  role?: "keys" | "health" | "magic" | "armor" | undefined;
1089
1155
  }[];
@@ -1095,6 +1161,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1095
1161
  source?: string | undefined;
1096
1162
  category?: string | undefined;
1097
1163
  short?: string | undefined;
1164
+ count?: string | undefined;
1098
1165
  }[];
1099
1166
  chips: {
1100
1167
  label: string;
@@ -1113,6 +1180,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1113
1180
  title: string;
1114
1181
  counters: string[];
1115
1182
  kind: "counters";
1183
+ hideMissing?: boolean | undefined;
1116
1184
  })[];
1117
1185
  missions: {
1118
1186
  id: string;
@@ -1207,6 +1275,10 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1207
1275
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
1208
1276
  supportedBuildIds: [string, {
1209
1277
  region: string;
1278
+ ramAnchor?: {
1279
+ romOffset: number;
1280
+ ramAddress: number;
1281
+ } | undefined;
1210
1282
  }][];
1211
1283
  executableHints: string[];
1212
1284
  wrapperMayOmitStats?: string[] | undefined;
@@ -1230,7 +1302,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1230
1302
  id: string;
1231
1303
  icon?: string | undefined;
1232
1304
  max?: string | number | undefined;
1233
- format?: "number" | "percent" | undefined;
1305
+ format?: "number" | "duration" | "percent" | undefined;
1234
1306
  display?: Record<string, string> | undefined;
1235
1307
  role?: "keys" | "health" | "magic" | "armor" | undefined;
1236
1308
  }[];
@@ -1242,6 +1314,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1242
1314
  source?: string | undefined;
1243
1315
  category?: string | undefined;
1244
1316
  short?: string | undefined;
1317
+ count?: string | undefined;
1245
1318
  }[];
1246
1319
  chips: {
1247
1320
  label: string;
@@ -1260,6 +1333,7 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1260
1333
  title: string;
1261
1334
  counters: string[];
1262
1335
  kind: "counters";
1336
+ hideMissing?: boolean | undefined;
1263
1337
  })[];
1264
1338
  missions: {
1265
1339
  id: string;
@@ -1354,6 +1428,10 @@ export declare const SandboxDescriptionSchema: z.ZodObject<{
1354
1428
  capabilities: ("location" | "map_2d" | "objectives" | "inventory" | "stats" | "chat_chips")[];
1355
1429
  supportedBuildIds: [string, {
1356
1430
  region: string;
1431
+ ramAnchor?: {
1432
+ romOffset: number;
1433
+ ramAddress: number;
1434
+ } | undefined;
1357
1435
  }][];
1358
1436
  executableHints: string[];
1359
1437
  wrapperMayOmitStats?: string[] | undefined;
@@ -11,7 +11,18 @@ export const SandboxSourceSchema = z.object({
11
11
  gameId: z.string().min(1),
12
12
  stateSchemaVersion: z.number().int(),
13
13
  capabilities: z.array(GameCapabilitySchema),
14
- supportedBuildIds: z.array(z.tuple([z.string(), z.object({ region: z.string() })])),
14
+ supportedBuildIds: z.array(z.tuple([
15
+ z.string(),
16
+ z.object({
17
+ region: z.string(),
18
+ ramAnchor: z
19
+ .object({
20
+ romOffset: z.number().int().nonnegative().multipleOf(4),
21
+ ramAddress: z.number().int().gte(0x80000000).lt(0x80800000),
22
+ })
23
+ .optional(),
24
+ }),
25
+ ])),
15
26
  executableHints: z.array(z.string()),
16
27
  wrapperMayOmitStats: z.array(z.string()).optional(),
17
28
  unsupportedExecutables: z
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.12",
3
+ "version": "0.3.14",
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
 
@@ -204,6 +207,20 @@ first). Commit the spec and the generated table; the decomp and ROM stay local.
204
207
  that works (Banjo-Kazooie's health code is the low byte of an s32): find the field's start.
205
208
  Project64's `Config/Cheats/*.cht` files are per revision; `drive codes` reads them with
206
209
  `--rom <rom>` and refuses a list whose header CRC isn't that ROM's.
210
+ - **ScriptHawk** (github.com/Isotarge/ScriptHawk, MIT) names many games' addresses per release,
211
+ pointers and whole flag lists included (SSSV, Rayman 2, Conker, DK64, Banjo). `drive codes` reads
212
+ a module's `Game.Memory` table (`--version <release>`) and a flag list such as `dk64_flags.lua`
213
+ (`--flag-base <block address>`, which the module computes at run time: read its code for it).
214
+ DK64's 7165S snapshots set exactly the movie's 5 flags at slot 0's `0x807ECEA8`.
215
+ - **Flag ids for collectibles: read the pause menu's totals first.** The function that fills the
216
+ pause or file-select counts (`flagCountRange(first, count)`, a table of flag ids, single flags)
217
+ names every collectible set the player sees, with the maximum beside it, all in the decomp. DK64's
218
+ `hudPauseMenuRefreshTotals` gave keys, crowns, medals, fairies, blueprints and both coins, so
219
+ ScriptHawk's list was only a cross-check and no third-party names were needed.
220
+ - **A save slot may move.** DK64 keeps its four files in sectors it swaps on every save
221
+ (`gEepromSectorSlot`), sized at boot from a model count: read the indirection each poll, compute
222
+ the size the way the game does, and check across snapshots that the set flags stay put whichever
223
+ sector holds the file.
207
224
  - A byte-pattern lead stays a pattern: read it with `memory.scan({ pattern, kind, offset })`, so it
208
225
  survives patches. It must match exactly once.
209
226
 
@@ -215,6 +232,27 @@ or store each (docs/emulator-driving.md, "Finding an address from snapshots"). T
215
232
  values pin a count; a 0/1 flag needs the whole series. A hit is a lead: read those functions and
216
233
  confirm the width and sign there, as with any lead.
217
234
 
235
+ **No movie, but a table the boot loads (save records, defaults):** copy any N64 `.bk2` made on the
236
+ same BizHawk, set `GameName` and `SHA1` in its `Header.txt` to your ROM's, and replace its `Input
237
+ Log.txt` with the `LogKey` lines, N neutral frames and `[/Input]`. `drive tas` boots it on an
238
+ empty save, and the snapshots show the table holding its init values at every entry (F-Zero X's
239
+ 24 course records all read `MAX_TIMER` from frame 60, 2026-12-04). That pins the address and the
240
+ stride, not a set value: say so, and leave the set case to synthetic memory and a live check.
241
+
242
+ **A phase byte no lead names** (the title, menus and attract demos keep the last match's
243
+ score, so the score alone can't say when it's live): list the snapshots by what their screens
244
+ show, then search every byte for one value through the phase and another at every frame outside
245
+ it (a short Node script over the `rdram.bin`s; keep values small and the outside values few, or
246
+ you get thousands of heap bytes). Then run the ROM idle (a copy of the movie with N neutral
247
+ frames, framed exactly as the original's `Input Log.txt`: adding an `[Input]` line to a BizHawk
248
+ 1.9.1 log made 2.9.1 quit before the script ran) through the attract demos: a byte that holds in
249
+ the demos too means "a match is on", not "the player is playing". Mario Tennis needed both: one
250
+ byte for any match on court, another for the player's own.
251
+ Before releasing, replay once more with `--watch` on the phase bytes: snapshots every 100 frames
252
+ missed Mario Tennis's black screen (court byte 6) and its 24-frame walk-on (player byte 1 with
253
+ the menu court byte), so 0.34.0 threw for the three seconds before every match. Give every pair
254
+ the watch log shows a phase, and keep throwing on the rest.
255
+
218
256
  **A game with no decomp (Castlevania: Legacy of Darkness is the worked example):** the leads and
219
257
  the screen are all the evidence there is, so `addresses.ts` is hand-written with each address's
220
258
  frames and what the screen showed.
@@ -436,6 +474,26 @@ plugin exactly as the core will before running it. Then bump `version`, tag `vX.
436
474
  game could repeat, add it here (in `@gameslate/sdk`'s `template/claude/skills`, then copy it into
437
475
  the plugin repos) in the same change as the fix. The next game should not have to find it again.
438
476
 
477
+ - **Run the support check in `check` once the repo has a support table.** Add `"support":
478
+ "gameslate-plugin support plugin --built dist/<id>"` and `&& yarn support` to `check`. Without
479
+ it, gameslate-n64's README frontmatter said Harvest Moon 64 had no missions for a release after
480
+ it gained 16, and three hand-edited table rows drifted from what the generator writes (2026-12-04).
481
+ Change a pack's missions, items or map, then rerun it with `--write`.
482
+ - **A save table copied at boot can be read half-copied.** The daemon reads memory between the
483
+ game's own steps, so a poll can land in the middle of a loop like F-Zero X's `Save_Load`. If
484
+ the copy runs in order, read "copied, then not yet" as still loading. Throw only on a shape no
485
+ copy leaves, such as a loaded entry after an unloaded one (2026-12-04 review).
486
+ - **Read a round's fields only once the round is up.** Mario Golf's course select runs
487
+ `holeIndex--` and wraps the hole only at the end of the function, so a poll in the menus can see
488
+ hole -1. Its first cut range-checked the hole on every poll, so it could throw in a menu that
489
+ never shows one. Read the scene first, and read and check the round's fields only in a round
490
+ scene (2026-12-04 review).
491
+ - **Follow the game's own lookup, not the field's name.** Mario Golf's Ring Shot reuses
492
+ `GameState.holeIndex` as a stage number. The game maps the stage through `f_RingShotHoles` in
493
+ `GetHoleRecordIndex`, and the driving range always uses hole 0. Before indexing a table by a
494
+ field, grep for the functions that read that field, and mirror their branches. Read the game's
495
+ tables from RAM rather than copying them. A file-static goes under the spec's `statics`; when
496
+ the decomp also builds with GCC, `nm` on its ELF confirms the offset.
439
497
  - **Write a different value at each address in a poll test.** Bomberman Hero's poll test wrote 3
440
498
  to both bombs and fire, so a swap of the two in `readRaw` still passed. Take a snapshot where
441
499
  the fields differ (frame 15000 had bombs 4 and fire 3 on the HUD).
@@ -454,6 +512,22 @@ the plugin repos) in the same change as the fix. The next game should not have t
454
512
  games shipped map extractors and `map_2d` in `gameslate-registry` while omitting `'map_2d'` from
455
513
  `source.capabilities` in `source.ts`. `gameslate-plugin support` cross-checks `map.status`
456
514
  against `source.capabilities` so the two cannot drift.
515
+ - **An unnamed id in a header can still be written: find every writer before you throw on it.**
516
+ Harvest Moon 64's rucksack loops run 9 times over 8-byte arrays, so its ninth slot is
517
+ `heldItem`, whatever Pete holds: a tavern beer (122, set in `shop.c`), a fox facing east (an id
518
+ inside an 8-wide block `items.h` names only by its first). Reading it as a rucksack slot and
519
+ throwing on unnamed ids would have dropped the whole state the moment he picked one up. Grep the
520
+ assignments (`= ` on the field, `SET_` in cutscene bytecode) and the flag table that limits what
521
+ a slot may hold (`itemFlags`' `ITEM_RUCKSACK_STORABLE`) before calling an id impossible.
522
+ - **A bit that marks a mission done must never be cleared.** Check `clear…Bit` calls in C *and*
523
+ the cutscene bytecode's `CLEAR_SPECIAL_BIT n, array[w]` (numeric, so grep the word and bit, not
524
+ the name). HM64's `HAVE_GREENHOUSE` is cleared by a typhoon and `WON_VEGETABLE_FESTIVAL` after
525
+ Basil's visit, so neither can be a mission. Read where a bit is set, too: `HAVE_STABLE` reads like
526
+ a house extension but is a Horse Race medal prize.
527
+ - **Use the item-name table the menu itself reads.** Quest 64's decomp leaves item ids unnamed;
528
+ disassembling the inventory menu's draw (`names[gInventory[i]]`, a pointer table in a
529
+ decompressed data blob) gave the id → name map and the empty value from the init loop. Pin the
530
+ names with a ROM-gated test that decodes the table, so a wrong index fails.
457
531
  - **A table the decomp hasn't split is still in the ROM.** Quest 64's `gBossData` (8 bosses,
458
532
  0x18 bytes each) lives in an unsplit data blob. Scanning the ROM for the struct's shape found
459
533
  it at 0xD873A0: plausible map ids, zero padding, RAM pointers, and a `bossNumber` that is a
@@ -621,7 +695,9 @@ the plugin repos) in the same change as the fix. The next game should not have t
621
695
  - **Before a file is chosen, the save index is stale.** Super Mario 64's `gCurrSaveFileNum` starts
622
696
  at 1 and keeps the last file after Save & Quit, so file select showed file 1's stars as fact.
623
697
  Leave save-derived flags and counters out until a file is entered (an absent flag reads as
624
- untracked), and keep them where a file is known (in play, the ending).
698
+ untracked), and keep them where a file is known (in play, the ending), loads and cutscenes
699
+ included: a slot grid fed by `inventory` has no "not tracked" state, so gating items on "the
700
+ player is placed" empties it on every map load (DK64 review, 2026-12-05).
625
701
  - **The game mode can be a function pointer:** when the decomp keeps the current mode in a
626
702
  file-static the symbol maps don't list, read the mode table instead (Paper Mario:
627
703
  `gMainGameMode[0].step` equals a `state_step_*` symbol).
@@ -649,3 +725,11 @@ the plugin repos) in the same change as the fix. The next game should not have t
649
725
  lands somewhere else next time. Pin each choice with the game's own menu variables.
650
726
  - **Prove it on real data before writing to a player's files.** Back up what's there before the
651
727
  first run on a real machine.
728
+ - **Check the core can find the game's RAM before you ship.** The core finds an N64 game's RAM
729
+ by the code its boot chip copies from ROM 0x1000 (and 0x2000). A game that boots a
730
+ decompressor there and then draws over it is never found: no error, the game just never
731
+ attaches (Mario Tennis, found live on 2026-12-05, after the TAS work had passed). Check every
732
+ `rdram.bin` of your replays for the ROM's bytes at 0x1000 and 0x2000 at the entry point. If
733
+ they're gone, find 64 bytes of ROM code that sit at one RAM address in every snapshot, once,
734
+ and declare them on the build: `supportedBuildIds: new Map([['NM8E.0', { region, ramAnchor:
735
+ { romOffset: 0x1300, ramAddress: 0x80042f50 } }]])` (sdk 0.3.14).
@@ -91,9 +91,23 @@ Script the route per game as inputs plus checks, such as "Start until game state
91
91
  categories that play the game as intended, the newest BizHawk, the default core and plugin;
92
92
  avoid ACE, wrong-warp and game-end-glitch runs, and read the submission (`tasvideos.org/<n>S`)
93
93
  for sync steps. On Windows 11 24H2 old Mupen64Plus code fails (the dynarec,
94
- Glide64mk2): a movie that sits at frame 0 or crashes may run with `Core` 1 (interpreter) in a
95
- copy of its `SyncSettings.json`, but such a copy is a deviation: prove sync (menu picks, counts
96
- rising steadily, no lost health, level clears) before trusting any frame of it.
94
+ Glide64mk2): a movie that sits at frame 0 or crashes may run on `Core` 1 (interpreter):
95
+ `drive tas … --cpu interpreter` replays such a copy, but it is a deviation: prove sync (menu
96
+ picks, counts rising steadily, no lost health, level clears) before trusting any frame of it. A movie asking
97
+ for Jabo (`VideoPlugin` 3, gone in 2.x) is refused; `drive tas … --video gliden64` replays a
98
+ copy on another plugin (no hand-made zip needed): when GLideN64 (4) leaves BizHawk's
99
+ screenshots stale and `screen.png` comes out as noise (a framebuffer it misreads), use
100
+ `--video angrylion` (5), the software renderer: slower, but every screenshot is the frame
101
+ (Mario Tennis, 2026-12-05).
102
+ - **Only a `.m64` (mupen64-rr)?** `drive m64 <movie.m64> <rom> --out movie.bk2` converts it with
103
+ one BizHawk pass that hands each pad read the next sample. It syncs where the game reads the pad
104
+ as it did under mupen64-rr: check the samples-per-VI first (Yoshi's Story 1982M, ~1 a VI,
105
+ synced to its second reset; F-Zero X 2467M reads during BizHawk's boot logo and desyncs at the
106
+ title). A reset timed to a save (to skip a cutscene) is where a conversion stops syncing: take
107
+ frames before it. The ROM must match the movie's CRC1 and country: many SM64 and Smash `.m64`s
108
+ are for the Japanese ROM. A frame that reads the pad twice for two different samples can't be
109
+ held in a `.bk2`: the conversion refuses unless `--inexact allow`, and then sync must be proven
110
+ past the first such frame it names.
97
111
  - **Naming an enum's values from a TAS** (an ability, a character, a fruit): the decomp often
98
112
  proves the address and the numbering but not which value is which. Replay with `--watch
99
113
  <addr>:<size>` and "-" for frames to log every change, then replay to a few hundred frames