@rpgjs/server 5.0.0-alpha.4 → 5.0.0-alpha.41
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/Gui/DialogGui.d.ts +5 -0
- package/dist/Gui/GameoverGui.d.ts +23 -0
- package/dist/Gui/Gui.d.ts +6 -0
- package/dist/Gui/MenuGui.d.ts +22 -3
- package/dist/Gui/NotificationGui.d.ts +1 -2
- package/dist/Gui/SaveLoadGui.d.ts +13 -0
- package/dist/Gui/ShopGui.d.ts +28 -3
- package/dist/Gui/TitleGui.d.ts +23 -0
- package/dist/Gui/index.d.ts +10 -1
- package/dist/Player/BattleManager.d.ts +34 -12
- package/dist/Player/ClassManager.d.ts +46 -13
- package/dist/Player/ComponentManager.d.ts +123 -0
- package/dist/Player/Components.d.ts +345 -0
- package/dist/Player/EffectManager.d.ts +86 -0
- package/dist/Player/ElementManager.d.ts +104 -0
- package/dist/Player/GoldManager.d.ts +22 -0
- package/dist/Player/GuiManager.d.ts +259 -0
- package/dist/Player/ItemFixture.d.ts +6 -0
- package/dist/Player/ItemManager.d.ts +450 -9
- package/dist/Player/MoveManager.d.ts +324 -69
- package/dist/Player/ParameterManager.d.ts +344 -14
- package/dist/Player/Player.d.ts +460 -8
- package/dist/Player/SkillManager.d.ts +197 -15
- package/dist/Player/StateManager.d.ts +89 -25
- package/dist/Player/VariableManager.d.ts +74 -0
- package/dist/RpgServer.d.ts +502 -64
- package/dist/RpgServerEngine.d.ts +2 -1
- package/dist/decorators/event.d.ts +46 -0
- package/dist/decorators/map.d.ts +287 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +21653 -20900
- package/dist/index.js.map +1 -1
- package/dist/logs/log.d.ts +2 -3
- package/dist/module.d.ts +43 -1
- package/dist/presets/index.d.ts +0 -9
- package/dist/rooms/BaseRoom.d.ts +132 -0
- package/dist/rooms/lobby.d.ts +10 -2
- package/dist/rooms/map.d.ts +1236 -17
- package/dist/services/save.d.ts +43 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/localStorage.d.ts +23 -0
- package/package.json +14 -10
- package/src/Gui/DialogGui.ts +19 -4
- package/src/Gui/GameoverGui.ts +39 -0
- package/src/Gui/Gui.ts +23 -1
- package/src/Gui/MenuGui.ts +155 -6
- package/src/Gui/NotificationGui.ts +1 -2
- package/src/Gui/SaveLoadGui.ts +60 -0
- package/src/Gui/ShopGui.ts +146 -16
- package/src/Gui/TitleGui.ts +39 -0
- package/src/Gui/index.ts +15 -2
- package/src/Player/BattleManager.ts +91 -49
- package/src/Player/ClassManager.ts +118 -50
- package/src/Player/ComponentManager.ts +425 -19
- package/src/Player/Components.ts +380 -0
- package/src/Player/EffectManager.ts +81 -44
- package/src/Player/ElementManager.ts +109 -86
- package/src/Player/GoldManager.ts +32 -35
- package/src/Player/GuiManager.ts +308 -150
- package/src/Player/ItemFixture.ts +4 -5
- package/src/Player/ItemManager.ts +774 -355
- package/src/Player/MoveManager.ts +1544 -774
- package/src/Player/ParameterManager.ts +546 -104
- package/src/Player/Player.ts +1163 -88
- package/src/Player/SkillManager.ts +520 -195
- package/src/Player/StateManager.ts +170 -182
- package/src/Player/VariableManager.ts +101 -63
- package/src/RpgServer.ts +525 -63
- package/src/core/context.ts +1 -0
- package/src/decorators/event.ts +61 -0
- package/src/decorators/map.ts +327 -0
- package/src/index.ts +11 -1
- package/src/logs/log.ts +10 -3
- package/src/module.ts +126 -3
- package/src/presets/index.ts +1 -10
- package/src/rooms/BaseRoom.ts +232 -0
- package/src/rooms/lobby.ts +25 -7
- package/src/rooms/map.ts +2502 -194
- package/src/services/save.ts +147 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/localStorage.ts +76 -0
- package/tests/battle.spec.ts +375 -0
- package/tests/change-map.spec.ts +72 -0
- package/tests/class.spec.ts +274 -0
- package/tests/effect.spec.ts +219 -0
- package/tests/element.spec.ts +221 -0
- package/tests/event.spec.ts +80 -0
- package/tests/gold.spec.ts +99 -0
- package/tests/item.spec.ts +609 -0
- package/tests/module.spec.ts +38 -0
- package/tests/move.spec.ts +601 -0
- package/tests/player-param.spec.ts +28 -0
- package/tests/prediction-reconciliation.spec.ts +182 -0
- package/tests/random-move.spec.ts +65 -0
- package/tests/skill.spec.ts +658 -0
- package/tests/state.spec.ts +467 -0
- package/tests/variable.spec.ts +185 -0
- package/tests/world-maps.spec.ts +896 -0
- package/vite.config.ts +16 -0
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
|
@@ -1,23 +1,205 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlayerCtor } from '../../../common/src';
|
|
2
2
|
import { RpgPlayer } from './Player';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Type for skill class constructor
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
type SkillClass = {
|
|
7
|
+
new (...args: any[]): any;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Interface defining the hooks that can be implemented on skill classes or objects
|
|
11
|
+
*
|
|
12
|
+
* These hooks are called at specific moments during the skill lifecycle:
|
|
13
|
+
* - `onLearn`: When the skill is learned by the player
|
|
14
|
+
* - `onUse`: When the skill is successfully used
|
|
15
|
+
* - `onUseFailed`: When the skill usage fails (e.g., chance roll failed)
|
|
16
|
+
* - `onForget`: When the skill is forgotten
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const skillHooks: SkillHooks = {
|
|
21
|
+
* onLearn(player) {
|
|
22
|
+
* console.log('Skill learned!');
|
|
23
|
+
* },
|
|
24
|
+
* onUse(player, target) {
|
|
25
|
+
* console.log('Skill used on target');
|
|
26
|
+
* }
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface SkillHooks {
|
|
31
|
+
/**
|
|
32
|
+
* Called when the skill is learned by the player
|
|
33
|
+
*
|
|
34
|
+
* @param player - The player learning the skill
|
|
35
|
+
*/
|
|
36
|
+
onLearn?: (player: RpgPlayer) => void | Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Called when the skill is successfully used
|
|
39
|
+
*
|
|
40
|
+
* @param player - The player using the skill
|
|
41
|
+
* @param target - The target player(s) if any
|
|
42
|
+
*/
|
|
43
|
+
onUse?: (player: RpgPlayer, target?: RpgPlayer | RpgPlayer[]) => void | Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Called when the skill usage fails (e.g., chance roll failed)
|
|
46
|
+
*
|
|
47
|
+
* @param player - The player attempting to use the skill
|
|
48
|
+
* @param target - The intended target player(s) if any
|
|
49
|
+
*/
|
|
50
|
+
onUseFailed?: (player: RpgPlayer, target?: RpgPlayer | RpgPlayer[]) => void | Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Called when the skill is forgotten
|
|
53
|
+
*
|
|
54
|
+
* @param player - The player forgetting the skill
|
|
55
|
+
*/
|
|
56
|
+
onForget?: (player: RpgPlayer) => void | Promise<void>;
|
|
12
57
|
}
|
|
13
58
|
/**
|
|
14
|
-
* Interface
|
|
59
|
+
* Interface for skill object definition
|
|
60
|
+
*
|
|
61
|
+
* Defines the properties that a skill can have when defined as an object.
|
|
62
|
+
* Skills can be defined as objects, classes, or string IDs referencing the database.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const fireSkill: SkillObject = {
|
|
67
|
+
* id: 'fire',
|
|
68
|
+
* name: 'Fire',
|
|
69
|
+
* description: 'A basic fire spell',
|
|
70
|
+
* spCost: 10,
|
|
71
|
+
* hitRate: 0.9,
|
|
72
|
+
* power: 50,
|
|
73
|
+
* onUse(player) {
|
|
74
|
+
* console.log('Fire spell cast!');
|
|
75
|
+
* }
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* player.learnSkill(fireSkill);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export interface SkillObject extends SkillHooks {
|
|
82
|
+
/**
|
|
83
|
+
* Unique identifier for the skill
|
|
84
|
+
* If not provided, one will be auto-generated
|
|
85
|
+
*/
|
|
86
|
+
id?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Display name of the skill
|
|
89
|
+
*/
|
|
90
|
+
name?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Description of the skill
|
|
93
|
+
*/
|
|
94
|
+
description?: string;
|
|
95
|
+
/**
|
|
96
|
+
* SP (Skill Points) cost to use the skill
|
|
97
|
+
* @default 0
|
|
98
|
+
*/
|
|
99
|
+
spCost?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Hit rate (0-1) - probability of successful skill usage
|
|
102
|
+
* @default 1
|
|
103
|
+
*/
|
|
104
|
+
hitRate?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Base power of the skill for damage calculation
|
|
107
|
+
*/
|
|
108
|
+
power?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Coefficient multipliers for damage calculation
|
|
111
|
+
*/
|
|
112
|
+
coefficient?: Record<string, number>;
|
|
113
|
+
/**
|
|
114
|
+
* Type marker for database
|
|
115
|
+
*/
|
|
116
|
+
_type?: 'skill';
|
|
117
|
+
/**
|
|
118
|
+
* Allow additional properties
|
|
119
|
+
*/
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Skill Manager Mixin
|
|
124
|
+
*
|
|
125
|
+
* Provides skill management capabilities to any class. This mixin handles
|
|
126
|
+
* learning, forgetting, and using skills, including SP cost management,
|
|
127
|
+
* hit rate calculations, and skill effects application.
|
|
128
|
+
*
|
|
129
|
+
* Supports three input formats for skills:
|
|
130
|
+
* - **String ID**: References a skill in the database
|
|
131
|
+
* - **Class**: A skill class that will be instantiated
|
|
132
|
+
* - **Object**: A skill object with properties and hooks
|
|
133
|
+
*
|
|
134
|
+
* @param Base - The base class to extend with skill management
|
|
135
|
+
* @returns Extended class with skill management methods
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* // Using string ID (from database)
|
|
140
|
+
* player.learnSkill('fire');
|
|
141
|
+
*
|
|
142
|
+
* // Using skill class
|
|
143
|
+
* player.learnSkill(FireSkill);
|
|
144
|
+
*
|
|
145
|
+
* // Using skill object
|
|
146
|
+
* player.learnSkill({
|
|
147
|
+
* id: 'ice',
|
|
148
|
+
* name: 'Ice',
|
|
149
|
+
* spCost: 15,
|
|
150
|
+
* onUse(player) {
|
|
151
|
+
* console.log('Ice spell cast!');
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function WithSkillManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
157
|
+
/**
|
|
158
|
+
* Interface for Skill Manager functionality
|
|
159
|
+
*
|
|
160
|
+
* Provides skill management capabilities including learning, forgetting, and using skills.
|
|
161
|
+
* This interface defines the public API of the SkillManager mixin.
|
|
15
162
|
*/
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
163
|
+
export interface ISkillManager {
|
|
164
|
+
/**
|
|
165
|
+
* Retrieves a learned skill. Returns null if not found
|
|
166
|
+
*
|
|
167
|
+
* @param skillInput - Skill class, object, or data id
|
|
168
|
+
* @returns The skill data or null
|
|
169
|
+
*/
|
|
170
|
+
getSkill(skillInput: SkillClass | SkillObject | string): any | null;
|
|
171
|
+
/**
|
|
172
|
+
* Learn a skill
|
|
173
|
+
*
|
|
174
|
+
* Supports three input formats:
|
|
175
|
+
* - String ID: Retrieves from database
|
|
176
|
+
* - Class: Creates instance and adds to database
|
|
177
|
+
* - Object: Uses directly and adds to database
|
|
178
|
+
*
|
|
179
|
+
* @param skillInput - Skill class, object, or data id
|
|
180
|
+
* @returns The learned skill data
|
|
181
|
+
* @throws SkillLog.alreadyLearned if the player already knows the skill
|
|
182
|
+
*/
|
|
183
|
+
learnSkill(skillInput: SkillClass | SkillObject | string): any;
|
|
184
|
+
/**
|
|
185
|
+
* Forget a skill
|
|
186
|
+
*
|
|
187
|
+
* @param skillInput - Skill class, object, or data id
|
|
188
|
+
* @returns The forgotten skill data
|
|
189
|
+
* @throws SkillLog.notLearned if trying to forget a skill not learned
|
|
190
|
+
*/
|
|
191
|
+
forgetSkill(skillInput: SkillClass | SkillObject | string): any;
|
|
192
|
+
/**
|
|
193
|
+
* Use a skill
|
|
194
|
+
*
|
|
195
|
+
* @param skillInput - Skill class, object, or data id
|
|
196
|
+
* @param otherPlayer - Optional target player(s) to apply skill to
|
|
197
|
+
* @returns The used skill data
|
|
198
|
+
* @throws SkillLog.restriction if player has Effect.CAN_NOT_SKILL
|
|
199
|
+
* @throws SkillLog.notLearned if player tries to use an unlearned skill
|
|
200
|
+
* @throws SkillLog.notEnoughSp if player does not have enough SP
|
|
201
|
+
* @throws SkillLog.chanceToUseFailed if the chance to use the skill has failed
|
|
202
|
+
*/
|
|
203
|
+
useSkill(skillInput: SkillClass | SkillObject | string, otherPlayer?: RpgPlayer | RpgPlayer[]): any;
|
|
21
204
|
}
|
|
22
|
-
export declare function WithSkillManager<TBase extends Constructor<RpgCommonPlayer & SkillManagerDependencies>>(Base: TBase): Constructor<IWithSkillManager> & TBase;
|
|
23
205
|
export {};
|
|
@@ -1,39 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WritableArraySignal } from '@signe/reactive';
|
|
1
|
+
import { PlayerCtor } from '../../../common/src';
|
|
3
2
|
import { RpgPlayer } from './Player';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
type StateClass = {
|
|
4
|
+
new (...args: any[]): any;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* State Manager Mixin
|
|
8
|
+
*
|
|
9
|
+
* Provides state management capabilities to any class. This mixin handles
|
|
10
|
+
* player states (buffs/debuffs), state defense from equipment, and state
|
|
11
|
+
* efficiency modifiers. It manages the complete state system including
|
|
12
|
+
* application, removal, and resistance mechanics.
|
|
13
|
+
*
|
|
14
|
+
* @param Base - The base class to extend with state management
|
|
15
|
+
* @returns Extended class with state management methods
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* class MyPlayer extends WithStateManager(BasePlayer) {
|
|
20
|
+
* constructor() {
|
|
21
|
+
* super();
|
|
22
|
+
* // State system is automatically initialized
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const player = new MyPlayer();
|
|
27
|
+
* player.addState(Paralyze);
|
|
28
|
+
* console.log(player.getState(Paralyze));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function WithStateManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
10
32
|
/**
|
|
11
|
-
* Interface
|
|
33
|
+
* Interface for State Manager functionality
|
|
34
|
+
*
|
|
35
|
+
* Provides state management capabilities including state defense, efficiency modifiers,
|
|
36
|
+
* and state application/removal. This interface defines the public API of the StateManager mixin.
|
|
12
37
|
*/
|
|
13
38
|
export interface IStateManager {
|
|
39
|
+
/**
|
|
40
|
+
* Gets the defensive capabilities against various states from equipped items
|
|
41
|
+
*
|
|
42
|
+
* @returns Array of state defense objects with rate and state properties
|
|
43
|
+
*/
|
|
14
44
|
statesDefense: {
|
|
15
45
|
rate: number;
|
|
16
46
|
state: any;
|
|
17
47
|
}[];
|
|
18
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Manages the player's state efficiency modifiers
|
|
50
|
+
*
|
|
51
|
+
* @returns Signal containing array of state efficiency objects
|
|
52
|
+
*/
|
|
53
|
+
statesEfficiency: any;
|
|
54
|
+
/**
|
|
55
|
+
* Apply states to a player from skill or item effects
|
|
56
|
+
*
|
|
57
|
+
* @param player - The target player to apply states to
|
|
58
|
+
* @param states - Object containing arrays of states to add or remove
|
|
59
|
+
*/
|
|
19
60
|
applyStates(player: RpgPlayer, states: {
|
|
20
|
-
addStates?:
|
|
21
|
-
|
|
61
|
+
addStates?: Array<{
|
|
62
|
+
state: any;
|
|
63
|
+
rate: number;
|
|
64
|
+
}>;
|
|
65
|
+
removeStates?: Array<{
|
|
66
|
+
state: any;
|
|
67
|
+
rate: number;
|
|
68
|
+
}>;
|
|
22
69
|
}): void;
|
|
23
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Get a state to the player. Returns null if the state is not present
|
|
72
|
+
*
|
|
73
|
+
* @param stateClass - The state class constructor or state ID to search for
|
|
74
|
+
* @returns The state instance if found, null otherwise
|
|
75
|
+
*/
|
|
76
|
+
getState(stateClass: StateClass | string): any | null;
|
|
77
|
+
/**
|
|
78
|
+
* Adds a state to the player
|
|
79
|
+
*
|
|
80
|
+
* @param stateClass - The state class constructor or state ID to apply
|
|
81
|
+
* @param chance - Probability of successful application (0-1, default 1)
|
|
82
|
+
* @returns The state instance if successfully applied, null if already present
|
|
83
|
+
* @throws StateLog.addFailed if the chance roll fails
|
|
84
|
+
*/
|
|
24
85
|
addState(stateClass: StateClass | string, chance?: number): object | null;
|
|
86
|
+
/**
|
|
87
|
+
* Remove a state to the player
|
|
88
|
+
*
|
|
89
|
+
* @param stateClass - The state class constructor or state ID to remove
|
|
90
|
+
* @param chance - Probability of successful removal (0-1, default 1)
|
|
91
|
+
* @throws StateLog.removeFailed if the chance roll fails
|
|
92
|
+
* @throws StateLog.notApplied if the state is not currently active
|
|
93
|
+
*/
|
|
25
94
|
removeState(stateClass: StateClass | string, chance?: number): void;
|
|
95
|
+
/**
|
|
96
|
+
* Find state efficiency modifier for a specific state class
|
|
97
|
+
*
|
|
98
|
+
* @param stateClass - The state class to find efficiency for
|
|
99
|
+
* @returns The efficiency object if found, undefined otherwise
|
|
100
|
+
*/
|
|
101
|
+
findStateEfficiency(stateClass: any): any | undefined;
|
|
26
102
|
}
|
|
27
|
-
type StateClass = {
|
|
28
|
-
new (...args: any[]): any;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Move Manager mixin
|
|
32
|
-
*
|
|
33
|
-
* Adds methods to manage player movement
|
|
34
|
-
*
|
|
35
|
-
* @param Base - The base class to extend
|
|
36
|
-
* @returns A new class with move management capabilities
|
|
37
|
-
*/
|
|
38
|
-
export declare function WithStateManager<TBase extends Constructor<RpgCommonPlayer & StateManagerDependencies>>(Base: TBase): Constructor<IStateManager> & TBase;
|
|
39
103
|
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { PlayerCtor } from '../../../common/src';
|
|
2
|
+
/**
|
|
3
|
+
* Variable Manager Mixin
|
|
4
|
+
*
|
|
5
|
+
* Provides variable management capabilities to any class. Variables are key-value
|
|
6
|
+
* pairs that can store any type of data associated with the player, such as
|
|
7
|
+
* quest progress, game flags, inventory state, and custom game data.
|
|
8
|
+
*
|
|
9
|
+
* @param Base - The base class to extend with variable management
|
|
10
|
+
* @returns Extended class with variable management methods
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* class MyPlayer extends WithVariableManager(BasePlayer) {
|
|
15
|
+
* constructor() {
|
|
16
|
+
* super();
|
|
17
|
+
* // Variables are automatically initialized
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* const player = new MyPlayer();
|
|
22
|
+
* player.setVariable('questCompleted', true);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function WithVariableManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
26
|
+
/**
|
|
27
|
+
* Interface for Variable Manager functionality
|
|
28
|
+
*
|
|
29
|
+
* Provides variable management capabilities including storing, retrieving, and managing
|
|
30
|
+
* key-value pairs for player-specific data. This interface defines the public API
|
|
31
|
+
* of the VariableManager mixin.
|
|
32
|
+
*/
|
|
33
|
+
export interface IVariableManager {
|
|
34
|
+
/** Map storing all player variables */
|
|
35
|
+
variables: Map<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Assign a variable to the player
|
|
38
|
+
*
|
|
39
|
+
* @param key - The variable identifier
|
|
40
|
+
* @param val - The value to store
|
|
41
|
+
*/
|
|
42
|
+
setVariable(key: string, val: any): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get a variable value
|
|
45
|
+
*
|
|
46
|
+
* @param key - The variable identifier to retrieve
|
|
47
|
+
* @returns The stored value or undefined if not found
|
|
48
|
+
*/
|
|
49
|
+
getVariable<U = any>(key: string): U | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Remove a variable
|
|
52
|
+
*
|
|
53
|
+
* @param key - The variable identifier to remove
|
|
54
|
+
* @returns true if a variable existed and has been removed, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
removeVariable(key: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a variable exists
|
|
59
|
+
*
|
|
60
|
+
* @param key - The variable identifier to check
|
|
61
|
+
* @returns true if the variable exists, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
hasVariable(key: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get all variable keys
|
|
66
|
+
*
|
|
67
|
+
* @returns Array of all variable keys
|
|
68
|
+
*/
|
|
69
|
+
getVariableKeys(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Clear all variables
|
|
72
|
+
*/
|
|
73
|
+
clearVariables(): void;
|
|
74
|
+
}
|