@wildshard/shard-format 0.16.0 → 0.18.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.18.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": {
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"./contracts": "./src/format/contracts.ts",
|
|
105
105
|
"./coverAppearance": "./src/format/coverAppearance.ts",
|
|
106
106
|
"./creatures": "./src/format/creatures.ts",
|
|
107
|
+
"./creaturePerch": "./src/format/creature-perch.ts",
|
|
107
108
|
"./creatureLayers": "./src/format/creature-layers.ts",
|
|
108
109
|
"./creatureSkeletons": "./src/format/creature-skeletons.ts",
|
|
109
110
|
"./crowdPresentation": "./src/format/crowdPresentation.ts",
|
|
@@ -440,7 +441,7 @@
|
|
|
440
441
|
"packageManager": "pnpm@10.34.9",
|
|
441
442
|
"scripts": {
|
|
442
443
|
"pnpm:devPreinstall": "git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath .githooks || true",
|
|
443
|
-
"typecheck": "npr tsc -p kit/tsconfig.json && npr tsc -p src/format/tsconfig.json && npr tsc -p src/format/tsconfig.lib.json",
|
|
444
|
+
"typecheck": "npr tsc -p kit/tsconfig.json && npr tsc -p src/format/tsconfig.json && npr tsc -p src/format/tsconfig.lib.json && npr tsc -p tsconfig.browser-tools.json",
|
|
444
445
|
"lint": "node kit/scripts/lint.mjs --type-aware --deny-warnings --no-error-on-unmatched-pattern --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'scripts/scratch-sweep*' --ignore-pattern 'scripts/lane-live*' --ignore-pattern 'scripts/leftovers-report*' --ignore-pattern 'scripts/keep-copy*' --ignore-pattern 'scripts/disk-audit*' --ignore-pattern 'test/tooling/disk-land.test.mjs' --ignore-pattern 'test/tooling/land-fixture.mjs' --ignore-pattern 'test/tooling/owned-scratch.mjs' --ignore-pattern 'test/tooling/lane-live.test.mjs' --ignore-pattern 'test/tooling/keep-copy.test.mjs' --ignore-pattern 'test/tooling/leftovers-report.test.mjs' --ignore-pattern 'test/tooling/reap-report.test.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**' --ignore-pattern 'scripts/chromium-keychain*' --ignore-pattern 'scripts/worktree-ignore*' --ignore-pattern 'scripts/land*' --ignore-pattern 'scripts/main-push*' --ignore-pattern 'scripts/worktree.mjs' --ignore-pattern 'scripts/worktree-reap.mjs' --ignore-pattern 'scripts/pid-lock*' --ignore-pattern 'scripts/apfs-clone.mjs' --ignore-pattern 'scripts/assert-store-layout.mjs' --ignore-pattern 'test/tooling/worktree-guard.test.mjs' --ignore-pattern 'scripts/vite-tmp*' --ignore-pattern 'vitest.config.ts' --ignore-pattern 'test/tooling/chrome-keychain.test.mjs' --ignore-pattern 'packages/wire/frozen/**' --ignore-pattern 'packages/wire/lib/**'",
|
|
445
446
|
"lint:fix": "node kit/scripts/lint.mjs --type-aware --fix --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'scripts/scratch-sweep*' --ignore-pattern 'scripts/lane-live*' --ignore-pattern 'scripts/leftovers-report*' --ignore-pattern 'scripts/keep-copy*' --ignore-pattern 'scripts/disk-audit*' --ignore-pattern 'test/tooling/disk-land.test.mjs' --ignore-pattern 'test/tooling/land-fixture.mjs' --ignore-pattern 'test/tooling/owned-scratch.mjs' --ignore-pattern 'test/tooling/lane-live.test.mjs' --ignore-pattern 'test/tooling/keep-copy.test.mjs' --ignore-pattern 'test/tooling/leftovers-report.test.mjs' --ignore-pattern 'test/tooling/reap-report.test.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**'",
|
|
446
447
|
"lint:format": "node src/tools/format-ratchet.ts",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { acceptsShardfileCost, textureLibrarySource } from './deviceMemoryCost.ts';
|
|
2
|
+
import { creaturePerchAdmissionRows } from './creature-perch.ts';
|
|
2
3
|
import { admitScriptContract, decisionModuleContracts, type ScriptAdmissionRows } from './scriptContract.ts';
|
|
3
4
|
import type { TextureTranscodeSupport } from './contentBounds.ts';
|
|
4
5
|
import { admitScript } from './scriptAdmission.ts';
|
|
@@ -89,7 +90,9 @@ interface AssetAdmission {
|
|
|
89
90
|
function assetAdmission(input: unknown, memory: MemoryAdmission | undefined, scripts: ScriptAdmissionRows, sections?: ReadonlyMap<string, unknown>): AssetAdmission {
|
|
90
91
|
preflightShardfile(input);
|
|
91
92
|
const s = parseShardfile(input, sections), files = new Map(s.files.map((f) => [f.hash, f]));
|
|
92
|
-
const
|
|
93
|
+
const perchRows = creaturePerchAdmissionRows(s.creatures.perchBodies ?? [], scripts);
|
|
94
|
+
const combined = [...scripts, ...perchRows];
|
|
95
|
+
const contracts = decisionModuleContracts(combined, s.files);
|
|
93
96
|
const legacyModules = new Set([...s.sim.scripts, ...s.clientScripts.bindings.map(row => row.module), ...s.movers.filter(row => row.execution !== 'native').map(row => row.module)]);
|
|
94
97
|
if ([...contracts.keys()].some(hash => legacyModules.has(hash))) throw new Error('Decision module cannot also use a legacy script host');
|
|
95
98
|
preflightAssetGraph(s);
|
|
@@ -115,7 +118,7 @@ function assetAdmission(input: unknown, memory: MemoryAdmission | undefined, scr
|
|
|
115
118
|
const propMaterials = s.props?.materials;
|
|
116
119
|
const propModels = new Set([...s.props?.tiles ?? [], ...s.props?.panels ?? [], ...s.props?.models ?? []].map(row => row.file));
|
|
117
120
|
if (s.props?.far !== undefined && s.props.far !== null) propModels.add(s.props.far);
|
|
118
|
-
return { shard: s, files, contracts, declared, closure, sum, commons: 0, commonsCosts, admissions, propMaterials, propModels, scripts };
|
|
121
|
+
return { shard: s, files, contracts, declared, closure, sum, commons: 0, commonsCosts, admissions, propMaterials, propModels, scripts: combined };
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
/** The pinned commons: present, of their wire size and hash, and of their pinned costs. */
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { parseDecisionScripts } from './decisionScripts.ts'
|
|
2
|
+
|
|
3
|
+
import type { CreaturePerchBody } from './creature-perch.ts'
|
|
4
|
+
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
5
|
+
|
|
6
|
+
type Frozen<Value> = Value extends readonly (infer Item)[]
|
|
7
|
+
? readonly Frozen<Item>[]
|
|
8
|
+
: Value extends object
|
|
9
|
+
? { readonly [Key in keyof Value]: Frozen<Value[Key]> }
|
|
10
|
+
: Value
|
|
11
|
+
|
|
12
|
+
const ZERO = 0
|
|
13
|
+
const ABI_TWO = 2
|
|
14
|
+
type Row = ScriptAdmissionRows[number]
|
|
15
|
+
|
|
16
|
+
function admissionIdentity(row: Frozen<Row>): string {
|
|
17
|
+
return JSON.stringify(
|
|
18
|
+
row.abi === ABI_TWO
|
|
19
|
+
? [
|
|
20
|
+
row.side,
|
|
21
|
+
row.abi,
|
|
22
|
+
row.pages,
|
|
23
|
+
row.lane,
|
|
24
|
+
row.ioBytes,
|
|
25
|
+
row.compilerRevision,
|
|
26
|
+
row.admissionRevision,
|
|
27
|
+
]
|
|
28
|
+
: [row.side, row.abi, row.pages],
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function programRow(body: Frozen<CreaturePerchBody>): Row {
|
|
33
|
+
const { program } = body
|
|
34
|
+
const artifact = program.v2?.artifact
|
|
35
|
+
const module =
|
|
36
|
+
artifact === undefined
|
|
37
|
+
? program.script.module
|
|
38
|
+
: `blobs/wasm/${artifact.hash}.wasm`
|
|
39
|
+
const id = `perch.${module.slice('blobs/wasm/'.length, -'.wasm'.length)}`
|
|
40
|
+
if (artifact !== undefined) {
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
side: 'sim' as const,
|
|
44
|
+
module,
|
|
45
|
+
abi: ABI_TWO,
|
|
46
|
+
lane: artifact.lane,
|
|
47
|
+
pages: artifact.pages,
|
|
48
|
+
ioBytes: artifact.ioBytes,
|
|
49
|
+
compilerRevision: artifact.compilerRevision,
|
|
50
|
+
admissionRevision: artifact.admissionRevision,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const [row] = parseDecisionScripts([{ ...program.script, id }])
|
|
54
|
+
if (row === undefined) {
|
|
55
|
+
throw new Error('Missing perch module contract')
|
|
56
|
+
}
|
|
57
|
+
return row
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Add only the actual runtime VM to normal file, byte and whole-host admission.
|
|
61
|
+
* An ABI-2 program's ABI-1 witness is not another live simulation instance. */
|
|
62
|
+
function creaturePerchAdmissionRows(
|
|
63
|
+
bodies: readonly Frozen<CreaturePerchBody>[],
|
|
64
|
+
existing: readonly Frozen<Row>[] = [],
|
|
65
|
+
): ScriptAdmissionRows {
|
|
66
|
+
const rows: Row[] = []
|
|
67
|
+
for (const body of bodies) {
|
|
68
|
+
const row = programRow(body)
|
|
69
|
+
const matches = [...existing, ...rows].filter(
|
|
70
|
+
(candidate: Frozen<Row>): boolean => candidate.module === row.module,
|
|
71
|
+
)
|
|
72
|
+
if (
|
|
73
|
+
matches.some(
|
|
74
|
+
(previous: Frozen<Row>): boolean =>
|
|
75
|
+
admissionIdentity(previous) !== admissionIdentity(row),
|
|
76
|
+
)
|
|
77
|
+
) {
|
|
78
|
+
throw new Error('Conflicting perch module contracts')
|
|
79
|
+
}
|
|
80
|
+
if (matches.length === ZERO) {
|
|
81
|
+
rows.push(row)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return rows
|
|
85
|
+
}
|
|
86
|
+
export { creaturePerchAdmissionRows }
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
check,
|
|
4
|
+
finite,
|
|
5
|
+
maxLength,
|
|
6
|
+
maxValue,
|
|
7
|
+
minLength,
|
|
8
|
+
minValue,
|
|
9
|
+
number,
|
|
10
|
+
pipe,
|
|
11
|
+
regex,
|
|
12
|
+
strictObject,
|
|
13
|
+
string,
|
|
14
|
+
tuple,
|
|
15
|
+
picklist,
|
|
16
|
+
intersect,
|
|
17
|
+
object,
|
|
18
|
+
} from 'valibot'
|
|
19
|
+
|
|
20
|
+
import { BodySlotsSchema } from './bodySlots.ts'
|
|
21
|
+
import { MixedPopulationSchema } from './mixedPopulation.ts'
|
|
22
|
+
import { BodyLaunchSchema } from './nativeItems.ts'
|
|
23
|
+
import { ReturnProgramWireDocumentSchema } from './returnProgramDocument.ts'
|
|
24
|
+
|
|
25
|
+
import type { BodySlotsData } from './bodySlots.ts'
|
|
26
|
+
import type {
|
|
27
|
+
MixedPopulationRows,
|
|
28
|
+
MixedPopulationRowsInput,
|
|
29
|
+
} from './mixedPopulation.ts'
|
|
30
|
+
import type { ReturnProgramDocumentInput } from './returnProgramDocument.ts'
|
|
31
|
+
import type { GenericSchema, InferInput, InferOutput } from 'valibot'
|
|
32
|
+
|
|
33
|
+
type Frozen<Value> = Value extends readonly (infer Item)[]
|
|
34
|
+
? readonly Frozen<Item>[]
|
|
35
|
+
: Value extends object
|
|
36
|
+
? { readonly [Key in keyof Value]: Frozen<Value[Key]> }
|
|
37
|
+
: Value
|
|
38
|
+
|
|
39
|
+
type Stream = 'ai' | 'spawn' | 'gameplay' | 'cosmetic'
|
|
40
|
+
type PolicyInput = MixedPopulationRowsInput['perch'] & { attackStream: Stream }
|
|
41
|
+
type Policy = MixedPopulationRows['perch'] & { attackStream: Stream }
|
|
42
|
+
|
|
43
|
+
/** One shared physical pool and explicit native perch-body authority. */
|
|
44
|
+
interface CreaturePerchBodyInput {
|
|
45
|
+
id: string
|
|
46
|
+
sites: { at: [number, number, number]; base: [number, number, number] }[]
|
|
47
|
+
program: unknown
|
|
48
|
+
policy: PolicyInput
|
|
49
|
+
projectile: {
|
|
50
|
+
strike: string
|
|
51
|
+
launch: InferInput<typeof BodyLaunchSchema>
|
|
52
|
+
pool: BodySlotsData
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Defaults and serialization stay with each existing defining child schema. */
|
|
56
|
+
interface CreaturePerchBody {
|
|
57
|
+
id: string
|
|
58
|
+
sites: { at: [number, number, number]; base: [number, number, number] }[]
|
|
59
|
+
program: ReturnProgramDocumentInput
|
|
60
|
+
policy: Policy
|
|
61
|
+
projectile: {
|
|
62
|
+
strike: string
|
|
63
|
+
launch: InferOutput<typeof BodyLaunchSchema>
|
|
64
|
+
pool: BodySlotsData
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const ID_MAX = 128
|
|
69
|
+
const COORD_MAX = 250
|
|
70
|
+
const ZERO = 0
|
|
71
|
+
const ONE = 1
|
|
72
|
+
const TWO = 2
|
|
73
|
+
const SITE_MAX = 1024
|
|
74
|
+
|
|
75
|
+
const identifier = pipe(
|
|
76
|
+
string(),
|
|
77
|
+
regex(/^[a-z][a-z0-9.:-]*$/u),
|
|
78
|
+
maxLength(ID_MAX),
|
|
79
|
+
)
|
|
80
|
+
const coordinate = pipe(
|
|
81
|
+
number(),
|
|
82
|
+
finite(),
|
|
83
|
+
minValue(-COORD_MAX),
|
|
84
|
+
maxValue(COORD_MAX),
|
|
85
|
+
)
|
|
86
|
+
const point = tuple([coordinate, coordinate, coordinate])
|
|
87
|
+
const native = MixedPopulationSchema.entries.perch
|
|
88
|
+
const rootNames = [
|
|
89
|
+
['drop', 'drop'],
|
|
90
|
+
['velocity', 'vy'],
|
|
91
|
+
['land', 'land'],
|
|
92
|
+
['climb', 'climb'],
|
|
93
|
+
['height', 'perchH'],
|
|
94
|
+
['baseX', 'bx'],
|
|
95
|
+
['baseZ', 'bz'],
|
|
96
|
+
['x', 'px'],
|
|
97
|
+
['z', 'pz'],
|
|
98
|
+
] as const
|
|
99
|
+
|
|
100
|
+
function validPolicy(row: Frozen<Policy>): boolean {
|
|
101
|
+
const { root } = row
|
|
102
|
+
const names = rootNames.every(
|
|
103
|
+
([key, name]: readonly [string, string]): boolean =>
|
|
104
|
+
Reflect.get(root, key) === name,
|
|
105
|
+
)
|
|
106
|
+
const { actions } = row
|
|
107
|
+
return (
|
|
108
|
+
names &&
|
|
109
|
+
root.gravity > ZERO &&
|
|
110
|
+
root.speed > ZERO &&
|
|
111
|
+
root.landing >= ZERO &&
|
|
112
|
+
Math.abs(row.sourceHeight) <= COORD_MAX &&
|
|
113
|
+
Math.abs(row.targetHeight) <= COORD_MAX &&
|
|
114
|
+
actions.stateKey === 'st' &&
|
|
115
|
+
actions.states.join('|') ===
|
|
116
|
+
'perch|ground-idle|attack|drop|ground|return|climb' &&
|
|
117
|
+
actions.actions.length === TWO &&
|
|
118
|
+
new Set(
|
|
119
|
+
actions.actions.map(
|
|
120
|
+
(action: Frozen<Policy['actions']['actions'][number]>): string =>
|
|
121
|
+
action.effect,
|
|
122
|
+
),
|
|
123
|
+
).size === TWO &&
|
|
124
|
+
actions.actions.every(
|
|
125
|
+
(action: Frozen<Policy['actions']['actions'][number]>): boolean =>
|
|
126
|
+
(action.effect === 'bite' || action.effect === 'throw') &&
|
|
127
|
+
action.state === TWO &&
|
|
128
|
+
action.phase >= ZERO &&
|
|
129
|
+
action.phase <= ONE &&
|
|
130
|
+
action.once.key === 'hit' &&
|
|
131
|
+
action.once.value === ONE &&
|
|
132
|
+
action.once.test === 'falsy' &&
|
|
133
|
+
action.when?.key === 'bite' &&
|
|
134
|
+
action.when.test === (action.effect === 'bite' ? 'truthy' : 'falsy'),
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const requiredStream = object({
|
|
140
|
+
attackStream: picklist(['ai', 'spawn', 'gameplay', 'cosmetic']),
|
|
141
|
+
})
|
|
142
|
+
const policy: GenericSchema<PolicyInput, Policy> = pipe(
|
|
143
|
+
intersect([native, requiredStream]),
|
|
144
|
+
check<Policy, string>(
|
|
145
|
+
validPolicy,
|
|
146
|
+
'Existing native perch memory and body protocol',
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
const site = strictObject({ at: point, base: point })
|
|
151
|
+
const sites = pipe(array(site), minLength(ONE), maxLength(SITE_MAX))
|
|
152
|
+
|
|
153
|
+
/** Complete data only: native admission still verifies module bytes and references. */
|
|
154
|
+
const CreaturePerchBodySchema: GenericSchema<
|
|
155
|
+
CreaturePerchBodyInput,
|
|
156
|
+
CreaturePerchBody
|
|
157
|
+
> = pipe(
|
|
158
|
+
strictObject({
|
|
159
|
+
id: identifier,
|
|
160
|
+
sites,
|
|
161
|
+
program: ReturnProgramWireDocumentSchema,
|
|
162
|
+
policy,
|
|
163
|
+
projectile: strictObject({
|
|
164
|
+
strike: identifier,
|
|
165
|
+
launch: BodyLaunchSchema,
|
|
166
|
+
pool: BodySlotsSchema,
|
|
167
|
+
}),
|
|
168
|
+
}),
|
|
169
|
+
check<CreaturePerchBody, string>(
|
|
170
|
+
(row: Frozen<CreaturePerchBody>): boolean =>
|
|
171
|
+
row.program.script.side === 'sim' &&
|
|
172
|
+
new Set(
|
|
173
|
+
row.sites.map(
|
|
174
|
+
(position: Frozen<CreaturePerchBody['sites'][number]>): string =>
|
|
175
|
+
position.at.join(','),
|
|
176
|
+
),
|
|
177
|
+
).size === row.sites.length,
|
|
178
|
+
'Unique declared perch sites and a simulation-owned return program',
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
const BODY_MAX = 64
|
|
183
|
+
const POOL_MAX = 128
|
|
184
|
+
function boundedCatalogue(rows: readonly Frozen<CreaturePerchBody>[]): boolean {
|
|
185
|
+
return (
|
|
186
|
+
new Set(rows.map((row: Frozen<CreaturePerchBody>): string => row.id))
|
|
187
|
+
.size === rows.length &&
|
|
188
|
+
rows.reduce(
|
|
189
|
+
(total: number, row: Frozen<CreaturePerchBody>): number =>
|
|
190
|
+
total + row.projectile.pool.count,
|
|
191
|
+
ZERO,
|
|
192
|
+
) <= POOL_MAX
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
/** Catalogue identities own shared bounded pools, independently of actor count. */
|
|
196
|
+
const CreaturePerchBodiesSchema: GenericSchema<
|
|
197
|
+
CreaturePerchBodyInput[],
|
|
198
|
+
CreaturePerchBody[]
|
|
199
|
+
> = pipe(
|
|
200
|
+
array(CreaturePerchBodySchema),
|
|
201
|
+
maxLength(BODY_MAX),
|
|
202
|
+
check<CreaturePerchBody[], string>(
|
|
203
|
+
boundedCatalogue,
|
|
204
|
+
'Unique perch bodies and at most 128 physical slots',
|
|
205
|
+
),
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
interface BrainIdentity {
|
|
209
|
+
readonly id: string
|
|
210
|
+
readonly kind?: string
|
|
211
|
+
readonly pattern?: string
|
|
212
|
+
}
|
|
213
|
+
interface BodyReference {
|
|
214
|
+
readonly id: string
|
|
215
|
+
readonly policy: { readonly kind: string; readonly strike: string }
|
|
216
|
+
}
|
|
217
|
+
interface SpawnReference {
|
|
218
|
+
readonly brain: string | null
|
|
219
|
+
readonly species?: string
|
|
220
|
+
readonly strike?: string | null
|
|
221
|
+
readonly home?: unknown
|
|
222
|
+
readonly perchBody?: string
|
|
223
|
+
}
|
|
224
|
+
/** Reference checks run with the existing creature section before a host exists. */
|
|
225
|
+
function creaturePerchRules(
|
|
226
|
+
content: Readonly<{
|
|
227
|
+
brains: readonly BrainIdentity[]
|
|
228
|
+
perchBodies?: readonly BodyReference[]
|
|
229
|
+
spawns: readonly SpawnReference[]
|
|
230
|
+
}>,
|
|
231
|
+
): string[] {
|
|
232
|
+
const catalogue = new Map(
|
|
233
|
+
(content.perchBodies ?? []).map(
|
|
234
|
+
(row: BodyReference): readonly [string, BodyReference] => [row.id, row],
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
const errors: string[] = []
|
|
238
|
+
for (const spawn of content.spawns) {
|
|
239
|
+
if (spawn.perchBody !== undefined) {
|
|
240
|
+
const authority = catalogue.get(spawn.perchBody)
|
|
241
|
+
const brain = content.brains.find(
|
|
242
|
+
(row: BrainIdentity): boolean => row.id === spawn.brain,
|
|
243
|
+
)
|
|
244
|
+
if (
|
|
245
|
+
authority === undefined ||
|
|
246
|
+
spawn.home === undefined ||
|
|
247
|
+
authority.policy.kind !== spawn.species ||
|
|
248
|
+
authority.policy.strike !== spawn.strike ||
|
|
249
|
+
!(
|
|
250
|
+
brain?.kind === 'perch-hunter' ||
|
|
251
|
+
(brain?.kind === 'guardian' && brain.pattern === 'perch')
|
|
252
|
+
)
|
|
253
|
+
) {
|
|
254
|
+
errors.push('declared perch body authority')
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return errors
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export {
|
|
262
|
+
CreaturePerchBodySchema,
|
|
263
|
+
CreaturePerchBodiesSchema,
|
|
264
|
+
creaturePerchRules,
|
|
265
|
+
type CreaturePerchBody,
|
|
266
|
+
type CreaturePerchBodyInput,
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { creaturePerchAdmissionRows } from './creature-perch-admission.ts'
|
package/src/format/creatures.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CreaturePerchBodiesSchema, creaturePerchRules } from './creature-perch.ts';
|
|
2
|
+
import type { CreaturePerchBodyInput, CreaturePerchBody } from './creature-perch.ts';
|
|
1
3
|
import { StrikeDebrisSchema } from './strike-debris.ts';
|
|
2
4
|
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
3
5
|
import * as v from 'valibot';
|
|
@@ -20,7 +22,7 @@ const brain = v.pipe(v.strictObject({ id, kind: v.literal('pursue'), awareRadius
|
|
|
20
22
|
v.check((b) => b.stopDistance <= b.awareRadius && b.awareRadius <= b.leashRadius && b.wanderRadius <= b.leashRadius, 'ordered brain radii'));
|
|
21
23
|
/** One authored body's home; never inferred from a species or another actor. */
|
|
22
24
|
export const CreatureHomeSchema: v.GenericSchema<ShardCreatureHomeInput, ShardCreatureHome> = v.strictObject({ x: coord, y: coord, z: coord, r: v.pipe(radius, v.minValue(Number.MIN_VALUE)) });
|
|
23
|
-
/** Bounded per-spawn home
|
|
25
|
+
/** Bounded per-spawn home for an admitted home-aware or perch policy. */
|
|
24
26
|
|
|
25
27
|
const memoryKey = v.pipe(v.string(), v.regex(/^[a-zA-Z][a-zA-Z0-9._-]{0,63}$/u),
|
|
26
28
|
v.check(key => !['constructor', 'prototype', '__proto__'].includes(key), 'safe memory key'));
|
|
@@ -60,14 +62,14 @@ const phase = v.pipe(finite, v.minValue(-2 * Math.PI), v.maxValue(2 * Math.PI));
|
|
|
60
62
|
const RESPAWN_MAX = 3600, RESPAWN_MIN = 1;
|
|
61
63
|
const respawn = v.pipe(finite, v.minValue(RESPAWN_MIN), v.maxValue(RESPAWN_MAX));
|
|
62
64
|
/** Social membership names no controller; the species temperament owns assistance. */
|
|
63
|
-
const spawn = v.strictObject({ group: v.exactOptional(id), phaseOffset: v.optional(phase), home: v.optional(CreatureHomeSchema), respawn: v.optional(respawn), id, species: id, 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 });
|
|
65
|
+
const spawn = v.strictObject({ perchBody: v.exactOptional(id), group: v.exactOptional(id), phaseOffset: v.optional(phase), home: v.optional(CreatureHomeSchema), respawn: v.optional(respawn), id, species: id, 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 });
|
|
64
66
|
/** Pure-data creature archetypes and stable spawn layouts, expanded before the local sim boots. */
|
|
65
|
-
export const CreaturesSchema: v.GenericSchema<ShardCreaturesInput, ShardCreatures> = v.pipe(v.strictObject({ 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)), []), spawns: v.pipe(v.array(spawn), v.maxLength(10000)) }),
|
|
67
|
+
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)), []), spawns: v.pipe(v.array(spawn), v.maxLength(10000)) }),
|
|
66
68
|
v.check((c) => creatureRules(c).length === 0, 'creature reference rules'));
|
|
67
69
|
/** Validated brain parameters and spawn layout, with no rig or runtime closure. */
|
|
68
70
|
|
|
69
71
|
/** Unique ids and brain references; species and strikes are resolved against the loader's declared catalogues. */
|
|
70
|
-
export function creatureRules(content: { brains: readonly { id: string; kind?: string; pattern?: string }[]; groups?: readonly { id: string; members: readonly string[] }[]; spawns: readonly { id: string; brain: string | null; home?: unknown; phaseOffset?: unknown }[] }): string[] {
|
|
72
|
+
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[] {
|
|
71
73
|
const errors: string[] = [], brains = new Set(content.brains.map((b) => b.id));
|
|
72
74
|
if (brains.size !== content.brains.length) errors.push('unique brain ids');
|
|
73
75
|
for (const group of content.groups ?? []) { if (brains.has(group.id)) errors.push('unique controller ids'); brains.add(group.id); }
|
|
@@ -79,10 +81,11 @@ export function creatureRules(content: { brains: readonly { id: string; kind?: s
|
|
|
79
81
|
|| (policy?.kind === 'grazer' && policy.pattern === 'circle-challenge'))) errors.push('declared per-body circle phase policy');
|
|
80
82
|
if (body.home === undefined) continue;
|
|
81
83
|
if (policy === undefined || !(policy.kind === 'ram-grazer' || policy.kind === 'orbit-diver'
|
|
82
|
-
|| policy.kind === 'patrol-diver' || policy.kind === 'burst-flyer' || policy.kind === 'diver'
|
|
84
|
+
|| policy.kind === 'patrol-diver' || policy.kind === 'burst-flyer' || policy.kind === 'diver' || policy.kind === 'perch-hunter'
|
|
85
|
+
|| (policy.kind === 'guardian' && policy.pattern === 'perch')
|
|
83
86
|
|| (policy.kind === 'grazer' && policy.pattern === 'wander-ram'))) errors.push('declared per-body home policy');
|
|
84
87
|
}
|
|
85
|
-
errors.push(...groupBrainRules(content.groups ?? [], content.spawns, content.brains.map((row) => row.id)));
|
|
88
|
+
errors.push(...creaturePerchRules(content), ...groupBrainRules(content.groups ?? [], content.spawns, content.brains.map((row) => row.id)));
|
|
86
89
|
return errors;
|
|
87
90
|
}
|
|
88
91
|
|
|
@@ -165,8 +168,8 @@ export interface CreatureMemoryActionsRows { stateKey: string; states: (string)[
|
|
|
165
168
|
export interface CreatureBodyRecipeRowsInput { actions?: CreatureMemoryActionsRowsInput; offset?: { field: string; from: number; to: number; }; kind: 'animal'; motion: 'ground' | 'flight'; attack: 'keeper' | 'unlimited'; stunned: 'none' | 'look-hold'; contact: ({ kind: 'environment'; halfArc: number; }) | ({ kind: 'actor'; halfArc: number; move: string; }); }
|
|
166
169
|
export interface CreatureBodyRecipeRows { actions?: CreatureMemoryActionsRows; offset?: { field: string; from: number; to: number; }; kind: 'animal'; motion: 'ground' | 'flight'; attack: 'keeper' | 'unlimited'; stunned: 'none' | 'look-hold'; contact: ({ kind: 'environment'; halfArc: number; }) | ({ kind: 'actor'; halfArc: number; move: string; }); }
|
|
167
170
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Valibot's readonly defaults need the alias's implicit dictionary compatibility.
|
|
168
|
-
export type ShardCreaturesInput = { brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferInput<typeof SkirmisherSchema>) | (v.InferInput<typeof GuardianSchema>) | (v.InferInput<typeof PerchHunterSchema>) | (v.InferInput<typeof ScriptBrainSchema>) | (v.InferInput<typeof RamGrazerSchema>) | (v.InferInput<typeof ChallengeGrazerSchema>) | (v.InferInput<typeof OrbitDiverSchema>) | (v.InferInput<typeof PatrolDiverSchema>) | (v.InferInput<typeof BurstFlyerSchema>) | (v.InferInput<typeof GrazerSchema>) | (v.InferInput<typeof DiverSchema>) | (v.InferInput<typeof GuardianPatternsSchema>) | (v.InferInput<typeof StalkerSchema>))[]; groups?: (v.InferInput<typeof GroupBrainSchema>)[] | undefined; spawns: ({ group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHomeInput | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; };
|
|
169
|
-
export interface ShardCreatures { brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferOutput<typeof SkirmisherSchema>) | (v.InferOutput<typeof GuardianSchema>) | (v.InferOutput<typeof PerchHunterSchema>) | (v.InferOutput<typeof ScriptBrainSchema>) | (v.InferOutput<typeof RamGrazerSchema>) | (v.InferOutput<typeof ChallengeGrazerSchema>) | (v.InferOutput<typeof OrbitDiverSchema>) | (v.InferOutput<typeof PatrolDiverSchema>) | (v.InferOutput<typeof BurstFlyerSchema>) | (v.InferOutput<typeof GrazerSchema>) | (v.InferOutput<typeof DiverSchema>) | (v.InferOutput<typeof GuardianPatternsSchema>) | (v.InferOutput<typeof StalkerSchema>))[]; groups: (v.InferOutput<typeof GroupBrainSchema>)[]; spawns: ({ group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHome | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; }
|
|
171
|
+
export type ShardCreaturesInput = { perchBodies?: CreaturePerchBodyInput[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferInput<typeof SkirmisherSchema>) | (v.InferInput<typeof GuardianSchema>) | (v.InferInput<typeof PerchHunterSchema>) | (v.InferInput<typeof ScriptBrainSchema>) | (v.InferInput<typeof RamGrazerSchema>) | (v.InferInput<typeof ChallengeGrazerSchema>) | (v.InferInput<typeof OrbitDiverSchema>) | (v.InferInput<typeof PatrolDiverSchema>) | (v.InferInput<typeof BurstFlyerSchema>) | (v.InferInput<typeof GrazerSchema>) | (v.InferInput<typeof DiverSchema>) | (v.InferInput<typeof GuardianPatternsSchema>) | (v.InferInput<typeof StalkerSchema>))[]; groups?: (v.InferInput<typeof GroupBrainSchema>)[] | undefined; spawns: ({ perchBody?: string; group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHomeInput | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; };
|
|
172
|
+
export interface ShardCreatures { perchBodies?: CreaturePerchBody[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferOutput<typeof SkirmisherSchema>) | (v.InferOutput<typeof GuardianSchema>) | (v.InferOutput<typeof PerchHunterSchema>) | (v.InferOutput<typeof ScriptBrainSchema>) | (v.InferOutput<typeof RamGrazerSchema>) | (v.InferOutput<typeof ChallengeGrazerSchema>) | (v.InferOutput<typeof OrbitDiverSchema>) | (v.InferOutput<typeof PatrolDiverSchema>) | (v.InferOutput<typeof BurstFlyerSchema>) | (v.InferOutput<typeof GrazerSchema>) | (v.InferOutput<typeof DiverSchema>) | (v.InferOutput<typeof GuardianPatternsSchema>) | (v.InferOutput<typeof StalkerSchema>))[]; groups: (v.InferOutput<typeof GroupBrainSchema>)[]; spawns: ({ perchBody?: string; group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHome | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; }
|
|
170
173
|
export type CreatureStrikeRowsInput = CreatureStrikeRows;
|
|
171
174
|
export interface CreatureStrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }); windup: number; active: number; recover: number; cooldown: number; range: (number) | null; damage: number; tags: (`${string}.${string}`)[]; weight: ({ kind: 'constant'; value: number; }) | ({ kind: 'horizontal-distance'; above: number; far: number; near: number; }); units?: 'world' | 'actor'; alternatives?: (({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }))[]; motion?: { speed?: number; delay?: number; track?: 'none' | 'lead' | 'follow'; overshoot?: number; skid?: number; }; eligibility?: { maxDy?: number; jumpDodges?: boolean; }; }
|
|
172
175
|
export type CreatureStrikesInput = unknown;
|
package/src/format/quests.ts
CHANGED
|
@@ -18,13 +18,21 @@ const trigger = v.variant('kind', [
|
|
|
18
18
|
v.strictObject({ id, kind: v.literal('death'), flag: id, tag: id, when: v.exactOptional(condition) }),
|
|
19
19
|
v.strictObject({ id, kind: v.literal('script'), flag: id, condition: id, when: v.exactOptional(condition) }),
|
|
20
20
|
]);
|
|
21
|
+
/** A timed run: per player, the ticks from `start` rising to `stop` rising file `fact` with the seconds; past `cap` the run lapses. */
|
|
22
|
+
const RACE_CAP_MAX_S = 3600;
|
|
23
|
+
const RACE_CAP_MIN_S = 1;
|
|
24
|
+
const RACES_MAX = 32;
|
|
25
|
+
const raceCap = v.pipe(finite, v.safeInteger(), v.minValue(RACE_CAP_MIN_S), v.maxValue(RACE_CAP_MAX_S));
|
|
26
|
+
const race = v.strictObject({ id, start: id, stop: id, fact: id, cap: raceCap });
|
|
27
|
+
const raceRows = v.pipe(v.array(race), v.maxLength(RACES_MAX));
|
|
28
|
+
const raceList = v.exactOptional(raceRows);
|
|
21
29
|
const choice = v.strictObject({ id, label: text, next: v.nullable(id), when: v.exactOptional(condition), sets: v.exactOptional(names), scene: v.exactOptional(id) });
|
|
22
30
|
const node = v.strictObject({ id, lines: v.pipe(v.array(text), v.minLength(1), v.maxLength(32)), sets: v.exactOptional(names), choices: v.pipe(v.array(choice), v.maxLength(16)) });
|
|
23
31
|
const dialogue = v.strictObject({ id, name: text, start: id, nodes: v.pipe(v.array(node), v.minLength(1), v.maxLength(128)) });
|
|
24
32
|
/** Display metadata for the existing achievement registry and ledger; no new progress save. */
|
|
25
33
|
const achievement = v.strictObject({ id, name: text, goal: text, count: v.pipe(finite, v.safeInteger(), v.minValue(1), v.maxValue(4096)),
|
|
26
34
|
kind: v.exactOptional(id), variant: v.exactOptional(id), event: v.exactOptional(id), title: text, icon: CatalogueIconSchema });
|
|
27
|
-
const raw: v.GenericSchema<{ [K in keyof QuestDataInput]: QuestDataInput[K] }, QuestData> = v.strictObject({ achievements: v.exactOptional(v.pipe(v.array(achievement), v.maxLength(256))), flags: names, quests: v.pipe(v.array(quest), v.maxLength(32)), triggers: v.pipe(v.array(trigger), v.maxLength(128)), dialogue: v.pipe(v.array(dialogue), v.maxLength(32)) });
|
|
35
|
+
const raw: v.GenericSchema<{ [K in keyof QuestDataInput]: QuestDataInput[K] }, QuestData> = v.strictObject({ achievements: v.exactOptional(v.pipe(v.array(achievement), v.maxLength(256))), flags: names, quests: v.pipe(v.array(quest), v.maxLength(32)), triggers: v.pipe(v.array(trigger), v.maxLength(128)), races: raceList, dialogue: v.pipe(v.array(dialogue), v.maxLength(32)) });
|
|
28
36
|
/** Plain quest graphs, declared flags/triggers and finite dialogue trees; hooks name platform-resolved script ports. */
|
|
29
37
|
|
|
30
38
|
const reads = (c: v.InferOutput<typeof condition> | undefined): string[] => [...(c?.all ?? []), ...(c?.any ?? []), ...(c?.none ?? [])];
|
|
@@ -40,6 +48,12 @@ export function questDataRules(data: QuestData): string[] {
|
|
|
40
48
|
for (const m of q.intro?.markers ?? []) checkFlags(reads(m.hideWhen));
|
|
41
49
|
}
|
|
42
50
|
for (const t of data.triggers) checkFlags([t.flag, ...reads(t.when)]);
|
|
51
|
+
const raceIds: string[] = [];
|
|
52
|
+
for (const run of data.races ?? []) {
|
|
53
|
+
raceIds.push(run.id); checkFlags([run.start, run.stop]);
|
|
54
|
+
if (run.start === run.stop) { errors.push(`race ${run.id} starts and stops on one flag`); }
|
|
55
|
+
}
|
|
56
|
+
unique(raceIds);
|
|
43
57
|
for (const d of data.dialogue) {
|
|
44
58
|
unique(d.nodes.map((n) => n.id)); const nodes = new Map(d.nodes.map((n) => [n.id, n])), visited = new Set<string>(), active = new Set<string>();
|
|
45
59
|
const visit = (name: string): void => {
|
|
@@ -170,6 +184,13 @@ interface QuestDataInputFields {
|
|
|
170
184
|
none?: (string)[];
|
|
171
185
|
};
|
|
172
186
|
}))[];
|
|
187
|
+
races?: ({
|
|
188
|
+
id: string;
|
|
189
|
+
start: string;
|
|
190
|
+
stop: string;
|
|
191
|
+
fact: string;
|
|
192
|
+
cap: number;
|
|
193
|
+
})[];
|
|
173
194
|
dialogue: ({
|
|
174
195
|
id: string;
|
|
175
196
|
name: string;
|
|
@@ -305,6 +326,13 @@ interface QuestDataFields {
|
|
|
305
326
|
none?: (string)[];
|
|
306
327
|
};
|
|
307
328
|
}))[];
|
|
329
|
+
races?: ({
|
|
330
|
+
id: string;
|
|
331
|
+
start: string;
|
|
332
|
+
stop: string;
|
|
333
|
+
fact: string;
|
|
334
|
+
cap: number;
|
|
335
|
+
})[];
|
|
308
336
|
dialogue: ({
|
|
309
337
|
id: string;
|
|
310
338
|
name: string;
|
|
@@ -346,6 +346,9 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
346
346
|
if (s.terrain?.sampling !== undefined && s.meshCollision !== null) errors.push('terrain sampling and mesh ground are mutually exclusive');
|
|
347
347
|
if (s.look.families.some((family) => !materialExists({}, family)) || (s.terrain !== null && s.terrain.form !== 'query' && !materialExists(s.look.materials, s.terrain.family)) || s.rows.looks.some((row) => row.material !== null && !materialExists(s.look.materials, row.material))) errors.push('declared platform material family');
|
|
348
348
|
const species = new Map(s.rows.species.map((row) => [row.id, row])), strikes = new Map(s.rows.strikes.map((row) => [row.id, row]));
|
|
349
|
+
for (const row of s.creatures.perchBodies ?? []) {
|
|
350
|
+
if (!strikes.has(row.policy.strike) || !strikes.has(row.projectile.strike)) { errors.push('declared perch body strikes'); }
|
|
351
|
+
}
|
|
349
352
|
for (const brain of s.creatures.brains) if (brain.kind === 'script' && (!s.sim.scripts.includes(brain.module) || brain.strikes.some((request) => !strikes.has(request.strike)))) errors.push('declared custom brain module and strikes');
|
|
350
353
|
for (const declared of s.creatures.brains) {
|
|
351
354
|
const brain = declared.kind === 'grazer' ? grazerPreset(declared) : declared.kind === 'diver' ? diverPreset(declared) : declared;
|