@wildshard/shard-format 0.61.0 → 0.63.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 +1 -1
- package/src/format/rows.ts +13 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.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": {
|
package/src/format/rows.ts
CHANGED
|
@@ -47,6 +47,11 @@ const strike: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.Ge
|
|
|
47
47
|
const numbers = v.strictObject({ overcast: unit, rain: unit, wet: unit, wind: unit, fog: unit });
|
|
48
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,
|
|
49
49
|
modes: v.pipe(v.array(v.strictObject({ id, hold: v.nullable(id), at: unit, dry: v.boolean() })), v.maxLength(64)) });
|
|
50
|
+
/** OF23e3: a weather row may name its program instead of a plain chain: a product file the server parses as a
|
|
51
|
+
* `WeatherProgram` and runs (the rows a native assembly's `weather.program` host read; Pine's `world/weather.json`). */
|
|
52
|
+
const programFile = v.pipe(text, v.nonEmpty());
|
|
53
|
+
const programWeather = v.strictObject({ id, program: programFile });
|
|
54
|
+
const weatherRow = v.union([weather, programWeather]);
|
|
50
55
|
const hour = v.pipe(finite, v.minValue(0), v.maxValue(24));
|
|
51
56
|
const day = v.strictObject({ id, units: v.literal('hour'), start: hour,
|
|
52
57
|
schedule: v.pipe(v.array(v.strictObject({ phase: v.picklist(['dawn', 'day', 'golden', 'dusk', 'night']), from: hour, to: hour, minutes: duration })), v.minLength(1), v.maxLength(64)),
|
|
@@ -81,7 +86,7 @@ const loot = v.union([
|
|
|
81
86
|
v.strictObject({ id, gear: v.literal('purse.coins'), finds: v.null(), marks: v.null(), charted: v.boolean(), chime: id, economy: v.exactOptional(LootEconomySchema) }),
|
|
82
87
|
v.strictObject({ id, economy: BarterEconomySchema }),
|
|
83
88
|
]);
|
|
84
|
-
const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v.ArraySchema<typeof strike, undefined>, v.MaxLengthAction<ShardRows['strikes'], 256, undefined>]>; readonly weather: v.GenericSchema<ShardRowsInput['weather'], ShardRows['weather']>; readonly days: v.GenericSchema<ShardRowsInput['days'], ShardRows['days']>; readonly species: v.GenericSchema<ShardRowsInput['species'], ShardRows['species']>; readonly looks: v.GenericSchema<ShardRowsInput['looks'], ShardRows['looks']>; readonly compendiums: v.GenericSchema<ShardRowsInput['compendiums'], ShardRows['compendiums']>; readonly loot: v.GenericSchema<ShardRowsInput['loot'], ShardRows['loot']>; }, undefined> = v.strictObject({ strikes: v.pipe(v.array(strike), v.maxLength(256)), weather: v.pipe(v.array(
|
|
89
|
+
const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v.ArraySchema<typeof strike, undefined>, v.MaxLengthAction<ShardRows['strikes'], 256, undefined>]>; readonly weather: v.GenericSchema<ShardRowsInput['weather'], ShardRows['weather']>; readonly days: v.GenericSchema<ShardRowsInput['days'], ShardRows['days']>; readonly species: v.GenericSchema<ShardRowsInput['species'], ShardRows['species']>; readonly looks: v.GenericSchema<ShardRowsInput['looks'], ShardRows['looks']>; readonly compendiums: v.GenericSchema<ShardRowsInput['compendiums'], ShardRows['compendiums']>; readonly loot: v.GenericSchema<ShardRowsInput['loot'], ShardRows['loot']>; }, undefined> = v.strictObject({ strikes: v.pipe(v.array(strike), v.maxLength(256)), weather: v.pipe(v.array(weatherRow), v.maxLength(16)), days: v.pipe(v.array(day), v.maxLength(16)),
|
|
85
90
|
species: v.pipe(v.array(species), v.maxLength(256)), looks: v.pipe(v.array(look), v.maxLength(256)), compendiums: v.pipe(v.array(v.union([basicCompendium, JournalRowSchema])), v.maxLength(16)), loot: v.pipe(v.array(loot), v.maxLength(16)) });
|
|
86
91
|
/** Pure author rows: numeric weights, state output tables, clocks and registered view/presentation recipes. */
|
|
87
92
|
|
|
@@ -90,9 +95,12 @@ function rowRules(rows: ShardRows): string[] {
|
|
|
90
95
|
const errors: string[] = harvestSpeciesRules(rows.species);
|
|
91
96
|
for (const list of Object.values(rows)) if (new Set(list.map((r) => r.id)).size !== list.length) errors.push('unique row ids');
|
|
92
97
|
for (const row of rows.loot) if (row.economy !== undefined && !('kind' in row.economy)) errors.push(...lootEconomyRules(row.economy));
|
|
98
|
+
// OF23e3: a row that names its program has no chain to check
|
|
93
99
|
for (const w of rows.weather) {
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
if (!('program' in w)) {
|
|
101
|
+
const states = new Set(w.states.map((s) => s.id));
|
|
102
|
+
if (states.size !== w.states.length || w.states.some((s) => !states.has(s.next)) || w.modes.some((m) => m.hold !== null && !states.has(m.hold)) || new Set(w.modes.map((m) => m.id)).size !== w.modes.length) errors.push('weather states and transitions');
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
for (const d of rows.days) if (d.schedule[0]?.from !== 0 || d.schedule.at(-1)?.to !== 24 || d.schedule.some((s, i) => s.from >= s.to || (i > 0 && d.schedule[i - 1]?.to !== s.from))) errors.push('complete ordered day schedule');
|
|
98
106
|
const speciesIds = new Set(rows.species.map((s) => s.id));
|
|
@@ -135,9 +143,9 @@ function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input
|
|
|
135
143
|
/** Admitted author data independent of validator implementation metadata. */
|
|
136
144
|
type StrikeRowsInput = StrikeRows;
|
|
137
145
|
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; }
|
|
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>; }))[]; }
|
|
146
|
+
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; })[]; }) | ({ id: string; program: string; }))[]; 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>; }))[]; }
|
|
139
147
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
|
|
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>; }))[]; };
|
|
148
|
+
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; })[]; }) | ({ id: string; program: string; }))[]; 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>; }))[]; };
|
|
141
149
|
|
|
142
150
|
type SpeciesRowInput = Omit<SpeciesRow, "abilities"> & { abilities?: CreatureAbilityInput[] };
|
|
143
151
|
|