@wildshard/shard-format 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -18,13 +18,21 @@ const trigger = v.variant('kind', [
18
18
  v.strictObject({ id, kind: v.literal('death'), flag: id, tag: id, when: v.exactOptional(condition) }),
19
19
  v.strictObject({ id, kind: v.literal('script'), flag: id, condition: id, when: v.exactOptional(condition) }),
20
20
  ]);
21
+ /** A timed run: per player, the ticks from `start` rising to `stop` rising file `fact` with the seconds; past `cap` the run lapses. */
22
+ const RACE_CAP_MAX_S = 3600;
23
+ const RACE_CAP_MIN_S = 1;
24
+ const RACES_MAX = 32;
25
+ const raceCap = v.pipe(finite, v.safeInteger(), v.minValue(RACE_CAP_MIN_S), v.maxValue(RACE_CAP_MAX_S));
26
+ const race = v.strictObject({ id, start: id, stop: id, fact: id, cap: raceCap });
27
+ const raceRows = v.pipe(v.array(race), v.maxLength(RACES_MAX));
28
+ const raceList = v.exactOptional(raceRows);
21
29
  const choice = v.strictObject({ id, label: text, next: v.nullable(id), when: v.exactOptional(condition), sets: v.exactOptional(names), scene: v.exactOptional(id) });
22
30
  const node = v.strictObject({ id, lines: v.pipe(v.array(text), v.minLength(1), v.maxLength(32)), sets: v.exactOptional(names), choices: v.pipe(v.array(choice), v.maxLength(16)) });
23
31
  const dialogue = v.strictObject({ id, name: text, start: id, nodes: v.pipe(v.array(node), v.minLength(1), v.maxLength(128)) });
24
32
  /** Display metadata for the existing achievement registry and ledger; no new progress save. */
25
33
  const achievement = v.strictObject({ id, name: text, goal: text, count: v.pipe(finite, v.safeInteger(), v.minValue(1), v.maxValue(4096)),
26
34
  kind: v.exactOptional(id), variant: v.exactOptional(id), event: v.exactOptional(id), title: text, icon: CatalogueIconSchema });
27
- const raw: v.GenericSchema<{ [K in keyof QuestDataInput]: QuestDataInput[K] }, QuestData> = v.strictObject({ achievements: v.exactOptional(v.pipe(v.array(achievement), v.maxLength(256))), flags: names, quests: v.pipe(v.array(quest), v.maxLength(32)), triggers: v.pipe(v.array(trigger), v.maxLength(128)), dialogue: v.pipe(v.array(dialogue), v.maxLength(32)) });
35
+ const raw: v.GenericSchema<{ [K in keyof QuestDataInput]: QuestDataInput[K] }, QuestData> = v.strictObject({ achievements: v.exactOptional(v.pipe(v.array(achievement), v.maxLength(256))), flags: names, quests: v.pipe(v.array(quest), v.maxLength(32)), triggers: v.pipe(v.array(trigger), v.maxLength(128)), races: raceList, dialogue: v.pipe(v.array(dialogue), v.maxLength(32)) });
28
36
  /** Plain quest graphs, declared flags/triggers and finite dialogue trees; hooks name platform-resolved script ports. */
29
37
 
30
38
  const reads = (c: v.InferOutput<typeof condition> | undefined): string[] => [...(c?.all ?? []), ...(c?.any ?? []), ...(c?.none ?? [])];
@@ -40,6 +48,12 @@ export function questDataRules(data: QuestData): string[] {
40
48
  for (const m of q.intro?.markers ?? []) checkFlags(reads(m.hideWhen));
41
49
  }
42
50
  for (const t of data.triggers) checkFlags([t.flag, ...reads(t.when)]);
51
+ const raceIds: string[] = [];
52
+ for (const run of data.races ?? []) {
53
+ raceIds.push(run.id); checkFlags([run.start, run.stop]);
54
+ if (run.start === run.stop) { errors.push(`race ${run.id} starts and stops on one flag`); }
55
+ }
56
+ unique(raceIds);
43
57
  for (const d of data.dialogue) {
44
58
  unique(d.nodes.map((n) => n.id)); const nodes = new Map(d.nodes.map((n) => [n.id, n])), visited = new Set<string>(), active = new Set<string>();
45
59
  const visit = (name: string): void => {
@@ -170,6 +184,13 @@ interface QuestDataInputFields {
170
184
  none?: (string)[];
171
185
  };
172
186
  }))[];
187
+ races?: ({
188
+ id: string;
189
+ start: string;
190
+ stop: string;
191
+ fact: string;
192
+ cap: number;
193
+ })[];
173
194
  dialogue: ({
174
195
  id: string;
175
196
  name: string;
@@ -305,6 +326,13 @@ interface QuestDataFields {
305
326
  none?: (string)[];
306
327
  };
307
328
  }))[];
329
+ races?: ({
330
+ id: string;
331
+ start: string;
332
+ stop: string;
333
+ fact: string;
334
+ cap: number;
335
+ })[];
308
336
  dialogue: ({
309
337
  id: string;
310
338
  name: string;