@dreamboard-games/sdk 0.5.0-alpha.3 → 0.5.0-alpha.4

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.
Files changed (36) hide show
  1. package/README.md +52 -2
  2. package/dist/board-target-B0QG6OYx.d.ts +8 -0
  3. package/dist/chunk-3JXUL4VN.js +139 -0
  4. package/dist/chunk-3JXUL4VN.js.map +1 -0
  5. package/dist/{chunk-LRILEVKC.js → chunk-C77SYIVT.js} +82 -109
  6. package/dist/chunk-C77SYIVT.js.map +1 -0
  7. package/dist/{chunk-SP234IY4.js → chunk-OOFMBCFF.js} +178 -203
  8. package/dist/chunk-OOFMBCFF.js.map +1 -0
  9. package/dist/{chunk-ZPRKWPEP.js → chunk-UG2Q4NLG.js} +108 -29
  10. package/dist/chunk-UG2Q4NLG.js.map +1 -0
  11. package/dist/{chunk-FMM5LVJW.js → chunk-XU6WJW6K.js} +26 -12
  12. package/dist/chunk-XU6WJW6K.js.map +1 -0
  13. package/dist/{diagnostics-B0lgnuZ6.d.ts → diagnostics-B8d5aLad.d.ts} +2 -2
  14. package/dist/{definition-BaHNPZol.d.ts → extract-gVKcB8Og.d.ts} +484 -387
  15. package/dist/index.d.ts +404 -175
  16. package/dist/index.js +266 -215
  17. package/dist/index.js.map +1 -1
  18. package/dist/model-vdpLHrxh.d.ts +432 -0
  19. package/dist/react.d.ts +35 -7
  20. package/dist/react.js +136 -8
  21. package/dist/react.js.map +1 -1
  22. package/dist/reducer.d.ts +169 -118
  23. package/dist/reducer.js +206 -328
  24. package/dist/reducer.js.map +1 -1
  25. package/dist/testing.d.ts +5 -3
  26. package/dist/testing.js +9 -6
  27. package/dist/testing.js.map +1 -1
  28. package/dist/{types-DimqnJBq.d.ts → types-Bj5ZLTUV.d.ts} +38 -10
  29. package/package.json +19 -16
  30. package/dist/chunk-FMM5LVJW.js.map +0 -1
  31. package/dist/chunk-LRILEVKC.js.map +0 -1
  32. package/dist/chunk-SP234IY4.js.map +0 -1
  33. package/dist/chunk-VUWNJXLJ.js +0 -52
  34. package/dist/chunk-VUWNJXLJ.js.map +0 -1
  35. package/dist/chunk-ZPRKWPEP.js.map +0 -1
  36. package/dist/model-BHro6yXu.d.ts +0 -288
@@ -139,6 +139,8 @@ type RuntimeCardData = {
139
139
  cardType: string;
140
140
  name?: string;
141
141
  text?: string;
142
+ frontImage?: string;
143
+ backImage?: string;
142
144
  properties: RuntimeRecord;
143
145
  };
144
146
  type RuntimePieceData = {
@@ -227,179 +229,6 @@ type RuntimeTableRecord = {
227
229
  dice: Record<string, RuntimeDieData>;
228
230
  };
229
231
 
230
- declare const FrameworkErrorCodes: {
231
- readonly NOT_YOUR_TURN: "NOT_YOUR_TURN";
232
- readonly WRONG_PHASE: "WRONG_PHASE";
233
- readonly WRONG_STEP: "WRONG_STEP";
234
- readonly NO_LEGAL_INPUT: "NO_LEGAL_INPUT";
235
- readonly INVALID_PARAMS: "INVALID_PARAMS";
236
- readonly UNKNOWN_INTERACTION: "UNKNOWN_INTERACTION";
237
- readonly INTERNAL_ERROR: "INTERNAL_ERROR";
238
- };
239
- type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
240
-
241
- type TableOfState<State> = State extends {
242
- table: infer Table;
243
- } ? Table : never;
244
- type TableOfManifest<Manifest> = Manifest extends {
245
- tableSchema: z.ZodType<infer Table extends RuntimeTableRecord>;
246
- } ? Table : Manifest extends ReducerManifestContractLike<infer Table> ? Table : never;
247
- type PhaseNameOfState<State> = State extends {
248
- flow: {
249
- currentPhase: infer PhaseName;
250
- };
251
- } ? Extract<PhaseName, string> : never;
252
- type PhaseNameOfManifest<Manifest> = Manifest extends {
253
- literals: {
254
- phaseNames: readonly (infer PhaseName)[];
255
- };
256
- } ? Extract<PhaseName, string> : never;
257
- type PlayerIdOfTable<Table> = Table extends {
258
- playerOrder: readonly (infer PlayerId)[];
259
- } ? Extract<PlayerId, string> : never;
260
- type PlayerIdOfState<State> = PlayerIdOfTable<TableOfState<State>>;
261
- type ErrorCodeOfContract<Contract> = Contract extends {
262
- errors: infer Errors extends Record<string, string>;
263
- } ? (keyof Errors & string) | FrameworkErrorCode : string;
264
- /**
265
- * Manifest-declared resource id union for a runtime table.
266
- *
267
- * Derived from the shape of `table.resources`, which the generated
268
- * manifest contract seeds as `Record<PlayerId, Record<ResourceId, number>>`.
269
- * Resource identifiers come from the player balance record.
270
- */
271
- type ResourceIdOfTable<Table> = Table extends {
272
- resources: infer Resources;
273
- } ? PlayerRecordValue<Resources> extends infer PlayerValue ? PlayerValue extends Record<string, unknown> ? StringKeyOf<PlayerValue> : never : never : never;
274
- /**
275
- * Per-player balance shape for a runtime table. Extracts the
276
- * value of `table.resources` so callers receive the manifest-typed
277
- * record directly (e.g. `Record<ResourceId, number>`).
278
- */
279
- type ResourceBalancesOfTable<Table> = Table extends {
280
- resources: infer Resources;
281
- } ? PlayerRecordValue<Resources> extends infer PlayerValue ? PlayerValue extends Record<string, unknown> ? PlayerValue : never : never : never;
282
- /**
283
- * Per-player resource counts: a partial `Record<ResourceId, number>`.
284
- *
285
- * Used as the input shape for {@link ReducerTransaction.addResources},
286
- * {@link ReducerTransaction.spendResources}, and {@link ReducerTransaction.transferResources}.
287
- */
288
- type ResourceAmountsOfTable<Table> = Partial<Record<ResourceIdOfTable<Table>, number>>;
289
- type PhaseStateOfState<State> = State extends {
290
- phase: infer PhaseState;
291
- } ? PhaseState : never;
292
- type PublicStateOfState<State> = State extends {
293
- publicState: infer PublicState;
294
- } ? PublicState : never;
295
- type HiddenStateOfState<State> = State extends {
296
- hiddenState: infer HiddenState;
297
- } ? HiddenState : never;
298
- type PrivateStateOfState<State> = State extends {
299
- privateState: Record<string, infer PrivateState>;
300
- } ? PrivateState : never;
301
- type DeckIdOfTable<Table> = Table extends {
302
- decks: infer Decks;
303
- } ? StringKeyOf<Decks> : never;
304
- type HandIdOfTable<Table> = Table extends {
305
- hands: infer Hands;
306
- } ? StringKeyOf<Hands> : never;
307
- type CardIdOfTable<Table> = Table extends {
308
- cards: infer Cards;
309
- } ? StringKeyOf<Cards> : never;
310
- type DeckIdOfState<State> = DeckIdOfTable<TableOfState<State>>;
311
- type HandIdOfState<State> = HandIdOfTable<TableOfState<State>>;
312
- type CardIdOfManifest<Manifest> = Manifest extends {
313
- literals: {
314
- cardIds: readonly (infer CardId)[];
315
- };
316
- } ? Extract<CardId, string> : string;
317
- type SharedZoneIdOfTable<Table> = DeckIdOfTable<Table>;
318
- type PlayerZoneIdOfTable<Table> = HandIdOfTable<Table>;
319
- type BoardMapOfTable<Table> = Table extends {
320
- boards: {
321
- byId: infer Boards;
322
- };
323
- } ? Boards : never;
324
- type BoardIdOfTable<Table> = StringKeyOf<BoardMapOfTable<Table>>;
325
- type BoardStateOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardMapOfTable<Table>[BoardId];
326
- type TiledBoardIdOfTable<Table> = {
327
- [BoardId in BoardIdOfTable<Table>]: BoardStateOfTable<Table, BoardId> extends {
328
- layout: "hex" | "square";
329
- } ? BoardId : never;
330
- }[BoardIdOfTable<Table>];
331
- type TiledBoardStateOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends infer BoardState ? BoardState extends {
332
- layout: "hex" | "square";
333
- spaces: Record<string, unknown>;
334
- edges: readonly {
335
- id: string;
336
- }[];
337
- vertices: readonly {
338
- id: string;
339
- }[];
340
- } ? BoardState : never : never;
341
- type SpaceIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
342
- spaces: infer Spaces;
343
- } ? StringKeyOf<Spaces> : never;
344
- type BoardContainerIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
345
- containers: infer Containers;
346
- } ? StringKeyOf<Containers> : never;
347
- type TiledSpaceIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
348
- spaces: infer Spaces;
349
- } ? StringKeyOf<Spaces> : never;
350
- type TiledEdgeIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
351
- edges: readonly (infer Edge)[];
352
- } ? Edge extends {
353
- id: infer EdgeId;
354
- } ? Extract<EdgeId, string> : never : never;
355
- type TiledVertexIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
356
- vertices: readonly (infer Vertex)[];
357
- } ? Vertex extends {
358
- id: infer VertexId;
359
- } ? Extract<VertexId, string> : never : never;
360
- type ComponentIdOfTable<Table> = Table extends {
361
- componentLocations: infer ComponentLocations;
362
- } ? StringKeyOf<ComponentLocations> : never;
363
- type PlayerZoneIdOfState<State> = HandIdOfState<State>;
364
- type ManifestOf<Source> = Source extends {
365
- contract: infer Contract;
366
- } ? ManifestOf<Contract> : Source extends {
367
- manifest: infer Manifest;
368
- } ? Manifest : never;
369
- type StateDefinitionOfContract<Contract> = Contract extends {
370
- state: infer StateDefinitionValue;
371
- } ? StateDefinitionValue : never;
372
- type PhaseSchemasOfContract<Contract> = Contract extends {
373
- phases: infer Phases extends Record<string, SchemaLike<object>>;
374
- } ? Phases : Record<PhaseNameOfManifest<ManifestOf<Contract>>, SchemaLike<object>>;
375
- type PhaseStateMapOfContract<Contract> = {
376
- [Name in keyof PhaseSchemasOfContract<Contract> & string]: z.infer<PhaseSchemasOfContract<Contract>[Name]>;
377
- };
378
- type PublicSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<infer PublicSchema, SchemaLike<object>, SchemaLike<object>> ? PublicSchema : never;
379
- type PrivateSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, infer PrivateSchema, SchemaLike<object>> ? PrivateSchema : never;
380
- type HiddenSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, SchemaLike<object>, infer HiddenSchema> ? HiddenSchema : never;
381
- type PhaseNameOfContract<Contract> = keyof PhaseSchemasOfContract<Contract> extends string ? keyof PhaseSchemasOfContract<Contract> & string : PhaseNameOfManifest<ManifestOf<Contract>>;
382
- type ManifestContractOf<Contract> = ManifestContract<TableOfManifest<ManifestOf<Contract>>>;
383
- type ExactManifestContractOf<Contract> = ManifestOf<Contract> & ReducerManifestContractLike<TableOfManifest<ManifestOf<Contract>>>;
384
- type DeckCardsOfTable<Table, DeckId extends DeckIdOfTable<Table>> = Table extends {
385
- decks: infer Decks extends Record<string, readonly unknown[]>;
386
- } ? Decks[DeckId] : never;
387
- type PlayerRecordValue<T> = T extends Record<string, infer Value> ? Value : never;
388
- type HandCardsOfTable<Table, HandId extends HandIdOfTable<Table>> = Table extends {
389
- hands: infer Hands extends Record<string, unknown>;
390
- } ? HandId extends keyof Hands ? PlayerRecordValue<Hands[HandId]> extends infer Value ? Value extends readonly unknown[] ? Value : never : never : never : never;
391
- type CardIdOfDeck<Table, DeckId extends DeckIdOfTable<Table>> = DeckCardsOfTable<Table, DeckId>[number];
392
- type CardIdOfHand<Table, HandId extends HandIdOfTable<Table>> = HandCardsOfTable<Table, HandId>[number];
393
- type CompatibleHandIdForDeck<Table, DeckId extends DeckIdOfTable<Table>> = {
394
- [CandidateHandId in HandIdOfTable<Table>]: Extract<CardIdOfDeck<Table, DeckId>, CardIdOfHand<Table, CandidateHandId>> extends never ? never : CandidateHandId;
395
- }[HandIdOfTable<Table>];
396
- type CompatibleCardIdForHandAndDeck<Table, HandId extends HandIdOfTable<Table>, DeckId extends DeckIdOfTable<Table>> = Extract<CardIdOfHand<Table, HandId>, CardIdOfDeck<Table, DeckId>>;
397
- type CompatibleCardIdForTwoPlayerZones<Table, FromZoneId extends HandIdOfTable<Table>, ToZoneId extends HandIdOfTable<Table>> = Extract<CardIdOfHand<Table, FromZoneId>, CardIdOfHand<Table, ToZoneId>>;
398
- type OptionsSchemaOfContract<Contract> = Contract extends {
399
- options: infer Schema extends SchemaLike<RuntimeRecord>;
400
- } ? Schema : SchemaLike<Record<string, never>>;
401
- type OptionsOfContract<Contract> = z.infer<OptionsSchemaOfContract<Contract>>;
402
-
403
232
  declare const InteractionCommitPolicySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
404
233
  mode: z.ZodLiteral<"manual">;
405
234
  }, z.core.$strict>, z.ZodObject<{
@@ -436,7 +265,7 @@ declare const InputDomainSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
436
265
  targetKind: z.ZodLiteral<"card">;
437
266
  zoneIds: z.ZodArray<z.ZodString>;
438
267
  eligibleTargets: z.ZodArray<z.ZodString>;
439
- }, z.core.$strict>, z.ZodObject<{
268
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
440
269
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
441
270
  mode: z.ZodLiteral<"single">;
442
271
  }, z.core.$strict>, z.ZodObject<{
@@ -448,18 +277,34 @@ declare const InputDomainSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
448
277
  type: z.ZodLiteral<"boardTarget">;
449
278
  projection: z.ZodLiteral<"resolved">;
450
279
  targetKind: z.ZodEnum<{
280
+ space: "space";
451
281
  edge: "edge";
452
282
  vertex: "vertex";
453
- space: "space";
454
283
  tile: "tile";
455
284
  }>;
456
285
  boardId: z.ZodString;
457
- valueKind: z.ZodOptional<z.ZodEnum<{
458
- "board-id": "board-id";
459
- "player-board-space": "player-board-space";
460
- }>>;
286
+ valueKind: z.ZodLiteral<"board-id">;
461
287
  eligibleTargets: z.ZodArray<z.ZodString>;
462
288
  }, z.core.$strict>, z.ZodObject<{
289
+ selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
290
+ mode: z.ZodLiteral<"single">;
291
+ }, z.core.$strict>, z.ZodObject<{
292
+ mode: z.ZodLiteral<"many">;
293
+ min: z.ZodNumber;
294
+ max: z.ZodOptional<z.ZodNumber>;
295
+ distinct: z.ZodOptional<z.ZodBoolean>;
296
+ }, z.core.$strict>], "mode">>;
297
+ type: z.ZodLiteral<"boardTarget">;
298
+ projection: z.ZodLiteral<"resolved">;
299
+ targetKind: z.ZodLiteral<"space">;
300
+ boardId: z.ZodString;
301
+ valueKind: z.ZodLiteral<"player-board-space">;
302
+ eligibleTargets: z.ZodArray<z.ZodObject<{
303
+ boardId: z.ZodString;
304
+ playerId: z.ZodString;
305
+ spaceId: z.ZodString;
306
+ }, z.core.$strict>>;
307
+ }, z.core.$strict>], "valueKind">, z.ZodObject<{
463
308
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
464
309
  mode: z.ZodLiteral<"single">;
465
310
  }, z.core.$strict>, z.ZodObject<{
@@ -555,7 +400,7 @@ declare const InteractionInputDescriptorSchema: z.ZodObject<{
555
400
  targetKind: z.ZodLiteral<"card">;
556
401
  zoneIds: z.ZodArray<z.ZodString>;
557
402
  eligibleTargets: z.ZodArray<z.ZodString>;
558
- }, z.core.$strict>, z.ZodObject<{
403
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
559
404
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
560
405
  mode: z.ZodLiteral<"single">;
561
406
  }, z.core.$strict>, z.ZodObject<{
@@ -567,18 +412,34 @@ declare const InteractionInputDescriptorSchema: z.ZodObject<{
567
412
  type: z.ZodLiteral<"boardTarget">;
568
413
  projection: z.ZodLiteral<"resolved">;
569
414
  targetKind: z.ZodEnum<{
415
+ space: "space";
570
416
  edge: "edge";
571
417
  vertex: "vertex";
572
- space: "space";
573
418
  tile: "tile";
574
419
  }>;
575
420
  boardId: z.ZodString;
576
- valueKind: z.ZodOptional<z.ZodEnum<{
577
- "board-id": "board-id";
578
- "player-board-space": "player-board-space";
579
- }>>;
421
+ valueKind: z.ZodLiteral<"board-id">;
580
422
  eligibleTargets: z.ZodArray<z.ZodString>;
581
423
  }, z.core.$strict>, z.ZodObject<{
424
+ selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
425
+ mode: z.ZodLiteral<"single">;
426
+ }, z.core.$strict>, z.ZodObject<{
427
+ mode: z.ZodLiteral<"many">;
428
+ min: z.ZodNumber;
429
+ max: z.ZodOptional<z.ZodNumber>;
430
+ distinct: z.ZodOptional<z.ZodBoolean>;
431
+ }, z.core.$strict>], "mode">>;
432
+ type: z.ZodLiteral<"boardTarget">;
433
+ projection: z.ZodLiteral<"resolved">;
434
+ targetKind: z.ZodLiteral<"space">;
435
+ boardId: z.ZodString;
436
+ valueKind: z.ZodLiteral<"player-board-space">;
437
+ eligibleTargets: z.ZodArray<z.ZodObject<{
438
+ boardId: z.ZodString;
439
+ playerId: z.ZodString;
440
+ spaceId: z.ZodString;
441
+ }, z.core.$strict>>;
442
+ }, z.core.$strict>], "valueKind">, z.ZodObject<{
582
443
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
583
444
  mode: z.ZodLiteral<"single">;
584
445
  }, z.core.$strict>, z.ZodObject<{
@@ -702,7 +563,7 @@ declare const InteractionDescriptorSchema: z.ZodObject<{
702
563
  targetKind: z.ZodLiteral<"card">;
703
564
  zoneIds: z.ZodArray<z.ZodString>;
704
565
  eligibleTargets: z.ZodArray<z.ZodString>;
705
- }, z.core.$strict>, z.ZodObject<{
566
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
706
567
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
707
568
  mode: z.ZodLiteral<"single">;
708
569
  }, z.core.$strict>, z.ZodObject<{
@@ -714,18 +575,34 @@ declare const InteractionDescriptorSchema: z.ZodObject<{
714
575
  type: z.ZodLiteral<"boardTarget">;
715
576
  projection: z.ZodLiteral<"resolved">;
716
577
  targetKind: z.ZodEnum<{
578
+ space: "space";
717
579
  edge: "edge";
718
580
  vertex: "vertex";
719
- space: "space";
720
581
  tile: "tile";
721
582
  }>;
722
583
  boardId: z.ZodString;
723
- valueKind: z.ZodOptional<z.ZodEnum<{
724
- "board-id": "board-id";
725
- "player-board-space": "player-board-space";
726
- }>>;
584
+ valueKind: z.ZodLiteral<"board-id">;
727
585
  eligibleTargets: z.ZodArray<z.ZodString>;
728
586
  }, z.core.$strict>, z.ZodObject<{
587
+ selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
588
+ mode: z.ZodLiteral<"single">;
589
+ }, z.core.$strict>, z.ZodObject<{
590
+ mode: z.ZodLiteral<"many">;
591
+ min: z.ZodNumber;
592
+ max: z.ZodOptional<z.ZodNumber>;
593
+ distinct: z.ZodOptional<z.ZodBoolean>;
594
+ }, z.core.$strict>], "mode">>;
595
+ type: z.ZodLiteral<"boardTarget">;
596
+ projection: z.ZodLiteral<"resolved">;
597
+ targetKind: z.ZodLiteral<"space">;
598
+ boardId: z.ZodString;
599
+ valueKind: z.ZodLiteral<"player-board-space">;
600
+ eligibleTargets: z.ZodArray<z.ZodObject<{
601
+ boardId: z.ZodString;
602
+ playerId: z.ZodString;
603
+ spaceId: z.ZodString;
604
+ }, z.core.$strict>>;
605
+ }, z.core.$strict>], "valueKind">, z.ZodObject<{
729
606
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
730
607
  mode: z.ZodLiteral<"single">;
731
608
  }, z.core.$strict>, z.ZodObject<{
@@ -850,28 +727,6 @@ type PlayersDefinition = {
850
727
  maxPlayers: number;
851
728
  optimalPlayers?: number;
852
729
  };
853
- type PresetCardSetDefinition = {
854
- /**
855
- * Unique local identifier for the authored card set
856
- */
857
- id: string;
858
- /**
859
- * Built-in preset card-set selector
860
- */
861
- presetId: string;
862
- /**
863
- * Display name of the card set
864
- */
865
- name: string;
866
- /**
867
- * Type of card set source
868
- */
869
- type: "preset";
870
- /**
871
- * Default initial home for cards materialized from the preset.
872
- */
873
- defaultHome: ComponentHomeSpec;
874
- };
875
730
  /**
876
731
  * Arbitrary authored JSON value.
877
732
  */
@@ -935,7 +790,7 @@ type CardPropertySchemaVariants = {
935
790
  [key: string]: PropertySchema;
936
791
  };
937
792
  /**
938
- * Property schema for each card type in this manual card set.
793
+ * Property schema for each card type in this card set.
939
794
  */
940
795
  variants: {
941
796
  [key: string]: ObjectSchema;
@@ -1026,17 +881,22 @@ type ComponentVisibilitySpec = {
1026
881
  };
1027
882
  type BoardCard = {
1028
883
  /**
1029
- * Card type identifier used to generate runtime CardIds. When count > 1, runtime IDs are generated as '{type}-1', '{type}-2', etc.
884
+ * Card definition identifier used to generate runtime CardIds. When count > 1, runtime IDs are generated as '{id}-1', '{id}-2', etc.
1030
885
  */
1031
- type: string;
886
+ id: string;
1032
887
  /**
1033
888
  * Display name of the card
1034
889
  */
1035
890
  name: string;
1036
891
  /**
1037
- * URL to the card's image
892
+ * Front face image: a repository path under `assets/`, such as
893
+ * `assets/cards/queen-of-fire.webp`. Game UIs receive it as a loadable URL.
1038
894
  */
1039
- imageUrl?: string;
895
+ frontImage?: string;
896
+ /**
897
+ * Back face image, in the same form as `frontImage`.
898
+ */
899
+ backImage?: string;
1040
900
  /**
1041
901
  * Text content on the card
1042
902
  */
@@ -1046,11 +906,11 @@ type BoardCard = {
1046
906
  */
1047
907
  count: number;
1048
908
  /**
1049
- * Optional authored card category or subtype identifier
909
+ * Authored card category or subtype identifier
1050
910
  */
1051
- cardType?: string;
911
+ cardType: string;
1052
912
  /**
1053
- * Optional per-card initial home. Omitted cards use their manual card set's
913
+ * Optional per-card initial home. Omitted cards use their card set's
1054
914
  * defaultHome. Compatibility declarations such as allowedCardSetIds never
1055
915
  * imply placement. Player-scoped distribution belongs in reducer setup.
1056
916
  */
@@ -1066,7 +926,7 @@ type BoardCard = {
1066
926
  [key: string]: JsonValue;
1067
927
  };
1068
928
  };
1069
- type ManualCardSetDefinition = {
929
+ type CardSetDefinition = {
1070
930
  /**
1071
931
  * Unique identifier for the card set
1072
932
  */
@@ -1075,10 +935,6 @@ type ManualCardSetDefinition = {
1075
935
  * Display name of the card set
1076
936
  */
1077
937
  name: string;
1078
- /**
1079
- * Type of card set source
1080
- */
1081
- type: "manual";
1082
938
  /**
1083
939
  * Schema definition for authored card properties in this card set
1084
940
  */
@@ -1092,11 +948,6 @@ type ManualCardSetDefinition = {
1092
948
  */
1093
949
  cards: Array<BoardCard>;
1094
950
  };
1095
- type CardSetDefinition = ({
1096
- type: "preset";
1097
- } & PresetCardSetDefinition) | ({
1098
- type: "manual";
1099
- } & ManualCardSetDefinition);
1100
951
  /**
1101
952
  * Whether authored topology exists once for the table or once per player
1102
953
  */
@@ -1584,6 +1435,11 @@ type ResourceDefinition = {
1584
1435
  * Optional compact icon or emoji rendered by generic UI resource controls.
1585
1436
  */
1586
1437
  icon?: string;
1438
+ /**
1439
+ * Who sees each player's balance in seat projections. Defaults to
1440
+ * `"public"`; `"owner"` balances reach only the player who holds them.
1441
+ */
1442
+ visibility?: "public" | "owner";
1587
1443
  };
1588
1444
  /**
1589
1445
  * One authored setup option choice
@@ -2732,6 +2588,7 @@ declare const SeatProjectionSchema: z.ZodObject<{
2732
2588
  cardViewsById: z.ZodRecord<z.ZodString, z.ZodString>;
2733
2589
  playableByCardId: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
2734
2590
  }, z.core.$strict>>>;
2591
+ resources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
2735
2592
  }, z.core.$strict>;
2736
2593
  declare const SimultaneousPhaseProjectionSchema: z.ZodObject<{
2737
2594
  phaseName: z.ZodString;
@@ -2827,7 +2684,7 @@ declare const SeatProjectionBundleSchema: z.ZodObject<{
2827
2684
  targetKind: z.ZodLiteral<"card">;
2828
2685
  zoneIds: z.ZodArray<z.ZodString>;
2829
2686
  eligibleTargets: z.ZodArray<z.ZodString>;
2830
- }, z.core.$strict>, z.ZodObject<{
2687
+ }, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
2831
2688
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2832
2689
  mode: z.ZodLiteral<"single">;
2833
2690
  }, z.core.$strict>, z.ZodObject<{
@@ -2839,16 +2696,13 @@ declare const SeatProjectionBundleSchema: z.ZodObject<{
2839
2696
  type: z.ZodLiteral<"boardTarget">;
2840
2697
  projection: z.ZodLiteral<"resolved">;
2841
2698
  targetKind: z.ZodEnum<{
2699
+ space: "space";
2842
2700
  edge: "edge";
2843
2701
  vertex: "vertex";
2844
- space: "space";
2845
2702
  tile: "tile";
2846
2703
  }>;
2847
2704
  boardId: z.ZodString;
2848
- valueKind: z.ZodOptional<z.ZodEnum<{
2849
- "board-id": "board-id";
2850
- "player-board-space": "player-board-space";
2851
- }>>;
2705
+ valueKind: z.ZodLiteral<"board-id">;
2852
2706
  eligibleTargets: z.ZodArray<z.ZodString>;
2853
2707
  }, z.core.$strict>, z.ZodObject<{
2854
2708
  selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -2859,12 +2713,31 @@ declare const SeatProjectionBundleSchema: z.ZodObject<{
2859
2713
  max: z.ZodOptional<z.ZodNumber>;
2860
2714
  distinct: z.ZodOptional<z.ZodBoolean>;
2861
2715
  }, z.core.$strict>], "mode">>;
2862
- type: z.ZodLiteral<"resourceMap">;
2863
- resources: z.ZodArray<z.ZodObject<{
2864
- resourceId: z.ZodString;
2865
- label: z.ZodOptional<z.ZodString>;
2866
- icon: z.ZodOptional<z.ZodString>;
2867
- min: z.ZodNumber;
2716
+ type: z.ZodLiteral<"boardTarget">;
2717
+ projection: z.ZodLiteral<"resolved">;
2718
+ targetKind: z.ZodLiteral<"space">;
2719
+ boardId: z.ZodString;
2720
+ valueKind: z.ZodLiteral<"player-board-space">;
2721
+ eligibleTargets: z.ZodArray<z.ZodObject<{
2722
+ boardId: z.ZodString;
2723
+ playerId: z.ZodString;
2724
+ spaceId: z.ZodString;
2725
+ }, z.core.$strict>>;
2726
+ }, z.core.$strict>], "valueKind">, z.ZodObject<{
2727
+ selection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2728
+ mode: z.ZodLiteral<"single">;
2729
+ }, z.core.$strict>, z.ZodObject<{
2730
+ mode: z.ZodLiteral<"many">;
2731
+ min: z.ZodNumber;
2732
+ max: z.ZodOptional<z.ZodNumber>;
2733
+ distinct: z.ZodOptional<z.ZodBoolean>;
2734
+ }, z.core.$strict>], "mode">>;
2735
+ type: z.ZodLiteral<"resourceMap">;
2736
+ resources: z.ZodArray<z.ZodObject<{
2737
+ resourceId: z.ZodString;
2738
+ label: z.ZodOptional<z.ZodString>;
2739
+ icon: z.ZodOptional<z.ZodString>;
2740
+ min: z.ZodNumber;
2868
2741
  max: z.ZodNumber;
2869
2742
  }, z.core.$strict>>;
2870
2743
  }, z.core.$strict>, z.ZodObject<{
@@ -2955,6 +2828,7 @@ declare const SeatProjectionBundleSchema: z.ZodObject<{
2955
2828
  cardViewsById: z.ZodRecord<z.ZodString, z.ZodString>;
2956
2829
  playableByCardId: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
2957
2830
  }, z.core.$strict>>>;
2831
+ resources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
2958
2832
  }, z.core.$strict>>;
2959
2833
  timing: z.ZodOptional<z.ZodObject<{
2960
2834
  resolveAvailableInteractionsMs: z.ZodNumber;
@@ -3671,6 +3545,17 @@ type ScopedPhaseState<State extends {
3671
3545
  phase: PhaseState;
3672
3546
  };
3673
3547
 
3548
+ declare const FrameworkErrorCodes: {
3549
+ readonly NOT_YOUR_TURN: "NOT_YOUR_TURN";
3550
+ readonly WRONG_PHASE: "WRONG_PHASE";
3551
+ readonly WRONG_STEP: "WRONG_STEP";
3552
+ readonly NO_LEGAL_INPUT: "NO_LEGAL_INPUT";
3553
+ readonly INVALID_PARAMS: "INVALID_PARAMS";
3554
+ readonly UNKNOWN_INTERACTION: "UNKNOWN_INTERACTION";
3555
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
3556
+ };
3557
+ type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
3558
+
3674
3559
  type InputCollectorKind = InteractionInputDescriptor["kind"];
3675
3560
  type TargetKind = Extract<InputDomain, {
3676
3561
  type: "cardTarget" | "boardTarget";
@@ -3701,6 +3586,9 @@ type CardTargetDomainDescriptor = Extract<InputDomain, {
3701
3586
  type BoardTargetDomainDescriptor = Extract<InputDomain, {
3702
3587
  type: "boardTarget";
3703
3588
  }>;
3589
+ type ChoiceListDomainDescriptor = Extract<InputDomain, {
3590
+ type: "choiceList";
3591
+ }>;
3704
3592
  type DomainProjector<Domain extends InputDomainDescriptor> = (state: CollectorState, playerId: string, q: unknown) => Domain;
3705
3593
  type InputDomainForCollectorKind<Kind extends InputCollectorKind> = Kind extends "card" ? CardTargetDomainDescriptor : Kind extends BoardInputCollectorKind ? BoardTargetDomainDescriptor : Exclude<InputDomainDescriptor, CardTargetDomainDescriptor | BoardTargetDomainDescriptor>;
3706
3594
  /**
@@ -4098,6 +3986,168 @@ type PhaseDefinition<PhaseStateSchema extends SchemaLike<object>, State extends
4098
3986
  phase: object;
4099
3987
  }, Manifest extends ManifestContract<TableOfState<State>>, SubmitCollectors extends Record<string, InputCollector> = Record<string, InputCollector>, Interactions extends InteractionMap<ScopedPhaseState<State, z.infer<PhaseStateSchema>>, Manifest> = Record<string, never>, Options extends RuntimeRecord = RuntimeRecord, ErrorCode extends string = string> = AutoPhaseDefinition<PhaseStateSchema, State, Manifest, ErrorCode, Options> | PlayerPhaseDefinition<PhaseStateSchema, State, Manifest, Interactions, Options, ErrorCode> | SimultaneousPlayerPhaseDefinition<PhaseStateSchema, State, Manifest, SubmitCollectors, Interactions, Options, ErrorCode>;
4100
3988
 
3989
+ /** Authored fields retain their domain types; wire admission validates JSON. */
3990
+ type ViewData = Record<string, unknown> & {
3991
+ readonly boards?: never;
3992
+ };
3993
+ /** A JSON record for exactly one seat. `boards` is reserved for manifest geometry. */
3994
+ type ViewDefinition<State extends {
3995
+ table: RuntimeTableRecord;
3996
+ flow: {
3997
+ currentPhase: string;
3998
+ };
3999
+ }, Manifest extends ManifestContract<TableOfState<State>>, Projection extends ViewData = ViewData> = (args: ActionContext<State, Manifest> & ReadHelpers<State> & {
4000
+ state: State;
4001
+ playerId: PlayerIdOfState<State>;
4002
+ }) => Projection;
4003
+
4004
+ type ReducerGameContract<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, string, string, string, string, string>, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, Phases extends Record<string, SchemaLike<object>>, Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord> = SchemaLike<Record<string, never>>> = {
4005
+ manifest: Manifest;
4006
+ state: StateDefinition<PublicSchema, PrivateSchema, HiddenSchema>;
4007
+ phases: Phases;
4008
+ errors?: Errors;
4009
+ options: OptionsSchema;
4010
+ /** Derived from `phases`; retained as an internal runtime convenience. */
4011
+ phaseNames: readonly string[];
4012
+ };
4013
+ type BaseGameStateOfContract<Contract> = ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, PhaseStateMapOfContract<Contract>[PhaseNameOfContract<Contract>], PhaseNameOfContract<Contract>, PhaseStateMapOfContract<Contract>>;
4014
+ /**
4015
+ * Heterogeneous phase map for a contract. Each phase carries its own local
4016
+ * `PhaseStateSchema` plus authoring-time Actions/Flows/Interactions/
4017
+ * interaction and zone maps. The registries are bound to the contract's base state +
4018
+ * manifest so the runtime can iterate them through a single index type
4019
+ * without reaching for `any`.
4020
+ */
4021
+ type PhaseMapOf<Contract> = {
4022
+ [Name in PhaseNameOfContract<Contract>]: PhaseDefinition<SchemaLike<object>, BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>, Record<string, InputCollector>, InteractionMap<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>>, OptionsOfContract<Contract>>;
4023
+ };
4024
+ type PhaseStateOfDefinitions<Definitions extends Record<string, PhaseDefinition<SchemaLike<object>, any, any, Record<string, InputCollector>, InteractionMap<any, any>, any>>> = {
4025
+ [Name in keyof Definitions & string]: Definitions[Name] extends {
4026
+ state: infer PhaseStateSchema extends SchemaLike<object>;
4027
+ } ? z.infer<PhaseStateSchema> : never;
4028
+ }[keyof Definitions & string];
4029
+ type ResolvedGameStateOf<Contract, Definitions extends PhaseMapOf<Contract>> = {
4030
+ [Name in keyof Definitions & string]: ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, Definitions[Name] extends {
4031
+ state: infer PhaseStateSchema extends SchemaLike<object>;
4032
+ } ? z.infer<PhaseStateSchema> : never, PhaseNameOfContract<Contract>> & {
4033
+ flow: ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, PhaseStateOfDefinitions<Definitions>, PhaseNameOfContract<Contract>>["flow"] & {
4034
+ currentPhase: Name;
4035
+ };
4036
+ };
4037
+ }[keyof Definitions & string];
4038
+ type ViewOfContract<Contract, Projection extends ViewData = ViewData> = ViewDefinition<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>, Projection>;
4039
+ type PhasesOfDefinition<Definition> = Definition extends {
4040
+ phases: infer Definitions extends Record<string, unknown>;
4041
+ } ? Definitions : never;
4042
+ type NonNeverKeys<Registry> = {
4043
+ [Key in keyof Registry]-?: [Registry[Key]] extends [never] ? never : Key;
4044
+ }[keyof Registry];
4045
+ type ViewOfDefinition<Definition> = Definition extends {
4046
+ view: (...args: never[]) => infer Projection;
4047
+ } ? Projection : never;
4048
+ type PhaseNamesOfDefinition<Definition> = keyof PhasesOfDefinition<Definition> & string;
4049
+ type PhaseDefinitionByName<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseName extends keyof PhasesOfDefinition<Definition> & string ? PhasesOfDefinition<Definition>[PhaseName] : never;
4050
+ type GameStateOf<Source> = Source extends {
4051
+ contract: infer Contract extends ReducerGameContractLike;
4052
+ phases: infer Definitions;
4053
+ } ? Definitions extends PhaseMapOf<Contract> ? ResolvedGameStateOf<Contract, Definitions> : never : Source extends ReducerGameContract<any, any, any, any, any, any, any, any> ? BaseGameStateOfContract<Source> : never;
4054
+ /**
4055
+ * Public structural upper bound for a reducer game contract.
4056
+ *
4057
+ * The `manifest` slot is intentionally erased with `any` because concrete
4058
+ * manifests bind per-contract branded literals (e.g. `PlayerId` unions with
4059
+ * specific string literals). Using a ground `ManifestContract<...>` type
4060
+ * here would prevent assignability from contract-bound manifests in a
4061
+ * contravariant position.
4062
+ */
4063
+ type ReducerGameContractLike = {
4064
+ manifest: any;
4065
+ options: SchemaLike<RuntimeRecord>;
4066
+ state: StateDefinition<SchemaLike<object>, SchemaLike<object>, SchemaLike<object>>;
4067
+ };
4068
+ type InitialStateContextOf<Contract extends ReducerGameContractLike> = InitContext<TableOfManifest<ManifestOf<Contract>>, ExactManifestContractOf<Contract>, OptionsOfContract<Contract>>;
4069
+ type InitialStateCallbacks<Contract extends ReducerGameContractLike> = {
4070
+ public?: (ctx: InitialStateContextOf<Contract>) => z.infer<PublicSchemaOfContract<Contract>>;
4071
+ private?: (ctx: InitialStateContextOf<Contract> & {
4072
+ playerId: PlayerIdOfTable<TableOfManifest<ManifestOf<Contract>>>;
4073
+ }) => z.infer<PrivateSchemaOfContract<Contract>>;
4074
+ hidden?: (ctx: InitialStateContextOf<Contract>) => z.infer<HiddenSchemaOfContract<Contract>>;
4075
+ };
4076
+ declare const validatedReducerDefinition: unique symbol;
4077
+ /** Authored input to game.assemble; no runtime contract or validation marker. */
4078
+ type ReducerGameDefinitionInput<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>> = {
4079
+ initial?: InitialStateCallbacks<Contract>;
4080
+ initialPhase?: PhaseNameOfContract<Contract>;
4081
+ phases: Definitions & Record<Exclude<keyof Definitions, PhaseNameOfContract<Contract>>, never>;
4082
+ view: View;
4083
+ };
4084
+ /** Assembled definition accepted by reducer runtime consumers. */
4085
+ type ReducerGameDefinition<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>> = {
4086
+ readonly [validatedReducerDefinition]: true;
4087
+ contract: Contract;
4088
+ initial?: InitialStateCallbacks<Contract>;
4089
+ initialPhase?: PhaseNameOfContract<Contract>;
4090
+ phases: Definitions;
4091
+ view: View;
4092
+ };
4093
+ type RegistryKeys<Registry> = Registry extends Record<string, unknown> ? NonNeverKeys<Registry> & string : never;
4094
+ type InteractionRegistryOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4095
+ interactions?: infer Interactions;
4096
+ } ? NonNullable<Interactions> : Record<string, never>;
4097
+ type SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4098
+ submit?: infer Submit;
4099
+ } ? {
4100
+ submit: NonNullable<Submit>;
4101
+ } : Record<string, never>;
4102
+ type NonNeverRegistryValue<Registry, Key extends string> = Registry extends Record<string, unknown> ? Key extends keyof Registry ? [Registry[Key]] extends [never] ? never : Registry[Key] : never : never;
4103
+ type InteractionIdOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4104
+ kind: "auto";
4105
+ } ? never : InteractionRegistryOfDefinitionPhase<Definition, PhaseName> extends infer Interactions ? SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName> extends infer Submit ? RegistryKeys<Interactions> | RegistryKeys<Submit> : never : never;
4106
+ type InteractionSpecByNameOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>, InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>> = NonNeverRegistryValue<InteractionRegistryOfDefinitionPhase<Definition, PhaseName>, InteractionId> | NonNeverRegistryValue<SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName>, InteractionId>;
4107
+ type CollectorsOfInteractionDefinition<Spec> = Spec extends {
4108
+ readonly steps: {
4109
+ readonly collectors: infer Collectors extends Record<string, InputCollector>;
4110
+ };
4111
+ } ? Collectors : Spec extends {
4112
+ readonly inputs?: infer Collectors;
4113
+ } ? NonNullable<Collectors> extends Record<string, InputCollector> ? NonNullable<Collectors> : Record<string, never> : Record<string, never>;
4114
+ /** The canonical collector for a named interaction input, including step inputs. */
4115
+ type InputCollectorOfDefinition<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>, InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>, Input extends string> = InteractionSpecByNameOfDefinitionPhase<Definition, PhaseName, InteractionId> extends infer Spec ? Input extends keyof CollectorsOfInteractionDefinition<Spec> ? CollectorsOfInteractionDefinition<Spec>[Input] : Input extends "cardId" ? Spec extends {
4116
+ readonly cardType: unknown;
4117
+ readonly playFrom: unknown;
4118
+ } ? {
4119
+ readonly kind: "card";
4120
+ } : never : never : never;
4121
+ type ClientParamsOfCollectors<Collectors> = Collectors extends Record<string, InputCollector> ? {
4122
+ [K in keyof Collectors as Collectors[K] extends {
4123
+ readonly kind: "rng";
4124
+ } ? never : K]: Collectors[K] extends InputCollector<infer S> ? S extends SchemaLike<infer V> ? V : never : never;
4125
+ } : never;
4126
+ /**
4127
+ * Client-facing params shape for an interaction. Omits engine-sampled
4128
+ * collectors (`rngInput.*`) — clients never supply those fields; the
4129
+ * trusted reducer bundle fills them during `submitInteraction`.
4130
+ *
4131
+ * This is the type that drives `submit(playerId, id, params)`,
4132
+ * `handle.submit(params)`, and the generated `InteractionParams` surface
4133
+ * through `createGameUi(game)`. The `reduce`-input counterpart is
4134
+ * {@link ParamsOfInteractionOfDefinition}, which includes every field
4135
+ * because the engine has already filled the sampled ones by then.
4136
+ */
4137
+ type CurrentStepParams<Collectors extends Record<string, InputCollector>> = {
4138
+ [Key in keyof Collectors]: Pick<ClientParamsOfCollectors<Collectors>, Key & keyof ClientParamsOfCollectors<Collectors>> & {
4139
+ [Other in Exclude<keyof Collectors, Key>]?: never;
4140
+ };
4141
+ }[keyof Collectors];
4142
+ type ClientParamsOfInteractionOfDefinition<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>, InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>> = InteractionSpecByNameOfDefinitionPhase<Definition, PhaseName, InteractionId> extends infer Spec ? Spec extends {
4143
+ readonly steps: unknown;
4144
+ } ? CurrentStepParams<CollectorsOfInteractionDefinition<Spec>> : Spec extends {
4145
+ readonly cardType: unknown;
4146
+ readonly playFrom: unknown;
4147
+ } ? {
4148
+ cardId: string;
4149
+ } & ClientParamsOfCollectors<CollectorsOfInteractionDefinition<Spec>> : ClientParamsOfCollectors<CollectorsOfInteractionDefinition<Spec>> : never;
4150
+
4101
4151
  type SpaceId<Board extends RuntimeBoardState> = keyof Board["spaces"] & string;
4102
4152
  type CommonBoardQueries<Board extends RuntimeBoardState, ComponentId extends string> = {
4103
4153
  state: Board;
@@ -4146,6 +4196,10 @@ interface ViewCard<CardIdValue extends string = string, CardTypeValue extends st
4146
4196
  cardType: CardTypeValue;
4147
4197
  name?: string;
4148
4198
  text?: string;
4199
+ /** Manifest asset path; game UIs receive a loadable URL. */
4200
+ frontImage?: string;
4201
+ /** Manifest asset path; game UIs receive a loadable URL. */
4202
+ backImage?: string;
4149
4203
  properties: Properties;
4150
4204
  }
4151
4205
  interface CardCollection<CardIdValue extends string = string, Card extends ViewCard<CardIdValue> = ViewCard<CardIdValue>> {
@@ -4166,7 +4220,7 @@ type TiledBoardRecord<Table extends RuntimeTableRecord, BoardId extends TiledBoa
4166
4220
  }>;
4167
4221
  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;
4168
4222
  type CardsByIdOfTable<Table extends RuntimeTableRecord, CardIds extends readonly CardIdOfTable<Table>[]> = Readonly<{
4169
- [Id in CardIds[number]]: ViewCardOfTable<Table, Id> | undefined;
4223
+ [Id in CardIds[number]]: ViewCardOfTable<Table, Id>;
4170
4224
  }>;
4171
4225
  type DeckCardsForZone<Table extends RuntimeTableRecord, ZoneId extends DeckIdOfTable<Table>> = ZoneId extends infer Each extends DeckIdOfTable<Table> ? DeckCardsOfTable<Table, Each> : never;
4172
4226
  type HandCardsForZone<Table extends RuntimeTableRecord, ZoneId extends HandIdOfTable<Table>> = ZoneId extends infer Each extends HandIdOfTable<Table> ? HandCardsOfTable<Table, Each> : never;
@@ -4312,12 +4366,18 @@ type TableQueries<Table extends RuntimeTableRecord> = {
4312
4366
  visibility: <CardId extends CardIdOfTable<Table>>(cardId: CardId) => Table["visibility"][CardId];
4313
4367
  };
4314
4368
  slot: {
4315
- occupants: (host: RuntimeSlotHostRef, slotId: string) => SlotOccupantsOfTable<Table>;
4316
- occupantsByHost: (host: RuntimeSlotHostRef) => SlotOccupantsBySlotIdOfTable<Table>;
4317
- pieceOccupants: (hostId: string, slotId: string) => SlotOccupantsOfTable<Table>;
4318
- pieceOccupantsByHost: (hostId: string) => SlotOccupantsBySlotIdOfTable<Table>;
4319
- dieOccupants: (hostId: string, slotId: string) => SlotOccupantsOfTable<Table>;
4320
- dieOccupantsByHost: (hostId: string) => SlotOccupantsBySlotIdOfTable<Table>;
4369
+ occupants: <Host extends SlotHostOfTable<Table>>(host: Host, slotId: SlotIdOfTable<Table, NoInfer<Host>>) => SlotOccupantsOfTable<Table>;
4370
+ occupantsByHost: (host: SlotHostOfTable<Table>) => SlotOccupantsBySlotIdOfTable<Table>;
4371
+ pieceOccupants: <Id extends keyof Table["pieces"] & string>(hostId: Id, slotId: SlotIdOfTable<Table, {
4372
+ kind: "piece";
4373
+ id: NoInfer<Id>;
4374
+ }>) => SlotOccupantsOfTable<Table>;
4375
+ pieceOccupantsByHost: (hostId: keyof Table["pieces"] & string) => SlotOccupantsBySlotIdOfTable<Table>;
4376
+ dieOccupants: <Id extends keyof Table["dice"] & string>(hostId: Id, slotId: SlotIdOfTable<Table, {
4377
+ kind: "die";
4378
+ id: NoInfer<Id>;
4379
+ }>) => SlotOccupantsOfTable<Table>;
4380
+ dieOccupantsByHost: (hostId: keyof Table["dice"] & string) => SlotOccupantsBySlotIdOfTable<Table>;
4321
4381
  };
4322
4382
  player: {
4323
4383
  /** Seating order from the manifest / setup profile. */
@@ -4343,8 +4403,8 @@ type TableQueries<Table extends RuntimeTableRecord> = {
4343
4403
  missingResources: (playerId: PlayerIdOfTable<Table>, amounts: ResourceAmountsOfTable<Table>) => Partial<Record<ResourceIdOfTable<Table>, number>>;
4344
4404
  };
4345
4405
  component: {
4346
- data: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentDataOfTable<Table, ComponentId> | undefined;
4347
- location: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentLocationOfTable<Table, ComponentId> | undefined;
4406
+ data: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentDataOfTable<Table, ComponentId>;
4407
+ location: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ComponentLocationOfTable<Table, ComponentId>;
4348
4408
  deck: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedDeckLocation<Table, ComponentId> | null;
4349
4409
  hand: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedHandLocation<Table, ComponentId> | null;
4350
4410
  zone: <ComponentId extends ComponentIdOfTable<Table>>(componentId: ComponentId) => ResolvedZoneLocation<Table, ComponentId> | null;
@@ -4381,6 +4441,8 @@ type ManifestLiterals<PlayerId extends string, DeckId extends string, HandId ext
4381
4441
  label: string;
4382
4442
  icon?: string | null;
4383
4443
  }>;
4444
+ /** Resources whose balances are projected only to their holder. */
4445
+ ownerResourceIds?: readonly string[];
4384
4446
  pieceTypeIds: readonly string[];
4385
4447
  pieceIds: readonly string[];
4386
4448
  dieTypeIds: readonly string[];
@@ -4491,149 +4553,184 @@ type InitContext<Table extends RuntimeTableRecord, Manifest extends ReducerManif
4491
4553
  }>;
4492
4554
  };
4493
4555
 
4494
- /** Authored fields retain their domain types; wire admission validates JSON. */
4495
- type ViewData = Record<string, unknown> & {
4496
- readonly boards?: never;
4497
- };
4498
- /** A JSON record for exactly one seat. `boards` is reserved for manifest geometry. */
4499
- type ViewDefinition<State extends {
4500
- table: RuntimeTableRecord;
4556
+ type TableOfState<State> = State extends {
4557
+ table: infer Table;
4558
+ } ? Table : never;
4559
+ type TableOfManifest<Manifest> = Manifest extends {
4560
+ tableSchema: z.ZodType<infer Table extends RuntimeTableRecord>;
4561
+ } ? Table : Manifest extends ReducerManifestContractLike<infer Table> ? Table : never;
4562
+ type PhaseNameOfState<State> = State extends {
4501
4563
  flow: {
4502
- currentPhase: string;
4564
+ currentPhase: infer PhaseName;
4503
4565
  };
4504
- }, Manifest extends ManifestContract<TableOfState<State>>, Projection extends ViewData = ViewData> = (args: ActionContext<State, Manifest> & ReadHelpers<State> & {
4505
- state: State;
4506
- playerId: PlayerIdOfState<State>;
4507
- }) => Projection;
4508
-
4509
- type ReducerGameContract<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, string, string, string, string, string>, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, Phases extends Record<string, SchemaLike<object>>, Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord> = SchemaLike<Record<string, never>>> = {
4510
- manifest: Manifest;
4511
- state: StateDefinition<PublicSchema, PrivateSchema, HiddenSchema>;
4512
- phases: Phases;
4513
- errors?: Errors;
4514
- options: OptionsSchema;
4515
- /** Derived from `phases`; retained as an internal runtime convenience. */
4516
- phaseNames: readonly string[];
4517
- };
4518
- type BaseGameStateOfContract<Contract> = ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, PhaseStateMapOfContract<Contract>[PhaseNameOfContract<Contract>], PhaseNameOfContract<Contract>, PhaseStateMapOfContract<Contract>>;
4519
- /**
4520
- * Heterogeneous phase map for a contract. Each phase carries its own local
4521
- * `PhaseStateSchema` plus authoring-time Actions/Flows/Interactions/
4522
- * interaction and zone maps. The registries are bound to the contract's base state +
4523
- * manifest so the runtime can iterate them through a single index type
4524
- * without reaching for `any`.
4525
- */
4526
- type PhaseMapOf<Contract> = {
4527
- [Name in PhaseNameOfContract<Contract>]: PhaseDefinition<SchemaLike<object>, BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>, Record<string, InputCollector>, InteractionMap<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>>, OptionsOfContract<Contract>>;
4528
- };
4529
- type PhaseStateOfDefinitions<Definitions extends Record<string, PhaseDefinition<SchemaLike<object>, any, any, Record<string, InputCollector>, InteractionMap<any, any>, any>>> = {
4530
- [Name in keyof Definitions & string]: Definitions[Name] extends {
4531
- state: infer PhaseStateSchema extends SchemaLike<object>;
4532
- } ? z.infer<PhaseStateSchema> : never;
4533
- }[keyof Definitions & string];
4534
- type ResolvedGameStateOf<Contract, Definitions extends PhaseMapOf<Contract>> = {
4535
- [Name in keyof Definitions & string]: ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, Definitions[Name] extends {
4536
- state: infer PhaseStateSchema extends SchemaLike<object>;
4537
- } ? z.infer<PhaseStateSchema> : never, PhaseNameOfContract<Contract>> & {
4538
- flow: ReducerGameState<TableOfManifest<ManifestContractOf<Contract>>, z.infer<PublicSchemaOfContract<Contract>>, z.infer<PrivateSchemaOfContract<Contract>>, z.infer<HiddenSchemaOfContract<Contract>>, PhaseStateOfDefinitions<Definitions>, PhaseNameOfContract<Contract>>["flow"] & {
4539
- currentPhase: Name;
4540
- };
4566
+ } ? Extract<PhaseName, string> : never;
4567
+ type PhaseNameOfManifest<Manifest> = Manifest extends {
4568
+ literals: {
4569
+ phaseNames: readonly (infer PhaseName)[];
4541
4570
  };
4542
- }[keyof Definitions & string];
4543
- type ViewOfContract<Contract, Projection extends ViewData = ViewData> = ViewDefinition<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>, Projection>;
4544
- type PhasesOfDefinition<Definition> = Definition extends {
4545
- phases: infer Definitions extends Record<string, unknown>;
4546
- } ? Definitions : never;
4547
- type NonNeverKeys<Registry> = {
4548
- [Key in keyof Registry]-?: [Registry[Key]] extends [never] ? never : Key;
4549
- }[keyof Registry];
4550
- type ViewOfDefinition<Definition> = Definition extends {
4551
- view: (...args: never[]) => infer Projection;
4552
- } ? Projection : never;
4553
- type PhaseNamesOfDefinition<Definition> = keyof PhasesOfDefinition<Definition> & string;
4554
- type PhaseDefinitionByName<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseName extends keyof PhasesOfDefinition<Definition> & string ? PhasesOfDefinition<Definition>[PhaseName] : never;
4555
- type GameStateOf<Source> = Source extends {
4556
- contract: infer Contract extends ReducerGameContractLike;
4557
- phases: infer Definitions;
4558
- } ? Definitions extends PhaseMapOf<Contract> ? ResolvedGameStateOf<Contract, Definitions> : never : Source extends ReducerGameContract<any, any, any, any, any, any, any, any> ? BaseGameStateOfContract<Source> : never;
4571
+ } ? Extract<PhaseName, string> : never;
4572
+ type PlayerIdOfTable<Table> = Table extends {
4573
+ playerOrder: readonly (infer PlayerId)[];
4574
+ } ? Extract<PlayerId, string> : never;
4575
+ type PlayerIdOfState<State> = PlayerIdOfTable<TableOfState<State>>;
4576
+ type ErrorCodeOfContract<Contract> = Contract extends {
4577
+ errors: infer Errors extends Record<string, string>;
4578
+ } ? (keyof Errors & string) | FrameworkErrorCode : string;
4559
4579
  /**
4560
- * Public structural upper bound for a reducer game contract.
4580
+ * Manifest-declared resource id union for a runtime table.
4561
4581
  *
4562
- * The `manifest` slot is intentionally erased with `any` because concrete
4563
- * manifests bind per-contract branded literals (e.g. `PlayerId` unions with
4564
- * specific string literals). Using a ground `ManifestContract<...>` type
4565
- * here would prevent assignability from contract-bound manifests in a
4566
- * contravariant position.
4582
+ * Derived from the shape of `table.resources`, which the generated
4583
+ * manifest contract seeds as `Record<PlayerId, Record<ResourceId, number>>`.
4584
+ * Resource identifiers come from the player balance record.
4567
4585
  */
4568
- type ReducerGameContractLike = {
4569
- manifest: any;
4570
- options: SchemaLike<RuntimeRecord>;
4571
- state: StateDefinition<SchemaLike<object>, SchemaLike<object>, SchemaLike<object>>;
4572
- };
4573
- type InitialStateContextOf<Contract extends ReducerGameContractLike> = InitContext<TableOfManifest<ManifestOf<Contract>>, ExactManifestContractOf<Contract>, OptionsOfContract<Contract>>;
4574
- type InitialStateCallbacks<Contract extends ReducerGameContractLike> = {
4575
- public?: (ctx: InitialStateContextOf<Contract>) => z.infer<PublicSchemaOfContract<Contract>>;
4576
- private?: (ctx: InitialStateContextOf<Contract> & {
4577
- playerId: PlayerIdOfTable<TableOfManifest<ManifestOf<Contract>>>;
4578
- }) => z.infer<PrivateSchemaOfContract<Contract>>;
4579
- hidden?: (ctx: InitialStateContextOf<Contract>) => z.infer<HiddenSchemaOfContract<Contract>>;
4580
- };
4581
- type ReducerGameDefinition<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>> = {
4582
- contract: Contract;
4583
- initial?: InitialStateCallbacks<NoInfer<Contract>>;
4584
- initialPhase?: keyof Definitions & string;
4585
- phases: Definitions;
4586
- view: View;
4587
- };
4588
- type RegistryKeys<Registry> = Registry extends Record<string, unknown> ? NonNeverKeys<Registry> & string : never;
4589
- type InteractionRegistryOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4590
- interactions?: infer Interactions;
4591
- } ? NonNullable<Interactions> : Record<string, never>;
4592
- type SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4593
- submit?: infer Submit;
4594
- } ? {
4595
- submit: NonNullable<Submit>;
4596
- } : Record<string, never>;
4597
- type NonNeverRegistryValue<Registry, Key extends string> = Registry extends Record<string, unknown> ? Key extends keyof Registry ? [Registry[Key]] extends [never] ? never : Registry[Key] : never : never;
4598
- type InteractionIdOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>> = PhaseDefinitionByName<Definition, PhaseName> extends {
4599
- kind: "auto";
4600
- } ? never : InteractionRegistryOfDefinitionPhase<Definition, PhaseName> extends infer Interactions ? SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName> extends infer Submit ? RegistryKeys<Interactions> | RegistryKeys<Submit> : never : never;
4601
- type InteractionSpecByNameOfDefinitionPhase<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>, InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>> = NonNeverRegistryValue<InteractionRegistryOfDefinitionPhase<Definition, PhaseName>, InteractionId> | NonNeverRegistryValue<SimultaneousSubmitRegistryOfDefinitionPhase<Definition, PhaseName>, InteractionId>;
4602
- type CollectorsOfInteractionDefinition<Spec> = Spec extends {
4603
- readonly steps: {
4604
- readonly collectors: infer Collectors extends Record<string, InputCollector>;
4605
- };
4606
- } ? Collectors : Spec extends {
4607
- readonly inputs?: infer Collectors;
4608
- } ? NonNullable<Collectors> extends Record<string, InputCollector> ? NonNullable<Collectors> : Record<string, never> : Record<string, never>;
4609
- type ClientParamsOfCollectors<Collectors> = Collectors extends Record<string, InputCollector> ? {
4610
- [K in keyof Collectors as Collectors[K] extends {
4611
- readonly kind: "rng";
4612
- } ? never : K]: Collectors[K] extends InputCollector<infer S> ? S extends SchemaLike<infer V> ? V : never : never;
4613
- } : never;
4586
+ type ResourceIdOfTable<Table> = Table extends {
4587
+ resources: infer Resources;
4588
+ } ? PlayerRecordValue<Resources> extends infer PlayerValue ? PlayerValue extends Record<string, unknown> ? StringKeyOf<PlayerValue> : never : never : never;
4614
4589
  /**
4615
- * Client-facing params shape for an interaction. Omits engine-sampled
4616
- * collectors (`rngInput.*`) — clients never supply those fields; the
4617
- * trusted reducer bundle fills them during `submitInteraction`.
4590
+ * Per-player balance shape for a runtime table. Extracts the
4591
+ * value of `table.resources` so callers receive the manifest-typed
4592
+ * record directly (e.g. `Record<ResourceId, number>`).
4593
+ */
4594
+ type ResourceBalancesOfTable<Table> = Table extends {
4595
+ resources: infer Resources;
4596
+ } ? PlayerRecordValue<Resources> extends infer PlayerValue ? PlayerValue extends Record<string, unknown> ? PlayerValue : never : never : never;
4597
+ /**
4598
+ * Per-player resource counts: a partial `Record<ResourceId, number>`.
4618
4599
  *
4619
- * This is the type that drives `submit(playerId, id, params)`,
4620
- * `handle.submit(params)`, and the generated `InteractionParams` surface
4621
- * through `createGameUi(game)`. The `reduce`-input counterpart is
4622
- * {@link ParamsOfInteractionOfDefinition}, which includes every field
4623
- * because the engine has already filled the sampled ones by then.
4600
+ * Used as the input shape for {@link ReducerTransaction.addResources},
4601
+ * {@link ReducerTransaction.spendResources}, and {@link ReducerTransaction.transferResources}.
4624
4602
  */
4625
- type CurrentStepParams<Collectors extends Record<string, InputCollector>> = {
4626
- [Key in keyof Collectors]: Pick<ClientParamsOfCollectors<Collectors>, Key & keyof ClientParamsOfCollectors<Collectors>> & {
4627
- [Other in Exclude<keyof Collectors, Key>]?: never;
4603
+ type ResourceAmountsOfTable<Table> = Partial<Record<ResourceIdOfTable<Table>, number>>;
4604
+ type PhaseStateOfState<State> = State extends {
4605
+ phase: infer PhaseState;
4606
+ } ? PhaseState : never;
4607
+ type PublicStateOfState<State> = State extends {
4608
+ publicState: infer PublicState;
4609
+ } ? PublicState : never;
4610
+ type HiddenStateOfState<State> = State extends {
4611
+ hiddenState: infer HiddenState;
4612
+ } ? HiddenState : never;
4613
+ type PrivateStateOfState<State> = State extends {
4614
+ privateState: Record<string, infer PrivateState>;
4615
+ } ? PrivateState : never;
4616
+ type DeckIdOfTable<Table> = Table extends {
4617
+ decks: infer Decks;
4618
+ } ? StringKeyOf<Decks> : never;
4619
+ type HandIdOfTable<Table> = Table extends {
4620
+ hands: infer Hands;
4621
+ } ? StringKeyOf<Hands> : never;
4622
+ type CardIdOfTable<Table> = Table extends {
4623
+ cards: infer Cards;
4624
+ } ? StringKeyOf<Cards> : never;
4625
+ type DeckIdOfState<State> = DeckIdOfTable<TableOfState<State>>;
4626
+ type HandIdOfState<State> = HandIdOfTable<TableOfState<State>>;
4627
+ type CardIdOfManifest<Manifest> = Manifest extends {
4628
+ literals: {
4629
+ cardIds: readonly (infer CardId)[];
4628
4630
  };
4629
- }[keyof Collectors];
4630
- type ClientParamsOfInteractionOfDefinition<Definition, PhaseName extends PhaseNamesOfDefinition<Definition>, InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>> = InteractionSpecByNameOfDefinitionPhase<Definition, PhaseName, InteractionId> extends infer Spec ? Spec extends {
4631
- readonly steps: unknown;
4632
- } ? CurrentStepParams<CollectorsOfInteractionDefinition<Spec>> : Spec extends {
4633
- readonly cardType: unknown;
4634
- readonly playFrom: unknown;
4635
- } ? {
4636
- cardId: string;
4637
- } & ClientParamsOfCollectors<CollectorsOfInteractionDefinition<Spec>> : ClientParamsOfCollectors<CollectorsOfInteractionDefinition<Spec>> : never;
4631
+ } ? Extract<CardId, string> : string;
4632
+ type SharedZoneIdOfTable<Table> = DeckIdOfTable<Table>;
4633
+ type PlayerZoneIdOfTable<Table> = HandIdOfTable<Table>;
4634
+ type BoardMapOfTable<Table> = Table extends {
4635
+ boards: {
4636
+ byId: infer Boards;
4637
+ };
4638
+ } ? Boards : never;
4639
+ type BoardIdOfTable<Table> = StringKeyOf<BoardMapOfTable<Table>>;
4640
+ type BoardStateOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardMapOfTable<Table>[BoardId];
4641
+ type TiledBoardIdOfTable<Table> = {
4642
+ [BoardId in BoardIdOfTable<Table>]: BoardStateOfTable<Table, BoardId> extends {
4643
+ layout: "hex" | "square";
4644
+ } ? BoardId : never;
4645
+ }[BoardIdOfTable<Table>];
4646
+ type TiledBoardStateOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends infer BoardState ? BoardState extends {
4647
+ layout: "hex" | "square";
4648
+ spaces: Record<string, unknown>;
4649
+ edges: readonly {
4650
+ id: string;
4651
+ }[];
4652
+ vertices: readonly {
4653
+ id: string;
4654
+ }[];
4655
+ } ? BoardState : never : never;
4656
+ type SpaceIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
4657
+ spaces: infer Spaces;
4658
+ } ? StringKeyOf<Spaces> : never;
4659
+ type BoardContainerIdOfTable<Table, BoardId extends BoardIdOfTable<Table>> = BoardStateOfTable<Table, BoardId> extends {
4660
+ containers: infer Containers;
4661
+ } ? StringKeyOf<Containers> : never;
4662
+ type TiledSpaceIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
4663
+ spaces: infer Spaces;
4664
+ } ? StringKeyOf<Spaces> : never;
4665
+ type TiledEdgeIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
4666
+ edges: readonly (infer Edge)[];
4667
+ } ? Edge extends {
4668
+ id: infer EdgeId;
4669
+ } ? Extract<EdgeId, string> : never : never;
4670
+ type TiledVertexIdOfTable<Table, BoardId extends TiledBoardIdOfTable<Table>> = TiledBoardStateOfTable<Table, BoardId> extends {
4671
+ vertices: readonly (infer Vertex)[];
4672
+ } ? Vertex extends {
4673
+ id: infer VertexId;
4674
+ } ? Extract<VertexId, string> : never : never;
4675
+ type ComponentIdOfTable<Table> = Table extends {
4676
+ componentLocations: infer ComponentLocations;
4677
+ } ? StringKeyOf<ComponentLocations> : never;
4678
+ type PlayerZoneIdOfState<State> = HandIdOfState<State>;
4679
+ type ManifestOf<Source> = Source extends {
4680
+ contract: infer Contract;
4681
+ } ? ManifestOf<Contract> : Source extends {
4682
+ manifest: infer Manifest;
4683
+ } ? Manifest : never;
4684
+ type StateDefinitionOfContract<Contract> = Contract extends {
4685
+ state: infer StateDefinitionValue;
4686
+ } ? StateDefinitionValue : never;
4687
+ type PhaseSchemasOfContract<Contract> = Contract extends {
4688
+ phases: infer Phases extends Record<string, SchemaLike<object>>;
4689
+ } ? Phases : Record<PhaseNameOfManifest<ManifestOf<Contract>>, SchemaLike<object>>;
4690
+ type PhaseStateMapOfContract<Contract> = {
4691
+ [Name in keyof PhaseSchemasOfContract<Contract> & string]: z.infer<PhaseSchemasOfContract<Contract>[Name]>;
4692
+ };
4693
+ type PublicSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<infer PublicSchema, SchemaLike<object>, SchemaLike<object>> ? PublicSchema : never;
4694
+ type PrivateSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, infer PrivateSchema, SchemaLike<object>> ? PrivateSchema : never;
4695
+ type HiddenSchemaOfContract<Contract> = StateDefinitionOfContract<Contract> extends StateDefinition<SchemaLike<object>, SchemaLike<object>, infer HiddenSchema> ? HiddenSchema : never;
4696
+ type PhaseNameOfContract<Contract> = keyof PhaseSchemasOfContract<Contract> extends string ? keyof PhaseSchemasOfContract<Contract> & string : PhaseNameOfManifest<ManifestOf<Contract>>;
4697
+ type ManifestContractOf<Contract> = ManifestContract<TableOfManifest<ManifestOf<Contract>>>;
4698
+ type ExactManifestContractOf<Contract> = ManifestOf<Contract> & ReducerManifestContractLike<TableOfManifest<ManifestOf<Contract>>>;
4699
+ type DeckCardsOfTable<Table, DeckId extends DeckIdOfTable<Table>> = Table extends {
4700
+ decks: infer Decks extends Record<string, readonly unknown[]>;
4701
+ } ? Decks[DeckId] : never;
4702
+ type PlayerRecordValue<T> = T extends Record<string, infer Value> ? Value : never;
4703
+ type HandCardsOfTable<Table, HandId extends HandIdOfTable<Table>> = Table extends {
4704
+ hands: infer Hands extends Record<string, unknown>;
4705
+ } ? HandId extends keyof Hands ? PlayerRecordValue<Hands[HandId]> extends infer Value ? Value extends readonly unknown[] ? Value : never : never : never : never;
4706
+ type CardIdOfDeck<Table, DeckId extends DeckIdOfTable<Table>> = DeckCardsOfTable<Table, DeckId>[number];
4707
+ type CardIdOfHand<Table, HandId extends HandIdOfTable<Table>> = HandCardsOfTable<Table, HandId>[number];
4708
+ type CompatibleHandIdForDeck<Table, DeckId extends DeckIdOfTable<Table>> = {
4709
+ [CandidateHandId in HandIdOfTable<Table>]: Extract<CardIdOfDeck<Table, DeckId>, CardIdOfHand<Table, CandidateHandId>> extends never ? never : CandidateHandId;
4710
+ }[HandIdOfTable<Table>];
4711
+ type CompatibleCardIdForHandAndDeck<Table, HandId extends HandIdOfTable<Table>, DeckId extends DeckIdOfTable<Table>> = Extract<CardIdOfHand<Table, HandId>, CardIdOfDeck<Table, DeckId>>;
4712
+ type CompatibleCardIdForTwoPlayerZones<Table, FromZoneId extends HandIdOfTable<Table>, ToZoneId extends HandIdOfTable<Table>> = Extract<CardIdOfHand<Table, FromZoneId>, CardIdOfHand<Table, ToZoneId>>;
4713
+ type OptionsSchemaOfContract<Contract> = Contract extends {
4714
+ options: infer Schema extends SchemaLike<RuntimeRecord>;
4715
+ } ? Schema : SchemaLike<Record<string, never>>;
4716
+ type OptionsOfContract<Contract> = z.infer<OptionsSchemaOfContract<Contract>>;
4717
+ /** Slot hosts share the canonical piece and die inventories. */
4718
+ type SlotHostOfTable<Table extends RuntimeTableRecord> = {
4719
+ kind: "piece";
4720
+ id: keyof Table["pieces"] & string;
4721
+ } | {
4722
+ kind: "die";
4723
+ id: keyof Table["dice"] & string;
4724
+ };
4725
+ type SlotLocationOfTable<Table> = Table extends {
4726
+ componentLocations: infer Locations;
4727
+ } ? Extract<Locations[keyof Locations], {
4728
+ type: "InSlot";
4729
+ }> : never;
4730
+ type SlotIdForHost<Location, Host> = Location extends {
4731
+ host: infer Candidate;
4732
+ slotId: infer Id;
4733
+ } ? Host extends Candidate ? Extract<Id, string> : never : never;
4734
+ type SlotIdOfTable<Table, Host> = SlotIdForHost<SlotLocationOfTable<Table>, Host>;
4638
4735
 
4639
- export { type OutcomeResult as $, type InteractionChoiceOption as A, type BaseGameStateOfContract as B, type CardIdOfManifest as C, type DieTypeSpec as D, type ErrorCodeOfContract as E, FrameworkErrorCodes as F, type GameEvent as G, type HexEdgeId as H, type InitializeRequest as I, type InteractionCommitPolicy$1 as J, InteractionCommitPolicySchema as K, type InteractionDescriptor as L, InteractionDescriptorSchema as M, type InteractionDiagnosticReason as N, type InteractionIdOfDefinitionPhase as O, type InteractionInputDescriptor as P, InteractionInputDescriptorSchema as Q, type InteractionMap as R, type InteractionRule as S, type InteractionSpec as T, type InteractionSpecByNameOfDefinitionPhase as U, InteractionSteps as V, type JsonValue as W, type ManifestContractOf as X, type ManifestIdSchema as Y, type ObjectSchema as Z, type OptionsOfContract as _, type BoardContainerIdOfTable as a, rectangle as a$, type OutcomeScoreComponent as a0, type OutcomeStanding as a1, type OutcomeTieBreak as a2, type PhaseDefinition as a3, type PhaseMapOf as a4, type PhaseNameOfContract as a5, type PhaseNamesOfDefinition as a6, type PhaseSchemasOfContract as a7, type PlayerIdOfState as a8, type ProjectRequest as a9, type RuntimeSquareBoardState as aA, type RuntimeSquareSpaceState as aB, type RuntimeTableRecord as aC, type RuntimeTiledEdgeState as aD, type RuntimeTiledVertexState as aE, type SchemaLike as aF, type ScopedPhaseState as aG, type SeatProjectionBundle as aH, type SimultaneousPhaseProjection as aI, type SquareBoardSpec as aJ, type StateDefinition as aK, type SystemActionEvent as aL, type TableOfManifest as aM, type TableQueries as aN, type TableQueriesOfState as aO, type TiledBoardIdOfTable as aP, type TiledEdgeIdOfTable as aQ, type TiledSpaceIdOfTable as aR, type TiledVertexIdOfTable as aS, type ValidationIssue as aT, type ViewCard as aU, type ViewData as aV, type ViewDefinition as aW, type ViewOfContract as aX, type ViewOfDefinition as aY, fromCoordinates as aZ, hexagon as a_, type PropertySchema as aa, type ReducerAccept as ab, type ReducerContractVersion as ac, type ReducerGameContract as ad, type ReducerGameContractLike as ae, type ReducerGameDefinition as af, type ReducerManifestContract as ag, type ReducerManifestContractLike as ah, type ReducerReject as ai, type ReducerResult as aj, type ReducerSessionState as ak, type ReducerTransaction as al, type ReducerTransactionOutcome as am, type ReducerValidationResult as an, type RotatePlayerZoneArgs as ao, type RuntimeBoardState as ap, type RuntimeCardData as aq, type RuntimeDieData as ar, type RuntimeGenericBoardState as as, type RuntimeHexBoardState as at, type RuntimeHexSpaceState as au, type RuntimeJson as av, RuntimeJsonSchema as aw, type RuntimePayload as ax, type RuntimePieceData as ay, type RuntimeRecord as az, type BoardEdgeRef as b, ring as b0, runtimeSchema as b1, runtimeTypes as b2, spiral as b3, type BoardIdOfTable as c, type BoardStaticProjection as d, type BoardVertexRef as e, type Brand as f, type ClientParamsOfInteractionOfDefinition as g, type CollectorState as h, type DispatchRequest as i, type DispatchResult as j, type GameEventDetail as k, type GameInput as l, type GameOutcome as m, type GameOutcome$1 as n, type GameStateOf as o, type GameTopologyManifest as p, type HexSpaceId as q, type HexVertexId as r, type InitializeResult as s, type InputCollector as t, type InputDomain as u, InputDomainSchema as v, type InputSelection as w, type InputSelectionDescriptor as x, type InteractionAvailability as y, InteractionAvailabilitySchema as z };
4736
+ export { type JsonValue as $, InputDomainSchema as A, type BaseGameStateOfContract as B, type CardIdOfManifest as C, type DeckIdOfTable as D, type ErrorCodeOfContract as E, FrameworkErrorCodes as F, type GameEvent as G, type HandIdOfTable as H, type InitializeRequest as I, type InputSelection as J, type InputSelectionDescriptor as K, type InteractionAvailability as L, InteractionAvailabilitySchema as M, type InteractionChoiceOption as N, type InteractionCommitPolicy$1 as O, InteractionCommitPolicySchema as P, type InteractionDescriptor as Q, InteractionDescriptorSchema as R, type InteractionDiagnosticReason as S, type InteractionIdOfDefinitionPhase as T, type InteractionInputDescriptor as U, InteractionInputDescriptorSchema as V, type InteractionMap as W, type InteractionRule as X, type InteractionSpec as Y, type InteractionSpecByNameOfDefinitionPhase as Z, InteractionSteps as _, type BoardContainerIdOfTable as a, type ViewCard as a$, type ManifestContractOf as a0, type ManifestIdSchema as a1, type ObjectSchema as a2, type OptionsOfContract as a3, type OutcomeResult as a4, type OutcomeScoreComponent as a5, type OutcomeStanding as a6, type OutcomeTieBreak as a7, type PhaseDefinition as a8, type PhaseMapOf as a9, type RuntimeGenericBoardState as aA, type RuntimeHexBoardState as aB, type RuntimeJson as aC, RuntimeJsonSchema as aD, type RuntimePayload as aE, type RuntimePieceData as aF, type RuntimeRecord as aG, type RuntimeSquareBoardState as aH, type RuntimeTableRecord as aI, type RuntimeTiledEdgeState as aJ, type RuntimeTiledVertexState as aK, type SchemaLike as aL, type ScopedPhaseState as aM, type SeatProjectionBundle as aN, type SimultaneousPhaseProjection as aO, type SpaceIdOfTable as aP, type SquareBoardSpec as aQ, type StateDefinition as aR, type SystemActionEvent as aS, type TableOfManifest as aT, type TableQueries as aU, type TableQueriesOfState as aV, type TiledBoardIdOfTable as aW, type TiledEdgeIdOfTable as aX, type TiledSpaceIdOfTable as aY, type TiledVertexIdOfTable as aZ, type ValidationIssue as a_, type PhaseNameOfContract as aa, type PhaseNamesOfDefinition as ab, type PhaseSchemasOfContract as ac, type PlayerIdOfState as ad, type PlayerIdOfTable as ae, type ProjectRequest as af, type PropertySchema as ag, type ReducerAccept as ah, type ReducerContractVersion as ai, type ReducerGameContract as aj, type ReducerGameContractLike as ak, type ReducerGameDefinition as al, type ReducerGameDefinitionInput as am, type ReducerManifestContract as an, type ReducerManifestContractLike as ao, type ReducerReject as ap, type ReducerResult as aq, type ReducerSessionState as ar, type ReducerTransaction as as, type ReducerTransactionOutcome as at, type ReducerValidationResult as au, type RotatePlayerZoneArgs as av, type RuntimeBoardState as aw, type RuntimeCardData as ax, type RuntimeComponentLocation as ay, type RuntimeDieData as az, type BoardEdgeRef as b, type ViewData as b0, type ViewDefinition as b1, type ViewOfContract as b2, type ViewOfDefinition as b3, fromCoordinates as b4, hexagon as b5, rectangle as b6, ring as b7, runtimeSchema as b8, runtimeTypes as b9, spiral as ba, type BoardIdOfTable as c, type BoardStateOfTable as d, type BoardStaticProjection as e, type BoardVertexRef as f, type Brand as g, type ChoiceListDomainDescriptor as h, type ClientParamsOfInteractionOfDefinition as i, type CollectorState as j, type DieTypeSpec as k, type DispatchRequest as l, type DispatchResult as m, type GameEventDetail as n, type GameInput as o, type GameOutcome as p, type GameOutcome$1 as q, type GameStateOf as r, type GameTopologyManifest as s, type HexEdgeId as t, type HexSpaceId as u, type HexVertexId as v, type InitializeResult as w, type InputCollector as x, type InputCollectorOfDefinition as y, type InputDomain as z };