@wildshard/shard-format 0.55.2 → 0.56.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.55.2",
3
+ "version": "0.56.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,11 +18,9 @@ const entry = v.strictObject({ id: key, kind: entryKind, tab: key, name: text, n
18
18
  const stat = v.strictObject({ label: text, value: v.picklist(['seen', 'taken', 'best', 'rarity', 'status']),
19
19
  fallback: v.exactOptional(text), suffix: v.exactOptional(text), words: v.exactOptional(v.record(key, text)) });
20
20
  const stats = v.pipe(v.array(stat), v.maxLength(8));
21
- const iconSelectors = { entryKind: v.exactOptional(entryKind), matchKind: v.exactOptional(key) };
22
- const legacyIcon = v.strictObject({ ...iconSelectors, icon: v.picklist(['antlers', 'ghost', 'ironhide', 'deer', 'boar', 'elk', 'bear']) });
23
21
  const iconImage = v.pipe(text, v.check(sketchReference, 'bounded inert SVG data or admitted image hash'));
24
- const imageIcon = v.strictObject({ ...iconSelectors, image: iconImage, tint: v.exactOptional(v.literal('currentColor')) });
25
- const icon = v.union([imageIcon, legacyIcon]);
22
+ const icon = v.strictObject({ entryKind: v.exactOptional(entryKind), matchKind: v.exactOptional(key),
23
+ image: iconImage, tint: v.exactOptional(v.literal('currentColor')) });
26
24
  const cell = v.strictObject({ x: finite, y: finite, w: positive, h: positive });
27
25
  const trophy = v.strictObject({ entry: key, outline: key, mount: v.exactOptional(v.strictObject({ kind: key, variant: key })), title: text });
28
26
  const wall = v.strictObject({ cabin: natural, at: v.tuple([finite, finite, finite]), yaw: finite, width: positive,
@@ -51,14 +49,14 @@ export function journalRowRules(row: JournalRow): readonly string[] {
51
49
  }
52
50
  /** All raster images must be charged immutable library roots; logical URLs are resolved by the admitted product. */
53
51
  export function journalImageRefs(row: JournalRow): readonly string[] {
54
- const icons = row.icons.flatMap((value: Readonly<JournalIcon>): string[] => 'image' in value && !value.image.startsWith('data:') ? [value.image] : []);
52
+ const icons = row.icons.flatMap((value: Readonly<JournalIcon>): string[] => value.image.startsWith('data:') ? [] : [value.image]);
55
53
  return [...new Set([...row.entries.flatMap(value => [value.plate.sketch, ...value.plate.silhouette === undefined ? [] : [value.plate.silhouette]]),
56
54
  ...row.chalk === undefined ? [] : [row.chalk.atlas], ...icons])];
57
55
  }
58
56
 
59
57
  /** Admitted data contracts, independent of validator implementation metadata. */
60
58
  export type JournalRowInput = JournalRow;
61
- type JournalIcon = { entryKind?: 'species' | 'variant' | 'elite' | 'boss' | 'place'; matchKind?: string } & ({ image: string; tint?: 'currentColor' } | { icon: 'antlers' | 'ghost' | 'ironhide' | 'deer' | 'boar' | 'elk' | 'bear' });
59
+ interface JournalIcon { entryKind?: 'species' | 'variant' | 'elite' | 'boss' | 'place'; matchKind?: string; image: string; tint?: 'currentColor' }
62
60
  interface JournalRowFields {
63
61
  kind: 'journal';
64
62
  id: string;
@@ -3,10 +3,10 @@ import { parseSketchSvg, sketchReference, type CompendiumSketch } from './sketch
3
3
  import type { ShardRows } from './rows.ts';
4
4
 
5
5
  const prefix = 'data:image/svg+xml,';
6
- type SketchRow = Readonly<{ kind: 'journal'; icons: readonly Readonly<{ image?: string; icon?: string }>[] }> | Readonly<{ kind?: never; entries: readonly Readonly<{ sketch: string }>[] }>;
6
+ type SketchRow = Readonly<{ kind: 'journal'; icons: readonly Readonly<{ image: string }>[] }> | Readonly<{ kind?: never; entries: readonly Readonly<{ sketch: string }>[] }>;
7
7
  function sketchRefs(row: SketchRow): string[] {
8
8
  if (row.kind === 'journal') {
9
- return row.icons.flatMap((value: Readonly<{ image?: string; icon?: string }>): string[] => value.image?.startsWith(prefix) === true ? [value.image] : []);
9
+ return row.icons.flatMap((value: Readonly<{ image: string }>): string[] => value.image.startsWith(prefix) ? [value.image] : []);
10
10
  }
11
11
  return row.entries.map((entry: Readonly<{ sketch: string }>): string => entry.sketch);
12
12
  }
@@ -6,11 +6,32 @@ const text = v.pipe(v.string(), v.minLength(1), v.maxLength(512));
6
6
  const finite = v.pipe(v.number(), v.finite());
7
7
  const names = v.pipe(v.array(id), v.maxLength(128));
8
8
  const condition = v.strictObject({ all: v.exactOptional(names), any: v.exactOptional(names), none: v.exactOptional(names) });
9
- const marker = v.strictObject({ id, label: text, short: v.exactOptional(v.pipe(text, v.maxLength(18))), at: v.strictObject({ poi: v.literal('world'), x: finite, z: finite, y: v.exactOptional(finite) }), hideWhen: v.exactOptional(condition) });
9
+ const worldAt = v.strictObject({ poi: v.literal('world'), x: finite, z: finite, y: v.exactOptional(finite) });
10
+ const marker = v.strictObject({ id, label: text, short: v.exactOptional(v.pipe(text, v.maxLength(18))), at: worldAt, hideWhen: v.exactOptional(condition) });
10
11
  const markers = v.pipe(v.array(marker), v.maxLength(32));
11
12
  const done = v.pipe(condition, v.check((c) => [...(c.all ?? []), ...(c.any ?? []), ...(c.none ?? [])].length > 0, 'nonempty done condition'));
12
- const step = v.strictObject({ id, objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), done, count: v.exactOptional(names), markers: v.exactOptional(markers) });
13
- const quest = v.strictObject({ id, title: text, track: v.exactOptional(v.boolean()), completeFlag: id, startWhen: v.exactOptional(condition), intro: v.exactOptional(v.strictObject({ objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), markers: v.exactOptional(markers) })), steps: v.pipe(v.array(step), v.minLength(1), v.maxLength(64)), onComplete: v.exactOptional(v.strictObject({ fact: v.exactOptional(id), scene: v.exactOptional(id), coins: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100))) })) });
13
+ /** Meta MOSSGATE-ZONE MZ31 (QA 11-19 row 35, "nothing happens"): where a quest beat lands, and how. The engine flares the
14
+ * spot in `colour`, spreads its light over the ground for `radius` metres, pops a small reward there and sounds one of its own
15
+ * synth voices (`InteractSfx`, no recorded audio). */
16
+ const SPREAD_MIN = 1;
17
+ const SPREAD_MAX = 40;
18
+ const colour = v.pipe(v.string(), v.regex(/^#[0-9a-fA-F]{6}$/u));
19
+ const spread = v.pipe(finite, v.minValue(SPREAD_MIN), v.maxValue(SPREAD_MAX));
20
+ const voice = v.picklist(['chime', 'glyph', 'ignite', 'chest', 'lever', 'plate', 'door', 'grate']);
21
+ const landing = { at: v.omit(worldAt, ['poi']), colour: v.exactOptional(colour), radius: v.exactOptional(spread), sound: v.exactOptional(voice) };
22
+ /** A step's landing: shown where the step was done, the moment its `done` first holds. */
23
+ const feedback = v.strictObject(landing);
24
+ /** A quest's payoff: a bigger landing as it completes, the score's reward take (`music`, default `dawn`), then the next goal
25
+ * (`next`) on the tracker. The world change is `onComplete.scene`, the shard's own declared scene hook. */
26
+ const music = v.picklist(['dawn', 'none']);
27
+ const payoff = v.strictObject({ ...landing, music: v.exactOptional(music), next: v.exactOptional(text) });
28
+ const optionalPayoff = v.exactOptional(payoff);
29
+ /** MZ31: a quest beat's landing (a step's `feedback`, the base of a quest's `onComplete.payoff`). */
30
+ interface QuestFeedbackRows { at: Record<'x' | 'z', number> & Partial<Record<'y', number>>; colour?: string; radius?: number; sound?: 'chime' | 'glyph' | 'ignite' | 'chest' | 'lever' | 'plate' | 'door' | 'grate' }
31
+ /** MZ31: a quest's payoff as it completes. */
32
+ interface QuestPayoffRows extends QuestFeedbackRows { music?: 'dawn' | 'none'; next?: string }
33
+ const step = v.strictObject({ id, objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), done, count: v.exactOptional(names), markers: v.exactOptional(markers), feedback: v.exactOptional(feedback) });
34
+ const quest = v.strictObject({ id, title: text, track: v.exactOptional(v.boolean()), completeFlag: id, startWhen: v.exactOptional(condition), intro: v.exactOptional(v.strictObject({ objective: text, chip: v.exactOptional(v.pipe(text, v.maxLength(18))), hint: v.exactOptional(text), markers: v.exactOptional(markers) })), steps: v.pipe(v.array(step), v.minLength(1), v.maxLength(64)), onComplete: v.exactOptional(v.strictObject({ fact: v.exactOptional(id), scene: v.exactOptional(id), coins: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100))), payoff: optionalPayoff })) });
14
35
  /** Complete presentation chapter after its native completion owner is omitted. */
15
36
  export const QuestPresentationChapterSchema:v.GenericSchema<Omit<QuestDataInput['quests'][number],'onComplete'>,Omit<QuestData['quests'][number],'onComplete'>>=v.omit(quest,['onComplete']);
16
37
  const trigger = v.variant('kind', [
@@ -133,6 +154,7 @@ interface QuestDataInputFields {
133
154
  none?: (string)[];
134
155
  };
135
156
  count?: (string)[];
157
+ feedback?: QuestFeedbackRows;
136
158
  markers?: ({
137
159
  id: string;
138
160
  label: string;
@@ -154,6 +176,7 @@ interface QuestDataInputFields {
154
176
  fact?: string;
155
177
  scene?: string;
156
178
  coins?: number;
179
+ payoff?: QuestPayoffRows;
157
180
  };
158
181
  })[];
159
182
  triggers: (({
@@ -276,6 +299,7 @@ interface QuestDataFields {
276
299
  none?: (string)[];
277
300
  };
278
301
  count?: (string)[];
302
+ feedback?: QuestFeedbackRows;
279
303
  markers?: ({
280
304
  id: string;
281
305
  label: string;
@@ -297,6 +321,7 @@ interface QuestDataFields {
297
321
  fact?: string;
298
322
  scene?: string;
299
323
  coins?: number;
324
+ payoff?: QuestPayoffRows;
300
325
  };
301
326
  })[];
302
327
  triggers: (({