@wildshard/shard-format 0.10.0 → 0.11.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.11.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": {
|
|
@@ -26,6 +26,7 @@ import { MeshCollisionSchema, meshCollisionRules } from './meshCollision.ts';
|
|
|
26
26
|
import { NativeGroundSchema, nativeGroundRules } from './nativeGround.ts';
|
|
27
27
|
import { WaterSchema } from './water.ts';
|
|
28
28
|
import { CreaturesSchema } from './creatures.ts';
|
|
29
|
+
import type { ShardCreatures } from './creatures.ts';
|
|
29
30
|
import { FlockSchema } from './crowds.ts';
|
|
30
31
|
import { groupBrainRules } from './groupBrains.ts';
|
|
31
32
|
import { EncountersSchema, encounterRules } from './encounters.ts';
|
|
@@ -363,7 +364,20 @@ export function shardfileRules(s: Shardfile): string[] {
|
|
|
363
364
|
errors.push(...encounterRules(s.encounters, s.creatures.spawns.map((spawn) => spawn.id), s.ui.filter((row) => row.kind === 'bossPanel')));
|
|
364
365
|
const controlled = new Set(s.encounters.map((row) => row.entity));
|
|
365
366
|
errors.push(...groupBrainRules(s.creatures.groups, s.creatures.spawns, s.creatures.brains.map((row) => row.id), [...controlled]));
|
|
366
|
-
|
|
367
|
+
// Keep every previously admitted named/encounter controller. Only the formerly
|
|
368
|
+
// unowned null-brain case is extended to an actual engine policy or declaration.
|
|
369
|
+
const inlineBrains: Record<ShardCreatures['brains'][number]['kind'] | 'hunt', true> = {
|
|
370
|
+
hunt: true, pursue: true, skirmisher: true, guardian: true, 'perch-hunter': true,
|
|
371
|
+
script: true, 'ram-grazer': true, 'challenge-grazer': true, 'orbit-diver': true,
|
|
372
|
+
'patrol-diver': true, 'burst-flyer': true, grazer: true, diver: true, stalker: true,
|
|
373
|
+
};
|
|
374
|
+
if (s.creatures.spawns.some((row) => {
|
|
375
|
+
if (controlled.has(row.id)) { return row.brain !== null; }
|
|
376
|
+
if (row.brain !== null) { return false; }
|
|
377
|
+
const brain = species.get(row.species)?.temperament?.brain;
|
|
378
|
+
return brain === undefined || !(Object.hasOwn(inlineBrains, brain)
|
|
379
|
+
|| s.creatures.brains.some((declaration: { readonly id: string }): boolean => declaration.id === brain));
|
|
380
|
+
})) errors.push('exactly one declared creature controller');
|
|
367
381
|
return [...new Set(errors)];
|
|
368
382
|
}
|
|
369
383
|
/** Strict schema for the public SDK format; rejects unknown fields and invalid references.
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
minValue,
|
|
11
11
|
number,
|
|
12
12
|
pipe,
|
|
13
|
+
picklist,
|
|
13
14
|
regex,
|
|
14
15
|
strictObject,
|
|
15
16
|
string,
|
|
@@ -35,10 +36,7 @@ const MAX_PARTICLES = 64
|
|
|
35
36
|
const MAX_OVERRIDES = 64
|
|
36
37
|
const MAX_ID = 128
|
|
37
38
|
const EMPTY = 0
|
|
38
|
-
const surface =
|
|
39
|
-
(value: unknown): boolean =>
|
|
40
|
-
value === 'shell' || value === 'wood' || value === 'sand',
|
|
41
|
-
)
|
|
39
|
+
const surface = picklist(['shell', 'wood', 'sand'])
|
|
42
40
|
const count = pipe(
|
|
43
41
|
number(),
|
|
44
42
|
integer(),
|
|
@@ -74,8 +72,11 @@ const policy = strictObject({
|
|
|
74
72
|
default: effect,
|
|
75
73
|
overrides: exactOptional(overrides),
|
|
76
74
|
})
|
|
75
|
+
/** Exact plain-data preflight identity for structural JSON Schema projectors. */
|
|
76
|
+
const StrikeDebrisJsonGuard: GenericSchema<StrikeDebrisPolicy> =
|
|
77
|
+
custom<StrikeDebrisPolicy>(isJsonData, 'plain strike debris')
|
|
77
78
|
const StrikeDebrisSchema: GenericSchema<StrikeDebrisPolicy> = pipe(
|
|
78
|
-
|
|
79
|
+
StrikeDebrisJsonGuard,
|
|
79
80
|
policy,
|
|
80
81
|
)
|
|
81
82
|
|
|
@@ -104,5 +105,5 @@ function strikeDebrisCatalogueRules(value: StrikeDebrisCatalogue): string[] {
|
|
|
104
105
|
}
|
|
105
106
|
return errors
|
|
106
107
|
}
|
|
107
|
-
export { StrikeDebrisSchema, strikeDebrisCatalogueRules }
|
|
108
|
+
export { StrikeDebrisSchema, StrikeDebrisJsonGuard, strikeDebrisCatalogueRules }
|
|
108
109
|
export type { StrikeDebris, StrikeDebrisPolicy, StrikeDebrisCatalogue }
|