@wildshard/shard-format 0.76.0 → 0.77.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.77.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": {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { WeaponSlotSchema } from './weapon-slot.ts';
|
|
3
|
+
import type { WeaponSlot } from './weapon-slot.ts';
|
|
2
4
|
import { CatalogueIconSchema } from './items.ts';
|
|
3
5
|
import { PackedGeometryRowsSchema } from './geometryPack.ts';
|
|
4
6
|
|
|
5
7
|
const text = v.pipe(v.string(), v.minLength(1), v.maxLength(512));
|
|
6
8
|
const finite = v.pipe(v.number(), v.finite());
|
|
7
9
|
const natural = v.pipe(finite, v.integer(), v.minValue(0));
|
|
8
|
-
const weapon =
|
|
10
|
+
const weapon = WeaponSlotSchema;
|
|
9
11
|
const override = v.strictObject({ color: v.exactOptional(finite), emissive: v.exactOptional(finite), emissiveIntensity: v.exactOptional(finite),
|
|
10
12
|
roughness: v.exactOptional(finite), metalness: v.exactOptional(finite), envMapIntensity: v.exactOptional(finite), plain: v.exactOptional(v.boolean()) });
|
|
11
13
|
/** Pre-admission locker and Explorer card identities, in the authored order. */
|
|
@@ -354,7 +356,7 @@ interface HeldFinishesRowsInputFields {
|
|
|
354
356
|
order: (string)[];
|
|
355
357
|
rows: Record<string, {
|
|
356
358
|
id: string;
|
|
357
|
-
weapon:
|
|
359
|
+
weapon: WeaponSlot;
|
|
358
360
|
name: string;
|
|
359
361
|
blurb: string;
|
|
360
362
|
dropsFrom?: {
|
|
@@ -388,7 +390,7 @@ interface HeldFinishesRowsFields {
|
|
|
388
390
|
order: (string)[];
|
|
389
391
|
rows: Record<string, {
|
|
390
392
|
id: string;
|
|
391
|
-
weapon:
|
|
393
|
+
weapon: WeaponSlot;
|
|
392
394
|
name: string;
|
|
393
395
|
blurb: string;
|
|
394
396
|
dropsFrom?: {
|
package/src/format/items.ts
CHANGED
|
@@ -181,7 +181,7 @@ export function itemRules(items: ShardItems, modules?: readonly string[]): strin
|
|
|
181
181
|
const ids = items.rows.map((r) => r.id), weapons = items.rows.filter((r) => r.kind === 'weapon');
|
|
182
182
|
const runtimeContexts = items.runtimeContexts ?? [];
|
|
183
183
|
if (items.loadout.effects?.weapons.some(binding => new Set(binding.items).size !== binding.items.length
|
|
184
|
-
|| binding.items.some(id => !weapons.some(entry => entry.id === id && entry.equipment
|
|
184
|
+
|| binding.items.some(id => !weapons.some(entry => entry.id === id && entry.equipment !== undefined))) === true)
|
|
185
185
|
errors.push('item effect targets need unique native equipment ids');
|
|
186
186
|
if (weapons.some(row => row.profile !== undefined && !row.family.includes('.') && row.family !== row.profile.family && !(row.family === 'swept' && row.profile.family === 'melee'))) errors.push('weapon profile matches declared family');
|
|
187
187
|
if (weapons.some(row => row.profile?.family === 'cone' && (row.light.range !== row.heavy.range
|
|
@@ -356,6 +356,11 @@ import { UiSchema } from './ui.ts'
|
|
|
356
356
|
import { uniformIdentityTransforms } from './uniformRows.ts'
|
|
357
357
|
import { WaterSchema } from './water.ts'
|
|
358
358
|
import { WaterWorldSchema } from './waterWorld.ts'
|
|
359
|
+
import {
|
|
360
|
+
DECLARED_LIMIT,
|
|
361
|
+
DECLARED_PATTERN,
|
|
362
|
+
DeclaredWeaponSchema,
|
|
363
|
+
} from './weapon-slot.ts'
|
|
359
364
|
import {
|
|
360
365
|
WeaponProfileSchema,
|
|
361
366
|
MeleeWeaponProfileSchema,
|
|
@@ -402,6 +407,10 @@ const input = plumbing.entries.input.pipe[0].item
|
|
|
402
407
|
const debug = plumbing.entries.debug.pipe[0].item
|
|
403
408
|
// These identities are the defining schemas, not message-based permissions for arbitrary author code.
|
|
404
409
|
const customSchemas = new Map<object, FormatJsonSchema>([
|
|
410
|
+
[
|
|
411
|
+
DeclaredWeaponSchema,
|
|
412
|
+
{ type: 'string', maxLength: DECLARED_LIMIT, pattern: DECLARED_PATTERN },
|
|
413
|
+
],
|
|
405
414
|
[
|
|
406
415
|
WeatherHitTagSchema,
|
|
407
416
|
{ type: 'string', pattern: '^[a-z][a-zA-Z0-9.-]*\\.[a-zA-Z0-9.*-]+$' },
|
package/src/format/loadout.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { isJsonData } from './json.ts';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
import { WeaponSlotSchema } from './weapon-slot.ts';
|
|
4
|
+
import type { WeaponSlot } from './weapon-slot.ts';
|
|
3
5
|
|
|
4
6
|
const text = v.pipe(v.string(), v.minLength(1), v.maxLength(1024));
|
|
5
7
|
const finite = v.pipe(v.number(), v.finite());
|
|
6
8
|
const natural = v.pipe(finite, v.integer(), v.minValue(0));
|
|
7
9
|
const names = v.pipe(v.array(text), v.minLength(1), v.maxLength(64), v.check(rows => new Set(rows).size === rows.length));
|
|
8
|
-
const slot =
|
|
10
|
+
const slot = WeaponSlotSchema;
|
|
9
11
|
const action = v.custom<`${string}.${string}`>(value => typeof value === 'string' && /^[^.]+\..+$/.test(value));
|
|
10
12
|
const cue = v.custom<`cue.${string}`>(value => typeof value === 'string' && value.startsWith('cue.') && value.length > 4);
|
|
11
13
|
/** A held loadout's ammunition, ownership, save ABI, input and cues. Native weapon clocks remain in combat/items. */
|
|
@@ -58,15 +60,15 @@ interface LoadoutRowsFields {
|
|
|
58
60
|
};
|
|
59
61
|
launcher: {
|
|
60
62
|
item: string;
|
|
61
|
-
slot:
|
|
63
|
+
slot: WeaponSlot;
|
|
62
64
|
};
|
|
63
65
|
firearm: {
|
|
64
|
-
slot:
|
|
66
|
+
slot: WeaponSlot;
|
|
65
67
|
owned: string;
|
|
66
68
|
ammo: string;
|
|
67
69
|
};
|
|
68
70
|
bow: {
|
|
69
|
-
slot:
|
|
71
|
+
slot: WeaponSlot;
|
|
70
72
|
owned: string;
|
|
71
73
|
legacyItem: string;
|
|
72
74
|
ammo: string;
|
|
@@ -140,7 +142,7 @@ interface MountedLoadoutRowsFields {
|
|
|
140
142
|
item: `weapon.${string}`;
|
|
141
143
|
muzzleLight: boolean;
|
|
142
144
|
};
|
|
143
|
-
order:
|
|
145
|
+
order: WeaponSlot[];
|
|
144
146
|
};
|
|
145
147
|
variants: {
|
|
146
148
|
bow: {
|
|
@@ -81,8 +81,26 @@ export const FarImpostorSchema: v.GenericSchema<FarImpostorInput, FarImpostor> =
|
|
|
81
81
|
});
|
|
82
82
|
/** One far impostor row. */
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const UNIT_MIN = 0;
|
|
85
|
+
const UNIT_MAX = 1;
|
|
86
|
+
const unit = v.pipe(ShardFiniteSchema, v.minValue(UNIT_MIN), v.maxValue(UNIT_MAX));
|
|
87
|
+
const rgb = v.tuple([ShardFiniteSchema, ShardFiniteSchema, ShardFiniteSchema]);
|
|
88
|
+
const tint = v.exactOptional(rgb);
|
|
89
|
+
const farGrade = v.strictObject({ exposure: ShardFiniteSchema, saturation: ShardFiniteSchema, contrast: ShardFiniteSchema, tint });
|
|
90
|
+
const bandHeight = v.pipe(ShardFiniteSchema, v.minValue(UNIT_MIN), v.maxValue(CELL_ABOVE));
|
|
91
|
+
const farBand = v.strictObject({ colour: rgb, height: bandHeight, opacity: unit, own: unit });
|
|
92
|
+
const farHaze = v.strictObject({ colour: rgb });
|
|
93
|
+
const farFamily = v.picklist(['toon', 'painterly', 'pbr']);
|
|
94
|
+
/**
|
|
95
|
+
* FORMAT-PRUNE FP40: how the far tier draws the proxy (the shard's own far look, as its repo bake wrote `far.json`'s
|
|
96
|
+
* `look`): its shading `family`, the `haze` it fades into, an optional `grade` on its own pixels and an optional mood
|
|
97
|
+
* `band` (SF19b: a fog strip rising at its border, `height` metres, seen from the road; `own` its share inside the cell).
|
|
98
|
+
*/
|
|
99
|
+
const farLook: v.GenericSchema<FarLook, FarLook> = v.strictObject({ family: farFamily, haze: farHaze, grade: v.exactOptional(farGrade), band: v.exactOptional(farBand) });
|
|
100
|
+
const optionalFarLook = v.exactOptional(farLook);
|
|
101
|
+
|
|
102
|
+
/** Nullable far proxy references, bounds and conservative costs (its impostor's file is one of `files`), and its look. */
|
|
103
|
+
export const FarSchema: v.GenericSchema<ShardFarInput, ShardFar> = v.nullable(v.pipe(v.strictObject({ files: ShardReferencesSchema, bounds: CellBoundsSchema, impostor: v.exactOptional(FarImpostorSchema), look: optionalFarLook, ...costs }),
|
|
86
104
|
v.check((far) => far.impostor === undefined || (far.files.includes(far.impostor.file) && far.impostor.bottom < far.impostor.top), 'far impostor file and span')));
|
|
87
105
|
/** Finite local player position and yaw; its default remains in root composition. */
|
|
88
106
|
export const SpawnSchema: v.GenericSchema<ShardSpawnInput, ShardSpawn> = v.strictObject({ x: ShardFiniteSchema, y: ShardFiniteSchema, z: ShardFiniteSchema, yaw: ShardFiniteSchema });
|
|
@@ -365,10 +383,19 @@ interface FarImpostorFields {
|
|
|
365
383
|
range: ShardFinite;
|
|
366
384
|
}
|
|
367
385
|
export type FarImpostor = { [Key in keyof FarImpostorFields]: FarImpostorFields[Key] };
|
|
386
|
+
type FarRgb = [number, number, number];
|
|
387
|
+
/** FP40: a far row's look; the input and output agree. */
|
|
388
|
+
interface FarLook {
|
|
389
|
+
family: 'toon' | 'painterly' | 'pbr';
|
|
390
|
+
haze: { colour: FarRgb };
|
|
391
|
+
grade?: { exposure: number; saturation: number; contrast: number; tint?: FarRgb };
|
|
392
|
+
band?: { colour: FarRgb; height: number; opacity: number; own: number };
|
|
393
|
+
}
|
|
368
394
|
export type ShardFarInput = (Omit<{
|
|
369
395
|
files: ShardReferencesInput;
|
|
370
396
|
bounds: CellBoundsInput;
|
|
371
397
|
impostor?: FarImpostorInput;
|
|
398
|
+
look?: FarLook;
|
|
372
399
|
}, keyof ({
|
|
373
400
|
compressed: ShardNaturalInput;
|
|
374
401
|
decoded: ShardNaturalInput;
|
|
@@ -386,6 +413,7 @@ export type ShardFar = (Omit<{
|
|
|
386
413
|
files: ShardReferences;
|
|
387
414
|
bounds: CellBounds;
|
|
388
415
|
impostor?: FarImpostor;
|
|
416
|
+
look?: FarLook;
|
|
389
417
|
}, keyof ({
|
|
390
418
|
compressed: ShardNatural;
|
|
391
419
|
decoded: ShardNatural;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// FORMAT-PRUNE FP22d: where a row names a held weapon (a loadout slot, a finish's weapon), it names an engine-native closed
|
|
2
|
+
// name (until `items.legacySlot` goes, FP22e) or the declared item the weapon plays under, `declared.<equipment id>`.
|
|
3
|
+
import { custom, picklist, union } from 'valibot'
|
|
4
|
+
|
|
5
|
+
import type { GenericSchema } from 'valibot'
|
|
6
|
+
|
|
7
|
+
type DeclaredWeaponId = `declared.weapon.${string}`
|
|
8
|
+
type WeaponSlot =
|
|
9
|
+
| 'crossbow'
|
|
10
|
+
| 'sword'
|
|
11
|
+
| 'rifle'
|
|
12
|
+
| 'sword-iron'
|
|
13
|
+
| 'bow'
|
|
14
|
+
| 'sabre'
|
|
15
|
+
| 'spear'
|
|
16
|
+
| 'empty'
|
|
17
|
+
| DeclaredWeaponId
|
|
18
|
+
|
|
19
|
+
const DECLARED_LIMIT = 256
|
|
20
|
+
const DECLARED_PATTERN: string = String.raw`^declared\.weapon\.[a-z][a-zA-Z0-9.-]*$`
|
|
21
|
+
const DECLARED = new RegExp(DECLARED_PATTERN, 'u')
|
|
22
|
+
|
|
23
|
+
/** A declared weapon id: `declared.weapon.` and the rest of its equipment id. */
|
|
24
|
+
function isDeclaredWeapon(input: unknown): input is DeclaredWeaponId {
|
|
25
|
+
return (
|
|
26
|
+
typeof input === 'string' &&
|
|
27
|
+
input.length <= DECLARED_LIMIT &&
|
|
28
|
+
DECLARED.test(input)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const DeclaredWeaponSchema: GenericSchema<DeclaredWeaponId> =
|
|
33
|
+
custom<DeclaredWeaponId>(isDeclaredWeapon, 'a declared weapon id')
|
|
34
|
+
const WeaponSlotSchema: GenericSchema<WeaponSlot> = union([
|
|
35
|
+
picklist([
|
|
36
|
+
'crossbow',
|
|
37
|
+
'sword',
|
|
38
|
+
'rifle',
|
|
39
|
+
'sword-iron',
|
|
40
|
+
'bow',
|
|
41
|
+
'sabre',
|
|
42
|
+
'spear',
|
|
43
|
+
'empty',
|
|
44
|
+
]),
|
|
45
|
+
DeclaredWeaponSchema,
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
DECLARED_LIMIT,
|
|
50
|
+
DECLARED_PATTERN,
|
|
51
|
+
DeclaredWeaponSchema,
|
|
52
|
+
WeaponSlotSchema,
|
|
53
|
+
type DeclaredWeaponId,
|
|
54
|
+
type WeaponSlot,
|
|
55
|
+
}
|