@dreamboard-games/sdk 0.4.0-alpha.5 → 0.4.0-alpha.7
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/REFERENCE.md +1493 -127
- package/dist/{HandView-x8MhbhFl.d.ts → HandView-Bi2lxzQP.d.ts} +3 -3
- package/dist/{ThemeProvider-DRalAWzY.d.ts → ThemeProvider-CElaL2ik.d.ts} +1 -1
- package/dist/authoring/index.d.ts +5 -4
- package/dist/authoring/index.js +4 -4
- package/dist/authoring/index.js.map +1 -1
- package/dist/browser-interaction.js +1 -1
- package/dist/{chunk-E3X552YM.js → chunk-2TRZSZGD.js} +1061 -425
- package/dist/chunk-2TRZSZGD.js.map +1 -0
- package/dist/{chunk-K5ZRJTZZ.js → chunk-3QIZKXJ2.js} +10 -5
- package/dist/chunk-3QIZKXJ2.js.map +1 -0
- package/dist/{chunk-KHY3RJLT.js → chunk-52DH7VQF.js} +62 -13
- package/dist/chunk-52DH7VQF.js.map +1 -0
- package/dist/chunk-5IHU5CUK.js +575 -0
- package/dist/chunk-5IHU5CUK.js.map +1 -0
- package/dist/{chunk-N6ZDIMRB.js → chunk-B2YBS3SG.js} +1 -1
- package/dist/chunk-B2YBS3SG.js.map +1 -0
- package/dist/chunk-IU6KGPY7.js +659 -0
- package/dist/chunk-IU6KGPY7.js.map +1 -0
- package/dist/{chunk-FXQPZZXC.js → chunk-KYEWGZ2Y.js} +2 -2
- package/dist/{chunk-FXQPZZXC.js.map → chunk-KYEWGZ2Y.js.map} +1 -1
- package/dist/{chunk-AQMEN3AT.js → chunk-NO537WSS.js} +2 -2
- package/dist/{chunk-TTISZQNI.js → chunk-Q322XCY2.js} +47 -31
- package/dist/chunk-Q322XCY2.js.map +1 -0
- package/dist/{chunk-QOFFRHZR.js → chunk-RKGJ64UN.js} +81 -41
- package/dist/chunk-RKGJ64UN.js.map +1 -0
- package/dist/{chunk-Y6Y2YABD.js → chunk-TGMXBRKY.js} +22 -6
- package/dist/chunk-TGMXBRKY.js.map +1 -0
- package/dist/{chunk-XZ667T4K.js → chunk-UC2UXAC6.js} +2 -2
- package/dist/chunk-VLG4YST5.js +564 -0
- package/dist/chunk-VLG4YST5.js.map +1 -0
- package/dist/{chunk-WUIVY2KE.js → chunk-WHR5UW3F.js} +1 -1
- package/dist/chunk-WHR5UW3F.js.map +1 -0
- package/dist/codegen.d.ts +13 -0
- package/dist/codegen.js +1 -1
- package/dist/{components-B7hFaEn_.d.ts → components-BTwSIjXj.d.ts} +77 -206
- package/dist/{stale-contract-artifact-error-BelRiIDR.d.ts → diagnostics-1BWjRo6-.d.ts} +1 -18
- package/dist/{hex-board-view-BFlWDb9k.d.ts → hex-board-view-aKkblDp6.d.ts} +180 -1
- package/dist/{index-gjxQichK.d.ts → index-CFTjJIXd.d.ts} +5 -4
- package/dist/{index.d-BL3bT5lt.d.ts → index.d-DMASeF6M.d.ts} +294 -27
- package/dist/index.js +2 -2
- package/dist/package-set.d.ts +2 -2
- package/dist/package-set.js +2 -2
- package/dist/{runtime-api-BJharVaj.d.ts → plugin-state-BRH3UiUp.d.ts} +19 -3
- package/dist/{protocol-BP193lva.d.ts → protocol-835hEGne.d.ts} +42 -1
- package/dist/reducer/advanced.d.ts +4 -2
- package/dist/reducer/advanced.js +1 -1
- package/dist/reducer-contract.d.ts +1 -1
- package/dist/reducer-contract.js +2 -2
- package/dist/reducer.d.ts +13 -6
- package/dist/reducer.js +322 -20
- package/dist/reducer.js.map +1 -1
- package/dist/reference-games/index.d.ts +223 -0
- package/dist/reference-games/index.js +230 -0
- package/dist/reference-games/index.js.map +1 -0
- package/dist/runtime/primitives.d.ts +32 -7
- package/dist/runtime/primitives.js +10 -5
- package/dist/runtime/runtime-api.d.ts +1 -1
- package/dist/runtime/workspace-contract.d.ts +7 -7
- package/dist/runtime/workspace-contract.js +7 -6
- package/dist/runtime-Dkfm1x2r.d.ts +1670 -0
- package/dist/runtime.d.ts +10 -9
- package/dist/runtime.js +53 -19
- package/dist/runtime.js.map +1 -1
- package/dist/stale-contract-artifact-error-C5AaZPJ8.d.ts +18 -0
- package/dist/testing-runtime.d.ts +42 -0
- package/dist/testing-runtime.js +153 -0
- package/dist/testing-runtime.js.map +1 -0
- package/dist/testing.d.ts +82 -205
- package/dist/testing.js +83 -640
- package/dist/testing.js.map +1 -1
- package/dist/types-DcADVHe9.d.ts +192 -0
- package/dist/{types-CYeN0wLK.d.ts → types-aI4V9CWe.d.ts} +5 -5
- package/dist/types.d.ts +13 -0
- package/dist/ui/components.d.ts +6 -3
- package/dist/ui/components.js +15 -3
- package/dist/ui/plugin-styles.css +2 -2
- package/dist/{ui-contract-B4NjRlvC.d.ts → ui-contract-Ue6SywvO.d.ts} +24 -10
- package/dist/ui.d.ts +9 -6
- package/dist/ui.js +16 -4
- package/dist/views-32rSsfeU.d.ts +1559 -0
- package/package.json +33 -21
- package/dist/chunk-E3X552YM.js.map +0 -1
- package/dist/chunk-K5ZRJTZZ.js.map +0 -1
- package/dist/chunk-KHY3RJLT.js.map +0 -1
- package/dist/chunk-N6ZDIMRB.js.map +0 -1
- package/dist/chunk-O6M6PN4E.js +0 -1225
- package/dist/chunk-O6M6PN4E.js.map +0 -1
- package/dist/chunk-QOFFRHZR.js.map +0 -1
- package/dist/chunk-TTISZQNI.js.map +0 -1
- package/dist/chunk-WUIVY2KE.js.map +0 -1
- package/dist/chunk-Y6Y2YABD.js.map +0 -1
- package/dist/views-fn2RuXOx.d.ts +0 -3168
- /package/dist/{chunk-AQMEN3AT.js.map → chunk-NO537WSS.js.map} +0 -0
- /package/dist/{chunk-XZ667T4K.js.map → chunk-UC2UXAC6.js.map} +0 -0
|
@@ -0,0 +1,1670 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CardCollection, ViewCard, ViewSlotOccupant } from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opaque brand applied to a runtime player identifier.
|
|
6
|
+
*
|
|
7
|
+
* Generators produce a workspace-specific `PlayerId` alias (e.g.
|
|
8
|
+
* `Brand<string, "PlayerId">` in `shared/manifest-contract.ts`). Authors
|
|
9
|
+
* obtain `PlayerId` values only through:
|
|
10
|
+
* - `q.player.order()` / `q.player.current()` (reducer queries),
|
|
11
|
+
* - engine-injected callback arguments (actions, phases, prompts),
|
|
12
|
+
* - `perPlayerKeys(...)` / entries iteration,
|
|
13
|
+
* - `asPlayerId(raw)` as an explicit escape hatch (e.g. ingress parsing).
|
|
14
|
+
*
|
|
15
|
+
* The brand is a phantom type: at runtime a `PlayerId` is just a string.
|
|
16
|
+
* Do not JSON-serialize the brand marker; it exists purely at the type
|
|
17
|
+
* level to block accidental literal comparisons such as
|
|
18
|
+
* `playerId === "player-1"`.
|
|
19
|
+
*/
|
|
20
|
+
type PlayerId = Brand<string, "PlayerId">;
|
|
21
|
+
/**
|
|
22
|
+
* Explicit conversion from a raw string to a branded `PlayerId`.
|
|
23
|
+
*
|
|
24
|
+
* Use at trust boundaries only (wire ingress, tests, fixtures). Inside
|
|
25
|
+
* reducer logic, obtain `PlayerId` values from the engine instead of
|
|
26
|
+
* constructing them yourself.
|
|
27
|
+
*/
|
|
28
|
+
declare function asPlayerId(raw: string): PlayerId;
|
|
29
|
+
/**
|
|
30
|
+
* Type guard that narrows `unknown` to `PlayerId` when the value is a
|
|
31
|
+
* non-empty string. Does not validate against a specific player roster;
|
|
32
|
+
* use `perPlayerSchema`/ingress parsing for that.
|
|
33
|
+
*/
|
|
34
|
+
declare function isPlayerId(value: unknown): value is PlayerId;
|
|
35
|
+
/**
|
|
36
|
+
* A runtime-accurate per-player map.
|
|
37
|
+
*
|
|
38
|
+
* `PerPlayer<Value>` is an opaque, ordered container whose entries are
|
|
39
|
+
* exactly the players that exist at runtime (the seats passed to
|
|
40
|
+
* `initialize`).
|
|
41
|
+
*
|
|
42
|
+
* The `__perPlayer` discriminator keeps the structural type nominal-ish
|
|
43
|
+
* without depending on a symbol (symbols do not round-trip through JSON,
|
|
44
|
+
* which this shape must).
|
|
45
|
+
*
|
|
46
|
+
* Construct with `perPlayer(ids, init)` and read with the accessors in
|
|
47
|
+
* this module; do not reach into `entries` directly unless you need
|
|
48
|
+
* ordered iteration.
|
|
49
|
+
*/
|
|
50
|
+
interface PerPlayer<Value, Id extends PlayerId = PlayerId> {
|
|
51
|
+
readonly __perPlayer: true;
|
|
52
|
+
readonly entries: ReadonlyArray<readonly [Id, Value]>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Construct a `PerPlayer<Value>` with one entry per `id` in `ids`.
|
|
56
|
+
*
|
|
57
|
+
* `ids` is treated as the authoritative runtime seat list: the returned
|
|
58
|
+
* `PerPlayer` contains exactly `ids.length` entries, in the same order.
|
|
59
|
+
* Duplicate ids throw.
|
|
60
|
+
*/
|
|
61
|
+
declare function perPlayer<Value, Id extends PlayerId = PlayerId>(ids: readonly Id[], init: (id: Id, index: number) => Value): PerPlayer<Value, Id>;
|
|
62
|
+
/** Ordered list of seat ids present in the `PerPlayer`. */
|
|
63
|
+
declare function perPlayerKeys<Id extends PlayerId>(value: PerPlayer<unknown, Id>): Id[];
|
|
64
|
+
/** Ordered list of values present in the `PerPlayer`. */
|
|
65
|
+
declare function perPlayerValues<Value>(value: PerPlayer<Value, PlayerId>): Value[];
|
|
66
|
+
/**
|
|
67
|
+
* Ordered `[id, value]` pairs. Returns the backing array as-is; callers
|
|
68
|
+
* must not mutate it.
|
|
69
|
+
*/
|
|
70
|
+
declare function perPlayerEntries<Value, Id extends PlayerId>(value: PerPlayer<Value, Id>): ReadonlyArray<readonly [Id, Value]>;
|
|
71
|
+
/** Number of seats in the `PerPlayer`. */
|
|
72
|
+
declare function perPlayerSize(value: PerPlayer<unknown, PlayerId>): number;
|
|
73
|
+
/** Whether `id` has a value. */
|
|
74
|
+
declare function perPlayerHas<Id extends PlayerId>(value: PerPlayer<unknown, Id>, id: Id): boolean;
|
|
75
|
+
/** Lookup with no fallback; returns `undefined` for missing seats. */
|
|
76
|
+
declare function perPlayerGet<Value, Id extends PlayerId>(value: PerPlayer<Value, Id>, id: Id): Value | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Lookup that throws if `id` is not present.
|
|
79
|
+
*
|
|
80
|
+
* Use when the caller has already established (via `q.player.order()`,
|
|
81
|
+
* an action context, etc.) that `id` is an active runtime seat.
|
|
82
|
+
*/
|
|
83
|
+
declare function perPlayerRequire<Value, Id extends PlayerId>(value: PerPlayer<Value, Id>, id: Id): Value;
|
|
84
|
+
/**
|
|
85
|
+
* Return a new `PerPlayer` with `id`'s value replaced (or added if the
|
|
86
|
+
* id is not present). Preserves entry order; new entries are appended.
|
|
87
|
+
*/
|
|
88
|
+
declare function perPlayerSet<Value, Id extends PlayerId>(value: PerPlayer<Value, Id>, id: Id, next: Value): PerPlayer<Value, Id>;
|
|
89
|
+
/**
|
|
90
|
+
* Return a new `PerPlayer` where each value is replaced by `f(value, id)`.
|
|
91
|
+
* Seat order is preserved.
|
|
92
|
+
*/
|
|
93
|
+
declare function perPlayerMap<Value, Next, Id extends PlayerId>(value: PerPlayer<Value, Id>, f: (v: Value, id: Id, index: number) => Next): PerPlayer<Next, Id>;
|
|
94
|
+
/**
|
|
95
|
+
* Structural check for a `PerPlayer` without a Zod schema. Useful in
|
|
96
|
+
* debug paths and as a fast pre-filter before schema validation.
|
|
97
|
+
*/
|
|
98
|
+
declare function isPerPlayer(value: unknown): value is PerPlayer<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Options accepted by `perPlayerSchema`.
|
|
101
|
+
*
|
|
102
|
+
* Setting `players` locks the schema to an exact seat list: parse fails
|
|
103
|
+
* if the input is missing any seat or has an unknown id. Leaving
|
|
104
|
+
* `players` unset yields a schema that accepts any non-empty string as
|
|
105
|
+
* a key, which is the right default for generic SDK types.
|
|
106
|
+
*
|
|
107
|
+
* `playerIdSchema` lets callers feed a manifest-scoped Zod id schema in
|
|
108
|
+
* so parse errors carry the same message as other branded ids.
|
|
109
|
+
*/
|
|
110
|
+
type PerPlayerSchemaOptions<Id extends PlayerId> = {
|
|
111
|
+
readonly playerIdSchema?: z.ZodType<Id>;
|
|
112
|
+
readonly players?: readonly Id[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Build a Zod schema that validates a wire-shaped `PerPlayer<Value>`.
|
|
116
|
+
*
|
|
117
|
+
* When `options.players` is supplied the schema enforces that entries
|
|
118
|
+
* match that exact set (same cardinality, same ids, any order). This is
|
|
119
|
+
* the mechanism that catches the class of bug where a 3-player session
|
|
120
|
+
* produced a view shape the old `Record<PlayerId, T>` type claimed had
|
|
121
|
+
* a `player-4` key.
|
|
122
|
+
*/
|
|
123
|
+
declare function perPlayerSchema<Value, Id extends PlayerId = PlayerId>(valueSchema: z.ZodType<Value>, options?: PerPlayerSchemaOptions<Id>): z.ZodType<PerPlayer<Value, Id>>;
|
|
124
|
+
/**
|
|
125
|
+
* Reference to a board by its authored `baseId`, plus an optional seat
|
|
126
|
+
* for per-player boards.
|
|
127
|
+
*
|
|
128
|
+
* Replaces the old generated `"ring:player-1" | "ring:player-2" | ...`
|
|
129
|
+
* flat unions whose keys pretended to be static but were actually
|
|
130
|
+
* derived from `maxPlayers` and therefore misaligned with the runtime
|
|
131
|
+
* seat list.
|
|
132
|
+
*
|
|
133
|
+
* The discriminant is the *presence* of `seat`, not a `scope` field, so
|
|
134
|
+
* authors can destructure and pass the ref directly without needing a
|
|
135
|
+
* discriminator check for shared boards.
|
|
136
|
+
*/
|
|
137
|
+
type BoardRef<BaseId extends string = string, Id extends PlayerId = PlayerId> = SharedBoardRef<BaseId> | PerPlayerBoardRef<BaseId, Id>;
|
|
138
|
+
interface SharedBoardRef<BaseId extends string = string> {
|
|
139
|
+
readonly baseId: BaseId;
|
|
140
|
+
readonly seat?: undefined;
|
|
141
|
+
}
|
|
142
|
+
interface PerPlayerBoardRef<BaseId extends string = string, Id extends PlayerId = PlayerId> {
|
|
143
|
+
readonly baseId: BaseId;
|
|
144
|
+
readonly seat: Id;
|
|
145
|
+
}
|
|
146
|
+
/** Construct a shared board ref. */
|
|
147
|
+
declare function sharedBoardRef<BaseId extends string>(baseId: BaseId): SharedBoardRef<BaseId>;
|
|
148
|
+
/** Construct a per-player board ref. */
|
|
149
|
+
declare function perPlayerBoardRef<BaseId extends string, Id extends PlayerId>(baseId: BaseId, seat: Id): PerPlayerBoardRef<BaseId, Id>;
|
|
150
|
+
/**
|
|
151
|
+
* Construct a `BoardRef` without knowing the scope ahead of time. Pass
|
|
152
|
+
* `seat` for per-player boards; omit for shared boards.
|
|
153
|
+
*/
|
|
154
|
+
declare function boardRef<BaseId extends string, Id extends PlayerId>(baseId: BaseId, seat?: Id): BoardRef<BaseId, Id>;
|
|
155
|
+
/** Stable string key for Maps/Records keyed by a `BoardRef`. */
|
|
156
|
+
declare function boardRefKey(ref: BoardRef): string;
|
|
157
|
+
/**
|
|
158
|
+
* Inverse of `boardRefKey`. Parses `"base"` as a shared ref and
|
|
159
|
+
* `"base:player-N"` as a per-player ref. Returns `null` for malformed
|
|
160
|
+
* input.
|
|
161
|
+
*/
|
|
162
|
+
declare function parseBoardRefKey(key: string): BoardRef | null;
|
|
163
|
+
/**
|
|
164
|
+
* Zod schema for a `BoardRef` with free-form base and seat ids.
|
|
165
|
+
*
|
|
166
|
+
* Feed a manifest-scoped `baseIdSchema` and `playerIdSchema` to bind
|
|
167
|
+
* the ref to a specific workspace.
|
|
168
|
+
*/
|
|
169
|
+
declare function boardRefSchema<BaseId extends string = string, Id extends PlayerId = PlayerId>(options?: {
|
|
170
|
+
readonly baseIdSchema?: z.ZodType<BaseId>;
|
|
171
|
+
readonly playerIdSchema?: z.ZodType<Id>;
|
|
172
|
+
}): z.ZodType<BoardRef<BaseId, Id>>;
|
|
173
|
+
/** True when `ref` targets a shared board (no seat). */
|
|
174
|
+
declare function isSharedBoardRef<BaseId extends string>(ref: BoardRef<BaseId, PlayerId>): ref is SharedBoardRef<BaseId>;
|
|
175
|
+
/** True when `ref` targets a per-player board (has a seat). */
|
|
176
|
+
declare function isPerPlayerBoardRef<BaseId extends string, Id extends PlayerId>(ref: BoardRef<BaseId, Id>): ref is PerPlayerBoardRef<BaseId, Id>;
|
|
177
|
+
|
|
178
|
+
type RuntimeScalar = boolean | number | string | null;
|
|
179
|
+
interface RuntimeRecord {
|
|
180
|
+
[key: string]: RuntimePayload;
|
|
181
|
+
}
|
|
182
|
+
type RuntimePayload = RuntimeScalar | RuntimePayload[] | RuntimeRecord;
|
|
183
|
+
type RuntimeParams = RuntimeRecord;
|
|
184
|
+
type SchemaLike<Output> = z.ZodType<Output>;
|
|
185
|
+
type AnySchema = z.ZodTypeAny;
|
|
186
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
187
|
+
type NonEmptyReadonlyArray<T> = readonly [T, ...T[]];
|
|
188
|
+
type Brand<Value, Name extends string> = Value & {
|
|
189
|
+
readonly __brand: Name;
|
|
190
|
+
};
|
|
191
|
+
type RuntimeHandVisibilityMode = "all" | "ownerOnly" | "public" | "hidden";
|
|
192
|
+
type RuntimeDeckMap = Record<string, string[]>;
|
|
193
|
+
type RuntimeHandMap = Record<string, PerPlayer<string[]>>;
|
|
194
|
+
type RuntimeZoneMap = {
|
|
195
|
+
shared: Record<string, string[]>;
|
|
196
|
+
perPlayer: Record<string, PerPlayer<string[]>>;
|
|
197
|
+
visibility: Record<string, RuntimeHandVisibilityMode>;
|
|
198
|
+
cardSetIdsByZoneId?: Record<string, readonly string[]>;
|
|
199
|
+
};
|
|
200
|
+
type RuntimeOwnerMap = Record<string, string | null>;
|
|
201
|
+
type RuntimeResourceMap = PerPlayer<RuntimeRecord>;
|
|
202
|
+
type RuntimeBoardSpaceState = {
|
|
203
|
+
id: string;
|
|
204
|
+
name?: string | null;
|
|
205
|
+
typeId?: string | null;
|
|
206
|
+
fields: RuntimeRecord;
|
|
207
|
+
zoneId?: string | null;
|
|
208
|
+
};
|
|
209
|
+
type RuntimeBoardRelationState = {
|
|
210
|
+
id?: string | null;
|
|
211
|
+
typeId: string;
|
|
212
|
+
fromSpaceId: string;
|
|
213
|
+
toSpaceId: string;
|
|
214
|
+
directed: boolean;
|
|
215
|
+
fields: RuntimeRecord;
|
|
216
|
+
};
|
|
217
|
+
type RuntimeBoardContainerState = {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
host: {
|
|
221
|
+
type: "board";
|
|
222
|
+
} | {
|
|
223
|
+
type: "space";
|
|
224
|
+
spaceId: string;
|
|
225
|
+
};
|
|
226
|
+
allowedCardSetIds?: readonly string[];
|
|
227
|
+
zoneId: string;
|
|
228
|
+
fields: RuntimeRecord;
|
|
229
|
+
};
|
|
230
|
+
type RuntimeBoardCompatibilityState = {
|
|
231
|
+
spaces: Record<string, RuntimeBoardSpaceState>;
|
|
232
|
+
relations: RuntimeBoardRelationState[];
|
|
233
|
+
containers: Record<string, RuntimeBoardContainerState>;
|
|
234
|
+
};
|
|
235
|
+
type RuntimeBoardBaseState = {
|
|
236
|
+
id: string;
|
|
237
|
+
baseId?: string;
|
|
238
|
+
layout: "generic" | "hex" | "square";
|
|
239
|
+
typeId?: string | null;
|
|
240
|
+
scope: "shared" | "perPlayer";
|
|
241
|
+
playerId?: string | null;
|
|
242
|
+
templateId?: string | null;
|
|
243
|
+
fields: RuntimeRecord;
|
|
244
|
+
};
|
|
245
|
+
type RuntimeGenericBoardState = RuntimeBoardBaseState & {
|
|
246
|
+
layout: "generic";
|
|
247
|
+
} & RuntimeBoardCompatibilityState;
|
|
248
|
+
type RuntimeHexSpaceState = RuntimeBoardSpaceState & {
|
|
249
|
+
q: number;
|
|
250
|
+
r: number;
|
|
251
|
+
};
|
|
252
|
+
type RuntimeSquareSpaceState = RuntimeBoardSpaceState & {
|
|
253
|
+
row: number;
|
|
254
|
+
col: number;
|
|
255
|
+
};
|
|
256
|
+
type RuntimeTiledSpaceState = RuntimeHexSpaceState | RuntimeSquareSpaceState;
|
|
257
|
+
type RuntimeTiledEdgeState = {
|
|
258
|
+
id: string;
|
|
259
|
+
spaceIds: readonly string[];
|
|
260
|
+
typeId?: string | null;
|
|
261
|
+
label?: string | null;
|
|
262
|
+
ownerId?: string | null;
|
|
263
|
+
fields: RuntimeRecord;
|
|
264
|
+
};
|
|
265
|
+
type RuntimeTiledVertexState = {
|
|
266
|
+
id: string;
|
|
267
|
+
spaceIds: readonly string[];
|
|
268
|
+
typeId?: string | null;
|
|
269
|
+
label?: string | null;
|
|
270
|
+
ownerId?: string | null;
|
|
271
|
+
fields: RuntimeRecord;
|
|
272
|
+
};
|
|
273
|
+
type RuntimeHexEdgeState = RuntimeTiledEdgeState;
|
|
274
|
+
type RuntimeHexVertexState = RuntimeTiledVertexState;
|
|
275
|
+
type RuntimeSquareEdgeState = RuntimeTiledEdgeState;
|
|
276
|
+
type RuntimeSquareVertexState = RuntimeTiledVertexState;
|
|
277
|
+
type RuntimeHexOrientation = "pointy-top" | "flat-top";
|
|
278
|
+
type RuntimeTiledBoardBaseState = RuntimeBoardBaseState & {
|
|
279
|
+
layout: "hex" | "square";
|
|
280
|
+
relations: RuntimeBoardRelationState[];
|
|
281
|
+
containers: Record<string, RuntimeBoardContainerState>;
|
|
282
|
+
edges: RuntimeTiledEdgeState[];
|
|
283
|
+
vertices: RuntimeTiledVertexState[];
|
|
284
|
+
};
|
|
285
|
+
type RuntimeHexBoardState = RuntimeTiledBoardBaseState & {
|
|
286
|
+
layout: "hex";
|
|
287
|
+
spaces: Record<string, RuntimeHexSpaceState>;
|
|
288
|
+
orientation: RuntimeHexOrientation;
|
|
289
|
+
edges: RuntimeHexEdgeState[];
|
|
290
|
+
vertices: RuntimeHexVertexState[];
|
|
291
|
+
};
|
|
292
|
+
type RuntimeSquareBoardState = RuntimeTiledBoardBaseState & {
|
|
293
|
+
layout: "square";
|
|
294
|
+
spaces: Record<string, RuntimeSquareSpaceState>;
|
|
295
|
+
edges: RuntimeSquareEdgeState[];
|
|
296
|
+
vertices: RuntimeSquareVertexState[];
|
|
297
|
+
};
|
|
298
|
+
type RuntimeTiledBoardState = RuntimeHexBoardState | RuntimeSquareBoardState;
|
|
299
|
+
type RuntimeBoardState = RuntimeGenericBoardState | RuntimeTiledBoardState;
|
|
300
|
+
type RuntimeBoardCollections = {
|
|
301
|
+
byId: Record<string, RuntimeBoardState>;
|
|
302
|
+
hex: Record<string, RuntimeHexBoardState>;
|
|
303
|
+
square: Record<string, RuntimeSquareBoardState>;
|
|
304
|
+
/** Structured board buckets used by manifest table schemas (empty when unused). */
|
|
305
|
+
network: Record<string, RuntimeRecord>;
|
|
306
|
+
track: Record<string, RuntimeRecord>;
|
|
307
|
+
};
|
|
308
|
+
type RuntimeCardVisibility = {
|
|
309
|
+
faceUp: boolean;
|
|
310
|
+
visibleTo?: string[] | null;
|
|
311
|
+
};
|
|
312
|
+
type RuntimeCardData = {
|
|
313
|
+
componentType?: string;
|
|
314
|
+
id: string;
|
|
315
|
+
cardSetId: string;
|
|
316
|
+
cardType: string;
|
|
317
|
+
name?: string;
|
|
318
|
+
text?: string;
|
|
319
|
+
properties: RuntimeRecord;
|
|
320
|
+
};
|
|
321
|
+
type RuntimePieceData = {
|
|
322
|
+
componentType?: string;
|
|
323
|
+
id: string;
|
|
324
|
+
pieceTypeId: string;
|
|
325
|
+
pieceName?: string | null;
|
|
326
|
+
ownerId?: string | null;
|
|
327
|
+
properties: RuntimeRecord;
|
|
328
|
+
};
|
|
329
|
+
type RuntimeDieData = {
|
|
330
|
+
componentType?: string;
|
|
331
|
+
id: string;
|
|
332
|
+
dieTypeId: string;
|
|
333
|
+
dieName?: string | null;
|
|
334
|
+
ownerId?: string | null;
|
|
335
|
+
sides: number;
|
|
336
|
+
value?: number | null;
|
|
337
|
+
properties: RuntimeRecord;
|
|
338
|
+
};
|
|
339
|
+
type RuntimeSlotHostRef = {
|
|
340
|
+
kind: "piece";
|
|
341
|
+
id: string;
|
|
342
|
+
} | {
|
|
343
|
+
kind: "die";
|
|
344
|
+
id: string;
|
|
345
|
+
};
|
|
346
|
+
type RuntimeComponentLocation = {
|
|
347
|
+
type: "Detached";
|
|
348
|
+
} | {
|
|
349
|
+
type: "InDeck";
|
|
350
|
+
deckId: string;
|
|
351
|
+
playedBy: string | null;
|
|
352
|
+
position?: number | null;
|
|
353
|
+
} | {
|
|
354
|
+
type: "InHand";
|
|
355
|
+
handId: string;
|
|
356
|
+
playerId: string;
|
|
357
|
+
position?: number | null;
|
|
358
|
+
} | {
|
|
359
|
+
type: "InZone";
|
|
360
|
+
zoneId: string;
|
|
361
|
+
playedBy?: string | null;
|
|
362
|
+
position?: number | null;
|
|
363
|
+
} | {
|
|
364
|
+
type: "OnSpace";
|
|
365
|
+
boardId: string;
|
|
366
|
+
spaceId: string;
|
|
367
|
+
position?: number | null;
|
|
368
|
+
} | {
|
|
369
|
+
type: "InContainer";
|
|
370
|
+
boardId: string;
|
|
371
|
+
containerId: string;
|
|
372
|
+
position?: number | null;
|
|
373
|
+
} | {
|
|
374
|
+
type: "OnEdge";
|
|
375
|
+
boardId: string;
|
|
376
|
+
edgeId: string;
|
|
377
|
+
position?: number | null;
|
|
378
|
+
} | {
|
|
379
|
+
type: "OnVertex";
|
|
380
|
+
boardId: string;
|
|
381
|
+
vertexId: string;
|
|
382
|
+
position?: number | null;
|
|
383
|
+
} | {
|
|
384
|
+
type: "InSlot";
|
|
385
|
+
host: RuntimeSlotHostRef;
|
|
386
|
+
slotId: string;
|
|
387
|
+
position?: number | null;
|
|
388
|
+
};
|
|
389
|
+
type RuntimeComponentLocationMap = Record<string, RuntimeComponentLocation>;
|
|
390
|
+
type RuntimeVisibilityMap = Record<string, RuntimeCardVisibility>;
|
|
391
|
+
type RuntimeTableRecord = {
|
|
392
|
+
playerOrder: string[];
|
|
393
|
+
zones: RuntimeZoneMap;
|
|
394
|
+
decks: RuntimeDeckMap;
|
|
395
|
+
hands: RuntimeHandMap;
|
|
396
|
+
handVisibility: Record<string, RuntimeHandVisibilityMode>;
|
|
397
|
+
cards: Record<string, RuntimeCardData>;
|
|
398
|
+
pieces: Record<string, RuntimePieceData>;
|
|
399
|
+
componentLocations: RuntimeComponentLocationMap;
|
|
400
|
+
ownerOfCard: RuntimeOwnerMap;
|
|
401
|
+
visibility: RuntimeVisibilityMap;
|
|
402
|
+
resources: RuntimeResourceMap;
|
|
403
|
+
boards: RuntimeBoardCollections;
|
|
404
|
+
dice: Record<string, RuntimeDieData>;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
declare const FrameworkErrorCodes: {
|
|
408
|
+
readonly NOT_YOUR_TURN: "NOT_YOUR_TURN";
|
|
409
|
+
readonly WRONG_PHASE: "WRONG_PHASE";
|
|
410
|
+
readonly WRONG_STEP: "WRONG_STEP";
|
|
411
|
+
readonly INVALID_PARAMS: "INVALID_PARAMS";
|
|
412
|
+
readonly UNKNOWN_INTERACTION: "UNKNOWN_INTERACTION";
|
|
413
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
414
|
+
};
|
|
415
|
+
type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
|
|
416
|
+
|
|
417
|
+
type TableOfState<State> = State extends {
|
|
418
|
+
table: infer Table;
|
|
419
|
+
} ? Table : never;
|
|
420
|
+
type TableOfManifest<Manifest> = Manifest extends {
|
|
421
|
+
tableSchema: z.ZodType<infer Table extends RuntimeTableRecord>;
|
|
422
|
+
} ? Table : Manifest extends GeneratedManifestContractLike<infer Table> ? Table : never;
|
|
423
|
+
type PhaseNameOfState<State> = State extends {
|
|
424
|
+
flow: {
|
|
425
|
+
currentPhase: infer PhaseName;
|
|
426
|
+
};
|
|
427
|
+
} ? Extract<PhaseName, string> : never;
|
|
428
|
+
type PhaseNameOfManifest<Manifest> = Manifest extends {
|
|
429
|
+
literals: {
|
|
430
|
+
phaseNames: readonly (infer PhaseName)[];
|
|
431
|
+
};
|
|
432
|
+
} ? Extract<PhaseName, string> : never;
|
|
433
|
+
type PlayerIdOfTable<Table> = Table extends {
|
|
434
|
+
playerOrder: readonly (infer PlayerId)[];
|
|
435
|
+
} ? Extract<PlayerId, string> : never;
|
|
436
|
+
type PlayerIdOfManifest<Manifest> = Manifest extends {
|
|
437
|
+
literals: {
|
|
438
|
+
playerIds: readonly (infer PlayerId)[];
|
|
439
|
+
};
|
|
440
|
+
} ? Extract<PlayerId, string> : string;
|
|
441
|
+
type PlayerIdOfState<State> = PlayerIdOfTable<TableOfState<State>>;
|
|
442
|
+
type ErrorCodeOfContract<Contract> = Contract extends {
|
|
443
|
+
errors: infer Errors extends Record<string, string>;
|
|
444
|
+
} ? (keyof Errors & string) | FrameworkErrorCode : string;
|
|
445
|
+
/**
|
|
446
|
+
* Manifest-declared resource id union for a runtime table.
|
|
447
|
+
*
|
|
448
|
+
* Derived from the shape of `table.resources`, which the generated
|
|
449
|
+
* manifest contract seeds as `PerPlayer<Record<ResourceId, number>>`.
|
|
450
|
+
* The helper peeks inside the `PerPlayer` wrapper to surface the
|
|
451
|
+
* resource-id keys without forcing callers to remember the wrapper.
|
|
452
|
+
*/
|
|
453
|
+
type ResourceIdOfTable<Table> = Table extends {
|
|
454
|
+
resources: infer Resources;
|
|
455
|
+
} ? ValueOfPerPlayer<Resources> extends infer PerPlayerValue ? PerPlayerValue extends Record<string, unknown> ? StringKeyOf<PerPlayerValue> : never : never : never;
|
|
456
|
+
type ResourceIdOfState<State> = ResourceIdOfTable<TableOfState<State>>;
|
|
457
|
+
/**
|
|
458
|
+
* Per-player balance shape for a runtime table. Strips the `PerPlayer`
|
|
459
|
+
* wrapper around `table.resources` so callers receive the manifest-typed
|
|
460
|
+
* record directly (e.g. `Record<ResourceId, number>`).
|
|
461
|
+
*/
|
|
462
|
+
type ResourceBalancesOfTable<Table> = Table extends {
|
|
463
|
+
resources: infer Resources;
|
|
464
|
+
} ? ValueOfPerPlayer<Resources> extends infer PerPlayerValue ? PerPlayerValue extends Record<string, unknown> ? PerPlayerValue : never : never : never;
|
|
465
|
+
type ResourceBalancesOfState<State> = ResourceBalancesOfTable<TableOfState<State>>;
|
|
466
|
+
type ResourceIdOfManifest<Manifest> = Manifest extends {
|
|
467
|
+
literals: {
|
|
468
|
+
resourceIds: readonly (infer ResourceId)[];
|
|
469
|
+
};
|
|
470
|
+
} ? Extract<ResourceId, string> : string;
|
|
471
|
+
/**
|
|
472
|
+
* Per-player resource counts: a partial `Record<ResourceId, number>`.
|
|
473
|
+
*
|
|
474
|
+
* Used as the input shape for {@link ReducerOps.addResources},
|
|
475
|
+
* {@link ReducerOps.spendResources}, and {@link ReducerOps.transferResources}.
|
|
476
|
+
*/
|
|
477
|
+
type ResourceAmountsOfTable<Table> = Partial<Record<ResourceIdOfTable<Table>, number>>;
|
|
478
|
+
type PhaseStateOfState<State> = State extends {
|
|
479
|
+
phase: infer PhaseState;
|
|
480
|
+
} ? PhaseState : never;
|
|
481
|
+
type PhaseStepOfState<State> = PhaseStateOfState<State> extends {
|
|
482
|
+
step?: infer Step;
|
|
483
|
+
} ? Extract<NonNullable<Step>, string> : never;
|
|
484
|
+
type PhaseMapOfState<State> = PhaseStateOfState<State>;
|
|
485
|
+
type PublicStateOfState<State> = State extends {
|
|
486
|
+
publicState: infer PublicState;
|
|
487
|
+
} ? PublicState : never;
|
|
488
|
+
type HiddenStateOfState<State> = State extends {
|
|
489
|
+
hiddenState: infer HiddenState;
|
|
490
|
+
} ? HiddenState : never;
|
|
491
|
+
type PrivateStateOfState<State> = State extends {
|
|
492
|
+
privateState: Record<string, infer PrivateState>;
|
|
493
|
+
} ? PrivateState : never;
|
|
494
|
+
type DeckIdOfTable<Table> = Table extends {
|
|
495
|
+
decks: infer Decks;
|
|
496
|
+
} ? StringKeyOf<Decks> : never;
|
|
497
|
+
type HandIdOfTable<Table> = Table extends {
|
|
498
|
+
hands: infer Hands;
|
|
499
|
+
} ? StringKeyOf<Hands> : never;
|
|
500
|
+
type CardIdOfTable<Table> = Table extends {
|
|
501
|
+
cards: infer Cards;
|
|
502
|
+
} ? StringKeyOf<Cards> : never;
|
|
503
|
+
type CardTypeOfTable<Table> = Table extends {
|
|
504
|
+
cards: Record<string, {
|
|
505
|
+
cardType: infer CardType;
|
|
506
|
+
}>;
|
|
507
|
+
} ? Extract<CardType, string> : string;
|
|
508
|
+
type DeckIdOfState<State> = DeckIdOfTable<TableOfState<State>>;
|
|
509
|
+
type HandIdOfState<State> = HandIdOfTable<TableOfState<State>>;
|
|
510
|
+
type CardIdOfState<State> = CardIdOfTable<TableOfState<State>>;
|
|
511
|
+
type CardTypeOfState<State> = CardTypeOfTable<TableOfState<State>>;
|
|
512
|
+
type CardIdOfManifest<Manifest> = Manifest extends {
|
|
513
|
+
literals: {
|
|
514
|
+
cardIds: readonly (infer CardId)[];
|
|
515
|
+
};
|
|
516
|
+
} ? Extract<CardId, string> : string;
|
|
517
|
+
type SharedZoneIdOfTable<Table> = DeckIdOfTable<Table>;
|
|
518
|
+
type PlayerZoneIdOfTable<Table> = HandIdOfTable<Table>;
|
|
519
|
+
type BoardMapOfTable<Table> = Table extends {
|
|
520
|
+
boards: {
|
|
521
|
+
byId: infer Boards;
|
|
522
|
+
};
|
|
523
|
+
} ? Boards : never;
|
|
524
|
+
type BoardIdOfTable<Table> = StringKeyOf<BoardMapOfTable<Table>>;
|
|
525
|
+
type BoardStateOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardMapOfTable<Table>[BoardId];
|
|
526
|
+
type BoardTypeIdOfTable<Table> = BoardStateOfTable<Table, BoardIdOfTable<Table>> extends {
|
|
527
|
+
typeId?: infer BoardTypeId | null;
|
|
528
|
+
} ? Extract<BoardTypeId, string> : never;
|
|
529
|
+
type TiledBoardIdOfTable<Table> = {
|
|
530
|
+
[BoardId in BoardIdOfTable<Table>]: BoardStateOfTable<Table, BoardId> extends {
|
|
531
|
+
layout: "hex" | "square";
|
|
532
|
+
} ? BoardId : never;
|
|
533
|
+
}[BoardIdOfTable<Table>];
|
|
534
|
+
type TiledBoardStateOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends infer BoardState ? BoardState extends {
|
|
535
|
+
layout: "hex" | "square";
|
|
536
|
+
spaces: Record<string, unknown>;
|
|
537
|
+
edges: readonly {
|
|
538
|
+
id: string;
|
|
539
|
+
}[];
|
|
540
|
+
vertices: readonly {
|
|
541
|
+
id: string;
|
|
542
|
+
}[];
|
|
543
|
+
} ? BoardState : never : never;
|
|
544
|
+
type HexBoardIdOfTable<Table> = {
|
|
545
|
+
[BoardId in BoardIdOfTable<Table>]: BoardStateOfTable<Table, BoardId> extends {
|
|
546
|
+
layout: "hex";
|
|
547
|
+
} ? BoardId : never;
|
|
548
|
+
}[BoardIdOfTable<Table>];
|
|
549
|
+
type HexBoardStateOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends infer BoardState ? BoardState extends {
|
|
550
|
+
layout: "hex";
|
|
551
|
+
spaces: Record<string, unknown>;
|
|
552
|
+
edges: readonly {
|
|
553
|
+
id: string;
|
|
554
|
+
}[];
|
|
555
|
+
vertices: readonly {
|
|
556
|
+
id: string;
|
|
557
|
+
}[];
|
|
558
|
+
} ? BoardState : never : never;
|
|
559
|
+
type SquareBoardIdOfTable<Table> = {
|
|
560
|
+
[BoardId in BoardIdOfTable<Table>]: BoardStateOfTable<Table, BoardId> extends {
|
|
561
|
+
layout: "square";
|
|
562
|
+
} ? BoardId : never;
|
|
563
|
+
}[BoardIdOfTable<Table>];
|
|
564
|
+
type SquareBoardStateOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends infer BoardState ? BoardState extends {
|
|
565
|
+
layout: "square";
|
|
566
|
+
spaces: Record<string, unknown>;
|
|
567
|
+
edges: readonly {
|
|
568
|
+
id: string;
|
|
569
|
+
}[];
|
|
570
|
+
vertices: readonly {
|
|
571
|
+
id: string;
|
|
572
|
+
}[];
|
|
573
|
+
} ? BoardState : never : never;
|
|
574
|
+
type SpaceIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
|
|
575
|
+
spaces: infer Spaces;
|
|
576
|
+
} ? StringKeyOf<Spaces> : never;
|
|
577
|
+
type SpaceTypeIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
|
|
578
|
+
spaces: infer Spaces extends Record<string, unknown>;
|
|
579
|
+
} ? Spaces[StringKeyOf<Spaces>] extends {
|
|
580
|
+
typeId?: infer SpaceTypeId | null;
|
|
581
|
+
} ? Extract<SpaceTypeId, string> : never : never;
|
|
582
|
+
type BoardContainerIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
|
|
583
|
+
containers: infer Containers;
|
|
584
|
+
} ? StringKeyOf<Containers> : never;
|
|
585
|
+
type RelationTypeIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
|
|
586
|
+
relations: readonly (infer Relation)[];
|
|
587
|
+
} ? Relation extends {
|
|
588
|
+
typeId: infer RelationTypeId;
|
|
589
|
+
} ? Extract<RelationTypeId, string> : never : never;
|
|
590
|
+
type TiledSpaceIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
591
|
+
spaces: infer Spaces;
|
|
592
|
+
} ? StringKeyOf<Spaces> : never;
|
|
593
|
+
type HexSpaceIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
594
|
+
spaces: infer Spaces;
|
|
595
|
+
} ? StringKeyOf<Spaces> : never;
|
|
596
|
+
type SquareSpaceIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
597
|
+
spaces: infer Spaces;
|
|
598
|
+
} ? StringKeyOf<Spaces> : never;
|
|
599
|
+
type HexSpaceTypeIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
600
|
+
spaces: infer Spaces extends Record<string, unknown>;
|
|
601
|
+
} ? Spaces[StringKeyOf<Spaces>] extends {
|
|
602
|
+
typeId?: infer SpaceTypeId | null;
|
|
603
|
+
} ? Extract<SpaceTypeId, string> : never : never;
|
|
604
|
+
type SquareSpaceTypeIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
605
|
+
spaces: infer Spaces extends Record<string, unknown>;
|
|
606
|
+
} ? Spaces[StringKeyOf<Spaces>] extends {
|
|
607
|
+
typeId?: infer SpaceTypeId | null;
|
|
608
|
+
} ? Extract<SpaceTypeId, string> : never : never;
|
|
609
|
+
type TiledEdgeIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
610
|
+
edges: readonly (infer Edge)[];
|
|
611
|
+
} ? Edge extends {
|
|
612
|
+
id: infer EdgeId;
|
|
613
|
+
} ? Extract<EdgeId, string> : never : never;
|
|
614
|
+
type HexEdgeIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
615
|
+
edges: readonly (infer Edge)[];
|
|
616
|
+
} ? Edge extends {
|
|
617
|
+
id: infer EdgeId;
|
|
618
|
+
} ? Extract<EdgeId, string> : never : never;
|
|
619
|
+
type SquareEdgeIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
620
|
+
edges: readonly (infer Edge)[];
|
|
621
|
+
} ? Edge extends {
|
|
622
|
+
id: infer EdgeId;
|
|
623
|
+
} ? Extract<EdgeId, string> : never : never;
|
|
624
|
+
/**
|
|
625
|
+
* Edge record on a tiled board narrowed to a specific `EdgeId` literal.
|
|
626
|
+
*
|
|
627
|
+
* The generated board state stores edges as a single array element type
|
|
628
|
+
* `{ id: <union-of-edge-ids>, spaceIds, typeId, fields, ... }`. Looking up an
|
|
629
|
+
* edge by id should return a record whose `id` is narrowed to the literal
|
|
630
|
+
* that was requested, not the entire edge-id union.
|
|
631
|
+
*/
|
|
632
|
+
type TiledEdgeStateOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>, EdgeId extends TiledEdgeIdOfTable<Table, BoardId>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
633
|
+
edges: readonly (infer Edge)[];
|
|
634
|
+
} ? Edge extends {
|
|
635
|
+
id: string;
|
|
636
|
+
} ? Omit<Edge, "id"> & {
|
|
637
|
+
id: EdgeId;
|
|
638
|
+
} : never : never;
|
|
639
|
+
type HexEdgeStateOfTable<Table, BoardId extends HexBoardIdOfTable<Table>, EdgeId extends HexEdgeIdOfTable<Table, BoardId>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
640
|
+
edges: readonly (infer Edge)[];
|
|
641
|
+
} ? Edge extends {
|
|
642
|
+
id: string;
|
|
643
|
+
} ? Omit<Edge, "id"> & {
|
|
644
|
+
id: EdgeId;
|
|
645
|
+
} : never : never;
|
|
646
|
+
type SquareEdgeStateOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>, EdgeId extends SquareEdgeIdOfTable<Table, BoardId>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
647
|
+
edges: readonly (infer Edge)[];
|
|
648
|
+
} ? Edge extends {
|
|
649
|
+
id: string;
|
|
650
|
+
} ? Omit<Edge, "id"> & {
|
|
651
|
+
id: EdgeId;
|
|
652
|
+
} : never : never;
|
|
653
|
+
type TiledEdgeTypeIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
654
|
+
edges: readonly (infer Edge)[];
|
|
655
|
+
} ? Edge extends {
|
|
656
|
+
typeId?: infer EdgeTypeId | null;
|
|
657
|
+
} ? Extract<EdgeTypeId, string> : never : never;
|
|
658
|
+
type HexEdgeTypeIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
659
|
+
edges: readonly (infer Edge)[];
|
|
660
|
+
} ? Edge extends {
|
|
661
|
+
typeId?: infer EdgeTypeId | null;
|
|
662
|
+
} ? Extract<EdgeTypeId, string> : never : never;
|
|
663
|
+
type SquareEdgeTypeIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
664
|
+
edges: readonly (infer Edge)[];
|
|
665
|
+
} ? Edge extends {
|
|
666
|
+
typeId?: infer EdgeTypeId | null;
|
|
667
|
+
} ? Extract<EdgeTypeId, string> : never : never;
|
|
668
|
+
type TiledVertexIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
669
|
+
vertices: readonly (infer Vertex)[];
|
|
670
|
+
} ? Vertex extends {
|
|
671
|
+
id: infer VertexId;
|
|
672
|
+
} ? Extract<VertexId, string> : never : never;
|
|
673
|
+
type HexVertexIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
674
|
+
vertices: readonly (infer Vertex)[];
|
|
675
|
+
} ? Vertex extends {
|
|
676
|
+
id: infer VertexId;
|
|
677
|
+
} ? Extract<VertexId, string> : never : never;
|
|
678
|
+
type SquareVertexIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
679
|
+
vertices: readonly (infer Vertex)[];
|
|
680
|
+
} ? Vertex extends {
|
|
681
|
+
id: infer VertexId;
|
|
682
|
+
} ? Extract<VertexId, string> : never : never;
|
|
683
|
+
/**
|
|
684
|
+
* Vertex record on a tiled board narrowed to a specific `VertexId` literal.
|
|
685
|
+
* See {@link TiledEdgeStateOfTable} for rationale.
|
|
686
|
+
*/
|
|
687
|
+
type TiledVertexStateOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>, VertexId extends TiledVertexIdOfTable<Table, BoardId>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
688
|
+
vertices: readonly (infer Vertex)[];
|
|
689
|
+
} ? Vertex extends {
|
|
690
|
+
id: string;
|
|
691
|
+
} ? Omit<Vertex, "id"> & {
|
|
692
|
+
id: VertexId;
|
|
693
|
+
} : never : never;
|
|
694
|
+
type HexVertexStateOfTable<Table, BoardId extends HexBoardIdOfTable<Table>, VertexId extends HexVertexIdOfTable<Table, BoardId>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
695
|
+
vertices: readonly (infer Vertex)[];
|
|
696
|
+
} ? Vertex extends {
|
|
697
|
+
id: string;
|
|
698
|
+
} ? Omit<Vertex, "id"> & {
|
|
699
|
+
id: VertexId;
|
|
700
|
+
} : never : never;
|
|
701
|
+
type SquareVertexStateOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>, VertexId extends SquareVertexIdOfTable<Table, BoardId>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
702
|
+
vertices: readonly (infer Vertex)[];
|
|
703
|
+
} ? Vertex extends {
|
|
704
|
+
id: string;
|
|
705
|
+
} ? Omit<Vertex, "id"> & {
|
|
706
|
+
id: VertexId;
|
|
707
|
+
} : never : never;
|
|
708
|
+
type TiledVertexTypeIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
|
|
709
|
+
vertices: readonly (infer Vertex)[];
|
|
710
|
+
} ? Vertex extends {
|
|
711
|
+
typeId?: infer VertexTypeId | null;
|
|
712
|
+
} ? Extract<VertexTypeId, string> : never : never;
|
|
713
|
+
type HexVertexTypeIdOfTable<Table, BoardId extends HexBoardIdOfTable<Table>> = HexBoardStateOfTable<Table, BoardId> extends {
|
|
714
|
+
vertices: readonly (infer Vertex)[];
|
|
715
|
+
} ? Vertex extends {
|
|
716
|
+
typeId?: infer VertexTypeId | null;
|
|
717
|
+
} ? Extract<VertexTypeId, string> : never : never;
|
|
718
|
+
type SquareVertexTypeIdOfTable<Table, BoardId extends SquareBoardIdOfTable<Table>> = SquareBoardStateOfTable<Table, BoardId> extends {
|
|
719
|
+
vertices: readonly (infer Vertex)[];
|
|
720
|
+
} ? Vertex extends {
|
|
721
|
+
typeId?: infer VertexTypeId | null;
|
|
722
|
+
} ? Extract<VertexTypeId, string> : never : never;
|
|
723
|
+
type TiledSpaceMap<Table, BoardId extends TiledBoardIdOfTable<Table>, Value> = Partial<Record<TiledSpaceIdOfTable<Table, BoardId>, Value>>;
|
|
724
|
+
type TiledEdgeMap<Table, BoardId extends TiledBoardIdOfTable<Table>, Value> = Partial<Record<TiledEdgeIdOfTable<Table, BoardId>, Value>>;
|
|
725
|
+
type TiledVertexMap<Table, BoardId extends TiledBoardIdOfTable<Table>, Value> = Partial<Record<TiledVertexIdOfTable<Table, BoardId>, Value>>;
|
|
726
|
+
type ComponentIdOfTable<Table> = Table extends {
|
|
727
|
+
componentLocations: infer ComponentLocations;
|
|
728
|
+
} ? StringKeyOf<ComponentLocations> : never;
|
|
729
|
+
type SharedZoneIdOfManifest<Manifest> = Manifest extends {
|
|
730
|
+
literals: {
|
|
731
|
+
sharedZoneIds: readonly (infer ZoneId)[];
|
|
732
|
+
};
|
|
733
|
+
} ? Extract<ZoneId, string> : string;
|
|
734
|
+
type PlayerZoneIdOfManifest<Manifest> = Manifest extends {
|
|
735
|
+
literals: {
|
|
736
|
+
playerZoneIds: readonly (infer ZoneId)[];
|
|
737
|
+
};
|
|
738
|
+
} ? Extract<ZoneId, string> : string;
|
|
739
|
+
type SharedZoneIdOfState<State> = DeckIdOfState<State>;
|
|
740
|
+
type PlayerZoneIdOfState<State> = HandIdOfState<State>;
|
|
741
|
+
type BoardIdOfManifest<Manifest> = Manifest extends {
|
|
742
|
+
literals: {
|
|
743
|
+
boardIds: readonly (infer BoardId)[];
|
|
744
|
+
};
|
|
745
|
+
} ? Extract<BoardId, string> : string;
|
|
746
|
+
type BoardLayoutOfManifest<Manifest> = Manifest extends {
|
|
747
|
+
literals: {
|
|
748
|
+
boardLayouts: readonly (infer BoardLayout)[];
|
|
749
|
+
};
|
|
750
|
+
} ? Extract<BoardLayout, string> : "generic" | "hex" | "square";
|
|
751
|
+
type BoardTypeIdOfManifest<Manifest> = Manifest extends {
|
|
752
|
+
literals: {
|
|
753
|
+
boardTypeIds: readonly (infer BoardTypeId)[];
|
|
754
|
+
};
|
|
755
|
+
} ? Extract<BoardTypeId, string> : string;
|
|
756
|
+
type BoardBaseIdOfManifest<Manifest> = Manifest extends {
|
|
757
|
+
literals: {
|
|
758
|
+
boardBaseIds: readonly (infer BoardBaseId)[];
|
|
759
|
+
};
|
|
760
|
+
} ? Extract<BoardBaseId, string> : string;
|
|
761
|
+
type RelationTypeIdOfManifest<Manifest> = Manifest extends {
|
|
762
|
+
literals: {
|
|
763
|
+
relationTypeIds: readonly (infer RelationTypeId)[];
|
|
764
|
+
};
|
|
765
|
+
} ? Extract<RelationTypeId, string> : string;
|
|
766
|
+
type BoardContainerIdOfManifest<Manifest> = Manifest extends {
|
|
767
|
+
literals: {
|
|
768
|
+
boardContainerIds: readonly (infer ContainerId)[];
|
|
769
|
+
};
|
|
770
|
+
} ? Extract<ContainerId, string> : string;
|
|
771
|
+
type EdgeTypeIdOfManifest<Manifest> = Manifest extends {
|
|
772
|
+
literals: {
|
|
773
|
+
edgeTypeIds: readonly (infer EdgeTypeId)[];
|
|
774
|
+
};
|
|
775
|
+
} ? Extract<EdgeTypeId, string> : string;
|
|
776
|
+
type VertexTypeIdOfManifest<Manifest> = Manifest extends {
|
|
777
|
+
literals: {
|
|
778
|
+
vertexTypeIds: readonly (infer VertexTypeId)[];
|
|
779
|
+
};
|
|
780
|
+
} ? Extract<VertexTypeId, string> : string;
|
|
781
|
+
type SpaceIdOfManifest<Manifest> = Manifest extends {
|
|
782
|
+
literals: {
|
|
783
|
+
spaceIds: readonly (infer SpaceId)[];
|
|
784
|
+
};
|
|
785
|
+
} ? Extract<SpaceId, string> : string;
|
|
786
|
+
type SpaceTypeIdOfManifest<Manifest> = Manifest extends {
|
|
787
|
+
literals: {
|
|
788
|
+
spaceTypeIds: readonly (infer SpaceTypeId)[];
|
|
789
|
+
};
|
|
790
|
+
} ? Extract<SpaceTypeId, string> : string;
|
|
791
|
+
type PieceIdOfManifest<Manifest> = Manifest extends {
|
|
792
|
+
literals: {
|
|
793
|
+
pieceIds: readonly (infer PieceId)[];
|
|
794
|
+
};
|
|
795
|
+
} ? Extract<PieceId, string> : string;
|
|
796
|
+
type DieIdOfManifest<Manifest> = Manifest extends {
|
|
797
|
+
literals: {
|
|
798
|
+
dieIds: readonly (infer DieId)[];
|
|
799
|
+
};
|
|
800
|
+
} ? Extract<DieId, string> : string;
|
|
801
|
+
type ManifestOf<Source> = Source extends {
|
|
802
|
+
contract: infer Contract;
|
|
803
|
+
} ? ManifestOf<Contract> : Source extends {
|
|
804
|
+
manifest: infer Manifest;
|
|
805
|
+
} ? Manifest : never;
|
|
806
|
+
type SetupOptionIdOfManifest<Manifest> = Manifest extends {
|
|
807
|
+
literals: {
|
|
808
|
+
setupOptionIds: readonly (infer SetupOptionId)[];
|
|
809
|
+
};
|
|
810
|
+
} ? Extract<SetupOptionId, string> : string;
|
|
811
|
+
type SetupProfileIdOfManifest<Manifest> = Manifest extends {
|
|
812
|
+
literals: {
|
|
813
|
+
setupProfileIds: readonly (infer SetupProfileId)[];
|
|
814
|
+
};
|
|
815
|
+
} ? Extract<SetupProfileId, string> : string;
|
|
816
|
+
type SetupSelectionInputOfManifest<Manifest> = {
|
|
817
|
+
profileId: SetupProfileIdOfManifest<Manifest>;
|
|
818
|
+
optionValues?: Partial<Record<SetupOptionIdOfManifest<Manifest>, string>>;
|
|
819
|
+
};
|
|
820
|
+
type SetupSelectionOfManifest<Manifest> = {
|
|
821
|
+
profileId: SetupProfileIdOfManifest<Manifest>;
|
|
822
|
+
optionValues: Record<SetupOptionIdOfManifest<Manifest>, string | null>;
|
|
823
|
+
};
|
|
824
|
+
type RuntimeSetupSelectionInput<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = SetupSelectionInputOfManifest<Manifest>;
|
|
825
|
+
type RuntimeSetupSelection<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = SetupSelectionOfManifest<Manifest>;
|
|
826
|
+
type RuntimeSetupSelectionOverride<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = SetupSelectionInputOfManifest<Manifest>;
|
|
827
|
+
type StateDefinitionOfContract<Contract> = Contract extends {
|
|
828
|
+
state: infer StateDefinitionValue;
|
|
829
|
+
} ? StateDefinitionValue : never;
|
|
830
|
+
type PhaseSchemasOfContract<Contract> = Contract extends {
|
|
831
|
+
phases: infer Phases extends Record<string, SchemaLike<object>>;
|
|
832
|
+
} ? Phases : Record<PhaseNameOfManifest<ManifestOf<Contract>>, SchemaLike<object>>;
|
|
833
|
+
type PhaseStateMapOfContract<Contract> = {
|
|
834
|
+
[Name in keyof PhaseSchemasOfContract<Contract> & string]: z.infer<PhaseSchemasOfContract<Contract>[Name]>;
|
|
835
|
+
};
|
|
836
|
+
type PublicSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<infer PublicSchema, SchemaLike<object>, SchemaLike<object>> ? PublicSchema : never;
|
|
837
|
+
type PrivateSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, infer PrivateSchema, SchemaLike<object>> ? PrivateSchema : never;
|
|
838
|
+
type HiddenSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, SchemaLike<object>, infer HiddenSchema> ? HiddenSchema : never;
|
|
839
|
+
type PhaseNameOfContract<Contract> = keyof PhaseSchemasOfContract<Contract> extends string ? keyof PhaseSchemasOfContract<Contract> & string : PhaseNameOfManifest<ManifestOf<Contract>>;
|
|
840
|
+
type ManifestContractOf<Contract> = ManifestContract<TableOfManifest<ManifestOf<Contract>>>;
|
|
841
|
+
type ExactManifestContractOf<Contract> = ManifestOf<Contract> & GeneratedManifestContractLike<TableOfManifest<ManifestOf<Contract>>>;
|
|
842
|
+
type PhaseNameOf<Source> = Source extends {
|
|
843
|
+
flow: {
|
|
844
|
+
currentPhase: infer PhaseName;
|
|
845
|
+
};
|
|
846
|
+
} ? Extract<PhaseName, string> : PhaseNameOfContract<Source>;
|
|
847
|
+
type DeckCardsOfTable<Table, DeckId extends DeckIdOfTable<Table>> = Table extends {
|
|
848
|
+
decks: infer Decks extends Record<string, readonly unknown[]>;
|
|
849
|
+
} ? Decks[DeckId] : never;
|
|
850
|
+
type ValueOfPerPlayer<T> = T extends {
|
|
851
|
+
readonly entries: ReadonlyArray<readonly [unknown, infer Value]>;
|
|
852
|
+
} ? Value : never;
|
|
853
|
+
type HandCardsOfTable<Table, HandId extends HandIdOfTable<Table>> = Table extends {
|
|
854
|
+
hands: infer Hands extends Record<string, unknown>;
|
|
855
|
+
} ? HandId extends keyof Hands ? ValueOfPerPlayer<Hands[HandId]> extends infer Value ? Value extends readonly unknown[] ? Value : never : never : never : never;
|
|
856
|
+
type CardIdOfDeck<Table, DeckId extends DeckIdOfTable<Table>> = DeckCardsOfTable<Table, DeckId>[number];
|
|
857
|
+
type CardIdOfHand<Table, HandId extends HandIdOfTable<Table>> = HandCardsOfTable<Table, HandId>[number];
|
|
858
|
+
type CompatibleHandIdForDeck<Table, DeckId extends DeckIdOfTable<Table>> = {
|
|
859
|
+
[CandidateHandId in HandIdOfTable<Table>]: Extract<CardIdOfDeck<Table, DeckId>, CardIdOfHand<Table, CandidateHandId>> extends never ? never : CandidateHandId;
|
|
860
|
+
}[HandIdOfTable<Table>];
|
|
861
|
+
type CompatibleCardIdForHandAndDeck<Table, HandId extends HandIdOfTable<Table>, DeckId extends DeckIdOfTable<Table>> = Extract<CardIdOfHand<Table, HandId>, CardIdOfDeck<Table, DeckId>>;
|
|
862
|
+
type CompatibleCardIdForTwoPlayerZones<Table, FromZoneId extends HandIdOfTable<Table>, ToZoneId extends HandIdOfTable<Table>> = Extract<CardIdOfHand<Table, FromZoneId>, CardIdOfHand<Table, ToZoneId>>;
|
|
863
|
+
|
|
864
|
+
type BoardRecord<Table extends RuntimeTableRecord, BoardId extends BoardIdOfTable<Table>> = Table["boards"]["byId"][BoardId];
|
|
865
|
+
type TiledBoardRecord<Table extends RuntimeTableRecord, BoardId extends TiledBoardIdOfTable<Table>> = Extract<BoardRecord<Table, BoardId>, {
|
|
866
|
+
layout: "hex" | "square";
|
|
867
|
+
}>;
|
|
868
|
+
type ViewCardOfTable<Table extends RuntimeTableRecord, CardId extends CardIdOfTable<Table>> = CardId extends CardIdOfTable<Table> ? ViewCard<CardId & string, Table["cards"][CardId]["cardType"] & string, Extract<Table["cards"][CardId]["properties"], Record<string, unknown>>> : never;
|
|
869
|
+
type CardsByIdOfTable<Table extends RuntimeTableRecord, CardIds extends readonly CardIdOfTable<Table>[]> = Readonly<{
|
|
870
|
+
[Id in CardIds[number]]: ViewCardOfTable<Table, Id> | undefined;
|
|
871
|
+
}>;
|
|
872
|
+
type DeckCardsForZone<Table extends RuntimeTableRecord, ZoneId extends DeckIdOfTable<Table>> = ZoneId extends infer Each extends DeckIdOfTable<Table> ? DeckCardsOfTable<Table, Each> : never;
|
|
873
|
+
type HandCardsForZone<Table extends RuntimeTableRecord, ZoneId extends HandIdOfTable<Table>> = ZoneId extends infer Each extends HandIdOfTable<Table> ? HandCardsOfTable<Table, Each> : never;
|
|
874
|
+
type CardCollectionOfTable<Table extends RuntimeTableRecord> = CardCollection<CardIdOfTable<Table> & string, ViewCardOfTable<Table, CardIdOfTable<Table>>>;
|
|
875
|
+
type SlotOccupantOfTable<Table extends RuntimeTableRecord> = ViewSlotOccupant<ComponentIdOfTable<Table> & string, PlayerIdOfTable<Table> & string, string, Record<string, unknown>>;
|
|
876
|
+
type SlotOccupantsOfTable<Table extends RuntimeTableRecord> = ReadonlyArray<SlotOccupantOfTable<Table>>;
|
|
877
|
+
type SlotOccupantsBySlotIdOfTable<Table extends RuntimeTableRecord> = Readonly<Record<string, SlotOccupantsOfTable<Table>>>;
|
|
878
|
+
type ComponentLocationOfTable<Table, ComponentId extends ComponentIdOfTable<Table>> = Table extends {
|
|
879
|
+
componentLocations: infer ComponentLocations extends Record<string, unknown>;
|
|
880
|
+
} ? ComponentLocations[ComponentId] : never;
|
|
881
|
+
type ComponentDataOfTable<Table, ComponentId extends ComponentIdOfTable<Table>> = Table extends {
|
|
882
|
+
cards: infer Cards extends Record<string, unknown>;
|
|
883
|
+
pieces: infer Pieces extends Record<string, unknown>;
|
|
884
|
+
dice: infer Dice extends Record<string, unknown>;
|
|
885
|
+
} ? ComponentId extends keyof Cards ? Cards[ComponentId] : ComponentId extends keyof Pieces ? Pieces[ComponentId] : ComponentId extends keyof Dice ? Dice[ComponentId] : never : never;
|
|
886
|
+
type ComponentLocationByTypeOfTable<Table, ComponentId extends ComponentIdOfTable<Table>, Type extends RuntimeComponentLocation["type"]> = Extract<ComponentLocationOfTable<Table, ComponentId>, {
|
|
887
|
+
type: Type;
|
|
888
|
+
}>;
|
|
889
|
+
type ResolvedDeckLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
890
|
+
[DeckId in DeckIdOfTable<Table>]: {
|
|
891
|
+
componentId: ComponentId;
|
|
892
|
+
deckId: DeckId;
|
|
893
|
+
cards: DeckCardsOfTable<Table, DeckId>;
|
|
894
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "InDeck"> & {
|
|
895
|
+
deckId: DeckId;
|
|
896
|
+
};
|
|
897
|
+
};
|
|
898
|
+
}[DeckIdOfTable<Table>];
|
|
899
|
+
type ResolvedHandLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
900
|
+
[HandId in HandIdOfTable<Table>]: {
|
|
901
|
+
[PlayerId in PlayerIdOfTable<Table>]: {
|
|
902
|
+
componentId: ComponentId;
|
|
903
|
+
handId: HandId;
|
|
904
|
+
playerId: PlayerId;
|
|
905
|
+
cards: HandCardsOfTable<Table, HandId>;
|
|
906
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "InHand"> & {
|
|
907
|
+
handId: HandId;
|
|
908
|
+
playerId: PlayerId;
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
}[PlayerIdOfTable<Table>];
|
|
912
|
+
}[HandIdOfTable<Table>];
|
|
913
|
+
type ResolvedZoneLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = ComponentLocationByTypeOfTable<Table, ComponentId, "InZone"> extends infer Location ? Location extends {
|
|
914
|
+
type: "InZone";
|
|
915
|
+
zoneId: infer ZoneId extends string;
|
|
916
|
+
} ? {
|
|
917
|
+
componentId: ComponentId;
|
|
918
|
+
zoneId: ZoneId;
|
|
919
|
+
location: Location;
|
|
920
|
+
} : never : never;
|
|
921
|
+
type ResolvedSpaceLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
922
|
+
[BoardId in BoardIdOfTable<Table>]: {
|
|
923
|
+
[SpaceId in SpaceIdOfTable<Table, BoardId>]: {
|
|
924
|
+
componentId: ComponentId;
|
|
925
|
+
boardId: BoardId;
|
|
926
|
+
board: BoardRecord<Table, BoardId>;
|
|
927
|
+
spaceId: SpaceId;
|
|
928
|
+
space: Table["boards"]["byId"][BoardId]["spaces"][SpaceId];
|
|
929
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "OnSpace"> & {
|
|
930
|
+
boardId: BoardId;
|
|
931
|
+
spaceId: SpaceId;
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
}[SpaceIdOfTable<Table, BoardId>];
|
|
935
|
+
}[BoardIdOfTable<Table>];
|
|
936
|
+
type ResolvedContainerLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
937
|
+
[BoardId in BoardIdOfTable<Table>]: {
|
|
938
|
+
[ContainerId in BoardContainerIdOfTable<Table, BoardId>]: {
|
|
939
|
+
componentId: ComponentId;
|
|
940
|
+
boardId: BoardId;
|
|
941
|
+
board: BoardRecord<Table, BoardId>;
|
|
942
|
+
containerId: ContainerId;
|
|
943
|
+
container: Table["boards"]["byId"][BoardId]["containers"][ContainerId];
|
|
944
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "InContainer"> & {
|
|
945
|
+
boardId: BoardId;
|
|
946
|
+
containerId: ContainerId;
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
}[BoardContainerIdOfTable<Table, BoardId>];
|
|
950
|
+
}[BoardIdOfTable<Table>];
|
|
951
|
+
type ResolvedEdgeLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
952
|
+
[BoardId in TiledBoardIdOfTable<Table>]: {
|
|
953
|
+
[EdgeId in TiledEdgeIdOfTable<Table, BoardId>]: {
|
|
954
|
+
componentId: ComponentId;
|
|
955
|
+
boardId: BoardId;
|
|
956
|
+
board: TiledBoardRecord<Table, BoardId>;
|
|
957
|
+
edgeId: EdgeId;
|
|
958
|
+
edge: Extract<Table["boards"]["byId"][BoardId], {
|
|
959
|
+
layout: "hex" | "square";
|
|
960
|
+
}>["edges"][number];
|
|
961
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "OnEdge"> & {
|
|
962
|
+
boardId: BoardId;
|
|
963
|
+
edgeId: EdgeId;
|
|
964
|
+
};
|
|
965
|
+
};
|
|
966
|
+
}[TiledEdgeIdOfTable<Table, BoardId>];
|
|
967
|
+
}[TiledBoardIdOfTable<Table>];
|
|
968
|
+
type ResolvedVertexLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = {
|
|
969
|
+
[BoardId in TiledBoardIdOfTable<Table>]: {
|
|
970
|
+
[VertexId in TiledVertexIdOfTable<Table, BoardId>]: {
|
|
971
|
+
componentId: ComponentId;
|
|
972
|
+
boardId: BoardId;
|
|
973
|
+
board: TiledBoardRecord<Table, BoardId>;
|
|
974
|
+
vertexId: VertexId;
|
|
975
|
+
vertex: Extract<Table["boards"]["byId"][BoardId], {
|
|
976
|
+
layout: "hex" | "square";
|
|
977
|
+
}>["vertices"][number];
|
|
978
|
+
location: ComponentLocationByTypeOfTable<Table, ComponentId, "OnVertex"> & {
|
|
979
|
+
boardId: BoardId;
|
|
980
|
+
vertexId: VertexId;
|
|
981
|
+
};
|
|
982
|
+
};
|
|
983
|
+
}[TiledVertexIdOfTable<Table, BoardId>];
|
|
984
|
+
}[TiledBoardIdOfTable<Table>];
|
|
985
|
+
type ResolvedSlotLocation<Table extends RuntimeTableRecord, ComponentId extends ComponentIdOfTable<Table>> = ComponentLocationByTypeOfTable<Table, ComponentId, "InSlot"> extends infer Location ? Location extends {
|
|
986
|
+
type: "InSlot";
|
|
987
|
+
host: infer Host extends RuntimeSlotHostRef;
|
|
988
|
+
slotId: infer SlotId extends string;
|
|
989
|
+
} ? {
|
|
990
|
+
componentId: ComponentId;
|
|
991
|
+
host: Host;
|
|
992
|
+
slotId: SlotId;
|
|
993
|
+
location: Location;
|
|
994
|
+
} : never : never;
|
|
995
|
+
type TableQueries<Table extends RuntimeTableRecord> = {
|
|
996
|
+
board: {
|
|
997
|
+
get: <BoardId extends BoardIdOfTable<Table>>(boardId: BoardId) => BoardRecord<Table, BoardId>;
|
|
998
|
+
hex: <BoardId extends HexBoardIdOfTable<Table>>(boardId: BoardId) => Extract<BoardRecord<Table, BoardId>, {
|
|
999
|
+
layout: "hex";
|
|
1000
|
+
}>;
|
|
1001
|
+
square: <BoardId extends SquareBoardIdOfTable<Table>>(boardId: BoardId) => Extract<BoardRecord<Table, BoardId>, {
|
|
1002
|
+
layout: "square";
|
|
1003
|
+
}>;
|
|
1004
|
+
tiled: <BoardId extends TiledBoardIdOfTable<Table>>(boardId: BoardId) => TiledBoardRecord<Table, BoardId>;
|
|
1005
|
+
space: <BoardId extends BoardIdOfTable<Table>, SpaceId extends SpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId) => Table["boards"]["byId"][BoardId]["spaces"][SpaceId];
|
|
1006
|
+
hexSpace: <BoardId extends HexBoardIdOfTable<Table>, SpaceId extends HexSpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId) => Extract<Table["boards"]["byId"][BoardId], {
|
|
1007
|
+
layout: "hex";
|
|
1008
|
+
}>["spaces"][SpaceId];
|
|
1009
|
+
squareSpace: <BoardId extends SquareBoardIdOfTable<Table>, SpaceId extends SquareSpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId) => Extract<Table["boards"]["byId"][BoardId], {
|
|
1010
|
+
layout: "square";
|
|
1011
|
+
}>["spaces"][SpaceId];
|
|
1012
|
+
container: <BoardId extends BoardIdOfTable<Table>, ContainerId extends BoardContainerIdOfTable<Table, BoardId>>(boardId: BoardId, containerId: ContainerId) => Table["boards"]["byId"][BoardId]["containers"][ContainerId];
|
|
1013
|
+
edge: <BoardId extends TiledBoardIdOfTable<Table>, EdgeId extends TiledEdgeIdOfTable<Table, BoardId>>(boardId: BoardId, edgeId: EdgeId) => TiledEdgeStateOfTable<Table, BoardId, EdgeId>;
|
|
1014
|
+
vertex: <BoardId extends TiledBoardIdOfTable<Table>, VertexId extends TiledVertexIdOfTable<Table, BoardId>>(boardId: BoardId, vertexId: VertexId) => TiledVertexStateOfTable<Table, BoardId, VertexId>;
|
|
1015
|
+
byType: <TypeId extends BoardTypeIdOfTable<Table>>(typeId: TypeId) => BoardIdOfTable<Table>[];
|
|
1016
|
+
spacesByType: <BoardId extends BoardIdOfTable<Table>, TypeId extends SpaceTypeIdOfTable<Table, BoardId>>(boardId: BoardId, typeId: TypeId) => SpaceIdOfTable<Table, BoardId>[];
|
|
1017
|
+
edgesByType: <BoardId extends TiledBoardIdOfTable<Table>, TypeId extends TiledEdgeTypeIdOfTable<Table, BoardId>>(boardId: BoardId, typeId: TypeId) => TiledEdgeIdOfTable<Table, BoardId>[];
|
|
1018
|
+
verticesByType: <BoardId extends TiledBoardIdOfTable<Table>, TypeId extends TiledVertexTypeIdOfTable<Table, BoardId>>(boardId: BoardId, typeId: TypeId) => TiledVertexIdOfTable<Table, BoardId>[];
|
|
1019
|
+
adjacentSpaces: <BoardId extends BoardIdOfTable<Table>, SpaceId extends SpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId) => SpaceIdOfTable<Table, BoardId>[];
|
|
1020
|
+
relatedSpaces: <BoardId extends BoardIdOfTable<Table>, SpaceId extends SpaceIdOfTable<Table, BoardId>, TypeId extends RelationTypeIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId, relationTypeId: TypeId) => SpaceIdOfTable<Table, BoardId>[];
|
|
1021
|
+
incidentEdges: <BoardId extends TiledBoardIdOfTable<Table>, VertexId extends TiledVertexIdOfTable<Table, BoardId>>(boardId: BoardId, vertexId: VertexId) => TiledEdgeIdOfTable<Table, BoardId>[];
|
|
1022
|
+
incidentVertices: <BoardId extends TiledBoardIdOfTable<Table>, EdgeId extends TiledEdgeIdOfTable<Table, BoardId>>(boardId: BoardId, edgeId: EdgeId) => TiledVertexIdOfTable<Table, BoardId>[];
|
|
1023
|
+
spaceEdges: <BoardId extends TiledBoardIdOfTable<Table>>(boardId: BoardId, spaceId: SpaceIdOfTable<Table, BoardId>) => TiledEdgeIdOfTable<Table, BoardId>[];
|
|
1024
|
+
spaceVertices: <BoardId extends TiledBoardIdOfTable<Table>>(boardId: BoardId, spaceId: SpaceIdOfTable<Table, BoardId>) => TiledVertexIdOfTable<Table, BoardId>[];
|
|
1025
|
+
spaceDistance: <BoardId extends BoardIdOfTable<Table>, SpaceId extends SpaceIdOfTable<Table, BoardId>>(boardId: BoardId, fromSpaceId: SpaceId, toSpaceId: SpaceId) => number;
|
|
1026
|
+
hexSpaceAt: <BoardId extends HexBoardIdOfTable<Table>>(boardId: BoardId, q: number, r: number) => Extract<Table["boards"]["byId"][BoardId], {
|
|
1027
|
+
layout: "hex";
|
|
1028
|
+
}>["spaces"][HexSpaceIdOfTable<Table, BoardId>] | undefined;
|
|
1029
|
+
squareSpaceAt: <BoardId extends SquareBoardIdOfTable<Table>>(boardId: BoardId, row: number, col: number) => Extract<Table["boards"]["byId"][BoardId], {
|
|
1030
|
+
layout: "square";
|
|
1031
|
+
}>["spaces"][SquareSpaceIdOfTable<Table, BoardId>] | undefined;
|
|
1032
|
+
squareNeighbors: <BoardId extends SquareBoardIdOfTable<Table>, SpaceId extends SquareSpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId, options?: {
|
|
1033
|
+
mode?: "orthogonal" | "diagonal" | "all";
|
|
1034
|
+
}) => SquareSpaceIdOfTable<Table, BoardId>[];
|
|
1035
|
+
squareDistance: <BoardId extends SquareBoardIdOfTable<Table>, SpaceId extends SquareSpaceIdOfTable<Table, BoardId>>(boardId: BoardId, fromSpaceId: SpaceId, toSpaceId: SpaceId, options?: {
|
|
1036
|
+
metric?: "manhattan" | "chebyshev";
|
|
1037
|
+
}) => number;
|
|
1038
|
+
spaceOccupants: <BoardId extends BoardIdOfTable<Table>, SpaceId extends SpaceIdOfTable<Table, BoardId>>(boardId: BoardId, spaceId: SpaceId) => ComponentIdOfTable<Table>[];
|
|
1039
|
+
containerOccupants: <BoardId extends BoardIdOfTable<Table>, ContainerId extends BoardContainerIdOfTable<Table, BoardId>>(boardId: BoardId, containerId: ContainerId) => ComponentIdOfTable<Table>[];
|
|
1040
|
+
edgeOccupants: <BoardId extends TiledBoardIdOfTable<Table>, EdgeId extends TiledEdgeIdOfTable<Table, BoardId>>(boardId: BoardId, edgeId: EdgeId) => ComponentIdOfTable<Table>[];
|
|
1041
|
+
vertexOccupants: <BoardId extends TiledBoardIdOfTable<Table>, VertexId extends TiledVertexIdOfTable<Table, BoardId>>(boardId: BoardId, vertexId: VertexId) => ComponentIdOfTable<Table>[];
|
|
1042
|
+
};
|
|
1043
|
+
zone: {
|
|
1044
|
+
sharedCards: <ZoneId extends DeckIdOfTable<Table>>(zoneId: ZoneId) => DeckCardsForZone<Table, ZoneId>;
|
|
1045
|
+
sharedCardCollection: <ZoneId extends DeckIdOfTable<Table>>(zoneId: ZoneId) => CardCollectionOfTable<Table>;
|
|
1046
|
+
allSharedCards: () => {
|
|
1047
|
+
readonly [Z in DeckIdOfTable<Table>]: DeckCardsOfTable<Table, Z>;
|
|
1048
|
+
};
|
|
1049
|
+
playerCards: <PlayerId extends PlayerIdOfTable<Table>, ZoneId extends HandIdOfTable<Table>>(playerId: PlayerId, zoneId: ZoneId) => HandCardsForZone<Table, ZoneId>;
|
|
1050
|
+
playerCardCollection: <PlayerId extends PlayerIdOfTable<Table>, ZoneId extends HandIdOfTable<Table>>(playerId: PlayerId, zoneId: ZoneId) => CardCollectionOfTable<Table>;
|
|
1051
|
+
allPlayerCards: <ZoneId extends HandIdOfTable<Table>>(zoneId: ZoneId) => {
|
|
1052
|
+
readonly [P in PlayerIdOfTable<Table>]: HandCardsOfTable<Table, ZoneId>;
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
card: {
|
|
1056
|
+
get: <CardId extends CardIdOfTable<Table>>(cardId: CardId) => ViewCardOfTable<Table, CardId>;
|
|
1057
|
+
byIds: <CardIds extends readonly CardIdOfTable<Table>[]>(cardIds: CardIds) => CardsByIdOfTable<Table, CardIds>;
|
|
1058
|
+
owner: <CardId extends CardIdOfTable<Table>>(cardId: CardId) => Table["ownerOfCard"][CardId];
|
|
1059
|
+
visibility: <CardId extends CardIdOfTable<Table>>(cardId: CardId) => Table["visibility"][CardId];
|
|
1060
|
+
};
|
|
1061
|
+
slot: {
|
|
1062
|
+
occupants: (host: RuntimeSlotHostRef, slotId: string) => SlotOccupantsOfTable<Table>;
|
|
1063
|
+
occupantsByHost: (host: RuntimeSlotHostRef) => SlotOccupantsBySlotIdOfTable<Table>;
|
|
1064
|
+
pieceOccupants: (hostId: string, slotId: string) => SlotOccupantsOfTable<Table>;
|
|
1065
|
+
pieceOccupantsByHost: (hostId: string) => SlotOccupantsBySlotIdOfTable<Table>;
|
|
1066
|
+
dieOccupants: (hostId: string, slotId: string) => SlotOccupantsOfTable<Table>;
|
|
1067
|
+
dieOccupantsByHost: (hostId: string) => SlotOccupantsBySlotIdOfTable<Table>;
|
|
1068
|
+
};
|
|
1069
|
+
player: {
|
|
1070
|
+
/** Seating order from the manifest / setup profile. */
|
|
1071
|
+
order: () => Table["playerOrder"];
|
|
1072
|
+
/**
|
|
1073
|
+
* Next player id in seating order after `playerId`, wrapping around to
|
|
1074
|
+
* the first seat. Returns `null` when `playerId` is unknown or the
|
|
1075
|
+
* order is empty. Convenient for "whose turn is next" logic.
|
|
1076
|
+
*/
|
|
1077
|
+
nextInOrder: (playerId: PlayerIdOfTable<Table>) => PlayerIdOfTable<Table> | null;
|
|
1078
|
+
/** All resource balances for a player, as the manifest-typed record. */
|
|
1079
|
+
resources: <PlayerId extends PlayerIdOfTable<Table>>(playerId: PlayerId) => ResourceBalancesOfTable<Table>;
|
|
1080
|
+
/** Balance of a single resource; returns `0` when unset. */
|
|
1081
|
+
resource: (playerId: PlayerIdOfTable<Table>, resourceId: ResourceIdOfTable<Table>) => number;
|
|
1082
|
+
/**
|
|
1083
|
+
* Sum of every resource amount held by a player (e.g. "total cards in
|
|
1084
|
+
* hand" checks). Returns `0` for unknown players or empty balances.
|
|
1085
|
+
*/
|
|
1086
|
+
resourceTotal: (playerId: PlayerIdOfTable<Table>) => number;
|
|
1087
|
+
/** `true` when the player can pay every non-zero amount in `amounts`. */
|
|
1088
|
+
canAfford: (playerId: PlayerIdOfTable<Table>, amounts: ResourceAmountsOfTable<Table>) => boolean;
|
|
1089
|
+
/** Shortfall per resource when the player cannot afford `amounts`. */
|
|
1090
|
+
missingResources: (playerId: PlayerIdOfTable<Table>, amounts: ResourceAmountsOfTable<Table>) => Partial<Record<ResourceIdOfTable<Table>, number>>;
|
|
1091
|
+
};
|
|
1092
|
+
component: {
|
|
1093
|
+
data: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentDataOfTable<Table, ComponentId> | undefined;
|
|
1094
|
+
location: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentLocationOfTable<Table, ComponentId> | undefined;
|
|
1095
|
+
deck: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedDeckLocation<Table, ComponentId> | null;
|
|
1096
|
+
hand: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedHandLocation<Table, ComponentId> | null;
|
|
1097
|
+
zone: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedZoneLocation<Table, ComponentId> | null;
|
|
1098
|
+
space: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedSpaceLocation<Table, ComponentId> | null;
|
|
1099
|
+
container: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedContainerLocation<Table, ComponentId> | null;
|
|
1100
|
+
edge: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedEdgeLocation<Table, ComponentId> | null;
|
|
1101
|
+
vertex: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedVertexLocation<Table, ComponentId> | null;
|
|
1102
|
+
slot: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedSlotLocation<Table, ComponentId> | null;
|
|
1103
|
+
};
|
|
1104
|
+
};
|
|
1105
|
+
type TableQueriesOfState<State extends {
|
|
1106
|
+
table: RuntimeTableRecord;
|
|
1107
|
+
}> = TableQueries<TableOfState<State>>;
|
|
1108
|
+
|
|
1109
|
+
declare const manifestIdSchemaBrand: unique symbol;
|
|
1110
|
+
type ManifestIdSchema<Output = unknown> = z.ZodType<Output> & {
|
|
1111
|
+
readonly [manifestIdSchemaBrand]: true;
|
|
1112
|
+
};
|
|
1113
|
+
type ManifestLiterals<PlayerId extends string, DeckId extends string, HandId extends string, CardId extends string, PhaseName extends string = string> = {
|
|
1114
|
+
playerIds: readonly PlayerId[];
|
|
1115
|
+
phaseNames: readonly PhaseName[];
|
|
1116
|
+
boardLayouts: readonly ("generic" | "hex" | "square")[];
|
|
1117
|
+
setupOptionIds: readonly string[];
|
|
1118
|
+
setupProfileIds: readonly string[];
|
|
1119
|
+
cardSetIds: readonly string[];
|
|
1120
|
+
cardTypes: readonly string[];
|
|
1121
|
+
deckIds: readonly DeckId[];
|
|
1122
|
+
handIds: readonly HandId[];
|
|
1123
|
+
sharedZoneIds: readonly DeckId[];
|
|
1124
|
+
playerZoneIds: readonly HandId[];
|
|
1125
|
+
zoneIds: readonly (DeckId | HandId)[];
|
|
1126
|
+
cardIds: readonly CardId[];
|
|
1127
|
+
resourceIds: readonly string[];
|
|
1128
|
+
resourcePresentationById?: Record<string, {
|
|
1129
|
+
label: string;
|
|
1130
|
+
icon?: string | null;
|
|
1131
|
+
}>;
|
|
1132
|
+
pieceTypeIds: readonly string[];
|
|
1133
|
+
pieceIds: readonly string[];
|
|
1134
|
+
dieTypeIds: readonly string[];
|
|
1135
|
+
dieIds: readonly string[];
|
|
1136
|
+
boardTemplateIds: readonly string[];
|
|
1137
|
+
boardTypeIds: readonly string[];
|
|
1138
|
+
boardBaseIds: readonly string[];
|
|
1139
|
+
boardIds: readonly string[];
|
|
1140
|
+
boardContainerIds: readonly string[];
|
|
1141
|
+
relationTypeIds: readonly string[];
|
|
1142
|
+
edgeIds: readonly string[];
|
|
1143
|
+
edgeTypeIds: readonly string[];
|
|
1144
|
+
vertexIds: readonly string[];
|
|
1145
|
+
vertexTypeIds: readonly string[];
|
|
1146
|
+
spaceIds: readonly string[];
|
|
1147
|
+
spaceTypeIds: readonly string[];
|
|
1148
|
+
handVisibilityById: Record<HandId, RuntimeHandVisibilityMode>;
|
|
1149
|
+
zoneVisibilityById: Record<DeckId | HandId, RuntimeHandVisibilityMode>;
|
|
1150
|
+
setupChoiceIdsByOptionId: Record<string, readonly string[]>;
|
|
1151
|
+
cardSetIdByCardId: Record<CardId, string>;
|
|
1152
|
+
cardTypeByCardId: Record<CardId, string>;
|
|
1153
|
+
cardSetIdsBySharedZoneId: Record<DeckId, readonly string[]>;
|
|
1154
|
+
cardSetIdsByPlayerZoneId: Record<HandId, readonly string[]>;
|
|
1155
|
+
};
|
|
1156
|
+
type ManifestIds<PlayerId extends string, DeckId extends string, HandId extends string, CardId extends string, PhaseName extends string = string> = {
|
|
1157
|
+
playerId: z.ZodType<PlayerId>;
|
|
1158
|
+
phaseName: z.ZodType<PhaseName>;
|
|
1159
|
+
boardLayout: AnySchema;
|
|
1160
|
+
setupOptionId: AnySchema;
|
|
1161
|
+
setupProfileId: AnySchema;
|
|
1162
|
+
cardSetId: AnySchema;
|
|
1163
|
+
cardType: AnySchema;
|
|
1164
|
+
cardId: z.ZodType<CardId>;
|
|
1165
|
+
deckId: z.ZodType<DeckId>;
|
|
1166
|
+
handId: z.ZodType<HandId>;
|
|
1167
|
+
sharedZoneId: AnySchema;
|
|
1168
|
+
playerZoneId: AnySchema;
|
|
1169
|
+
zoneId: AnySchema;
|
|
1170
|
+
resourceId: AnySchema;
|
|
1171
|
+
pieceTypeId: AnySchema;
|
|
1172
|
+
pieceId: AnySchema;
|
|
1173
|
+
dieId: AnySchema;
|
|
1174
|
+
dieTypeId: AnySchema;
|
|
1175
|
+
boardTypeId: AnySchema;
|
|
1176
|
+
boardId: AnySchema;
|
|
1177
|
+
boardBaseId: AnySchema;
|
|
1178
|
+
boardContainerId: AnySchema;
|
|
1179
|
+
relationTypeId: AnySchema;
|
|
1180
|
+
edgeId: AnySchema;
|
|
1181
|
+
edgeTypeId: AnySchema;
|
|
1182
|
+
vertexId: AnySchema;
|
|
1183
|
+
vertexTypeId: AnySchema;
|
|
1184
|
+
spaceId: AnySchema;
|
|
1185
|
+
spaceTypeId: AnySchema;
|
|
1186
|
+
};
|
|
1187
|
+
type ManifestDefaults<Table extends RuntimeTableRecord> = {
|
|
1188
|
+
zones: (playerIds?: readonly string[]) => Table["zones"];
|
|
1189
|
+
decks: (playerIds?: readonly string[]) => Table["decks"];
|
|
1190
|
+
hands: (playerIds?: readonly string[]) => Table["hands"];
|
|
1191
|
+
handVisibility: (playerIds?: readonly string[]) => Table["handVisibility"];
|
|
1192
|
+
ownerOfCard: (playerIds?: readonly string[]) => Table["ownerOfCard"];
|
|
1193
|
+
visibility: (playerIds?: readonly string[]) => Table["visibility"];
|
|
1194
|
+
resources: (playerIds?: readonly string[]) => Table["resources"];
|
|
1195
|
+
};
|
|
1196
|
+
type StaticBoards<Table extends RuntimeTableRecord> = Pick<Table["boards"], "byId" | "hex" | "square">;
|
|
1197
|
+
type StaticBoardsJsonEnvelope<Table extends RuntimeTableRecord = RuntimeTableRecord> = {
|
|
1198
|
+
formatVersion: 1;
|
|
1199
|
+
generatedBy: "@dreamboard-games/sdk/codegen";
|
|
1200
|
+
boards: StaticBoards<Table>;
|
|
1201
|
+
initialTable: Table;
|
|
1202
|
+
};
|
|
1203
|
+
type SetupOptionChoiceMetadata = {
|
|
1204
|
+
id: string;
|
|
1205
|
+
label: string;
|
|
1206
|
+
description?: string | null;
|
|
1207
|
+
};
|
|
1208
|
+
type SetupOptionMetadata = {
|
|
1209
|
+
id: string;
|
|
1210
|
+
name: string;
|
|
1211
|
+
description?: string | null;
|
|
1212
|
+
choices: readonly SetupOptionChoiceMetadata[];
|
|
1213
|
+
};
|
|
1214
|
+
type SetupProfileMetadata = {
|
|
1215
|
+
id: string;
|
|
1216
|
+
name: string;
|
|
1217
|
+
description?: string | null;
|
|
1218
|
+
optionValues?: Record<string, string> | null;
|
|
1219
|
+
guidance?: {
|
|
1220
|
+
summary?: string | null;
|
|
1221
|
+
steps: readonly {
|
|
1222
|
+
id: string;
|
|
1223
|
+
label: string;
|
|
1224
|
+
description?: string | null;
|
|
1225
|
+
}[];
|
|
1226
|
+
} | null;
|
|
1227
|
+
};
|
|
1228
|
+
type ReducerManifestContract<Table extends RuntimeTableRecord, PhaseName extends string, PlayerId extends string, DeckId extends string, HandId extends string, CardId extends string> = {
|
|
1229
|
+
literals: ManifestLiterals<PlayerId, DeckId, HandId, CardId, PhaseName>;
|
|
1230
|
+
ids: ManifestIds<PlayerId, DeckId, HandId, CardId, PhaseName>;
|
|
1231
|
+
defaults: ManifestDefaults<Table>;
|
|
1232
|
+
staticBoards?: StaticBoards<Table>;
|
|
1233
|
+
setupOptionsById: Record<string, SetupOptionMetadata>;
|
|
1234
|
+
setupChoiceIdsByOptionId: Record<string, readonly string[]>;
|
|
1235
|
+
setupProfilesById: Record<string, SetupProfileMetadata>;
|
|
1236
|
+
tableSchema: z.ZodType<Table>;
|
|
1237
|
+
runtimeSchema: AnySchema;
|
|
1238
|
+
createGameStateSchema: (config: {
|
|
1239
|
+
phaseNameSchema: AnySchema;
|
|
1240
|
+
publicSchema: AnySchema;
|
|
1241
|
+
privateSchema: AnySchema;
|
|
1242
|
+
hiddenSchema: AnySchema;
|
|
1243
|
+
phasesSchema: AnySchema;
|
|
1244
|
+
}) => AnySchema;
|
|
1245
|
+
};
|
|
1246
|
+
type GeneratedManifestContractLike<Table extends RuntimeTableRecord = RuntimeTableRecord, PhaseName extends string = string, PlayerId extends string = string, DeckId extends string = string, HandId extends string = string, CardId extends string = string> = ReducerManifestContract<Table, PhaseName, PlayerId, DeckId, HandId, CardId>;
|
|
1247
|
+
type ManifestContract<Table extends RuntimeTableRecord> = ReducerManifestContract<Table, string, PlayerIdOfTable<Table>, DeckIdOfTable<Table>, HandIdOfTable<Table>, CardIdOfTable<Table>>;
|
|
1248
|
+
declare function markManifestScopedSchema<Schema extends z.ZodTypeAny>(schema: Schema): Schema & ManifestIdSchema<z.infer<Schema>>;
|
|
1249
|
+
declare function isManifestScopedSchema(schema: unknown): boolean;
|
|
1250
|
+
declare function createManifestStringLiteralSchema<Values extends readonly string[]>(values: Values): ManifestIdSchema<Values[number] extends never ? string : Values[number]>;
|
|
1251
|
+
declare function assumeManifestSchema<Output>(schema: z.ZodTypeAny): z.ZodType<Output>;
|
|
1252
|
+
declare function cloneManifestDefault<Value>(value: Value): Value;
|
|
1253
|
+
declare function resolveManifestPlayerIds<PlayerId extends string>(manifestPlayerIds: readonly PlayerId[], playerIds: readonly string[] | undefined): readonly PlayerId[];
|
|
1254
|
+
declare function createManifestRuntimeSchema<PhaseNameSchema extends z.ZodTypeAny, PlayerId extends string, SetupProfileId extends string>({ phaseNameSchema, playerIdSchema, setupProfileIdSchema, }: {
|
|
1255
|
+
phaseNameSchema: PhaseNameSchema;
|
|
1256
|
+
playerIdSchema: z.ZodType<PlayerId>;
|
|
1257
|
+
setupProfileIdSchema: z.ZodType<SetupProfileId>;
|
|
1258
|
+
}): z.ZodObject<{
|
|
1259
|
+
prompts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1260
|
+
id: z.ZodString;
|
|
1261
|
+
promptId: z.ZodString;
|
|
1262
|
+
to: z.ZodType<PlayerId, unknown, z.core.$ZodTypeInternals<PlayerId, unknown>>;
|
|
1263
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1264
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
1265
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1266
|
+
id: z.ZodString;
|
|
1267
|
+
label: z.ZodString;
|
|
1268
|
+
}, z.core.$strip>>>;
|
|
1269
|
+
resume: z.ZodObject<{
|
|
1270
|
+
id: z.ZodString;
|
|
1271
|
+
data: z.ZodUnknown;
|
|
1272
|
+
}, z.core.$strip>;
|
|
1273
|
+
}, z.core.$strip>>>;
|
|
1274
|
+
rng: z.ZodDefault<z.ZodObject<{
|
|
1275
|
+
seed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1276
|
+
cursor: z.ZodDefault<z.ZodNumber>;
|
|
1277
|
+
trace: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1278
|
+
}, z.core.$strip>>;
|
|
1279
|
+
setup: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1280
|
+
profileId: z.ZodType<SetupProfileId, unknown, z.core.$ZodTypeInternals<SetupProfileId, unknown>>;
|
|
1281
|
+
optionValues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
1282
|
+
}, z.core.$strip>>>;
|
|
1283
|
+
simultaneous: z.ZodDefault<z.ZodObject<{
|
|
1284
|
+
current: z.ZodNullable<z.ZodObject<{
|
|
1285
|
+
phaseName: PhaseNameSchema;
|
|
1286
|
+
actors: z.ZodArray<z.ZodType<PlayerId, unknown, z.core.$ZodTypeInternals<PlayerId, unknown>>>;
|
|
1287
|
+
submissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1288
|
+
interactionId: z.ZodString;
|
|
1289
|
+
params: z.ZodUnknown;
|
|
1290
|
+
}, z.core.$strip>>;
|
|
1291
|
+
}, z.core.$strip>>;
|
|
1292
|
+
}, z.core.$strip>>;
|
|
1293
|
+
lastTransition: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1294
|
+
from: PhaseNameSchema;
|
|
1295
|
+
to: PhaseNameSchema;
|
|
1296
|
+
}, z.core.$strip>>>;
|
|
1297
|
+
nextInstanceId: z.ZodDefault<z.ZodNumber>;
|
|
1298
|
+
}, z.core.$strip>;
|
|
1299
|
+
declare function createManifestGameStateSchema<Table extends RuntimeTableRecord, PhaseNameSchema extends z.ZodTypeAny, PublicSchema extends z.ZodTypeAny, PrivateSchema extends z.ZodTypeAny, HiddenSchema extends z.ZodTypeAny, PhasesSchema extends z.ZodTypeAny, PlayerId extends string, SetupProfileId extends string>({ tableSchema, playerIdSchema, setupProfileIdSchema, phaseNameSchema, publicSchema, privateSchema, hiddenSchema, phasesSchema, }: {
|
|
1300
|
+
tableSchema: z.ZodType<Table>;
|
|
1301
|
+
playerIdSchema: z.ZodType<PlayerId>;
|
|
1302
|
+
setupProfileIdSchema: z.ZodType<SetupProfileId>;
|
|
1303
|
+
phaseNameSchema: PhaseNameSchema;
|
|
1304
|
+
publicSchema: PublicSchema;
|
|
1305
|
+
privateSchema: PrivateSchema;
|
|
1306
|
+
hiddenSchema: HiddenSchema;
|
|
1307
|
+
phasesSchema: PhasesSchema;
|
|
1308
|
+
}): z.ZodObject<{
|
|
1309
|
+
table: z.ZodType<Table, unknown, z.core.$ZodTypeInternals<Table, unknown>>;
|
|
1310
|
+
public: PublicSchema;
|
|
1311
|
+
private: z.ZodRecord<z.ZodString, PrivateSchema>;
|
|
1312
|
+
hidden: HiddenSchema;
|
|
1313
|
+
flow: z.ZodObject<{
|
|
1314
|
+
currentPhase: PhaseNameSchema;
|
|
1315
|
+
turn: z.ZodNumber;
|
|
1316
|
+
round: z.ZodNumber;
|
|
1317
|
+
activePlayers: z.ZodArray<z.ZodType<PlayerId, unknown, z.core.$ZodTypeInternals<PlayerId, unknown>>>;
|
|
1318
|
+
}, z.core.$strip>;
|
|
1319
|
+
phase: PhasesSchema;
|
|
1320
|
+
runtime: z.ZodObject<{
|
|
1321
|
+
prompts: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1322
|
+
id: z.ZodString;
|
|
1323
|
+
promptId: z.ZodString;
|
|
1324
|
+
to: z.ZodType<PlayerId, unknown, z.core.$ZodTypeInternals<PlayerId, unknown>>;
|
|
1325
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1326
|
+
payload: z.ZodOptional<z.ZodUnknown>;
|
|
1327
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1328
|
+
id: z.ZodString;
|
|
1329
|
+
label: z.ZodString;
|
|
1330
|
+
}, z.core.$strip>>>;
|
|
1331
|
+
resume: z.ZodObject<{
|
|
1332
|
+
id: z.ZodString;
|
|
1333
|
+
data: z.ZodUnknown;
|
|
1334
|
+
}, z.core.$strip>;
|
|
1335
|
+
}, z.core.$strip>>>;
|
|
1336
|
+
rng: z.ZodDefault<z.ZodObject<{
|
|
1337
|
+
seed: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1338
|
+
cursor: z.ZodDefault<z.ZodNumber>;
|
|
1339
|
+
trace: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1340
|
+
}, z.core.$strip>>;
|
|
1341
|
+
setup: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1342
|
+
profileId: z.ZodType<SetupProfileId, unknown, z.core.$ZodTypeInternals<SetupProfileId, unknown>>;
|
|
1343
|
+
optionValues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
1344
|
+
}, z.core.$strip>>>;
|
|
1345
|
+
simultaneous: z.ZodDefault<z.ZodObject<{
|
|
1346
|
+
current: z.ZodNullable<z.ZodObject<{
|
|
1347
|
+
phaseName: PhaseNameSchema;
|
|
1348
|
+
actors: z.ZodArray<z.ZodType<PlayerId, unknown, z.core.$ZodTypeInternals<PlayerId, unknown>>>;
|
|
1349
|
+
submissions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1350
|
+
interactionId: z.ZodString;
|
|
1351
|
+
params: z.ZodUnknown;
|
|
1352
|
+
}, z.core.$strip>>;
|
|
1353
|
+
}, z.core.$strip>>;
|
|
1354
|
+
}, z.core.$strip>>;
|
|
1355
|
+
lastTransition: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
1356
|
+
from: PhaseNameSchema;
|
|
1357
|
+
to: PhaseNameSchema;
|
|
1358
|
+
}, z.core.$strip>>>;
|
|
1359
|
+
nextInstanceId: z.ZodDefault<z.ZodNumber>;
|
|
1360
|
+
}, z.core.$strip>;
|
|
1361
|
+
}, z.core.$strip>;
|
|
1362
|
+
type StateDefinition<PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>> = {
|
|
1363
|
+
public: PublicSchema;
|
|
1364
|
+
private: PrivateSchema;
|
|
1365
|
+
hidden: HiddenSchema;
|
|
1366
|
+
};
|
|
1367
|
+
type InitContext<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, string, string, string, string, string> = ManifestContract<Table>> = {
|
|
1368
|
+
manifest: Manifest;
|
|
1369
|
+
table: Table;
|
|
1370
|
+
playerIds: PlayerIdOfTable<Table>[];
|
|
1371
|
+
rngSeed?: number | null;
|
|
1372
|
+
setup: SetupSelectionOfManifest<Manifest> | null;
|
|
1373
|
+
q: TableQueriesOfState<{
|
|
1374
|
+
table: Table;
|
|
1375
|
+
}>;
|
|
1376
|
+
};
|
|
1377
|
+
type InitSetupSelectionInput<Manifest extends ReducerManifestContract<RuntimeTableRecord, string, string, string, string, string> = GeneratedManifestContractLike> = SetupSelectionInputOfManifest<Manifest>;
|
|
1378
|
+
type SetupBootstrapSharedZoneRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1379
|
+
type: "sharedZone";
|
|
1380
|
+
zoneId: SharedZoneIdOfManifest<Manifest>;
|
|
1381
|
+
};
|
|
1382
|
+
type SetupBootstrapPerPlayerZoneRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1383
|
+
type: "playerZone";
|
|
1384
|
+
zoneId: PlayerZoneIdOfManifest<Manifest>;
|
|
1385
|
+
playerId: PlayerIdOfManifest<Manifest>;
|
|
1386
|
+
};
|
|
1387
|
+
type SetupBootstrapSharedBoardContainerRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1388
|
+
type: "sharedBoardContainer";
|
|
1389
|
+
boardId: BoardBaseIdOfManifest<Manifest>;
|
|
1390
|
+
containerId: BoardContainerIdOfManifest<Manifest>;
|
|
1391
|
+
};
|
|
1392
|
+
type SetupBootstrapPerPlayerBoardContainerRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1393
|
+
type: "playerBoardContainer";
|
|
1394
|
+
boardId: BoardBaseIdOfManifest<Manifest>;
|
|
1395
|
+
playerId: PlayerIdOfManifest<Manifest>;
|
|
1396
|
+
containerId: BoardContainerIdOfManifest<Manifest>;
|
|
1397
|
+
};
|
|
1398
|
+
type SetupBootstrapSharedBoardSpaceRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1399
|
+
type: "sharedBoardSpace";
|
|
1400
|
+
boardId: BoardBaseIdOfManifest<Manifest>;
|
|
1401
|
+
spaceId: SpaceIdOfManifest<Manifest>;
|
|
1402
|
+
};
|
|
1403
|
+
type SetupBootstrapPerPlayerBoardSpaceRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1404
|
+
type: "playerBoardSpace";
|
|
1405
|
+
boardId: BoardBaseIdOfManifest<Manifest>;
|
|
1406
|
+
playerId: PlayerIdOfManifest<Manifest>;
|
|
1407
|
+
spaceId: SpaceIdOfManifest<Manifest>;
|
|
1408
|
+
};
|
|
1409
|
+
type SetupBootstrapContainerRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = SetupBootstrapSharedZoneRef<Manifest> | SetupBootstrapPerPlayerZoneRef<Manifest> | SetupBootstrapSharedBoardContainerRef<Manifest> | SetupBootstrapPerPlayerBoardContainerRef<Manifest>;
|
|
1410
|
+
type SetupBootstrapDestinationRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = SetupBootstrapContainerRef<Manifest> | SetupBootstrapSharedBoardSpaceRef<Manifest> | SetupBootstrapPerPlayerBoardSpaceRef<Manifest>;
|
|
1411
|
+
type SetupBootstrapPerPlayerContainerTemplateRef<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1412
|
+
type: "playerZone";
|
|
1413
|
+
zoneId: PlayerZoneIdOfManifest<Manifest>;
|
|
1414
|
+
} | {
|
|
1415
|
+
type: "playerBoardContainer";
|
|
1416
|
+
boardId: BoardBaseIdOfManifest<Manifest>;
|
|
1417
|
+
containerId: BoardContainerIdOfManifest<Manifest>;
|
|
1418
|
+
};
|
|
1419
|
+
type SetupBootstrapStep<Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1420
|
+
type: "shuffle";
|
|
1421
|
+
container: SetupBootstrapContainerRef<Manifest>;
|
|
1422
|
+
} | {
|
|
1423
|
+
type: "move";
|
|
1424
|
+
from: SetupBootstrapContainerRef<Manifest>;
|
|
1425
|
+
to: SetupBootstrapDestinationRef<Manifest>;
|
|
1426
|
+
count?: number;
|
|
1427
|
+
componentIds?: readonly (CardIdOfManifest<Manifest> | PieceIdOfManifest<Manifest> | DieIdOfManifest<Manifest>)[];
|
|
1428
|
+
} | {
|
|
1429
|
+
type: "deal";
|
|
1430
|
+
from: SetupBootstrapSharedZoneRef<Manifest> | SetupBootstrapSharedBoardContainerRef<Manifest>;
|
|
1431
|
+
to: SetupBootstrapPerPlayerContainerTemplateRef<Manifest>;
|
|
1432
|
+
count: number;
|
|
1433
|
+
playerIds?: readonly PlayerIdOfManifest<Manifest>[];
|
|
1434
|
+
};
|
|
1435
|
+
type SetupProfileDefinition<PhaseName extends string = string, Manifest extends GeneratedManifestContractLike = GeneratedManifestContractLike> = {
|
|
1436
|
+
initialPhase?: PhaseName;
|
|
1437
|
+
bootstrap?: readonly SetupBootstrapStep<Manifest>[];
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
type FlowInstruction<PhaseName extends string> = {
|
|
1441
|
+
kind: "flow.transition";
|
|
1442
|
+
to: PhaseName;
|
|
1443
|
+
};
|
|
1444
|
+
type EngineRollDieInstruction = {
|
|
1445
|
+
kind: "engine.rollDie";
|
|
1446
|
+
dieId: string;
|
|
1447
|
+
continuation?: AnyContinuationToken;
|
|
1448
|
+
};
|
|
1449
|
+
type EngineShuffleSharedZoneInstruction<DeckId extends string> = {
|
|
1450
|
+
kind: "engine.shuffleSharedZone";
|
|
1451
|
+
zoneId: DeckId;
|
|
1452
|
+
continuation?: AnyContinuationToken;
|
|
1453
|
+
};
|
|
1454
|
+
type EngineShufflePlayerZoneInstruction<PlayerZoneId extends string, PlayerId extends string> = {
|
|
1455
|
+
kind: "engine.shufflePlayerZone";
|
|
1456
|
+
zoneId: PlayerZoneId;
|
|
1457
|
+
playerId: PlayerId;
|
|
1458
|
+
continuation?: AnyContinuationToken;
|
|
1459
|
+
};
|
|
1460
|
+
type EngineInstruction<DeckId extends string, PlayerZoneId extends string = string, PlayerId extends string = string> = EngineRollDieInstruction | EngineShuffleSharedZoneInstruction<DeckId> | EngineShufflePlayerZoneInstruction<PlayerZoneId, PlayerId>;
|
|
1461
|
+
type RuntimeInstruction<PhaseName extends string, DeckId extends string, PlayerZoneId extends string = string, PlayerId extends string = string> = FlowInstruction<PhaseName> | EngineInstruction<DeckId, PlayerZoneId, PlayerId>;
|
|
1462
|
+
type RuntimeInstructionForState<State> = RuntimeInstruction<PhaseNameOfState<State>, DeckIdOfState<State>, PlayerZoneIdOfState<State>, PlayerIdOfState<State>>;
|
|
1463
|
+
|
|
1464
|
+
type ContinuationToken<Data = RuntimePayload, ContinuationId extends string = string, Response = RuntimePayload> = {
|
|
1465
|
+
id: ContinuationId;
|
|
1466
|
+
data: Data;
|
|
1467
|
+
readonly __responseType?: Response;
|
|
1468
|
+
};
|
|
1469
|
+
type ContinuationResponseOf<Token> = Token extends ContinuationToken<unknown, string, infer Response> ? Response : never;
|
|
1470
|
+
type AnyContinuationToken = ContinuationToken<RuntimePayload, string, RuntimePayload>;
|
|
1471
|
+
/**
|
|
1472
|
+
* Declarative choice option. Retained as the shape used by prompt-kind
|
|
1473
|
+
* interactions' `options` field (see `InteractionSpec.options` in
|
|
1474
|
+
* `model/spec.ts`). Independent of any specific prompt authoring API.
|
|
1475
|
+
*/
|
|
1476
|
+
type ChoiceOption<OptionId extends string = string> = {
|
|
1477
|
+
id: OptionId;
|
|
1478
|
+
label: string;
|
|
1479
|
+
};
|
|
1480
|
+
type RuntimePhaseState = object;
|
|
1481
|
+
type PhaseAccessor<PhaseStates extends Record<string, object>, CurrentPhase extends keyof PhaseStates & string = keyof PhaseStates & string> = {
|
|
1482
|
+
get<PhaseName extends keyof PhaseStates & string>(phaseName: PhaseName): CurrentPhase extends PhaseName ? PhaseStates[PhaseName] : PhaseStates[PhaseName] | null;
|
|
1483
|
+
};
|
|
1484
|
+
type PhasePayload<PhaseStates extends Record<string, object>, CurrentPhase extends keyof PhaseStates & string> = PhaseStates[CurrentPhase] & PhaseAccessor<PhaseStates, CurrentPhase>;
|
|
1485
|
+
type FlowState<PhaseName extends string, PlayerId extends string> = {
|
|
1486
|
+
currentPhase: PhaseName;
|
|
1487
|
+
turn: number;
|
|
1488
|
+
round: number;
|
|
1489
|
+
activePlayers: PlayerId[];
|
|
1490
|
+
};
|
|
1491
|
+
type RuntimeRngState = {
|
|
1492
|
+
seed?: number | null;
|
|
1493
|
+
cursor: number;
|
|
1494
|
+
trace: string[];
|
|
1495
|
+
};
|
|
1496
|
+
type RuntimeSimultaneousSubmission = {
|
|
1497
|
+
interactionId: string;
|
|
1498
|
+
params: RuntimePayload;
|
|
1499
|
+
};
|
|
1500
|
+
type RuntimeSimultaneousState<PhaseName extends string, PlayerId extends string> = {
|
|
1501
|
+
current: {
|
|
1502
|
+
phaseName: PhaseName;
|
|
1503
|
+
actors: PlayerId[];
|
|
1504
|
+
submissions: Partial<Record<PlayerId, RuntimeSimultaneousSubmission>>;
|
|
1505
|
+
} | null;
|
|
1506
|
+
};
|
|
1507
|
+
/**
|
|
1508
|
+
* Marker tag attached by `defineEffect` to every effect spec. `fx.effect`
|
|
1509
|
+
* uses `type` to dispatch to the right wire-effect builder.
|
|
1510
|
+
*/
|
|
1511
|
+
type EffectTypeTag = "rollDie" | "shuffleSharedZone" | "shufflePlayerZone";
|
|
1512
|
+
/**
|
|
1513
|
+
* Structural shape of the objects produced by `defineEffect`, as seen by
|
|
1514
|
+
* the `fx.effect` dispatcher. The public, per-type effect definitions live
|
|
1515
|
+
* in `model/spec.ts`.
|
|
1516
|
+
*/
|
|
1517
|
+
type EffectSpecLike<ContextSchema extends AnySchema = AnySchema> = {
|
|
1518
|
+
type: EffectTypeTag;
|
|
1519
|
+
id: string;
|
|
1520
|
+
contextSchema?: ContextSchema;
|
|
1521
|
+
/**
|
|
1522
|
+
* Opaque authoring-time continuation callable. The runtime only needs its
|
|
1523
|
+
* `id`; the heterogeneously-typed `(data) => ...` signature is erased
|
|
1524
|
+
* here. The `data` parameter is typed as `never` so that this structural
|
|
1525
|
+
* upper bound is assignable-from every concrete per-effect continuation
|
|
1526
|
+
* (function parameters are contravariant — a specific `(data: T) => R`
|
|
1527
|
+
* is assignable to `(data: X) => R` only when `X <: T`, and `never <: T`
|
|
1528
|
+
* holds for every `T`).
|
|
1529
|
+
*/
|
|
1530
|
+
__continuation?: ((data: never) => unknown) & {
|
|
1531
|
+
id: string;
|
|
1532
|
+
};
|
|
1533
|
+
};
|
|
1534
|
+
/**
|
|
1535
|
+
* Options accepted by `fx.effect(effect, options)`, specialized by
|
|
1536
|
+
* `effect.type`.
|
|
1537
|
+
*/
|
|
1538
|
+
type EffectContextValue<Effect extends EffectSpecLike> = NonNullable<Effect["contextSchema"]> extends AnySchema ? z.infer<NonNullable<Effect["contextSchema"]>> : undefined;
|
|
1539
|
+
type EffectInvokeOptions<Effect extends EffectSpecLike, State extends {
|
|
1540
|
+
table: RuntimeTableRecord;
|
|
1541
|
+
flow: {
|
|
1542
|
+
currentPhase: string;
|
|
1543
|
+
};
|
|
1544
|
+
}> = Effect["type"] extends "rollDie" ? {
|
|
1545
|
+
dieId: StringKeyOf<TableOfState<State>["dice"]>;
|
|
1546
|
+
context?: EffectContextValue<Effect>;
|
|
1547
|
+
} : Effect["type"] extends "shuffleSharedZone" ? {
|
|
1548
|
+
zoneId: DeckIdOfState<State>;
|
|
1549
|
+
context?: EffectContextValue<Effect>;
|
|
1550
|
+
} : Effect["type"] extends "shufflePlayerZone" ? {
|
|
1551
|
+
zoneId: PlayerZoneIdOfState<State>;
|
|
1552
|
+
playerId: PlayerIdOfState<State>;
|
|
1553
|
+
context?: EffectContextValue<Effect>;
|
|
1554
|
+
} : never;
|
|
1555
|
+
type EffectInstructionForState<Effect extends EffectSpecLike, State extends {
|
|
1556
|
+
table: RuntimeTableRecord;
|
|
1557
|
+
flow: {
|
|
1558
|
+
currentPhase: string;
|
|
1559
|
+
};
|
|
1560
|
+
}> = Effect["type"] extends "rollDie" ? EngineRollDieInstruction : Effect["type"] extends "shuffleSharedZone" ? EngineShuffleSharedZoneInstruction<DeckIdOfState<State>> : Effect["type"] extends "shufflePlayerZone" ? EngineShufflePlayerZoneInstruction<PlayerZoneIdOfState<State>, PlayerIdOfState<State>> : never;
|
|
1561
|
+
type ReducerFx<State extends {
|
|
1562
|
+
table: RuntimeTableRecord;
|
|
1563
|
+
flow: {
|
|
1564
|
+
currentPhase: string;
|
|
1565
|
+
};
|
|
1566
|
+
}> = {
|
|
1567
|
+
transition: <To extends PhaseNameOfState<State>>(to: To) => FlowInstruction<To>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Invoke an engine-side resumable effect authored via `defineEffect`.
|
|
1570
|
+
* The returned runtime instruction is consumed by the engine; if the effect
|
|
1571
|
+
* has a `reduce`, its continuation is delivered back as a typed input.
|
|
1572
|
+
*/
|
|
1573
|
+
effect: <Effect extends EffectSpecLike>(effect: Effect, options: EffectInvokeOptions<Effect, State>) => EffectInstructionForState<Effect, State>;
|
|
1574
|
+
};
|
|
1575
|
+
type RuntimeState<PhaseName extends string, PlayerId extends string, Setup extends RuntimeSetupSelection = RuntimeSetupSelection> = {
|
|
1576
|
+
rng: RuntimeRngState;
|
|
1577
|
+
setup: Setup | null;
|
|
1578
|
+
simultaneous: RuntimeSimultaneousState<PhaseName, PlayerId>;
|
|
1579
|
+
lastTransition: {
|
|
1580
|
+
from: PhaseName;
|
|
1581
|
+
to: PhaseName;
|
|
1582
|
+
} | null;
|
|
1583
|
+
};
|
|
1584
|
+
type ReducerRuntimeStateForState<State extends {
|
|
1585
|
+
table: RuntimeTableRecord;
|
|
1586
|
+
flow: {
|
|
1587
|
+
currentPhase: string;
|
|
1588
|
+
};
|
|
1589
|
+
}, Setup extends RuntimeSetupSelection = RuntimeSetupSelection> = RuntimeState<PhaseNameOfState<State>, PlayerIdOfState<State>, Setup>;
|
|
1590
|
+
type ReducerGameState<Table extends RuntimeTableRecord, PublicState extends object, PrivateState extends object, HiddenState extends object, PhaseState extends RuntimePhaseState, PhaseName extends string, PhaseStates extends Record<PhaseName, object> = Record<PhaseName, PhaseState>> = {
|
|
1591
|
+
table: Table;
|
|
1592
|
+
publicState: PublicState;
|
|
1593
|
+
privateState: Record<PlayerIdOfTable<Table>, PrivateState>;
|
|
1594
|
+
hiddenState: HiddenState;
|
|
1595
|
+
flow: FlowState<PhaseName, PlayerIdOfTable<Table>>;
|
|
1596
|
+
phase: PhaseState & PhaseAccessor<PhaseStates>;
|
|
1597
|
+
};
|
|
1598
|
+
type ReducerSessionState<State extends {
|
|
1599
|
+
table: RuntimeTableRecord;
|
|
1600
|
+
flow: {
|
|
1601
|
+
currentPhase: string;
|
|
1602
|
+
};
|
|
1603
|
+
}, Setup extends RuntimeSetupSelection = RuntimeSetupSelection> = {
|
|
1604
|
+
domain: State;
|
|
1605
|
+
runtime: ReducerRuntimeStateForState<State, Setup>;
|
|
1606
|
+
};
|
|
1607
|
+
type ReducerValidationResult = {
|
|
1608
|
+
valid: true;
|
|
1609
|
+
} | {
|
|
1610
|
+
valid: false;
|
|
1611
|
+
errorCode: string;
|
|
1612
|
+
message?: string;
|
|
1613
|
+
};
|
|
1614
|
+
type ReducerReject = {
|
|
1615
|
+
type: "reject";
|
|
1616
|
+
errorCode: string;
|
|
1617
|
+
message?: string;
|
|
1618
|
+
};
|
|
1619
|
+
type OutcomeResult = "win" | "draw" | "loss" | "eliminated";
|
|
1620
|
+
type OutcomeScoreComponent = {
|
|
1621
|
+
id: string;
|
|
1622
|
+
label: string;
|
|
1623
|
+
value: number;
|
|
1624
|
+
};
|
|
1625
|
+
type OutcomeTieBreak = {
|
|
1626
|
+
id: string;
|
|
1627
|
+
label: string;
|
|
1628
|
+
value: number | string;
|
|
1629
|
+
};
|
|
1630
|
+
type OutcomeStanding<PlayerId extends string = string> = {
|
|
1631
|
+
playerId: PlayerId;
|
|
1632
|
+
rank: number;
|
|
1633
|
+
result: OutcomeResult;
|
|
1634
|
+
score?: number;
|
|
1635
|
+
scoreBreakdown?: readonly OutcomeScoreComponent[];
|
|
1636
|
+
tieBreaks?: readonly OutcomeTieBreak[];
|
|
1637
|
+
};
|
|
1638
|
+
type GameOutcome<PlayerId extends string = string> = {
|
|
1639
|
+
reason: {
|
|
1640
|
+
code: string;
|
|
1641
|
+
message?: string;
|
|
1642
|
+
};
|
|
1643
|
+
standings: readonly OutcomeStanding<PlayerId>[];
|
|
1644
|
+
};
|
|
1645
|
+
type GameEventDetail = {
|
|
1646
|
+
label: string;
|
|
1647
|
+
value: string | number | boolean;
|
|
1648
|
+
};
|
|
1649
|
+
type SystemActionEvent = {
|
|
1650
|
+
kind: "systemAction";
|
|
1651
|
+
procedureId: string;
|
|
1652
|
+
title: string;
|
|
1653
|
+
summary?: string;
|
|
1654
|
+
details?: readonly GameEventDetail[];
|
|
1655
|
+
};
|
|
1656
|
+
type GameEvent = SystemActionEvent;
|
|
1657
|
+
type ReducerAcceptOptions<State> = {
|
|
1658
|
+
instructions?: readonly RuntimeInstructionForState<State>[];
|
|
1659
|
+
events?: readonly GameEvent[];
|
|
1660
|
+
};
|
|
1661
|
+
type ReducerAccept<State> = {
|
|
1662
|
+
type: "accept";
|
|
1663
|
+
state: State;
|
|
1664
|
+
instructions?: readonly RuntimeInstructionForState<State>[];
|
|
1665
|
+
events?: readonly GameEvent[];
|
|
1666
|
+
terminal?: GameOutcome<PlayerIdOfState<State>>;
|
|
1667
|
+
};
|
|
1668
|
+
type ReducerResult<State> = ReducerAccept<State> | ReducerReject;
|
|
1669
|
+
|
|
1670
|
+
export { type HexEdgeIdOfTable as $, type AnyContinuationToken as A, type BoardBaseIdOfManifest as B, type CardIdOfDeck as C, type ContinuationResponseOf as D, type ContinuationToken as E, type DeckCardsOfTable as F, type DeckIdOfState as G, type DeckIdOfTable as H, type DieIdOfManifest as I, type EdgeTypeIdOfManifest as J, type EffectInvokeOptions as K, type EffectSpecLike as L, type EffectTypeTag as M, type ErrorCodeOfContract as N, type ExactManifestContractOf as O, type FlowState as P, type FrameworkErrorCode as Q, FrameworkErrorCodes as R, type GameEvent as S, type GameEventDetail as T, type GameOutcome as U, type GeneratedManifestContractLike as V, type HandCardsOfTable as W, type HandIdOfState as X, type HandIdOfTable as Y, type HexBoardIdOfTable as Z, type HexBoardStateOfTable as _, type AnySchema as a, type ResolvedEdgeLocation as a$, type HexEdgeStateOfTable as a0, type HexEdgeTypeIdOfTable as a1, type HexSpaceIdOfTable as a2, type HexSpaceTypeIdOfTable as a3, type HexVertexIdOfTable as a4, type HexVertexStateOfTable as a5, type HexVertexTypeIdOfTable as a6, type HiddenSchemaOfContract as a7, type HiddenStateOfState as a8, type InitContext as a9, type PhaseStepOfState as aA, type PieceIdOfManifest as aB, type PlayerId as aC, type PlayerIdOfManifest as aD, type PlayerIdOfState as aE, type PlayerIdOfTable as aF, type PlayerZoneIdOfManifest as aG, type PlayerZoneIdOfState as aH, type PlayerZoneIdOfTable as aI, type PrivateSchemaOfContract as aJ, type PrivateStateOfState as aK, type PublicSchemaOfContract as aL, type PublicStateOfState as aM, type ReducerAccept as aN, type ReducerAcceptOptions as aO, type ReducerFx as aP, type ReducerGameState as aQ, type ReducerManifestContract as aR, type ReducerReject as aS, type ReducerResult as aT, type ReducerRuntimeStateForState as aU, type ReducerSessionState as aV, type ReducerValidationResult as aW, type RelationTypeIdOfManifest as aX, type RelationTypeIdOfTable as aY, type ResolvedContainerLocation as aZ, type ResolvedDeckLocation as a_, type InitSetupSelectionInput as aa, type ManifestContract as ab, type ManifestContractOf as ac, type ManifestDefaults as ad, type ManifestIdSchema as ae, type ManifestIds as af, type ManifestLiterals as ag, type ManifestOf as ah, type NonEmptyReadonlyArray as ai, type OutcomeResult as aj, type OutcomeScoreComponent as ak, type OutcomeStanding as al, type OutcomeTieBreak as am, type PerPlayer as an, type PerPlayerBoardRef as ao, type PerPlayerSchemaOptions as ap, type PhaseAccessor as aq, type PhaseMapOfState as ar, type PhaseNameOf as as, type PhaseNameOfContract as at, type PhaseNameOfManifest as au, type PhaseNameOfState as av, type PhasePayload as aw, type PhaseSchemasOfContract as ax, type PhaseStateMapOfContract as ay, type PhaseStateOfState as az, type BoardContainerIdOfManifest as b, type SetupBootstrapPerPlayerBoardContainerRef as b$, type ResolvedHandLocation as b0, type ResolvedSlotLocation as b1, type ResolvedSpaceLocation as b2, type ResolvedVertexLocation as b3, type ResolvedZoneLocation as b4, type ResourceAmountsOfTable as b5, type ResourceBalancesOfState as b6, type ResourceBalancesOfTable as b7, type ResourceIdOfManifest as b8, type ResourceIdOfState as b9, type RuntimePieceData as bA, type RuntimeRecord as bB, type RuntimeResourceMap as bC, type RuntimeRngState as bD, type RuntimeScalar as bE, type RuntimeSetupSelection as bF, type RuntimeSetupSelectionInput as bG, type RuntimeSetupSelectionOverride as bH, type RuntimeSimultaneousState as bI, type RuntimeSimultaneousSubmission as bJ, type RuntimeSlotHostRef as bK, type RuntimeSquareBoardState as bL, type RuntimeSquareEdgeState as bM, type RuntimeSquareSpaceState as bN, type RuntimeSquareVertexState as bO, type RuntimeState as bP, type RuntimeTableRecord as bQ, type RuntimeTiledBoardBaseState as bR, type RuntimeTiledBoardState as bS, type RuntimeTiledEdgeState as bT, type RuntimeTiledSpaceState as bU, type RuntimeTiledVertexState as bV, type RuntimeVisibilityMap as bW, type RuntimeZoneMap as bX, type SchemaLike as bY, type SetupBootstrapContainerRef as bZ, type SetupBootstrapDestinationRef as b_, type ResourceIdOfTable as ba, type RuntimeBoardBaseState as bb, type RuntimeBoardCollections as bc, type RuntimeBoardCompatibilityState as bd, type RuntimeBoardContainerState as be, type RuntimeBoardRelationState as bf, type RuntimeBoardSpaceState as bg, type RuntimeBoardState as bh, type RuntimeCardData as bi, type RuntimeCardVisibility as bj, type RuntimeComponentLocation as bk, type RuntimeComponentLocationMap as bl, type RuntimeDeckMap as bm, type RuntimeDieData as bn, type RuntimeGenericBoardState as bo, type RuntimeHandMap as bp, type RuntimeHandVisibilityMode as bq, type RuntimeHexBoardState as br, type RuntimeHexEdgeState as bs, type RuntimeHexOrientation as bt, type RuntimeHexSpaceState as bu, type RuntimeHexVertexState as bv, type RuntimeOwnerMap as bw, type RuntimeParams as bx, type RuntimePayload as by, type RuntimePhaseState as bz, type BoardContainerIdOfTable as c, createManifestRuntimeSchema as c$, type SetupBootstrapPerPlayerBoardSpaceRef as c0, type SetupBootstrapPerPlayerContainerTemplateRef as c1, type SetupBootstrapPerPlayerZoneRef as c2, type SetupBootstrapSharedBoardContainerRef as c3, type SetupBootstrapSharedBoardSpaceRef as c4, type SetupBootstrapSharedZoneRef as c5, type SetupBootstrapStep as c6, type SetupOptionChoiceMetadata as c7, type SetupOptionIdOfManifest as c8, type SetupOptionMetadata as c9, type StaticBoardsJsonEnvelope as cA, type StringKeyOf as cB, type SystemActionEvent as cC, type TableOfManifest as cD, type TableOfState as cE, type TableQueries as cF, type TableQueriesOfState as cG, type TiledBoardIdOfTable as cH, type TiledBoardStateOfTable as cI, type TiledEdgeIdOfTable as cJ, type TiledEdgeMap as cK, type TiledEdgeStateOfTable as cL, type TiledEdgeTypeIdOfTable as cM, type TiledSpaceIdOfTable as cN, type TiledSpaceMap as cO, type TiledVertexIdOfTable as cP, type TiledVertexMap as cQ, type TiledVertexStateOfTable as cR, type TiledVertexTypeIdOfTable as cS, type VertexTypeIdOfManifest as cT, asPlayerId as cU, assumeManifestSchema as cV, boardRef as cW, boardRefKey as cX, boardRefSchema as cY, cloneManifestDefault as cZ, createManifestGameStateSchema as c_, type SetupProfileDefinition as ca, type SetupProfileIdOfManifest as cb, type SetupProfileMetadata as cc, type SetupSelectionInputOfManifest as cd, type SetupSelectionOfManifest as ce, type SharedBoardRef as cf, type SharedZoneIdOfManifest as cg, type SharedZoneIdOfState as ch, type SharedZoneIdOfTable as ci, type SpaceIdOfManifest as cj, type SpaceIdOfTable as ck, type SpaceTypeIdOfManifest as cl, type SpaceTypeIdOfTable as cm, type SquareBoardIdOfTable as cn, type SquareBoardStateOfTable as co, type SquareEdgeIdOfTable as cp, type SquareEdgeStateOfTable as cq, type SquareEdgeTypeIdOfTable as cr, type SquareSpaceIdOfTable as cs, type SquareSpaceTypeIdOfTable as ct, type SquareVertexIdOfTable as cu, type SquareVertexStateOfTable as cv, type SquareVertexTypeIdOfTable as cw, type StateDefinition as cx, type StateDefinitionOfContract as cy, type StaticBoards as cz, type BoardIdOfManifest as d, createManifestStringLiteralSchema as d0, isManifestScopedSchema as d1, isPerPlayer as d2, isPerPlayerBoardRef as d3, isPlayerId as d4, isSharedBoardRef as d5, markManifestScopedSchema as d6, parseBoardRefKey as d7, perPlayer as d8, perPlayerBoardRef as d9, perPlayerEntries as da, perPlayerGet as db, perPlayerHas as dc, perPlayerKeys as dd, perPlayerMap as de, perPlayerRequire as df, perPlayerSchema as dg, perPlayerSet as dh, perPlayerSize as di, perPlayerValues as dj, resolveManifestPlayerIds as dk, sharedBoardRef as dl, type BoardIdOfTable as e, type BoardLayoutOfManifest as f, type BoardMapOfTable as g, type BoardRef as h, type BoardStateOfTable as i, type BoardTypeIdOfManifest as j, type BoardTypeIdOfTable as k, type Brand as l, type CardIdOfHand as m, type CardIdOfManifest as n, type CardIdOfState as o, type CardIdOfTable as p, type CardTypeOfState as q, type CardTypeOfTable as r, type ChoiceOption as s, type CompatibleCardIdForHandAndDeck as t, type CompatibleCardIdForTwoPlayerZones as u, type CompatibleHandIdForDeck as v, type ComponentDataOfTable as w, type ComponentIdOfTable as x, type ComponentLocationByTypeOfTable as y, type ComponentLocationOfTable as z };
|