@wildshard/shard-format 0.53.0 → 0.55.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.
|
|
3
|
+
"version": "0.55.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/creatures.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { CreaturePatrolsSchema, patrolsAdmitted, GroupBrainSchema, groupBrainRul
|
|
|
12
12
|
import { RamGrazerSchema, ChallengeGrazerSchema, GrazerSchema } from './grazers.ts';
|
|
13
13
|
import { DiverSchema, OrbitDiverSchema, PatrolDiverSchema, BurstFlyerSchema } from './flyers.ts';
|
|
14
14
|
/** One creature spawn row; input and output differ only in the home they carry. */
|
|
15
|
-
interface CreatureSpawnRow<Home> { hold?: { field: string; until: string }; perchBody?: string; group?: string; rank?: 'veteran' | 'elite' | 'champion' | 'legendary'; count?: { per: number; max: number }; when?: { quest?: { id: string; stage: number }; time?: 'day' | 'night'; wave?: { set: string; index: number } }; phaseOffset?: number | undefined; respawn?: number | undefined; home?: Home | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; }
|
|
15
|
+
interface CreatureSpawnRow<Home> { hold?: { field: string; until: string }; perchBody?: string; group?: string; rank?: 'veteran' | 'elite' | 'champion' | 'legendary'; count?: { per: number; max: number }; when?: { quest?: { id: string; stage: number }; time?: 'day' | 'night'; wave?: { set: string; index: number } }; phaseOffset?: number | undefined; respawn?: number | undefined; respawnWhen?: CreatureRespawnWhen; home?: Home | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; }
|
|
16
16
|
|
|
17
17
|
const ID_LENGTH = 128;
|
|
18
18
|
const id = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.:-]*$/u), v.maxLength(ID_LENGTH));
|
|
@@ -67,6 +67,17 @@ const phase = v.pipe(finite, v.minValue(-2 * Math.PI), v.maxValue(2 * Math.PI));
|
|
|
67
67
|
/** Seconds after its death that a spawn's body comes back at its `at` (TEMPLATE-E2E TC-E2); absent, it stays dead. */
|
|
68
68
|
const RESPAWN_MAX = 3600, RESPAWN_MIN = 1;
|
|
69
69
|
const respawn = v.pipe(finite, v.minValue(RESPAWN_MIN), v.maxValue(RESPAWN_MAX));
|
|
70
|
+
const RESPAWN_AWAY_MAX = 250, RESPAWN_FADE_MAX = 60, RESPAWN_LEAST = 0;
|
|
71
|
+
/** OF22b3: what else a return waits for once its `respawn` seconds are spent, as an island's returns do: up to `spread` more
|
|
72
|
+
* seconds (one seeded draw a death), no player within `away` metres of its `at`, night when `night`, then `fade` seconds
|
|
73
|
+
* for the fallen body to fade before the new one stands. */
|
|
74
|
+
const respawnSpread = v.pipe(finite, v.minValue(RESPAWN_LEAST), v.maxValue(RESPAWN_MAX));
|
|
75
|
+
const respawnAway = v.pipe(finite, v.minValue(RESPAWN_LEAST), v.maxValue(RESPAWN_AWAY_MAX));
|
|
76
|
+
const respawnFade = v.pipe(finite, v.minValue(RESPAWN_LEAST), v.maxValue(RESPAWN_FADE_MAX));
|
|
77
|
+
const respawnWhen = v.strictObject({ spread: v.exactOptional(respawnSpread), away: v.exactOptional(respawnAway),
|
|
78
|
+
night: v.exactOptional(v.literal(true)), fade: v.exactOptional(respawnFade) }, 'unknown respawn condition');
|
|
79
|
+
/** OF22b3: a timed return's further conditions (`respawnWhen`). */
|
|
80
|
+
interface CreatureRespawnWhen { spread?: number; away?: number; night?: true; fade?: number }
|
|
70
81
|
/** Social membership names no controller; the species temperament owns assistance. */
|
|
71
82
|
/** OF28: the rank names of ./creature-ranks.ts (kept in step by its test); the engine applies the multipliers. */
|
|
72
83
|
const rank = v.picklist(['veteran', 'elite', 'champion', 'legendary'], 'unknown creature rank');
|
|
@@ -87,20 +98,21 @@ const timeWhen = v.picklist(['day', 'night'], 'unknown spawn time');
|
|
|
87
98
|
const when = v.strictObject({ quest: v.exactOptional(questWhen), time: v.exactOptional(timeWhen), wave: v.exactOptional(waveWhen) }, 'unknown spawn condition');
|
|
88
99
|
// OF19b: the body's memory `field` reads 1 until the quest flag `until` is set (a runtime plan's population `holds` row)
|
|
89
100
|
const hold = v.strictObject({ field: memoryKey, until: id });
|
|
90
|
-
const spawn = v.strictObject({ hold: v.exactOptional(hold), perchBody: v.exactOptional(id), group: v.exactOptional(id), rank: v.exactOptional(rank), count: v.exactOptional(count), when: v.exactOptional(when), phaseOffset: v.optional(phase), home: v.optional(CreatureHomeSchema), respawn: v.optional(respawn), id, species: speciesId, variant: id, brain: v.nullable(id), strike: v.nullable(id), seed: v.pipe(finite, v.integer(), v.minValue(0), v.maxValue(0xffffffff)), scale: v.pipe(finite, v.minValue(0.1), v.maxValue(10)), at: v.tuple([coord, coord, coord]), yaw: finite });
|
|
101
|
+
const spawn = v.strictObject({ hold: v.exactOptional(hold), perchBody: v.exactOptional(id), group: v.exactOptional(id), rank: v.exactOptional(rank), count: v.exactOptional(count), when: v.exactOptional(when), phaseOffset: v.optional(phase), home: v.optional(CreatureHomeSchema), respawn: v.optional(respawn), respawnWhen: v.exactOptional(respawnWhen), id, species: speciesId, variant: id, brain: v.nullable(id), strike: v.nullable(id), seed: v.pipe(finite, v.integer(), v.minValue(0), v.maxValue(0xffffffff)), scale: v.pipe(finite, v.minValue(0.1), v.maxValue(10)), at: v.tuple([coord, coord, coord]), yaw: finite });
|
|
91
102
|
/** Pure-data creature archetypes and stable spawn layouts, expanded before the local sim boots. */
|
|
92
103
|
export const CreaturesSchema: v.GenericSchema<ShardCreaturesInput, ShardCreatures> = v.pipe(v.strictObject({ perchBodies: v.exactOptional(CreaturePerchBodiesSchema), brains: v.pipe(v.array(v.variant('kind', [brain, SkirmisherSchema, GuardianSchema, PerchHunterSchema, ScriptBrainSchema, RamGrazerSchema, ChallengeGrazerSchema, OrbitDiverSchema, PatrolDiverSchema, BurstFlyerSchema, GrazerSchema, DiverSchema, GuardianPatternsSchema, StalkerSchema])), v.maxLength(64)), groups: v.optional(v.pipe(v.array(GroupBrainSchema), v.maxLength(64)), []), patrols: v.exactOptional(CreaturePatrolsSchema), spawns: v.pipe(v.array(spawn), v.maxLength(10000)) }),
|
|
93
104
|
v.check((c) => creatureRules(c).length === 0 && patrolsAdmitted(c.patrols ?? [], c.spawns, c.groups), 'creature reference rules'));
|
|
94
105
|
/** Validated brain parameters and spawn layout, with no rig or runtime closure. */
|
|
95
106
|
|
|
96
107
|
/** Unique ids and brain references; species and strikes are resolved against the loader's declared catalogues. */
|
|
97
|
-
export function creatureRules(content: { brains: readonly { id: string; kind?: string; pattern?: string }[]; groups?: readonly { id: string; members: readonly string[] }[]; perchBodies?: readonly { id: string; policy: { kind: string; strike: string }; projectile: { pool: { count: number } } }[]; spawns: readonly { id: string; species?: string; strike?: string | null; brain: string | null; home?: unknown; phaseOffset?: unknown; perchBody?: string }[] }): string[] {
|
|
108
|
+
export function creatureRules(content: { brains: readonly { id: string; kind?: string; pattern?: string }[]; groups?: readonly { id: string; members: readonly string[] }[]; perchBodies?: readonly { id: string; policy: { kind: string; strike: string }; projectile: { pool: { count: number } } }[]; spawns: readonly { id: string; species?: string; strike?: string | null; brain: string | null; home?: unknown; phaseOffset?: unknown; perchBody?: string; respawn?: number | undefined; respawnWhen?: unknown }[] }): string[] {
|
|
98
109
|
const errors: string[] = [], brains = new Set(content.brains.map((b) => b.id));
|
|
99
110
|
if (brains.size !== content.brains.length) errors.push('unique brain ids');
|
|
100
111
|
for (const group of content.groups ?? []) { if (brains.has(group.id)) errors.push('unique controller ids'); brains.add(group.id); }
|
|
101
112
|
if (new Set(content.spawns.map((s) => s.id)).size !== content.spawns.length) errors.push('unique spawn ids');
|
|
102
113
|
if (content.spawns.some((s) => s.brain !== null && !brains.has(s.brain))) errors.push('declared spawn brain');
|
|
103
114
|
for (const body of content.spawns) {
|
|
115
|
+
if (body.respawnWhen !== undefined && body.respawn === undefined) { errors.push('a respawn condition needs its respawn'); }
|
|
104
116
|
const policy = content.brains.find(row => row.id === body.brain);
|
|
105
117
|
if (body.phaseOffset !== undefined && !(policy?.kind === 'challenge-grazer'
|
|
106
118
|
|| (policy?.kind === 'grazer' && policy.pattern === 'circle-challenge'))) errors.push('declared per-body circle phase policy');
|
package/src/format/items.ts
CHANGED
|
@@ -204,7 +204,11 @@ export function itemRules(items: ShardItems, modules?: readonly string[]): strin
|
|
|
204
204
|
const items: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, 'JSON-only items'>, typeof raw, v.CheckAction<ShardItems, 'valid item references'>]> = v.pipe(v.unknown(), v.check(isJsonData, 'JSON-only items'), raw, v.check((data) => itemRules(data).length === 0, 'valid item references'));
|
|
205
205
|
/** JSON-only admission rejects closures before serialisation and checks all item/loadout references.
|
|
206
206
|
* The named output bounds root-schema inference; pipe identities remain available to the JSON Schema bridge. */
|
|
207
|
-
|
|
207
|
+
// ONE-FORMAT OF22d1: the swept policy is also the `held/melee` section, a shard's swept sword kit as a declared row (Q-S8,
|
|
208
|
+
// J367 (4)): what a native plan's `item.swept` host read from a server file. A native world whose plan names no `item.swept`
|
|
209
|
+
// host stands its melee from the section.
|
|
210
|
+
export const HeldMeleeSchema: v.GenericSchema<NativeSweptPolicyRowsInput, NativeSweptPolicyRows> = sweptPolicy,
|
|
211
|
+
ItemsSchema: v.GenericSchema<unknown, ShardItems> & Pick<typeof items, 'pipe'> = items;
|
|
208
212
|
/** Validate authored item rows at both SDK and browser boundaries. */
|
|
209
213
|
export function parseItems(input: unknown): ShardItems { return v.parse(ItemsSchema, input); }
|
|
210
214
|
|
|
@@ -65,6 +65,7 @@ const DATA_SECTION_NAMES: Readonly<Record<keyof PlatformDataSections, true>> = {
|
|
|
65
65
|
"held/finishes": true,
|
|
66
66
|
"held/loadout": true,
|
|
67
67
|
"held/equipment": true,
|
|
68
|
+
"held/melee": true,
|
|
68
69
|
"ui/completion": true,
|
|
69
70
|
"sim/runtime-plan": true,
|
|
70
71
|
"actors/species-programs": true,
|
|
@@ -18,6 +18,8 @@ import { HeldFinishesSchema, type HeldFinishesRows } from './heldFinishes.ts';
|
|
|
18
18
|
import { HeldGearSchema, type HeldGearRows } from './heldGear.ts';
|
|
19
19
|
import * as v from 'valibot';
|
|
20
20
|
import { HeldEquipmentSchema, type HeldEquipmentRows } from './heldEquipment.ts';
|
|
21
|
+
import { HeldMeleeSchema } from './items.ts';
|
|
22
|
+
import type { NativeSweptPolicyRows } from './items.ts';
|
|
21
23
|
import { CompletionSchema, type CompletionRows } from './completion.ts';
|
|
22
24
|
import { SpeciesProgramsSchema, type SpeciesPrograms } from './speciesPrograms.ts';
|
|
23
25
|
import { CreatureStrikesSchema, type CreatureStrikes } from './creatures.ts';
|
|
@@ -52,6 +54,7 @@ export interface PlatformDataSections {
|
|
|
52
54
|
'held/finishes': HeldFinishesRows;
|
|
53
55
|
'held/loadout': LoadoutRows;
|
|
54
56
|
'held/equipment': HeldEquipmentRows;
|
|
57
|
+
'held/melee': NativeSweptPolicyRows;
|
|
55
58
|
'ui/completion': CompletionRows;
|
|
56
59
|
'sim/runtime-plan': NativeRuntimePlanData;
|
|
57
60
|
'actors/species-programs': SpeciesPrograms;
|
|
@@ -88,6 +91,7 @@ export const PLATFORM_DATA_SECTIONS: Readonly<{ [Name in keyof PlatformDataSecti
|
|
|
88
91
|
'held/finishes': { schema: HeldFinishesSchema },
|
|
89
92
|
'held/loadout': { schema: LoadoutSchema },
|
|
90
93
|
'held/equipment': { schema: HeldEquipmentSchema },
|
|
94
|
+
'held/melee': { schema: HeldMeleeSchema },
|
|
91
95
|
'ui/completion': { schema: CompletionSchema },
|
|
92
96
|
'sim/runtime-plan': { schema: NativeRuntimePlanSchema },
|
|
93
97
|
'actors/species-programs': { schema: SpeciesProgramsSchema },
|
package/src/format/sections.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { ToonLookRow } from './toonLook.ts';
|
|
|
10
10
|
import type { KeyedSkyStyle } from './keyedSky.ts';
|
|
11
11
|
import type { SpawnScriptRows } from './spawnScripts.ts';
|
|
12
12
|
import type { ClientPlan } from './clientPlan.ts';
|
|
13
|
+
import type { NativeSweptPolicyRows } from './items.ts';
|
|
13
14
|
import type { ReturnModuleRow, ViewModuleRow } from './scriptContract.ts';
|
|
14
15
|
import type { WorldScenesSection } from './worldScenes.ts';
|
|
15
16
|
import type { TreeSetRows } from './treeSetRows.ts';
|
|
@@ -66,6 +67,8 @@ export interface PlatformSections {
|
|
|
66
67
|
'held/finishes': HeldFinishesRows;
|
|
67
68
|
'held/loadout': LoadoutRows;
|
|
68
69
|
'held/equipment': HeldEquipmentRows;
|
|
70
|
+
/** ONE-FORMAT OF22d1: the swept sword kit, read by a native world with no `item.swept` host. */
|
|
71
|
+
'held/melee': NativeSweptPolicyRows;
|
|
69
72
|
'ui/completion': CompletionRows;
|
|
70
73
|
/** Existing native owners selected by admitted data, never client runtime code. */
|
|
71
74
|
'sim/runtime-plan': NativeRuntimePlanData;
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"held/equipment": {
|
|
68
68
|
"hosts": ["page HeldEquipment"]
|
|
69
69
|
},
|
|
70
|
+
"held/melee": {
|
|
71
|
+
"hosts": [],
|
|
72
|
+
"note": "Read by a native world whose plan names no item.swept host (engine, meta ONE-FORMAT OF22d2); until then each shard's item.swept host reads its server policy file."
|
|
73
|
+
},
|
|
70
74
|
"held/finishes": {
|
|
71
75
|
"hosts": ["page HeldFinishes"]
|
|
72
76
|
},
|