@dreamboard-games/sdk 0.5.0-alpha.34 → 0.5.0-alpha.36
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/README.md +62 -41
- package/dist/{board-element-DCjHsEnF.d.ts → board-element-yXrGm5eP.d.ts} +1 -1
- package/dist/{chunk-BVWJS3AB.js → chunk-54U3ZCFA.js} +16 -7
- package/dist/chunk-54U3ZCFA.js.map +1 -0
- package/dist/{chunk-KYQQIFXN.js → chunk-75QTSYRZ.js} +317 -86
- package/dist/chunk-75QTSYRZ.js.map +1 -0
- package/dist/{chunk-CZRPUWCT.js → chunk-7GX27XU6.js} +23 -2
- package/dist/{chunk-CZRPUWCT.js.map → chunk-7GX27XU6.js.map} +1 -1
- package/dist/{chunk-BSS4ORU3.js → chunk-G4MY5YMA.js} +8 -5
- package/dist/chunk-G4MY5YMA.js.map +1 -0
- package/dist/{chunk-2GUPNL7A.js → chunk-RNR4M67F.js} +3 -3
- package/dist/{diagnostics-Cl8mSexe.d.ts → diagnostics-Bgu7w8LA.d.ts} +1 -1
- package/dist/{extract-CNUw9Q8C.d.ts → extract-_TyEXSCt.d.ts} +2 -1
- package/dist/index.d.ts +78 -78
- package/dist/index.js +5 -5
- package/dist/{model-BD0OKVEc.d.ts → model-U0F5B3cr.d.ts} +2 -2
- package/dist/react.d.ts +3 -3
- package/dist/react.js +2 -2
- package/dist/reducer.d.ts +130 -186
- package/dist/reducer.js +29 -26
- package/dist/reducer.js.map +1 -1
- package/dist/{shortcuts-Br5h9mEV.d.ts → shortcuts-DXkAlfNw.d.ts} +2 -2
- package/dist/testing.d.ts +10 -4
- package/dist/testing.js +4 -4
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-BSS4ORU3.js.map +0 -1
- package/dist/chunk-BVWJS3AB.js.map +0 -1
- package/dist/chunk-KYQQIFXN.js.map +0 -1
- /package/dist/{chunk-2GUPNL7A.js.map → chunk-RNR4M67F.js.map} +0 -0
package/dist/reducer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { al as ManifestIdSchema,
|
|
2
|
-
export { f as AuthoredTileFaceAudience, h as BoardEdgeId, k as BoardSpaceHostId, p as BoardVertexId, J as FieldSchema, L as FieldsOutput, M as FrameworkErrorCodes, N as GameEvent, O as GameEventDetail, Q as GameOutcome, am as ManifestIdsOf,
|
|
1
|
+
import { al as ManifestIdSchema, b6 as SchemaLike, x as CollectorState, Z as InputCollector, aB as PlayerIdOfState, bn as TableQueriesOfState, aZ as ResourceMapDomainDescriptor, t as BoundedNumberDomainDescriptor, u as ChoiceDomainDescriptor, v as ChoiceListDomainDescriptor, by as TopologyDefinitions, z as CollectorValueWitness, y as CollectorValueOf, a2 as InputSelectionDescriptor, aT as ReducerManifestContractLike, b4 as RuntimeTableRecord, b3 as RuntimeRecord, bi as StateDefinition, aj as ManifestContractOf, B as BaseGameStateOfContract, I as ErrorCodeOfContract, bv as TiledBoardIdOfTable, bl as TableOfManifest, bx as TiledVertexIdOfTable, bw as TiledEdgeIdOfTable, j as BoardIdOfTable, bg as SpaceIdOfTable, l as BoardSpaceTarget, av as PerPlayerInstanceId, bK as ZoneIdOfTable, C as CardIdOfManifest, aG as PositionTargetSchema, aF as PositionTarget, bq as TileIdOfTable, ap as OptionsOfContract, aW as ReducerTransaction, bE as ViewData, bF as ViewDefinition, ax as PhaseMapOf, bG as ViewOfContract, aR as ReducerGameDefinitionInput, aQ as ReducerGameDefinition, ai as InteractionSteps, b7 as ScopedPhaseState, ag as InteractionSpec, af as InteractionRule, aw as PhaseDefinition, ae as InteractionMap, aS as ReducerManifestContract, aO as ReducerGameContract, F as CompiledManifestWitness, E as CompiledManifest, bk as SystemActionEvent, s as BotStrategyMetadata, aC as PluginGameplayFrame, bH as ViewOfDefinition, ay as PhaseNamesOfDefinition, ab as InteractionIdOfDefinitionPhase, w as ClientParamsOfInteractionOfDefinition, bY as validatedReducerDefinition, an as ManifestOf, ah as InteractionSpecByNameOfDefinitionPhase, _ as InputCollectorOfDefinition, aP as ReducerGameContractLike, b2 as RuntimeQueryTable, bI as ZoneDefinitions, bm as TableQueries, b5 as SchemaAuthoring, U as GameTopologyManifest$1, K as FieldsInput, e as AuthoredTileDisclosure, a$ as RuntimeIdsFromCount, bt as TileSpaceIds, i as BoardEdgeRef, q as BoardVertexRef, ak as ManifestCountValidation, bz as ValidatedManifest, c as AuthoredManifest, aM as ReadonlyRuntimeData, d as AuthoredOf } from './extract-_TyEXSCt.js';
|
|
2
|
+
export { f as AuthoredTileFaceAudience, h as BoardEdgeId, k as BoardSpaceHostId, p as BoardVertexId, J as FieldSchema, L as FieldsOutput, M as FrameworkErrorCodes, N as GameEvent, O as GameEventDetail, Q as GameOutcome, am as ManifestIdsOf, ao as ManifestTable, aq as OutcomeResult, ar as OutcomeScoreComponent, as as OutcomeStanding, at as OutcomeTieBreak, au as PerPlayerInstanceFamily, aA as PlayerId, aL as PublicTileAppearance, aX as ReducerTransactionOutcome, aY as ReducerValidationResult, bW as ReducerWire, bV as ReducerWireZod, a_ as RotateZoneArgs, ba as SeatSpaceRef, bb as SeatTileRef, bh as SquareBoardSpec, bo as TileDisclosure, bp as TileFaceAudience, br as TileSeedSpec, bs as TileSpaceId, bu as TileTypeSpec, bA as ValidationIssue, bN as asPlayerId, bO as boardSpaceHostId, bP as isPlayerId, bQ as parseBoardSpaceHostId, bR as parsePerPlayerInstanceId, bS as parseTileSpaceId, bT as perPlayerInstanceId, bU as ref, bX as tileSpaceId } from './extract-_TyEXSCt.js';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import { z as z$1 } from 'zod';
|
|
5
5
|
export { z };
|
|
6
|
-
import { N as InteractionKey } from './model-
|
|
7
|
-
import { a as ReducerBundleContract, c as ReducerDiagnosticsSink } from './diagnostics-
|
|
8
|
-
export { D as DispatchTraceSummaryEntry, M as MaybePromise, R as REDUCER_CONTRACT_VERSION, b as ReducerDiagnosticEvent, d as assertReducerBundleContract, n as noopDiagnosticsSink } from './diagnostics-
|
|
9
|
-
export { b as boardEdgeId, a as boardVertexId, p as parseBoardElementId } from './board-element-
|
|
6
|
+
import { N as InteractionKey } from './model-U0F5B3cr.js';
|
|
7
|
+
import { a as ReducerBundleContract, c as ReducerDiagnosticsSink } from './diagnostics-Bgu7w8LA.js';
|
|
8
|
+
export { D as DispatchTraceSummaryEntry, M as MaybePromise, R as REDUCER_CONTRACT_VERSION, b as ReducerDiagnosticEvent, d as assertReducerBundleContract, n as noopDiagnosticsSink } from './diagnostics-Bgu7w8LA.js';
|
|
9
|
+
export { b as boardEdgeId, a as boardVertexId, p as parseBoardElementId } from './board-element-yXrGm5eP.js';
|
|
10
10
|
import '@tanstack/store';
|
|
11
11
|
import 'honeycomb-grid';
|
|
12
12
|
|
|
@@ -257,25 +257,32 @@ declare const rngInput: {
|
|
|
257
257
|
coin: typeof coin;
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
-
type ManyOptions = {
|
|
260
|
+
type ManyOptions = ({
|
|
261
261
|
count: number;
|
|
262
|
-
distinct?: boolean;
|
|
263
262
|
} | {
|
|
264
263
|
min?: number;
|
|
265
264
|
max?: number;
|
|
265
|
+
}) & {
|
|
266
266
|
distinct?: boolean;
|
|
267
267
|
};
|
|
268
|
+
type ManySelection = Extract<InputSelectionDescriptor, {
|
|
269
|
+
mode: "many";
|
|
270
|
+
}>;
|
|
271
|
+
type AuthoredSelection<Options extends ManyOptions> = ManySelection & Pick<Options, Extract<keyof Options, "distinct">> & (Options extends {
|
|
272
|
+
count: infer Count extends number;
|
|
273
|
+
} ? {
|
|
274
|
+
readonly min: Count;
|
|
275
|
+
readonly max: Count;
|
|
276
|
+
} : Pick<Options, Extract<keyof Options, "min" | "max">>);
|
|
268
277
|
type NonRngCollector = InputCollector<SchemaLike<unknown>, CollectorState> & {
|
|
269
278
|
readonly kind: Exclude<InputCollector["kind"], "rng">;
|
|
270
279
|
};
|
|
271
280
|
/** Lift the value schema while retaining the collector's exact domain and routing. */
|
|
272
|
-
type ManyInputCollector<Collector extends NonRngCollector> = Omit<Collector, "schema" | "selection" | "defaultValue" | "resolveDefaultValue" | keyof CollectorValueWitness<unknown>> & CollectorValueWitness<CollectorValueOf<Collector>[]> & {
|
|
281
|
+
type ManyInputCollector<Collector extends NonRngCollector, Options extends ManyOptions = ManyOptions> = Omit<Collector, "schema" | "selection" | "defaultValue" | "resolveDefaultValue" | keyof CollectorValueWitness<unknown>> & CollectorValueWitness<CollectorValueOf<Collector>[]> & {
|
|
273
282
|
readonly schema: z.ZodArray<Collector["schema"]>;
|
|
274
|
-
readonly selection:
|
|
275
|
-
mode: "many";
|
|
276
|
-
}>;
|
|
283
|
+
readonly selection: AuthoredSelection<Options>;
|
|
277
284
|
};
|
|
278
|
-
declare function many<Collector extends NonRngCollector>(collector: Collector, options:
|
|
285
|
+
declare function many<Collector extends NonRngCollector, const Options extends ManyOptions>(collector: Collector, options: Options & Record<Exclude<keyof Options, "min" | "max" | "count" | "distinct">, never>): ManyInputCollector<Collector, Options>;
|
|
279
286
|
|
|
280
287
|
type TileTargetPredicate<State extends CollectorState, Id extends string, Definitions extends TopologyDefinitions = TopologyDefinitions> = TargetPredicate<State, Id, Definitions>;
|
|
281
288
|
|
|
@@ -381,16 +388,36 @@ type PhaseAuthoring<Contract extends ContractWithPhases, PhaseStateSchema extend
|
|
|
381
388
|
}>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
|
|
382
389
|
steps: unknown;
|
|
383
390
|
}>;
|
|
391
|
+
interaction<Collectors extends Record<string, InputCollector>, ParamsSchema extends z$1.core.SomeType>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
|
|
392
|
+
inputs: unknown;
|
|
393
|
+
}> & {
|
|
394
|
+
paramsSchema: ParamsSchema;
|
|
395
|
+
}): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
|
|
396
|
+
inputs: unknown;
|
|
397
|
+
}> & {
|
|
398
|
+
paramsSchema: ParamsSchema;
|
|
399
|
+
};
|
|
384
400
|
interaction<Collectors extends Record<string, InputCollector>>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
|
|
385
401
|
inputs: unknown;
|
|
386
402
|
}>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
|
|
387
403
|
inputs: unknown;
|
|
388
404
|
}>;
|
|
389
405
|
rule<Collectors extends Record<string, InputCollector> = Record<string, InputCollector>>(rule: InteractionRule<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>): InteractionRule<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>;
|
|
390
|
-
|
|
406
|
+
/** Preserve the submit collectors when there are no ordinary interactions. */
|
|
407
|
+
define<SubmitCollectors extends Record<string, InputCollector> = Record<string, InputCollector>, SubmitSpec extends object = Record<never, never>>(definition: PhaseDefinitionWithoutState<PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Record<string, never>, OptionsOfContract<Contract>, ContractErrorCode<Contract>>> & {
|
|
408
|
+
kind: "simultaneousPlayer";
|
|
409
|
+
submit?: SubmitSpec;
|
|
410
|
+
interactions?: never;
|
|
411
|
+
}): PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Record<string, never>, OptionsOfContract<Contract>, ContractErrorCode<Contract>> & {
|
|
412
|
+
kind: "simultaneousPlayer";
|
|
413
|
+
submit?: SubmitSpec;
|
|
414
|
+
};
|
|
415
|
+
define<SubmitCollectors extends Record<string, InputCollector> = Record<string, InputCollector>, Interactions extends InteractionMap<BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>> = Record<string, never>, const Kind extends "player" | "simultaneousPlayer" | "auto" = "player" | "simultaneousPlayer" | "auto", SubmitSpec extends object = Record<never, never>>(definition: PhaseDefinitionWithoutState<PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>>> & {
|
|
391
416
|
kind: Kind;
|
|
417
|
+
submit?: SubmitSpec;
|
|
392
418
|
}): PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>> & {
|
|
393
419
|
kind: Kind;
|
|
420
|
+
submit?: SubmitSpec;
|
|
394
421
|
};
|
|
395
422
|
readonly inputs: BoundInputBuilders<Contract>;
|
|
396
423
|
/** Compile-time only. Reading any member at runtime throws. */
|
|
@@ -494,10 +521,97 @@ interface BotStrategy<Game> extends BotStrategyMetadata {
|
|
|
494
521
|
decide(frame: BotFrame<Game>): BotDecision<Game>;
|
|
495
522
|
}
|
|
496
523
|
|
|
524
|
+
declare const registeredStrategies: unique symbol;
|
|
525
|
+
/** A strategy collection registered against one assembled game definition. */
|
|
526
|
+
type DefinedBots<Game> = {
|
|
527
|
+
readonly [registeredStrategies]: readonly BotStrategy<Game>[];
|
|
528
|
+
};
|
|
529
|
+
type VisibleCard = {
|
|
530
|
+
readonly id: string;
|
|
531
|
+
};
|
|
532
|
+
type SeatView<Game> = NonNullable<ViewOfDefinition<Game>>;
|
|
533
|
+
type CardResolver<View, Card extends VisibleCard> = (view: View) => readonly Card[];
|
|
534
|
+
type Scorer<Args> = (args: Args) => number;
|
|
535
|
+
type CardInputAlias<Key, Suffix extends "Id" | "Ids"> = Key extends `${infer Name}${Suffix}` ? Name extends "" ? never : Suffix extends "Ids" ? `${Name}s` : Exclude<Name, "view"> : never;
|
|
536
|
+
type SingleKey<Keys, Key = Keys> = Key extends string ? [Keys] extends [Key] ? Key : never : never;
|
|
537
|
+
type CardBinding<Key, Collector> = Collector extends {
|
|
538
|
+
readonly kind: "card";
|
|
539
|
+
} ? CollectorValueOf<Collector> extends readonly unknown[] ? Collector extends {
|
|
540
|
+
readonly selection: {
|
|
541
|
+
readonly mode: "many";
|
|
542
|
+
readonly min: infer Min extends number;
|
|
543
|
+
readonly max: infer Max extends number;
|
|
544
|
+
readonly distinct: true;
|
|
545
|
+
};
|
|
546
|
+
} ? number extends Min ? never : [Min, Max] extends [Max, Min] ? [CardInputAlias<Key, "Ids">] extends [never] ? never : {
|
|
547
|
+
alias: CardInputAlias<Key, "Ids">;
|
|
548
|
+
multiple: true;
|
|
549
|
+
} : never : never : [CardInputAlias<Key, "Id">] extends [never] ? never : {
|
|
550
|
+
alias: CardInputAlias<Key, "Id">;
|
|
551
|
+
multiple: false;
|
|
552
|
+
} : never;
|
|
553
|
+
type Binding<Game, Phase extends PhaseNamesOfDefinition<Game>, Id extends InteractionIdOfDefinitionPhase<Game, Phase>, Keys = keyof ClientParamsOfInteractionOfDefinition<Game, Phase, Id>> = InteractionSpecByNameOfDefinitionPhase<Game, Phase, Id> extends {
|
|
554
|
+
readonly steps: unknown;
|
|
555
|
+
} ? never : [Keys] extends [never] ? null : CardBinding<SingleKey<Keys>, InputCollectorOfDefinition<Game, Phase, Id, SingleKey<Keys>>>;
|
|
556
|
+
type Bindings<Game> = {
|
|
557
|
+
[Key in InteractionKey<Game>]: Key extends `${infer Phase extends PhaseNamesOfDefinition<Game>}.${infer Id}` ? Id extends InteractionIdOfDefinitionPhase<Game, Phase> ? Binding<Game, Phase, Id> : never : never;
|
|
558
|
+
};
|
|
559
|
+
type ResolvedArgs<Binding, Card> = Binding extends {
|
|
560
|
+
alias: infer Alias extends string;
|
|
561
|
+
multiple: infer Multiple;
|
|
562
|
+
} ? Record<Alias, Multiple extends true ? readonly Card[] : Card> : object;
|
|
563
|
+
type CardAlias<Binding> = Binding extends {
|
|
564
|
+
alias: infer Name extends string;
|
|
565
|
+
} ? Name : never;
|
|
566
|
+
type CandidateGenerator<Binding, View, Card> = (context: {
|
|
567
|
+
view: View;
|
|
568
|
+
eligible: Readonly<Record<CardAlias<Binding>, readonly Card[]>>;
|
|
569
|
+
selection: Readonly<Record<CardAlias<Binding>, {
|
|
570
|
+
readonly count: number;
|
|
571
|
+
}>>;
|
|
572
|
+
}) => Iterable<Record<CardAlias<Binding>, readonly Card[]>>;
|
|
573
|
+
type CandidateHandler<Binding, View, Card> = {
|
|
574
|
+
candidates: CandidateGenerator<Binding, View, Card> & (Binding extends {
|
|
575
|
+
multiple: true;
|
|
576
|
+
} ? unknown : never);
|
|
577
|
+
score: Scorer<{
|
|
578
|
+
view: View;
|
|
579
|
+
} & Record<CardAlias<Binding>, readonly Card[]>>;
|
|
580
|
+
};
|
|
581
|
+
type RequiredSkips<Game, HasResolver extends boolean> = {
|
|
582
|
+
[Key in keyof Bindings<Game>]: [Bindings<Game>[Key]] extends [never] ? Key : HasResolver extends true ? never : Bindings<Game>[Key] extends null ? never : Key;
|
|
583
|
+
}[keyof Bindings<Game>];
|
|
584
|
+
type AuthoredStrategy<Game, Card, Keys extends keyof Bindings<Game>, HasResolver extends boolean> = BotStrategyMetadata & {
|
|
585
|
+
score: {
|
|
586
|
+
[Key in Keys]: "skip" | CandidateHandler<Bindings<Game>[Key], SeatView<Game>, Card> | Scorer<{
|
|
587
|
+
view: SeatView<Game>;
|
|
588
|
+
} & ResolvedArgs<Bindings<Game>[Key], Card>>;
|
|
589
|
+
} & Record<keyof Bindings<Game>, unknown> & Record<RequiredSkips<Game, HasResolver>, "skip">;
|
|
590
|
+
};
|
|
591
|
+
type AssembledGame = {
|
|
592
|
+
readonly [validatedReducerDefinition]: true;
|
|
593
|
+
};
|
|
594
|
+
type GameCard<Game> = {
|
|
595
|
+
readonly id: CardIdOfManifest<ManifestOf<Game>>;
|
|
596
|
+
};
|
|
597
|
+
/** Register seat-view resolvers and strategies for every player interaction. */
|
|
598
|
+
declare function defineBots<Game extends AssembledGame, Card extends GameCard<Game>, Keys extends keyof Bindings<Game>>(game: Game, config: {
|
|
599
|
+
resolve: {
|
|
600
|
+
card: CardResolver<SeatView<Game>, Card>;
|
|
601
|
+
};
|
|
602
|
+
strategies: readonly AuthoredStrategy<Game, Card, Keys, true>[];
|
|
603
|
+
}): DefinedBots<Game>;
|
|
604
|
+
declare function defineBots<Game extends AssembledGame, Keys extends keyof Bindings<Game>>(game: Game, config: {
|
|
605
|
+
resolve: {
|
|
606
|
+
card?: never;
|
|
607
|
+
};
|
|
608
|
+
strategies: readonly AuthoredStrategy<Game, never, Keys, false>[];
|
|
609
|
+
}): DefinedBots<Game>;
|
|
610
|
+
|
|
497
611
|
type InteractionDiagnosticsMode = "verbose" | undefined;
|
|
498
612
|
|
|
499
613
|
type ReducerBundleOptions<Game = unknown> = {
|
|
500
|
-
botStrategies?:
|
|
614
|
+
botStrategies?: DefinedBots<Game>;
|
|
501
615
|
diagnostics?: ReducerDiagnosticsSink | InteractionDiagnosticsMode;
|
|
502
616
|
descriptorDiagnostics?: InteractionDiagnosticsMode;
|
|
503
617
|
};
|
|
@@ -1092,174 +1206,4 @@ type MaterializeOptions = {
|
|
|
1092
1206
|
/** Construct actual session inventory; references use the supplied live roster. */
|
|
1093
1207
|
declare function materializeManifestTable(options: MaterializeOptions): Record<string, unknown>;
|
|
1094
1208
|
|
|
1095
|
-
|
|
1096
|
-
declare function offeredInteraction<Key extends string>(frame: Pick<PluginGameplayFrame<unknown, string, Key>, "availableInteractions">, key: NoInfer<Key>): InteractionDescriptor<Key> | undefined;
|
|
1097
|
-
/** Resolve a named input in the current step and narrow its projected domain. */
|
|
1098
|
-
declare function offeredInputDomain<Type extends InputDomain["type"]>(interaction: InteractionDescriptor | undefined, key: string, type: Type): Extract<{
|
|
1099
|
-
readonly type: "cardTarget";
|
|
1100
|
-
readonly projection: "resolved";
|
|
1101
|
-
readonly targetKind: "card";
|
|
1102
|
-
readonly zoneIds: readonly string[];
|
|
1103
|
-
readonly eligibleTargets: readonly string[];
|
|
1104
|
-
readonly selection?: {
|
|
1105
|
-
readonly mode: "single";
|
|
1106
|
-
} | {
|
|
1107
|
-
readonly mode: "many";
|
|
1108
|
-
readonly min: number;
|
|
1109
|
-
readonly max?: number | undefined;
|
|
1110
|
-
readonly distinct?: boolean | undefined;
|
|
1111
|
-
} | undefined;
|
|
1112
|
-
}, {
|
|
1113
|
-
type: Type;
|
|
1114
|
-
}> | Extract<{
|
|
1115
|
-
readonly type: "tileTarget";
|
|
1116
|
-
readonly projection: "resolved";
|
|
1117
|
-
readonly targetKind: "tile";
|
|
1118
|
-
readonly zoneIds: readonly string[];
|
|
1119
|
-
readonly boardIds: readonly string[];
|
|
1120
|
-
readonly eligibleTargets: readonly (string & z.$brand<"SeatTileRef">)[];
|
|
1121
|
-
readonly selection?: {
|
|
1122
|
-
readonly mode: "single";
|
|
1123
|
-
} | {
|
|
1124
|
-
readonly mode: "many";
|
|
1125
|
-
readonly min: number;
|
|
1126
|
-
readonly max?: number | undefined;
|
|
1127
|
-
readonly distinct?: boolean | undefined;
|
|
1128
|
-
} | undefined;
|
|
1129
|
-
}, {
|
|
1130
|
-
type: Type;
|
|
1131
|
-
}> | Extract<{
|
|
1132
|
-
readonly type: "boardTarget";
|
|
1133
|
-
readonly projection: "resolved";
|
|
1134
|
-
readonly targetKind: "edge" | "vertex" | "space";
|
|
1135
|
-
readonly boardId: string;
|
|
1136
|
-
readonly valueKind: "board-id";
|
|
1137
|
-
readonly eligibleTargets: readonly string[];
|
|
1138
|
-
readonly selection?: {
|
|
1139
|
-
readonly mode: "single";
|
|
1140
|
-
} | {
|
|
1141
|
-
readonly mode: "many";
|
|
1142
|
-
readonly min: number;
|
|
1143
|
-
readonly max?: number | undefined;
|
|
1144
|
-
readonly distinct?: boolean | undefined;
|
|
1145
|
-
} | undefined;
|
|
1146
|
-
}, {
|
|
1147
|
-
type: Type;
|
|
1148
|
-
}> | Extract<{
|
|
1149
|
-
readonly type: "boardTarget";
|
|
1150
|
-
readonly projection: "resolved";
|
|
1151
|
-
readonly targetKind: "space";
|
|
1152
|
-
readonly boardBaseId: string;
|
|
1153
|
-
readonly valueKind: "board-space";
|
|
1154
|
-
readonly eligibleTargets: readonly {
|
|
1155
|
-
readonly boardId: string;
|
|
1156
|
-
readonly spaceId: string;
|
|
1157
|
-
}[];
|
|
1158
|
-
readonly selection?: {
|
|
1159
|
-
readonly mode: "single";
|
|
1160
|
-
} | {
|
|
1161
|
-
readonly mode: "many";
|
|
1162
|
-
readonly min: number;
|
|
1163
|
-
readonly max?: number | undefined;
|
|
1164
|
-
readonly distinct?: boolean | undefined;
|
|
1165
|
-
} | undefined;
|
|
1166
|
-
}, {
|
|
1167
|
-
type: Type;
|
|
1168
|
-
}> | Extract<{
|
|
1169
|
-
readonly type: "zonePosition";
|
|
1170
|
-
readonly zones: readonly {
|
|
1171
|
-
readonly zoneId: string;
|
|
1172
|
-
readonly hostId: string;
|
|
1173
|
-
readonly size: number;
|
|
1174
|
-
}[];
|
|
1175
|
-
readonly selection?: {
|
|
1176
|
-
readonly mode: "single";
|
|
1177
|
-
} | {
|
|
1178
|
-
readonly mode: "many";
|
|
1179
|
-
readonly min: number;
|
|
1180
|
-
readonly max?: number | undefined;
|
|
1181
|
-
readonly distinct?: boolean | undefined;
|
|
1182
|
-
} | undefined;
|
|
1183
|
-
}, {
|
|
1184
|
-
type: Type;
|
|
1185
|
-
}> | Extract<{
|
|
1186
|
-
readonly type: "resourceMap";
|
|
1187
|
-
readonly resources: readonly {
|
|
1188
|
-
readonly resourceId: string;
|
|
1189
|
-
readonly min: number;
|
|
1190
|
-
readonly max: number;
|
|
1191
|
-
readonly label?: string | undefined;
|
|
1192
|
-
readonly icon?: string | undefined;
|
|
1193
|
-
}[];
|
|
1194
|
-
readonly selection?: {
|
|
1195
|
-
readonly mode: "single";
|
|
1196
|
-
} | {
|
|
1197
|
-
readonly mode: "many";
|
|
1198
|
-
readonly min: number;
|
|
1199
|
-
readonly max?: number | undefined;
|
|
1200
|
-
readonly distinct?: boolean | undefined;
|
|
1201
|
-
} | undefined;
|
|
1202
|
-
}, {
|
|
1203
|
-
type: Type;
|
|
1204
|
-
}> | Extract<{
|
|
1205
|
-
readonly type: "boundedNumber";
|
|
1206
|
-
readonly min: number;
|
|
1207
|
-
readonly max: number;
|
|
1208
|
-
readonly selection?: {
|
|
1209
|
-
readonly mode: "single";
|
|
1210
|
-
} | {
|
|
1211
|
-
readonly mode: "many";
|
|
1212
|
-
readonly min: number;
|
|
1213
|
-
readonly max?: number | undefined;
|
|
1214
|
-
readonly distinct?: boolean | undefined;
|
|
1215
|
-
} | undefined;
|
|
1216
|
-
readonly step?: number | undefined;
|
|
1217
|
-
}, {
|
|
1218
|
-
type: Type;
|
|
1219
|
-
}> | Extract<{
|
|
1220
|
-
readonly type: "choice";
|
|
1221
|
-
readonly choices: readonly {
|
|
1222
|
-
readonly value: string | null;
|
|
1223
|
-
readonly label: string;
|
|
1224
|
-
readonly icon?: string | undefined;
|
|
1225
|
-
readonly badge?: string | undefined;
|
|
1226
|
-
readonly description?: string | undefined;
|
|
1227
|
-
readonly disabled?: boolean | undefined;
|
|
1228
|
-
readonly disabledReason?: string | undefined;
|
|
1229
|
-
}[];
|
|
1230
|
-
readonly selection?: {
|
|
1231
|
-
readonly mode: "single";
|
|
1232
|
-
} | {
|
|
1233
|
-
readonly mode: "many";
|
|
1234
|
-
readonly min: number;
|
|
1235
|
-
readonly max?: number | undefined;
|
|
1236
|
-
readonly distinct?: boolean | undefined;
|
|
1237
|
-
} | undefined;
|
|
1238
|
-
}, {
|
|
1239
|
-
type: Type;
|
|
1240
|
-
}> | Extract<{
|
|
1241
|
-
readonly type: "choiceList";
|
|
1242
|
-
readonly choices: readonly {
|
|
1243
|
-
readonly label: string;
|
|
1244
|
-
readonly value: string;
|
|
1245
|
-
readonly icon?: string | undefined;
|
|
1246
|
-
readonly badge?: string | undefined;
|
|
1247
|
-
readonly description?: string | undefined;
|
|
1248
|
-
readonly disabled?: boolean | undefined;
|
|
1249
|
-
readonly disabledReason?: string | undefined;
|
|
1250
|
-
}[];
|
|
1251
|
-
readonly selection?: {
|
|
1252
|
-
readonly mode: "single";
|
|
1253
|
-
} | {
|
|
1254
|
-
readonly mode: "many";
|
|
1255
|
-
readonly min: number;
|
|
1256
|
-
readonly max?: number | undefined;
|
|
1257
|
-
readonly distinct?: boolean | undefined;
|
|
1258
|
-
} | undefined;
|
|
1259
|
-
readonly min?: number | undefined;
|
|
1260
|
-
readonly max?: number | undefined;
|
|
1261
|
-
}, {
|
|
1262
|
-
type: Type;
|
|
1263
|
-
}> | undefined;
|
|
1264
|
-
|
|
1265
|
-
export { AuthoredManifest, AuthoredTileDisclosure, BoardSpaceTarget, type BoardTargetPredicate, type BotDecision, type BotStrategy, type BoundInputBuilders, type BoundTargetPredicate, type CardTargetPredicate, type ChoiceOptionsFactory, type ChoiceTargetOption, type ChoiceTargetPredicate, CompiledManifest, type ContractTypes, FieldsInput, type GameAuthoring, GameTopologyManifest$1 as GameTopologyManifest, InteractionRule, type ManyOptions, PerPlayerInstanceId, type PhaseAuthoring, type PhaseTypes, PositionTarget, type ReducerBundle, ReducerBundleContract, type ReducerBundleOptions, ReducerDiagnosticsSink, ReducerGameDefinition, ReducerGameDefinitionInput, ReducerTransaction, type SparseCounts, type SparseMap, SystemActionEvent, TableQueries, TableQueriesOfState, type TargetContext, type TargetPredicate, type TargetPredicateArgs, type TileTargetPredicate, type TypedTopologyManifest, ValidatedManifest, compileManifest, createGame, createReducerBundle, createStateQueries, createTableQueries, defineTopologyManifest, fromCoordinates, gameEvent, hexagon, many, materializeManifestTable, memoize, normalizeCommandParams, offeredInputDomain, offeredInteraction, parseTopologyManifestJson, rectangle, ring, sparseCounts, sparseMap, spiral };
|
|
1209
|
+
export { AuthoredManifest, AuthoredTileDisclosure, BoardSpaceTarget, type BoardTargetPredicate, type BoundInputBuilders, type BoundTargetPredicate, type CardTargetPredicate, type ChoiceOptionsFactory, type ChoiceTargetOption, type ChoiceTargetPredicate, CompiledManifest, type ContractTypes, FieldsInput, type GameAuthoring, GameTopologyManifest$1 as GameTopologyManifest, InteractionRule, type ManyOptions, PerPlayerInstanceId, type PhaseAuthoring, type PhaseTypes, PositionTarget, type ReducerBundle, ReducerBundleContract, type ReducerBundleOptions, ReducerDiagnosticsSink, ReducerGameDefinition, ReducerGameDefinitionInput, ReducerTransaction, type SparseCounts, type SparseMap, SystemActionEvent, TableQueries, TableQueriesOfState, type TargetContext, type TargetPredicate, type TargetPredicateArgs, type TileTargetPredicate, type TypedTopologyManifest, ValidatedManifest, compileManifest, createGame, createReducerBundle, createStateQueries, createTableQueries, defineBots, defineTopologyManifest, fromCoordinates, gameEvent, hexagon, many, materializeManifestTable, memoize, normalizeCommandParams, parseTopologyManifestJson, rectangle, ring, sparseCounts, sparseMap, spiral };
|
package/dist/reducer.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createReducerBundle,
|
|
13
13
|
createStateQueries,
|
|
14
14
|
createTableQueries,
|
|
15
|
+
defineBots,
|
|
15
16
|
enumerateZoneHosts,
|
|
16
17
|
getObjectShape,
|
|
17
18
|
getZodDef,
|
|
@@ -27,14 +28,14 @@ import {
|
|
|
27
28
|
sparseMap,
|
|
28
29
|
unwrapWrappers,
|
|
29
30
|
validatedReducerDefinition
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-75QTSYRZ.js";
|
|
31
32
|
import {
|
|
32
33
|
CARD_REFERENCE_PREFIX,
|
|
33
34
|
boardSpaceHostId,
|
|
34
35
|
isCardReferenceNamespace,
|
|
35
36
|
parseBoardSpaceHostId,
|
|
36
37
|
runtime_schema_exports
|
|
37
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-G4MY5YMA.js";
|
|
38
39
|
import {
|
|
39
40
|
AuthoredTileDisclosureSchema,
|
|
40
41
|
BoardRelationSchema,
|
|
@@ -62,7 +63,7 @@ import {
|
|
|
62
63
|
sameBoardSpaceTarget,
|
|
63
64
|
tileSpaceId,
|
|
64
65
|
zonePositions
|
|
65
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-7GX27XU6.js";
|
|
66
67
|
|
|
67
68
|
// src/reducer/authoring/validation.ts
|
|
68
69
|
var MANIFEST_SCOPED_ID_NAMES = [
|
|
@@ -608,20 +609,31 @@ var DEFAULT_MISSING_CANDIDATE_ISSUE = {
|
|
|
608
609
|
function createTargetRule(candidates, predicates, options = {}) {
|
|
609
610
|
const missingCandidateIssue = options.missingCandidateIssue ?? DEFAULT_MISSING_CANDIDATE_ISSUE;
|
|
610
611
|
const equals = options.equals ?? Object.is;
|
|
611
|
-
const
|
|
612
|
-
for (const
|
|
613
|
-
if (!
|
|
614
|
-
|
|
615
|
-
if (!predicate.test({ ...ctx, targetId: candidate })) {
|
|
616
|
-
return { errorCode: predicate.errorCode, message: predicate.message };
|
|
617
|
-
}
|
|
612
|
+
const validateCandidate = (ctx, targetId) => {
|
|
613
|
+
for (const predicate of predicates) {
|
|
614
|
+
if (!predicate.test({ ...ctx, targetId })) {
|
|
615
|
+
return { errorCode: predicate.errorCode, message: predicate.message };
|
|
618
616
|
}
|
|
619
|
-
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
};
|
|
620
|
+
const validate = (ctx, target, resolved = candidates(ctx)) => {
|
|
621
|
+
for (const candidate of resolved) {
|
|
622
|
+
if (equals(candidate, target)) return validateCandidate(ctx, candidate);
|
|
620
623
|
}
|
|
621
624
|
return missingCandidateIssue;
|
|
622
625
|
};
|
|
623
626
|
const rule = {
|
|
624
|
-
eligible
|
|
627
|
+
eligible(ctx) {
|
|
628
|
+
const resolved = candidates(ctx);
|
|
629
|
+
if (equals === Object.is)
|
|
630
|
+
return resolved.filter(
|
|
631
|
+
(candidate) => validateCandidate(ctx, candidate) == null
|
|
632
|
+
);
|
|
633
|
+
return resolved.filter(
|
|
634
|
+
(target) => validate(ctx, target, resolved) == null
|
|
635
|
+
);
|
|
636
|
+
},
|
|
625
637
|
validate,
|
|
626
638
|
isEligible: (ctx, target) => validate(ctx, target) == null,
|
|
627
639
|
bind: (ctx) => ({
|
|
@@ -1047,7 +1059,10 @@ function createPhaseAuthoring(contract, schema) {
|
|
|
1047
1059
|
rule: (rule) => defineInteractionRule()(
|
|
1048
1060
|
rule
|
|
1049
1061
|
),
|
|
1050
|
-
define: (definition) => ({
|
|
1062
|
+
define: ((definition) => ({
|
|
1063
|
+
...definition,
|
|
1064
|
+
state: schema
|
|
1065
|
+
})),
|
|
1051
1066
|
inputs: createBoundInputBuilders(contract),
|
|
1052
1067
|
types: phantomTypes()
|
|
1053
1068
|
};
|
|
@@ -4897,17 +4912,6 @@ function defineTopologyManifest(manifest) {
|
|
|
4897
4912
|
|
|
4898
4913
|
// src/reducer.ts
|
|
4899
4914
|
import * as z14 from "zod";
|
|
4900
|
-
|
|
4901
|
-
// src/reducer/bundle/offered-interaction.ts
|
|
4902
|
-
function offeredInteraction(frame, key) {
|
|
4903
|
-
return frame.availableInteractions.find(
|
|
4904
|
-
(descriptor) => descriptor.interactionKey === key && descriptor.availability.status === "available"
|
|
4905
|
-
);
|
|
4906
|
-
}
|
|
4907
|
-
function offeredInputDomain(interaction, key, type) {
|
|
4908
|
-
const domain = interaction?.inputs.find((input) => input.key === key)?.domain;
|
|
4909
|
-
return domain?.type === type ? domain : void 0;
|
|
4910
|
-
}
|
|
4911
4915
|
export {
|
|
4912
4916
|
FrameworkErrorCodes,
|
|
4913
4917
|
REDUCER_CONTRACT_VERSION,
|
|
@@ -4922,6 +4926,7 @@ export {
|
|
|
4922
4926
|
createReducerBundle,
|
|
4923
4927
|
createStateQueries,
|
|
4924
4928
|
createTableQueries,
|
|
4929
|
+
defineBots,
|
|
4925
4930
|
defineTopologyManifest,
|
|
4926
4931
|
fromCoordinates,
|
|
4927
4932
|
gameEvent,
|
|
@@ -4932,8 +4937,6 @@ export {
|
|
|
4932
4937
|
memoize,
|
|
4933
4938
|
noopDiagnosticsSink,
|
|
4934
4939
|
normalizeCommandParams,
|
|
4935
|
-
offeredInputDomain,
|
|
4936
|
-
offeredInteraction,
|
|
4937
4940
|
parseBoardElementId,
|
|
4938
4941
|
parseBoardSpaceHostId,
|
|
4939
4942
|
parsePerPlayerInstanceId,
|