@wildshard/shard-format 0.43.1 → 0.43.2
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 +1 -1
- package/src/format/rows.ts +9 -3
- package/src/format/shardSchema.ts +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.2",
|
|
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": {
|
package/src/format/rows.ts
CHANGED
|
@@ -22,6 +22,9 @@ const unit = v.pipe(finite, v.minValue(0), v.maxValue(1));
|
|
|
22
22
|
const dimension = v.pipe(positive, v.maxValue(20));
|
|
23
23
|
const MAX_OVERSHOOT = 30;
|
|
24
24
|
const overshoot = v.pipe(nonnegative, v.maxValue(MAX_OVERSHOOT));
|
|
25
|
+
const STRIKE_UNITS = ['world', 'actor'] as const;
|
|
26
|
+
/** How a strike row's shape sizes follow its body's scale (OF11b). */
|
|
27
|
+
type StrikeUnits = typeof STRIKE_UNITS[number];
|
|
25
28
|
/** A flyer's bake has no legs (OF11a): legs are nonnegative, the body stays positive. */
|
|
26
29
|
const NO_LEGS = 0;
|
|
27
30
|
const legs = v.union([v.literal(NO_LEGS), dimension]);
|
|
@@ -34,10 +37,13 @@ const shape = v.variant('kind', [
|
|
|
34
37
|
v.strictObject({ kind: v.literal('wedge'), length: dimension, halfAngle: v.pipe(positive, v.maxValue(Math.PI)) }),
|
|
35
38
|
v.pipe(v.strictObject({ kind: v.literal('ring'), inner: nonnegative, outer: dimension }), v.check((r) => r.inner <= r.outer, 'ordered ring')),
|
|
36
39
|
]);
|
|
37
|
-
const strike: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.GenericSchema<StrikeDebrisPolicy>, undefined>; readonly id: v.GenericSchema<StrikeRowsInput['id'], StrikeRows['id']>; readonly shape: v.GenericSchema<StrikeRowsInput['shape'], StrikeRows['shape']>; readonly windup: v.GenericSchema<StrikeRowsInput['windup'], StrikeRows['windup']>; readonly active: v.GenericSchema<StrikeRowsInput['active'], StrikeRows['active']>; readonly recover: v.GenericSchema<StrikeRowsInput['recover'], StrikeRows['recover']>; readonly cooldown: v.GenericSchema<StrikeRowsInput['cooldown'], StrikeRows['cooldown']>; readonly range: v.GenericSchema<StrikeRowsInput['range'], StrikeRows['range']>; readonly damage: v.GenericSchema<StrikeRowsInput['damage'], StrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<`${string}.${string}`>, undefined>, v.MaxLengthAction<StrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<StrikeRowsInput['weight'], StrikeRows['weight']>; readonly speed: v.GenericSchema<StrikeRowsInput['speed'], StrikeRows['speed']>; readonly overshoot: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; }, undefined> = v.strictObject({ debris: v.exactOptional(StrikeDebrisSchema), id, shape, windup: nonnegative, active: nonnegative, recover: nonnegative, cooldown: nonnegative, range: dimension, damage: nonnegative,
|
|
40
|
+
const strike: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.GenericSchema<StrikeDebrisPolicy>, undefined>; readonly id: v.GenericSchema<StrikeRowsInput['id'], StrikeRows['id']>; readonly shape: v.GenericSchema<StrikeRowsInput['shape'], StrikeRows['shape']>; readonly windup: v.GenericSchema<StrikeRowsInput['windup'], StrikeRows['windup']>; readonly active: v.GenericSchema<StrikeRowsInput['active'], StrikeRows['active']>; readonly recover: v.GenericSchema<StrikeRowsInput['recover'], StrikeRows['recover']>; readonly cooldown: v.GenericSchema<StrikeRowsInput['cooldown'], StrikeRows['cooldown']>; readonly range: v.GenericSchema<StrikeRowsInput['range'], StrikeRows['range']>; readonly damage: v.GenericSchema<StrikeRowsInput['damage'], StrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<`${string}.${string}`>, undefined>, v.MaxLengthAction<StrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<StrikeRowsInput['weight'], StrikeRows['weight']>; readonly speed: v.GenericSchema<StrikeRowsInput['speed'], StrikeRows['speed']>; readonly overshoot: v.ExactOptionalSchema<v.GenericSchema<number, number>, undefined>; readonly units: v.ExactOptionalSchema<v.GenericSchema<StrikeUnits, StrikeUnits>, undefined>; }, undefined> = v.strictObject({ debris: v.exactOptional(StrikeDebrisSchema), id, shape, windup: nonnegative, active: nonnegative, recover: nonnegative, cooldown: nonnegative, range: dimension, damage: nonnegative,
|
|
38
41
|
tags: v.pipe(v.array(v.custom<`${string}.${string}`>((value) => typeof value === 'string' && value.length <= 128 && /^[a-z][a-zA-Z0-9.-]*\.[a-zA-Z0-9.-]+$/u.test(value))), v.maxLength(32)), weight: nonnegative, speed: v.pipe(nonnegative, v.maxValue(15)),
|
|
39
42
|
/** OF11b: a lane charge runs this far past its target (a challenge brain scores its charge by its own tuning). */
|
|
40
|
-
overshoot: v.exactOptional(overshoot)
|
|
43
|
+
overshoot: v.exactOptional(overshoot),
|
|
44
|
+
/** OF11b: how the shape's sizes follow the body's scale: `world` metres as written, `actor` times the scale. Absent, they
|
|
45
|
+
* grow with a body larger than scale 1 and never shrink (the engine runner's default, as every row so far meant). */
|
|
46
|
+
units: v.exactOptional(v.picklist(STRIKE_UNITS)) });
|
|
41
47
|
const numbers = v.strictObject({ overcast: unit, rain: unit, wet: unit, wind: unit, fog: unit });
|
|
42
48
|
const weather = v.strictObject({ id, states: v.pipe(v.array(v.strictObject({ id, next: id, length: ordered, numbers })), v.minLength(1), v.maxLength(64)), initial: numbers, soak: unit, dry: unit,
|
|
43
49
|
modes: v.pipe(v.array(v.strictObject({ id, hold: v.nullable(id), at: unit, dry: v.boolean() })), v.maxLength(64)) });
|
|
@@ -128,7 +134,7 @@ function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input
|
|
|
128
134
|
|
|
129
135
|
/** Admitted author data independent of validator implementation metadata. */
|
|
130
136
|
type StrikeRowsInput = StrikeRows;
|
|
131
|
-
interface StrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; overshoot?: number; }
|
|
137
|
+
interface StrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; overshoot?: number; units?: StrikeUnits; }
|
|
132
138
|
interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRowInput[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap<string>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
|
|
133
139
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
|
|
134
140
|
type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
|
|
@@ -322,7 +322,17 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
322
322
|
if (s.migrations.some(step => step.equipmentSlots?.some(rename => !s.items.rows.some(row => row.kind === 'weapon' && row.slot === rename.to)))) errors.push('migration equipment slots resolve declared weapons');
|
|
323
323
|
if ((s.items.runtimeContexts?.length ?? 0) > 0 && !pageOwner && s.runtime?.binds?.includes('items') !== true) errors.push('native input contexts require their declared page or runtime owner');
|
|
324
324
|
if (s.items.rows.some((row) => row.kind === 'tool' && row.action === null) && s.runtime?.binds?.includes('items') !== true) errors.push('native tools require runtime.binds items');
|
|
325
|
-
if (s.modes !== undefined && (s.modes.traverse.some(row => row.kind !== 'ladder') || (s.modes.ride?.length ?? 0) > 0 || (s.modes.grapple
|
|
325
|
+
if (s.modes !== undefined && (s.modes.traverse.some(row => row.kind !== 'ladder') || (s.modes.ride?.length ?? 0) > 0 || (s.modes.grapple ?? []).some((row): boolean => row.profile === undefined)) && !pageOwner && s.runtime?.binds?.includes('modes') !== true) errors.push('traverse modes require their declared page or runtime player phase');
|
|
326
|
+
// OF41c: a grapple row that carries its tool installs from the row alone (the engine's server grapple and page claw), so
|
|
327
|
+
// only a timing-only row needs a page or runtime above; the looks it draws with are graph looks the page compiles from
|
|
328
|
+
// look.materials
|
|
329
|
+
for (const row of s.modes?.grapple ?? []) {
|
|
330
|
+
for (const id of Object.values(row.profile?.looks ?? {})) {
|
|
331
|
+
if (s.look.materials[id] === undefined) {
|
|
332
|
+
errors.push(`grapple ${row.id} names look ${id}, which look.materials does not declare`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
326
336
|
if (s.runtime !== null && s.modes?.traverse.some(row => row.kind === 'ladder')) errors.push('ladder traversal requires the data-only player owner');
|
|
327
337
|
errors.push(...skinLookRules(s), ...attachmentFileRules({ species: s.rows.species, files: s.files, library: s.library, materials: s.look.materials }));
|
|
328
338
|
errors.push(...clientScriptRules(s));
|