@gameslate/sdk 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +38 -2
- package/bin/gameslate-plugin.mjs +26 -0
- package/build/build-plugin.mjs +127 -0
- package/lib/assets.d.ts +1788 -0
- package/lib/assets.js +107 -0
- package/lib/bytes.d.ts +33 -0
- package/lib/bytes.js +89 -0
- package/lib/catalogue.d.ts +1228 -0
- package/lib/catalogue.js +305 -0
- package/lib/chips.d.ts +18 -0
- package/lib/chips.js +28 -0
- package/lib/condition.d.ts +58 -0
- package/lib/condition.js +125 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +16 -0
- package/lib/logic.d.ts +68 -0
- package/lib/logic.js +194 -0
- package/lib/navigation.d.ts +139 -0
- package/lib/navigation.js +38 -0
- package/lib/pack.d.ts +933 -0
- package/lib/pack.js +29 -0
- package/lib/pins.d.ts +19 -0
- package/lib/pins.js +35 -0
- package/lib/plugin/contract.d.ts +111 -0
- package/lib/plugin/contract.js +1 -0
- package/lib/plugin/index.d.ts +3 -0
- package/lib/plugin/index.js +9 -0
- package/lib/plugin/sandbox-guest.d.ts +12 -0
- package/lib/plugin/sandbox-guest.js +128 -0
- package/lib/plugin/seqlock.d.ts +8 -0
- package/lib/plugin/seqlock.js +19 -0
- package/lib/plugin-manifest.d.ts +131 -0
- package/lib/plugin-manifest.js +54 -0
- package/lib/plugins-api.d.ts +445 -0
- package/lib/plugins-api.js +38 -0
- package/lib/registry.d.ts +2231 -0
- package/lib/registry.js +170 -0
- package/lib/sandbox-protocol.d.ts +1363 -0
- package/lib/sandbox-protocol.js +39 -0
- package/lib/status.d.ts +24 -0
- package/lib/status.js +75 -0
- package/lib/types.d.ts +2684 -0
- package/lib/types.js +282 -0
- package/lib/views.d.ts +204 -0
- package/lib/views.js +35 -0
- package/package.json +53 -3
package/lib/registry.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ConditionSchema } from './condition.js';
|
|
3
|
+
import { GameCapabilitySchema } from './types.js';
|
|
4
|
+
// --- Registry Schemas (C1, C7, H6, H11) ---
|
|
5
|
+
export const LandmarkKindSchema = z.enum([
|
|
6
|
+
'calibration',
|
|
7
|
+
'entry',
|
|
8
|
+
'objective',
|
|
9
|
+
'poi',
|
|
10
|
+
'npc',
|
|
11
|
+
'enemy',
|
|
12
|
+
'exit',
|
|
13
|
+
'note',
|
|
14
|
+
]);
|
|
15
|
+
export const LandmarkSchema = z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
label: z.string(),
|
|
18
|
+
world: z.tuple([z.number(), z.number(), z.number()]),
|
|
19
|
+
kind: LandmarkKindSchema.optional(),
|
|
20
|
+
spoilerFree: z.boolean().optional(),
|
|
21
|
+
requiresObjective: z.string().optional(),
|
|
22
|
+
chestFlag: z.number().int().min(0).max(31).optional(),
|
|
23
|
+
/** OoT Gold Skulltula token flag: byte `index` of gSaveContext.gsFlags, bit `mask` (from En_Sw params). */
|
|
24
|
+
gsFlag: z
|
|
25
|
+
.object({ index: z.number().int().min(0).max(23), mask: z.number().int().min(1).max(255) })
|
|
26
|
+
.optional(),
|
|
27
|
+
/** v3: generic collected test for this pin (replaces per-kind flags as packs migrate). */
|
|
28
|
+
collectedBy: ConditionSchema.optional(),
|
|
29
|
+
/** v3: the pin isn't there in this state (e.g. a Doom thing absent on the current skill). */
|
|
30
|
+
hiddenWhen: ConditionSchema.optional(),
|
|
31
|
+
/** Which of the pack's pin categories it is in (the player filters by these). */
|
|
32
|
+
category: z.string().optional(),
|
|
33
|
+
/** How this pin connects to others on the map, e.g. a switch "Opens" a door, a door is
|
|
34
|
+
* "Opened by" a switch: `to` is the other pin's id. Shown on the card and given to the AI. */
|
|
35
|
+
links: z.array(z.object({ label: z.string(), to: z.string() })).optional(),
|
|
36
|
+
/** A colour the pin is coded by (a locked door and its key), from a fixed palette. */
|
|
37
|
+
tint: z.enum(['red', 'blue', 'yellow', 'green', 'purple', 'orange', 'grey']).optional(),
|
|
38
|
+
/** What the pack knows about this spot, for the AI and the spot card: which one it is among
|
|
39
|
+
* similar pins, where it is relative to other pins, how it's reached (plain sentences). */
|
|
40
|
+
context: z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
export const MapLayerSchema = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
name: z.string(),
|
|
45
|
+
priority: z.number().int(),
|
|
46
|
+
rooms: z.array(z.number().int()),
|
|
47
|
+
yRange: z.tuple([z.number(), z.number()]).optional(),
|
|
48
|
+
svg: z.string(),
|
|
49
|
+
affine: z.tuple([z.number(), z.number(), z.number(), z.number(), z.number(), z.number()]),
|
|
50
|
+
headingOffsetDeg: z.number(),
|
|
51
|
+
headingSign: z.union([z.literal(1), z.literal(-1)]),
|
|
52
|
+
landmarks: z.array(LandmarkSchema).min(3),
|
|
53
|
+
});
|
|
54
|
+
export const LocationMapConfigSchema = z.object({
|
|
55
|
+
viewBox: z.tuple([z.number().positive(), z.number().positive()]),
|
|
56
|
+
hysteresisMs: z.number().int().nonnegative().default(500),
|
|
57
|
+
layers: z.array(MapLayerSchema).min(1),
|
|
58
|
+
});
|
|
59
|
+
export const ObjectiveMetaSchema = z.object({
|
|
60
|
+
id: z.string(),
|
|
61
|
+
label: z.string(),
|
|
62
|
+
minDifficulty: z.string().optional(),
|
|
63
|
+
difficulties: z.array(z.string()).optional(),
|
|
64
|
+
completedByItems: z.array(z.string()).optional(),
|
|
65
|
+
completedByFlags: z.array(z.string()).optional(),
|
|
66
|
+
});
|
|
67
|
+
export const LocationMetaSchema = z.object({
|
|
68
|
+
name: z.string(),
|
|
69
|
+
act: z.string().optional(),
|
|
70
|
+
objectives: z.array(ObjectiveMetaSchema).optional(),
|
|
71
|
+
map: LocationMapConfigSchema.optional(),
|
|
72
|
+
});
|
|
73
|
+
export const GameManifestSchema = z.object({
|
|
74
|
+
schemaVersion: z.literal(1),
|
|
75
|
+
gameId: z.string(),
|
|
76
|
+
requiresStateSchema: z.number().int(),
|
|
77
|
+
title: z.string(),
|
|
78
|
+
capabilities: z.array(GameCapabilitySchema),
|
|
79
|
+
difficulties: z
|
|
80
|
+
.record(z.string(), z.object({ label: z.string(), rank: z.number().int() }))
|
|
81
|
+
.optional(),
|
|
82
|
+
locations: z.record(z.string(), LocationMetaSchema),
|
|
83
|
+
items: z.record(z.string(), z.object({ name: z.string(), category: z.string() })),
|
|
84
|
+
chips: z
|
|
85
|
+
.array(z.object({
|
|
86
|
+
id: z.string(),
|
|
87
|
+
label: z.string(),
|
|
88
|
+
prompt: z.string(),
|
|
89
|
+
}))
|
|
90
|
+
.optional(),
|
|
91
|
+
});
|
|
92
|
+
export const HintNodeSchema = z.object({
|
|
93
|
+
id: z.string(),
|
|
94
|
+
locationIds: z.array(z.string()),
|
|
95
|
+
requires: z.object({
|
|
96
|
+
minDifficulty: z.string().optional(),
|
|
97
|
+
difficulties: z.array(z.string()).optional(),
|
|
98
|
+
age: z.string().optional(),
|
|
99
|
+
objectivesIncomplete: z.array(z.string()).optional(),
|
|
100
|
+
objectivesComplete: z.array(z.string()).optional(),
|
|
101
|
+
inventory: z.array(z.string()).optional(),
|
|
102
|
+
flags: z.array(z.string()).optional(),
|
|
103
|
+
}),
|
|
104
|
+
excludes: z.object({
|
|
105
|
+
inventory: z.array(z.string()).optional(),
|
|
106
|
+
flags: z.array(z.string()).optional(),
|
|
107
|
+
objectivesComplete: z.array(z.string()).optional(),
|
|
108
|
+
}),
|
|
109
|
+
reveals: z.array(z.string()),
|
|
110
|
+
isPlotSpoiler: z.boolean(),
|
|
111
|
+
tiers: z.object({
|
|
112
|
+
'1': z.string(),
|
|
113
|
+
'2': z.string(),
|
|
114
|
+
'3': z.string().optional(),
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
export const HintGraphSchema = z.object({
|
|
118
|
+
schemaVersion: z.literal(1),
|
|
119
|
+
gameId: z.string(),
|
|
120
|
+
hints: z.array(HintNodeSchema),
|
|
121
|
+
});
|
|
122
|
+
export const RegistryIndexSchema = z.object({
|
|
123
|
+
schemaVersion: z.literal(1),
|
|
124
|
+
games: z.record(z.string(), z.object({
|
|
125
|
+
title: z.string(),
|
|
126
|
+
subtitle: z.string().optional(),
|
|
127
|
+
manifest: z.string(),
|
|
128
|
+
hints: z.string(),
|
|
129
|
+
nativeBuilds: z.array(z.object({
|
|
130
|
+
buildId: z.string(),
|
|
131
|
+
region: z.string(),
|
|
132
|
+
platform: z.string(),
|
|
133
|
+
executableHint: z.string(),
|
|
134
|
+
})),
|
|
135
|
+
romIds: z.array(z.string()).optional(),
|
|
136
|
+
})),
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* Locations extracted on the player's PC from their own game files (`local-assets/<id>/manifest.json`),
|
|
140
|
+
* e.g. Doom maps from the player's WAD. Never committed (data-licensing.md).
|
|
141
|
+
*/
|
|
142
|
+
export const LocalManifestSchema = z.object({
|
|
143
|
+
schemaVersion: z.literal(1),
|
|
144
|
+
locations: z.record(z.string(), LocationMetaSchema),
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Overlays local locations on the registry manifest. A local layer's `svg` is relative to the
|
|
148
|
+
* local-assets game dir, so it is rewritten to an absolute URL under `localBaseUrl`.
|
|
149
|
+
*/
|
|
150
|
+
export function mergeLocalManifest(manifest, local, localBaseUrl) {
|
|
151
|
+
const base = localBaseUrl.replace(/\/+$/, '');
|
|
152
|
+
const locations = { ...manifest.locations };
|
|
153
|
+
for (const [id, loc] of Object.entries(local.locations)) {
|
|
154
|
+
const map = loc.map && {
|
|
155
|
+
...loc.map,
|
|
156
|
+
layers: loc.map.layers.map(l => ({
|
|
157
|
+
...l,
|
|
158
|
+
svg: `${base}/${l.svg.replace(/^\/+/, '')}`,
|
|
159
|
+
})),
|
|
160
|
+
};
|
|
161
|
+
locations[id] = { ...locations[id], ...loc, ...(map ? { map } : {}) };
|
|
162
|
+
}
|
|
163
|
+
return { ...manifest, locations };
|
|
164
|
+
}
|
|
165
|
+
/** A layer's SVG URL: registry-relative, or already absolute (local overlays). */
|
|
166
|
+
export function resolveLayerSvgUrl(registryBaseUrl, svg) {
|
|
167
|
+
if (svg.startsWith('/') || /^[a-z]+:/i.test(svg))
|
|
168
|
+
return svg;
|
|
169
|
+
return `${registryBaseUrl.replace(/\/+$/, '')}/${svg}`;
|
|
170
|
+
}
|