@bct-app/game-engine 0.1.2 → 0.1.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.
package/dist/index.d.mts CHANGED
@@ -1,110 +1,27 @@
1
- type TAlignment = 'GOOD' | 'EVIL';
2
- type TReminder = {
3
- mark: string;
4
- color?: string;
5
- duration?: number;
6
- [key: string]: unknown;
7
- };
8
- type TPlayerReminder = {
9
- playerSeat: number;
10
- index: number;
11
- };
12
- type TPerceivedCharacter = {
13
- characterId: string;
14
- abilities: string[];
15
- asCharacter: boolean;
16
- };
17
- type TPopulatedPlayer = {
18
- seat: number;
19
- abilities: string[];
20
- reminders?: TReminder[];
21
- alignment?: TAlignment;
22
- characterId?: string;
23
- perceivedCharacter?: TPerceivedCharacter;
24
- isDead?: boolean;
25
- hasUsedDeadVote?: boolean;
26
- [key: string]: unknown;
27
- };
28
- type TAbilityInput = {
29
- readonly?: boolean;
30
- type?: string;
31
- [key: string]: unknown;
32
- };
33
- type TPayloadSource = {
34
- from: 'PAYLOAD';
35
- value: number | number[];
36
- };
37
- type TConstantSource = {
38
- from: 'CONSTANT';
39
- value: unknown;
40
- };
41
- type TEffectorSource = {
42
- from: 'EFFECTOR';
43
- value?: unknown;
44
- };
45
- type TOtherSource = {
46
- from: Exclude<string, 'PAYLOAD' | 'CONSTANT' | 'EFFECTOR'>;
47
- value?: unknown;
48
- };
49
- type TSource = TPayloadSource | TConstantSource | TEffectorSource | TOtherSource;
50
- type TAlignmentSource = TSource;
51
- type TCharacterSource = TSource;
52
- type TTarget = {
53
- from: 'EFFECTOR' | 'PAYLOAD' | 'CUSTOM' | string;
54
- value: unknown;
55
- };
56
- type TEffect = {
57
- type: string;
58
- target: TTarget;
59
- source: TSource;
60
- followPriority?: boolean;
61
- };
62
- type TAbility = {
63
- id: string;
64
- inputs: TAbilityInput[];
65
- effects: TEffect[];
66
- };
67
- type TPopulatedCharacter = {
68
- id: string;
69
- abilities: Array<{
70
- id: string;
71
- }>;
72
- };
73
- type TOperation = {
74
- abilityId: string;
75
- effector: number;
76
- payloads?: unknown[];
77
- };
78
- type TTimelineNomination = {
79
- voterSeats?: number[];
80
- };
81
- type TTimeline = {
82
- operations?: TOperation[];
83
- nominations?: TTimelineNomination[];
84
- };
1
+ import { TPlayer, TOperation, TAbility, TPopulatedCharacter, TTimeline, TEffect, TPlayerReminder, TReminder } from '@bct-app/game-model';
2
+
85
3
  type TApplyOperationToPlayersArgs = {
86
- players: TPopulatedPlayer[];
4
+ players: TPlayer[];
87
5
  operations: TOperation[];
88
6
  allAbilities: TAbility[];
89
7
  characters: TPopulatedCharacter[];
90
8
  timelines: TTimeline[];
91
9
  timelineIndexAtNow?: number;
92
10
  };
93
-
94
- declare const applyOperationToPlayers: ({ players, operations, allAbilities, characters, timelines, timelineIndexAtNow, }: TApplyOperationToPlayersArgs) => TPopulatedPlayer[];
11
+ declare const applyOperationToPlayers: ({ players, operations, allAbilities, characters, timelines, timelineIndexAtNow, }: TApplyOperationToPlayersArgs) => TPlayer[];
95
12
 
96
13
  declare const transformEmptyArray: <T>(arr: T[]) => T[];
97
- declare const copyPlayers: (players: TPopulatedPlayer[]) => TPopulatedPlayer[];
98
- declare const buildPlayerSeatMap: (players: TPopulatedPlayer[]) => Map<number, TPopulatedPlayer>;
14
+ declare const copyPlayers: (players: TPlayer[]) => TPlayer[];
15
+ declare const buildPlayerSeatMap: (players: TPlayer[]) => Map<number, TPlayer>;
99
16
  declare const adjustValueAsNumberArray: (value: unknown) => number[];
100
17
  declare const adjustValueAsNumber: (value: unknown) => number | undefined;
101
18
 
102
19
  declare const getValueFromPayloads: (payloads: unknown[], idx: number | number[]) => unknown;
103
- declare const getSourceValue: (source: TSource, payloads: unknown[]) => unknown;
20
+ declare const getSourceValue: (source: TEffect["source"], payloads: unknown[]) => unknown;
104
21
  /**
105
22
  * Resolve a value from effect source, handling PAYLOAD (with player-seat indirection), CONSTANT, and EFFECTOR.
106
23
  */
107
- declare const resolveSourceValue: (source: TAlignmentSource | TCharacterSource, writableParts: TAbility["inputs"], payloads: unknown[], effector: TPopulatedPlayer | undefined, snapshotSeatMap: Map<number, TPopulatedPlayer>, resolveFromPlayer: (player: TPopulatedPlayer) => unknown) => unknown;
24
+ declare const resolveSourceValue: <TResolved>(source: TEffect["source"], writableInputs: TAbility["inputs"], payloads: unknown[], effector: TPlayer | undefined, snapshotSeatMap: Map<number, TPlayer>, resolveFromPlayer: (player: TPlayer) => TResolved, isResolvedValue?: (value: unknown) => value is TResolved) => TResolved | undefined;
108
25
 
109
26
  /**
110
27
  * Type guard to check if a value is a number or an array of numbers.
@@ -125,4 +42,4 @@ declare const isReminder: (value: unknown) => value is TReminder;
125
42
  */
126
43
  declare const isPlayerReminderArray: (value: unknown) => value is TPlayerReminder[];
127
44
 
128
- export { type TAbility, type TAbilityInput, type TAlignment, type TAlignmentSource, type TApplyOperationToPlayersArgs, type TCharacterSource, type TEffect, type TOperation, type TPerceivedCharacter, type TPlayerReminder, type TPopulatedCharacter, type TPopulatedPlayer, type TReminder, type TSource, type TTarget, type TTimeline, type TTimelineNomination, adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };
45
+ export { adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };
package/dist/index.d.ts CHANGED
@@ -1,110 +1,27 @@
1
- type TAlignment = 'GOOD' | 'EVIL';
2
- type TReminder = {
3
- mark: string;
4
- color?: string;
5
- duration?: number;
6
- [key: string]: unknown;
7
- };
8
- type TPlayerReminder = {
9
- playerSeat: number;
10
- index: number;
11
- };
12
- type TPerceivedCharacter = {
13
- characterId: string;
14
- abilities: string[];
15
- asCharacter: boolean;
16
- };
17
- type TPopulatedPlayer = {
18
- seat: number;
19
- abilities: string[];
20
- reminders?: TReminder[];
21
- alignment?: TAlignment;
22
- characterId?: string;
23
- perceivedCharacter?: TPerceivedCharacter;
24
- isDead?: boolean;
25
- hasUsedDeadVote?: boolean;
26
- [key: string]: unknown;
27
- };
28
- type TAbilityInput = {
29
- readonly?: boolean;
30
- type?: string;
31
- [key: string]: unknown;
32
- };
33
- type TPayloadSource = {
34
- from: 'PAYLOAD';
35
- value: number | number[];
36
- };
37
- type TConstantSource = {
38
- from: 'CONSTANT';
39
- value: unknown;
40
- };
41
- type TEffectorSource = {
42
- from: 'EFFECTOR';
43
- value?: unknown;
44
- };
45
- type TOtherSource = {
46
- from: Exclude<string, 'PAYLOAD' | 'CONSTANT' | 'EFFECTOR'>;
47
- value?: unknown;
48
- };
49
- type TSource = TPayloadSource | TConstantSource | TEffectorSource | TOtherSource;
50
- type TAlignmentSource = TSource;
51
- type TCharacterSource = TSource;
52
- type TTarget = {
53
- from: 'EFFECTOR' | 'PAYLOAD' | 'CUSTOM' | string;
54
- value: unknown;
55
- };
56
- type TEffect = {
57
- type: string;
58
- target: TTarget;
59
- source: TSource;
60
- followPriority?: boolean;
61
- };
62
- type TAbility = {
63
- id: string;
64
- inputs: TAbilityInput[];
65
- effects: TEffect[];
66
- };
67
- type TPopulatedCharacter = {
68
- id: string;
69
- abilities: Array<{
70
- id: string;
71
- }>;
72
- };
73
- type TOperation = {
74
- abilityId: string;
75
- effector: number;
76
- payloads?: unknown[];
77
- };
78
- type TTimelineNomination = {
79
- voterSeats?: number[];
80
- };
81
- type TTimeline = {
82
- operations?: TOperation[];
83
- nominations?: TTimelineNomination[];
84
- };
1
+ import { TPlayer, TOperation, TAbility, TPopulatedCharacter, TTimeline, TEffect, TPlayerReminder, TReminder } from '@bct-app/game-model';
2
+
85
3
  type TApplyOperationToPlayersArgs = {
86
- players: TPopulatedPlayer[];
4
+ players: TPlayer[];
87
5
  operations: TOperation[];
88
6
  allAbilities: TAbility[];
89
7
  characters: TPopulatedCharacter[];
90
8
  timelines: TTimeline[];
91
9
  timelineIndexAtNow?: number;
92
10
  };
93
-
94
- declare const applyOperationToPlayers: ({ players, operations, allAbilities, characters, timelines, timelineIndexAtNow, }: TApplyOperationToPlayersArgs) => TPopulatedPlayer[];
11
+ declare const applyOperationToPlayers: ({ players, operations, allAbilities, characters, timelines, timelineIndexAtNow, }: TApplyOperationToPlayersArgs) => TPlayer[];
95
12
 
96
13
  declare const transformEmptyArray: <T>(arr: T[]) => T[];
97
- declare const copyPlayers: (players: TPopulatedPlayer[]) => TPopulatedPlayer[];
98
- declare const buildPlayerSeatMap: (players: TPopulatedPlayer[]) => Map<number, TPopulatedPlayer>;
14
+ declare const copyPlayers: (players: TPlayer[]) => TPlayer[];
15
+ declare const buildPlayerSeatMap: (players: TPlayer[]) => Map<number, TPlayer>;
99
16
  declare const adjustValueAsNumberArray: (value: unknown) => number[];
100
17
  declare const adjustValueAsNumber: (value: unknown) => number | undefined;
101
18
 
102
19
  declare const getValueFromPayloads: (payloads: unknown[], idx: number | number[]) => unknown;
103
- declare const getSourceValue: (source: TSource, payloads: unknown[]) => unknown;
20
+ declare const getSourceValue: (source: TEffect["source"], payloads: unknown[]) => unknown;
104
21
  /**
105
22
  * Resolve a value from effect source, handling PAYLOAD (with player-seat indirection), CONSTANT, and EFFECTOR.
106
23
  */
107
- declare const resolveSourceValue: (source: TAlignmentSource | TCharacterSource, writableParts: TAbility["inputs"], payloads: unknown[], effector: TPopulatedPlayer | undefined, snapshotSeatMap: Map<number, TPopulatedPlayer>, resolveFromPlayer: (player: TPopulatedPlayer) => unknown) => unknown;
24
+ declare const resolveSourceValue: <TResolved>(source: TEffect["source"], writableInputs: TAbility["inputs"], payloads: unknown[], effector: TPlayer | undefined, snapshotSeatMap: Map<number, TPlayer>, resolveFromPlayer: (player: TPlayer) => TResolved, isResolvedValue?: (value: unknown) => value is TResolved) => TResolved | undefined;
108
25
 
109
26
  /**
110
27
  * Type guard to check if a value is a number or an array of numbers.
@@ -125,4 +42,4 @@ declare const isReminder: (value: unknown) => value is TReminder;
125
42
  */
126
43
  declare const isPlayerReminderArray: (value: unknown) => value is TPlayerReminder[];
127
44
 
128
- export { type TAbility, type TAbilityInput, type TAlignment, type TAlignmentSource, type TApplyOperationToPlayersArgs, type TCharacterSource, type TEffect, type TOperation, type TPerceivedCharacter, type TPlayerReminder, type TPopulatedCharacter, type TPopulatedPlayer, type TReminder, type TSource, type TTarget, type TTimeline, type TTimelineNomination, adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };
45
+ export { adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };