@bct-app/game-engine 0.1.1 → 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 +24 -92
- package/dist/index.d.ts +24 -92
- package/dist/index.js +495 -165
- package/dist/index.mjs +495 -165
- package/package.json +20 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,113 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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:
|
|
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:
|
|
98
|
-
declare const buildPlayerSeatMap: (players:
|
|
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:
|
|
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:
|
|
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
|
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a number or an array of numbers.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns true if value is number or number[], false otherwise
|
|
30
|
+
*/
|
|
109
31
|
declare const isNumberOrNumberArray: (value: unknown) => value is number | number[];
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if a value is a TReminder object.
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @returns true if value is TReminder, false otherwise
|
|
36
|
+
*/
|
|
110
37
|
declare const isReminder: (value: unknown) => value is TReminder;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if a value is an array of TPlayerReminder.
|
|
40
|
+
* @param value - The value to check.
|
|
41
|
+
* @returns true if value is TPlayerReminder[], false otherwise
|
|
42
|
+
*/
|
|
111
43
|
declare const isPlayerReminderArray: (value: unknown) => value is TPlayerReminder[];
|
|
112
44
|
|
|
113
|
-
export {
|
|
45
|
+
export { adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,113 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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:
|
|
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:
|
|
98
|
-
declare const buildPlayerSeatMap: (players:
|
|
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:
|
|
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:
|
|
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
|
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a number or an array of numbers.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns true if value is number or number[], false otherwise
|
|
30
|
+
*/
|
|
109
31
|
declare const isNumberOrNumberArray: (value: unknown) => value is number | number[];
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if a value is a TReminder object.
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @returns true if value is TReminder, false otherwise
|
|
36
|
+
*/
|
|
110
37
|
declare const isReminder: (value: unknown) => value is TReminder;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if a value is an array of TPlayerReminder.
|
|
40
|
+
* @param value - The value to check.
|
|
41
|
+
* @returns true if value is TPlayerReminder[], false otherwise
|
|
42
|
+
*/
|
|
111
43
|
declare const isPlayerReminderArray: (value: unknown) => value is TPlayerReminder[];
|
|
112
44
|
|
|
113
|
-
export {
|
|
45
|
+
export { adjustValueAsNumber, adjustValueAsNumberArray, applyOperationToPlayers, buildPlayerSeatMap, copyPlayers, getSourceValue, getValueFromPayloads, isNumberOrNumberArray, isPlayerReminderArray, isReminder, resolveSourceValue, transformEmptyArray };
|