@wildshard/shard-format 0.47.0 → 0.47.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.47.0",
3
+ "version": "0.47.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": {
@@ -21,8 +21,9 @@ export function clientOwnershipRules(source: Shardfile, sections: ReadonlyMap<st
21
21
  || !source.questNpcs?.some(row => !('kind' in row) && row.npc.id === quest.rows.npc)) errors.push('Data page requires its original declared quest and NPC');
22
22
  if (held?.kind !== 'held.melee' || source.items.loadout.primary !== held.item || source.items.loadout.secondary !== null
23
23
  || source.items.loadout.tools.length > 0 || !source.items.rows.some(row => row.kind === 'weapon' && row.id === held.item)) errors.push('Data page requires its one admitted held primary');
24
- if (source.creatures.spawns.length + source.rows.species.length + source.encounters.length + source.crowds.length > 0)
25
- errors.push('Data page native roster cannot also install a flat simulation roster');
24
+ // ONE-FORMAT OF19b0/OF19c0: declared spawns, their species and encounters run beside the plan's keeper (the engine
25
+ // refuses a body both own); declared crowds do not
26
+ if (source.crowds.length > 0) errors.push('Data page native roster cannot also install declared crowds');
26
27
  for (const name of ['world/scenes', 'world/targets', 'actors/species-programs', 'sim/runtime-plan', 'sim/scripts', 'look/painted'])
27
28
  if (!sections.has(name)) errors.push(`Data page requires ${name}`);
28
29
  const channels = new Set(source.clientChannels?.map(row => row.id));
@@ -34,9 +35,13 @@ export function clientOwnershipRules(source: Shardfile, sections: ReadonlyMap<st
34
35
  if (rawPlan !== undefined) {
35
36
  const plan = parseNativeRuntimePlan(rawPlan), owner = plan.recipe.population.owner;
36
37
  const bosses = features.filter(row => row.kind === 'boss.held' || row.kind === 'boss.spawned');
37
- if (bosses.length !== 1 || bosses.some(row => row.actor !== owner.actor || (row.kind === 'boss.held') !== (owner.profile.pattern === 'held')))
38
+ // OF19c0b: a plan with no owner row has no keeper boss for a page boss feature to draw (its boss is declared)
39
+ const expected = owner === undefined ? [] : [owner];
40
+ if (bosses.length !== expected.length || bosses.some(row => row.actor !== owner?.actor || (row.kind === 'boss.held') !== (owner.profile.pattern === 'held')))
38
41
  errors.push('Data page requires its actual native encounter pattern');
42
+ // A declared spawn is a body the quest may name too
39
43
  const actors = new Set(nativeRuntimeActorIds(plan));
44
+ for (const spawn of source.creatures.spawns) { actors.add(spawn.id); }
40
45
  if (source.questHost?.actors.ids.some(id => !actors.has(id))) errors.push('Data page quest requires actual native actors');
41
46
  }
42
47
  return errors;
@@ -42,7 +42,8 @@ const motion = v.objectWithRest({ systemId: key, skipPrefix: v.exactOptional(key
42
42
  permissions: v.pipe(v.array(v.strictObject({ mover: key, flags: v.pipe(v.array(v.strictObject({ name: key, bit: count })), v.maxLength(16)) })), v.maxLength(64)),
43
43
  }, v.unknown());
44
44
  const recipe = v.strictObject({
45
- population: v.strictObject({ rows: population, sources: v.picklist(['actors', 'actors+bosses']), seed: v.picklist(['identity', 'declared']), owner: BossOwnerRowSchema }),
45
+ // ONE-FORMAT OF19c0b: a plan whose boss is a declared encounter keeps no owner row (its keeper then stands no boss)
46
+ population: v.strictObject({ rows: population, sources: v.picklist(['actors', 'actors+bosses']), seed: v.picklist(['identity', 'declared']), owner: v.exactOptional(BossOwnerRowSchema) }),
46
47
  terrain: v.picklist(['none', 'collider']), floor: v.exactOptional(v.literal('solids')),
47
48
  ground: v.strictObject({ size: number, height: number }),
48
49
  player: v.strictObject({ speed: number, lift: v.exactOptional(number), at: v.exactOptional(triple), yaw: v.exactOptional(number) }),
@@ -57,13 +58,19 @@ const recipe = v.strictObject({
57
58
  export const NativeRuntimePlanSchema: v.GenericSchema<unknown, NativeRuntimePlanData> = v.pipe(v.unknown(), v.check(isJsonData, 'Native runtime plan must be plain bounded JSON'),
58
59
  v.strictObject({ kind: v.literal('held-melee'), recipe, baked: v.unknown(),
59
60
  ownerInputs: v.exactOptional(v.pipe(v.array(key), v.maxLength(16))) }),
61
+ // A plan with no owner row has no owner inputs to order
60
62
  v.check(row => row.ownerInputs === undefined || (new Set(row.ownerInputs).size === row.ownerInputs.length
61
- && row.ownerInputs.length === Object.keys(row.recipe.population.owner.stages.inputs).length
62
- && row.ownerInputs.every(name => Object.hasOwn(row.recipe.population.owner.stages.inputs, name))), 'Exact native owner input order'),
63
+ && row.ownerInputs.length === Object.keys(row.recipe.population.owner?.stages.inputs ?? {}).length
64
+ && row.ownerInputs.every(name => Object.hasOwn(row.recipe.population.owner?.stages.inputs ?? {}, name))), 'Exact native owner input order'),
63
65
  v.transform(row => {
64
66
  // Canonical section JSON sorts object keys. Retain the authored director
65
67
  // input order explicitly because existing save contracts include that order.
66
- const owner = row.recipe.population.owner, ownerInputs = row.ownerInputs ?? Object.keys(owner.stages.inputs);
68
+ const owner = row.recipe.population.owner, ownerInputs = row.ownerInputs ?? Object.keys(owner?.stages.inputs ?? {});
69
+ // OF19c0b: a keeper that stands a boss needs the owner row that fights it; one with none stands only its homes
70
+ if (owner === undefined) {
71
+ if (row.recipe.population.rows.boss !== undefined) { throw new Error('A native keeper boss needs its owner row'); }
72
+ return { ...row, ownerInputs };
73
+ }
67
74
  const inputs = Object.fromEntries(ownerInputs.map(name => {
68
75
  const binding = owner.stages.inputs[name];
69
76
  if (binding === undefined) throw new Error('Missing native owner input');
@@ -86,4 +93,4 @@ export function nativeRuntimeActorIds(input: unknown): readonly string[] {
86
93
  }
87
94
 
88
95
  /** Admitted native recipe data; owner input ordering remains validated by the root schema. */
89
- export interface NativeRuntimeRecipeData { population: { rows: { program: { species: ({ id: string; kind: string; label: string; variants: ({ id: string; label: string; weight: number; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; scale: [number, number]; } & Record<string, unknown>)[]; brain?: v.InferOutput<typeof SpeciesBrainSchema>; body?: v.InferOutput<typeof CreatureBodyRecipeSchema>; } & Record<string, unknown>)[]; strikes: (v.InferOutput<typeof CreatureStrikeSchema>)[]; modules?: Record<string, string>; }; step: string; seed: number; homes: ({ id: string; kind: string; at: [number, number]; yaw: number; respawn: number; look?: string; late?: (boolean) | ('ground'); })[]; boss?: { id: string; kind: string; at: [number, number]; yaw: number; look?: string; }; attackers: (number) | null; think: ('legacy') | ({ every: number; dt: number; }); killY?: number; admission: 'prepare' | 'install'; placement?: { fallback: number; rows: ({ id: string; fromY: number; home: { x: number; z: number; r: number; y: number; }; })[]; }; holds?: ({ home: number; field: string; until: string; })[]; } & Record<string, unknown>; sources: 'actors' | 'actors+bosses'; seed: 'identity' | 'declared'; owner: v.InferOutput<typeof BossOwnerRowSchema>; }; terrain: 'none' | 'collider'; floor?: 'solids'; ground: { size: number; height: number; }; player: { speed: number; lift?: number; at?: [number, number, number]; yaw?: number; }; motion?: { systemId: string; skipPrefix?: string; composition: { sim: { bindings: v.InferOutput<typeof ScriptBindingsSchema>; scriptTickDivisor: number; }; state: Pick<v.InferOutput<(typeof StateSchema.pipe)[0]>, 'shared' | 'player'>; }; rules: { fields: Record<string, [number, number]>; archetypes: (number)[]; events: (number)[]; maxEntities: number; }; permissions: ({ mover: string; flags: ({ name: string; bit: number; })[]; })[]; } & Record<string, unknown>; runtime: { weapon: { id: string; stowOnBoard?: boolean; questWorld?: boolean; worldReactionAction?: number; }; quest: { spots: ('metadata') | ({ interact: ({ id: string; x: number; y: number; z: number; radius: number; })[]; crack: ({ id: string; x: number; y: number; z: number; radius: number; })[]; }); crack?: boolean; }; columns?: boolean; entries?: { lanes: number; walk: number; start: number; maxTicks: number; ramp?: { at: number; run: number; height: number; stride: number; look: number; halfWidths: { north: number; east: number; south: number; west: number; }; }; }; }; }
96
+ export interface NativeRuntimeRecipeData { population: { rows: { program: { species: ({ id: string; kind: string; label: string; variants: ({ id: string; label: string; weight: number; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; scale: [number, number]; } & Record<string, unknown>)[]; brain?: v.InferOutput<typeof SpeciesBrainSchema>; body?: v.InferOutput<typeof CreatureBodyRecipeSchema>; } & Record<string, unknown>)[]; strikes: (v.InferOutput<typeof CreatureStrikeSchema>)[]; modules?: Record<string, string>; }; step: string; seed: number; homes: ({ id: string; kind: string; at: [number, number]; yaw: number; respawn: number; look?: string; late?: (boolean) | ('ground'); })[]; boss?: { id: string; kind: string; at: [number, number]; yaw: number; look?: string; }; attackers: (number) | null; think: ('legacy') | ({ every: number; dt: number; }); killY?: number; admission: 'prepare' | 'install'; placement?: { fallback: number; rows: ({ id: string; fromY: number; home: { x: number; z: number; r: number; y: number; }; })[]; }; holds?: ({ home: number; field: string; until: string; })[]; } & Record<string, unknown>; sources: 'actors' | 'actors+bosses'; seed: 'identity' | 'declared'; owner?: v.InferOutput<typeof BossOwnerRowSchema>; }; terrain: 'none' | 'collider'; floor?: 'solids'; ground: { size: number; height: number; }; player: { speed: number; lift?: number; at?: [number, number, number]; yaw?: number; }; motion?: { systemId: string; skipPrefix?: string; composition: { sim: { bindings: v.InferOutput<typeof ScriptBindingsSchema>; scriptTickDivisor: number; }; state: Pick<v.InferOutput<(typeof StateSchema.pipe)[0]>, 'shared' | 'player'>; }; rules: { fields: Record<string, [number, number]>; archetypes: (number)[]; events: (number)[]; maxEntities: number; }; permissions: ({ mover: string; flags: ({ name: string; bit: number; })[]; })[]; } & Record<string, unknown>; runtime: { weapon: { id: string; stowOnBoard?: boolean; questWorld?: boolean; worldReactionAction?: number; }; quest: { spots: ('metadata') | ({ interact: ({ id: string; x: number; y: number; z: number; radius: number; })[]; crack: ({ id: string; x: number; y: number; z: number; radius: number; })[]; }); crack?: boolean; }; columns?: boolean; entries?: { lanes: number; walk: number; start: number; maxTicks: number; ramp?: { at: number; run: number; height: number; stride: number; look: number; halfWidths: { north: number; east: number; south: number; west: number; }; }; }; }; }