@rpgjs/server 5.0.0-alpha.1 → 5.0.0-alpha.10

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 (40) hide show
  1. package/dist/Player/BattleManager.d.ts +32 -22
  2. package/dist/Player/ClassManager.d.ts +31 -18
  3. package/dist/Player/ComponentManager.d.ts +60 -0
  4. package/dist/Player/EffectManager.d.ts +40 -0
  5. package/dist/Player/ElementManager.d.ts +31 -0
  6. package/dist/Player/GoldManager.d.ts +22 -0
  7. package/dist/Player/GuiManager.d.ts +176 -0
  8. package/dist/Player/ItemFixture.d.ts +6 -0
  9. package/dist/Player/ItemManager.d.ts +27 -13
  10. package/dist/Player/MoveManager.d.ts +31 -43
  11. package/dist/Player/ParameterManager.d.ts +27 -19
  12. package/dist/Player/Player.d.ts +123 -8
  13. package/dist/Player/SkillManager.d.ts +27 -19
  14. package/dist/Player/StateManager.d.ts +28 -35
  15. package/dist/Player/VariableManager.d.ts +30 -0
  16. package/dist/RpgServer.d.ts +224 -1
  17. package/dist/index.js +1097 -636
  18. package/dist/index.js.map +1 -1
  19. package/dist/rooms/map.d.ts +70 -1
  20. package/package.json +8 -8
  21. package/src/Player/BattleManager.ts +97 -38
  22. package/src/Player/ClassManager.ts +95 -35
  23. package/src/Player/ComponentManager.ts +64 -20
  24. package/src/Player/EffectManager.ts +110 -27
  25. package/src/Player/ElementManager.ts +126 -25
  26. package/src/Player/GoldManager.ts +32 -35
  27. package/src/Player/GuiManager.ts +187 -140
  28. package/src/Player/ItemFixture.ts +4 -5
  29. package/src/Player/ItemManager.ts +39 -26
  30. package/src/Player/MoveManager.ts +40 -31
  31. package/src/Player/ParameterManager.ts +35 -25
  32. package/src/Player/Player.ts +184 -39
  33. package/src/Player/SkillManager.ts +44 -23
  34. package/src/Player/StateManager.ts +210 -95
  35. package/src/Player/VariableManager.ts +180 -48
  36. package/src/RpgServer.ts +232 -1
  37. package/src/core/context.ts +1 -0
  38. package/src/rooms/map.ts +76 -8
  39. package/dist/Player/Event.d.ts +0 -0
  40. package/src/Player/Event.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { RpgCommonPlayer, ShowAnimationParams, Constructor, ZoneOptions } from '@rpgjs/common';
1
+ import { RpgCommonPlayer } from '@rpgjs/common';
2
2
  import { IComponentManager } from './ComponentManager';
3
3
  import { RpgMap } from '../rooms/map';
4
4
  import { Context } from '@signe/di';
@@ -6,12 +6,43 @@ import { IGuiManager } from './GuiManager';
6
6
  import { MockConnection } from '@signe/room';
7
7
  import { IMoveManager } from './MoveManager';
8
8
  import { IGoldManager } from './GoldManager';
9
- import { IWithVariableManager } from './VariableManager';
10
- import { IWithParameterManager } from './ParameterManager';
11
- import { IWithSkillManager } from './SkillManager';
12
- declare const RpgPlayer_base: Constructor<RpgCommonPlayer>;
9
+ import { IVariableManager } from './VariableManager';
10
+ import { IParameterManager } from './ParameterManager';
11
+ import { IItemManager } from './ItemManager';
12
+ import { IEffectManager } from './EffectManager';
13
+ import { IElementManager } from './ElementManager';
14
+ import { ISkillManager } from './SkillManager';
15
+ import { IBattleManager } from './BattleManager';
16
+ import { IClassManager } from './ClassManager';
17
+ import { IStateManager } from './StateManager';
18
+ interface ZoneOptions {
19
+ x?: number;
20
+ y?: number;
21
+ radius: number;
22
+ angle?: number;
23
+ direction?: any;
24
+ linkedTo?: string;
25
+ limitedByWalls?: boolean;
26
+ }
27
+ declare const RpgPlayer_base: typeof RpgCommonPlayer;
13
28
  /**
14
29
  * RPG Player class with component management capabilities
30
+ *
31
+ * Combines all player mixins to provide a complete player implementation
32
+ * with graphics, movement, inventory, skills, and battle capabilities.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // Create a new player
37
+ * const player = new RpgPlayer();
38
+ *
39
+ * // Set player graphics
40
+ * player.setGraphic("hero");
41
+ *
42
+ * // Add parameters and items
43
+ * player.addParameter("strength", { start: 10, end: 100 });
44
+ * player.addItem(sword);
45
+ * ```
15
46
  */
16
47
  export declare class RpgPlayer extends RpgPlayer_base {
17
48
  map: RpgMap | null;
@@ -47,7 +78,33 @@ export declare class RpgPlayer extends RpgPlayer_base {
47
78
  }): Promise<false | undefined>;
48
79
  getCurrentMap<T extends RpgMap = RpgMap>(): T | null;
49
80
  emit(type: string, value?: any): void;
50
- showAnimation(params: ShowAnimationParams): void;
81
+ /**
82
+ * Set the current animation of the player's sprite
83
+ *
84
+ * This method changes the animation state of the player's current sprite.
85
+ * It's used to trigger character animations like attack, skill, or custom movements.
86
+ * When `nbTimes` is set to a finite number, the animation will play that many times
87
+ * before returning to the previous animation state.
88
+ *
89
+ * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
90
+ * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * // Set continuous walk animation
95
+ * player.setAnimation('walk');
96
+ *
97
+ * // Play attack animation 3 times then return to previous state
98
+ * player.setAnimation('attack', 3);
99
+ *
100
+ * // Play skill animation once
101
+ * player.setAnimation('skill', 1);
102
+ *
103
+ * // Set idle/stand animation
104
+ * player.setAnimation('stand');
105
+ * ```
106
+ */
107
+ setAnimation(animationName: string, nbTimes?: number): void;
51
108
  /**
52
109
  * Run the change detection cycle. Normally, as soon as a hook is called in a class, the cycle is started. But you can start it manually
53
110
  * The method calls the `onChanges` method on events and synchronizes all map data with the client.
@@ -61,13 +118,71 @@ export declare class RpgPlayer extends RpgPlayer_base {
61
118
  databaseById(id: string): any;
62
119
  private _eventChanges;
63
120
  attachShape(id: string, options: ZoneOptions): void;
64
- broadcastEffect(id: string, params: any): void;
121
+ /**
122
+ * Show a temporary component animation on this player
123
+ *
124
+ * This method broadcasts a component animation to all clients, allowing
125
+ * temporary visual effects like hit indicators, spell effects, or status animations
126
+ * to be displayed on the player.
127
+ *
128
+ * @param id - The ID of the component animation to display
129
+ * @param params - Parameters to pass to the component animation
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * // Show a hit animation with damage text
134
+ * player.showComponentAnimation("hit", {
135
+ * text: "150",
136
+ * color: "red"
137
+ * });
138
+ *
139
+ * // Show a heal animation
140
+ * player.showComponentAnimation("heal", {
141
+ * amount: 50
142
+ * });
143
+ * ```
144
+ */
145
+ showComponentAnimation(id: string, params: any): void;
146
+ /**
147
+ * Display a spritesheet animation on the player
148
+ *
149
+ * This method displays a temporary visual animation using a spritesheet.
150
+ * The animation can either be displayed as an overlay on the player or replace
151
+ * the player's current graphic temporarily. This is useful for spell effects,
152
+ * transformations, or other visual feedback that uses predefined spritesheets.
153
+ *
154
+ * @param graphic - The ID of the spritesheet to use for the animation
155
+ * @param animationName - The name of the animation within the spritesheet (default: 'default')
156
+ * @param replaceGraphic - Whether to replace the player's sprite with the animation (default: false)
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * // Show explosion animation as overlay on player
161
+ * player.showAnimation("explosion");
162
+ *
163
+ * // Show specific spell effect animation
164
+ * player.showAnimation("spell-effects", "fireball");
165
+ *
166
+ * // Transform player graphic temporarily with animation
167
+ * player.showAnimation("transformation", "werewolf", true);
168
+ *
169
+ * // Show healing effect on player
170
+ * player.showAnimation("healing-effects", "holy-light");
171
+ * ```
172
+ */
173
+ showAnimation(graphic: string, animationName?: string, replaceGraphic?: boolean): void;
65
174
  showHit(text: string): void;
66
175
  }
67
176
  export declare class RpgEvent extends RpgPlayer {
68
177
  execMethod(methodName: string, methodData?: any[], instance?: this): Promise<any>;
69
178
  remove(): void;
70
179
  }
71
- export interface RpgPlayer extends RpgCommonPlayer, IComponentManager, IGuiManager, IMoveManager, IGoldManager, IWithVariableManager, IWithParameterManager, IWithSkillManager {
180
+ /**
181
+ * Interface extension for RpgPlayer
182
+ *
183
+ * Extends the RpgPlayer class with additional interfaces from mixins.
184
+ * This provides proper TypeScript support for all mixin methods and properties.
185
+ */
186
+ export interface RpgPlayer extends IVariableManager, IMoveManager, IGoldManager, IComponentManager, IGuiManager, IItemManager, IEffectManager, IParameterManager, IElementManager, ISkillManager, IBattleManager, IClassManager, IStateManager {
72
187
  }
73
188
  export {};
@@ -1,23 +1,31 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- import { RpgPlayer } from './Player';
1
+ import { PlayerCtor } from '@rpgjs/common';
3
2
  /**
4
- * Interface defining dependencies from other mixins that SkillManager needs
3
+ * Skill Manager Mixin
4
+ *
5
+ * Provides skill management capabilities to any class. This mixin handles
6
+ * learning, forgetting, and using skills, including SP cost management,
7
+ * hit rate calculations, and skill effects application.
8
+ *
9
+ * @param Base - The base class to extend with skill management
10
+ * @returns Extended class with skill management methods
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithSkillManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * // Skill system is automatically initialized
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * player.learnSkill(Fire);
23
+ * player.useSkill(Fire, targetPlayer);
24
+ * ```
5
25
  */
6
- interface SkillManagerDependencies {
7
- sp: number;
8
- skills(): any[];
9
- hasEffect(effect: string): boolean;
10
- databaseById(id: string): any;
11
- applyStates(player: RpgPlayer, skill: any): void;
12
- }
26
+ export declare function WithSkillManager<TBase extends PlayerCtor>(Base: TBase): TBase;
13
27
  /**
14
- * Interface defining what SkillManager adds to a class
28
+ * Type helper to extract the interface from the WithSkillManager mixin
29
+ * This provides the type without duplicating method signatures
15
30
  */
16
- export interface IWithSkillManager {
17
- getSkill(skillClass: any | string): any;
18
- learnSkill(skillId: any | string): any;
19
- forgetSkill(skillId: any | string): any;
20
- useSkill(skillId: any | string, otherPlayer?: RpgPlayer | RpgPlayer[]): any;
21
- }
22
- export declare function WithSkillManager<TBase extends Constructor<RpgCommonPlayer & SkillManagerDependencies>>(Base: TBase): Constructor<IWithSkillManager> & TBase;
23
- export {};
31
+ export type ISkillManager = InstanceType<ReturnType<typeof WithSkillManager>>;
@@ -1,39 +1,32 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- import { WritableArraySignal } from '@signe/reactive';
3
- import { RpgPlayer } from './Player';
4
- interface StateManagerDependencies {
5
- equipments(): any[];
6
- databaseById(id: string | StateClass): any;
7
- addState(stateClass: StateClass | string, chance?: number): object | null;
8
- removeState(stateClass: StateClass | string, chance?: number): void;
9
- }
1
+ import { PlayerCtor } from '@rpgjs/common';
10
2
  /**
11
- * Interface defining what MoveManager adds to a class
12
- */
13
- export interface IStateManager {
14
- statesDefense: {
15
- rate: number;
16
- state: any;
17
- }[];
18
- statesEfficiency: WritableArraySignal<any[]>;
19
- applyStates(player: RpgPlayer, states: {
20
- addStates?: any[];
21
- removeStates?: any[];
22
- }): void;
23
- getState(stateClass: StateClass | string): any;
24
- addState(stateClass: StateClass | string, chance?: number): object | null;
25
- removeState(stateClass: StateClass | string, chance?: number): void;
26
- }
27
- type StateClass = {
28
- new (...args: any[]): any;
29
- };
30
- /**
31
- * Move Manager mixin
3
+ * State Manager Mixin
4
+ *
5
+ * Provides state management capabilities to any class. This mixin handles
6
+ * player states (buffs/debuffs), state defense from equipment, and state
7
+ * efficiency modifiers. It manages the complete state system including
8
+ * application, removal, and resistance mechanics.
32
9
  *
33
- * Adds methods to manage player movement
10
+ * @param Base - The base class to extend with state management
11
+ * @returns Extended class with state management methods
34
12
  *
35
- * @param Base - The base class to extend
36
- * @returns A new class with move management capabilities
13
+ * @example
14
+ * ```ts
15
+ * class MyPlayer extends WithStateManager(BasePlayer) {
16
+ * constructor() {
17
+ * super();
18
+ * // State system is automatically initialized
19
+ * }
20
+ * }
21
+ *
22
+ * const player = new MyPlayer();
23
+ * player.addState(Paralyze);
24
+ * console.log(player.getState(Paralyze));
25
+ * ```
26
+ */
27
+ export declare function WithStateManager<TBase extends PlayerCtor>(Base: TBase): TBase;
28
+ /**
29
+ * Type helper to extract the interface from the WithStateManager mixin
30
+ * This provides the type without duplicating method signatures
37
31
  */
38
- export declare function WithStateManager<TBase extends Constructor<RpgCommonPlayer & StateManagerDependencies>>(Base: TBase): Constructor<IStateManager> & TBase;
39
- export {};
32
+ export type IStateManager = InstanceType<ReturnType<typeof WithStateManager>>;
@@ -0,0 +1,30 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
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
+ * Type helper to extract the interface from the WithVariableManager mixin
28
+ * This provides the type without duplicating method signatures
29
+ */
30
+ export type IVariableManager = InstanceType<ReturnType<typeof WithVariableManager>>;
@@ -210,19 +210,242 @@ export interface RpgPlayerHooks {
210
210
  */
211
211
  canChangeMap?: (player: RpgPlayer, nextMap: RpgClassMap<RpgMap>) => boolean | Promise<boolean>;
212
212
  }
213
+ /**
214
+ * Event hooks interface for handling various event lifecycle methods
215
+ *
216
+ * @interface RpgEventHooks
217
+ * @since 4.0.0
218
+ */
213
219
  export interface RpgEventHooks {
220
+ /**
221
+ * Called as soon as the event is created on the map
222
+ *
223
+ * @param {RpgEvent} event - The event instance being initialized
224
+ * @returns {any}
225
+ * @memberof RpgEventHooks
226
+ * @example
227
+ * ```ts
228
+ * const eventHooks: RpgEventHooks = {
229
+ * onInit(event) {
230
+ * console.log(`Event ${event.name} initialized`)
231
+ * event.graphic('default-sprite')
232
+ * }
233
+ * }
234
+ * ```
235
+ */
214
236
  onInit?: (event: RpgEvent) => any;
237
+ /**
238
+ * Called when the event collides with a player and the player presses the action key
239
+ *
240
+ * @param {RpgEvent} event - The event being interacted with
241
+ * @param {RpgPlayer} player - The player performing the action
242
+ * @returns {any}
243
+ * @memberof RpgEventHooks
244
+ * @example
245
+ * ```ts
246
+ * const eventHooks: RpgEventHooks = {
247
+ * onAction(event, player) {
248
+ * player.showText('You activated the chest!')
249
+ * player.addItem('POTION', 1)
250
+ * }
251
+ * }
252
+ * ```
253
+ */
215
254
  onAction?: (event: RpgEvent, player: RpgPlayer) => any;
255
+ /**
256
+ * Called before an event object is created and added to the map
257
+ * Allows modification of event properties before instantiation
258
+ *
259
+ * @param {any} object - The event object data before creation
260
+ * @param {RpgMap} map - The map where the event will be created
261
+ * @returns {any}
262
+ * @memberof RpgEventHooks
263
+ * @example
264
+ * ```ts
265
+ * const eventHooks: RpgEventHooks = {
266
+ * onBeforeCreated(object, map) {
267
+ * // Modify event properties based on map conditions
268
+ * if (map.id === 'dungeon') {
269
+ * object.graphic = 'monster-sprite'
270
+ * }
271
+ * }
272
+ * }
273
+ * ```
274
+ */
216
275
  onBeforeCreated?: (object: any, map: RpgMap) => any;
276
+ /**
277
+ * Called when a player or another event enters a shape attached to this event
278
+ *
279
+ * @param {RpgEvent} event - The event with the attached shape
280
+ * @param {RpgPlayer} player - The player entering the shape
281
+ * @param {RpgShape} shape - The shape being entered
282
+ * @returns {any}
283
+ * @since 4.1.0
284
+ * @memberof RpgEventHooks
285
+ * @example
286
+ * ```ts
287
+ * const eventHooks: RpgEventHooks = {
288
+ * onDetectInShape(event, player, shape) {
289
+ * console.log(`Player ${player.name} entered detection zone`)
290
+ * player.showText('You are being watched...')
291
+ * }
292
+ * }
293
+ * ```
294
+ */
217
295
  onDetectInShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any;
296
+ /**
297
+ * Called when a player or another event leaves a shape attached to this event
298
+ *
299
+ * @param {RpgEvent} event - The event with the attached shape
300
+ * @param {RpgPlayer} player - The player leaving the shape
301
+ * @param {RpgShape} shape - The shape being left
302
+ * @returns {any}
303
+ * @since 4.1.0
304
+ * @memberof RpgEventHooks
305
+ * @example
306
+ * ```ts
307
+ * const eventHooks: RpgEventHooks = {
308
+ * onDetectOutShape(event, player, shape) {
309
+ * console.log(`Player ${player.name} left detection zone`)
310
+ * player.showText('You escaped the watch...')
311
+ * }
312
+ * }
313
+ * ```
314
+ */
218
315
  onDetectOutShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any;
316
+ /**
317
+ * Called when the event enters a shape on the map
318
+ *
319
+ * @param {RpgEvent} event - The event entering the shape
320
+ * @param {RpgShape} shape - The shape being entered
321
+ * @returns {any}
322
+ * @memberof RpgEventHooks
323
+ * @example
324
+ * ```ts
325
+ * const eventHooks: RpgEventHooks = {
326
+ * onInShape(event, shape) {
327
+ * console.log(`Event entered shape: ${shape.id}`)
328
+ * event.speed = 1 // Slow down in this area
329
+ * }
330
+ * }
331
+ * ```
332
+ */
219
333
  onInShape?: (event: RpgEvent, shape: RpgShape) => any;
334
+ /**
335
+ * Called when the event leaves a shape on the map
336
+ *
337
+ * @param {RpgEvent} event - The event leaving the shape
338
+ * @param {RpgShape} shape - The shape being left
339
+ * @returns {any}
340
+ * @memberof RpgEventHooks
341
+ * @example
342
+ * ```ts
343
+ * const eventHooks: RpgEventHooks = {
344
+ * onOutShape(event, shape) {
345
+ * console.log(`Event left shape: ${shape.id}`)
346
+ * event.speed = 3 // Resume normal speed
347
+ * }
348
+ * }
349
+ * ```
350
+ */
220
351
  onOutShape?: (event: RpgEvent, shape: RpgShape) => any;
352
+ /**
353
+ * Called when the event collides with a player (without requiring action key press)
354
+ *
355
+ * @param {RpgEvent} event - The event touching the player
356
+ * @param {RpgPlayer} player - The player being touched
357
+ * @returns {any}
358
+ * @memberof RpgEventHooks
359
+ * @example
360
+ * ```ts
361
+ * const eventHooks: RpgEventHooks = {
362
+ * onPlayerTouch(event, player) {
363
+ * player.hp -= 10 // Damage on touch
364
+ * player.showText('Ouch! You touched a spike!')
365
+ * }
366
+ * }
367
+ * ```
368
+ */
221
369
  onPlayerTouch?: (event: RpgEvent, player: RpgPlayer) => any;
370
+ /**
371
+ * Called whenever any event on the map (including itself) is executed or changes state
372
+ * Useful for creating reactive events that respond to map state changes
373
+ *
374
+ * @param {RpgEvent} event - The event listening for changes
375
+ * @param {RpgPlayer} player - The player involved in the change
376
+ * @returns {any}
377
+ * @memberof RpgEventHooks
378
+ * @example
379
+ * ```ts
380
+ * const eventHooks: RpgEventHooks = {
381
+ * onChanges(event, player) {
382
+ * // Change chest graphic based on game state
383
+ * if (player.getVariable('BATTLE_END')) {
384
+ * event.graphic('chest-open')
385
+ * } else {
386
+ * event.graphic('chest-close')
387
+ * }
388
+ * }
389
+ * }
390
+ * ```
391
+ */
222
392
  onChanges?: (event: RpgEvent, player: RpgPlayer) => any;
223
393
  }
394
+ /**
395
+ * Map hooks interface for handling map lifecycle events
396
+ *
397
+ * @interface RpgMapHooks
398
+ * @since 4.0.0
399
+ */
224
400
  export interface RpgMapHooks {
225
- onBeforeUpdate<T = RpgMap>(mapData: any, map: T): T;
401
+ /**
402
+ * Called before a map is updated with new data
403
+ * Allows modification of map data before the update is applied
404
+ *
405
+ * The `mapData` parameter contains the loaded map data (retrieved from request body)
406
+ * You can modify the map before the update is processed
407
+ *
408
+ * @template T - Type of the incoming map data
409
+ * @template U - Type of the map instance (defaults to RpgMap)
410
+ * @param {T} mapData - The map data loaded from external source (e.g., request body)
411
+ * @param {U} map - The current map instance being updated
412
+ * @returns {U | Promise<U>} The modified map instance or a promise resolving to it
413
+ * @memberof RpgMapHooks
414
+ * @example
415
+ * ```ts
416
+ * const mapHooks: RpgMapHooks = {
417
+ * onBeforeUpdate(mapData, map) {
418
+ * // Modify map properties based on incoming data
419
+ * if (mapData.weather === 'rain') {
420
+ * map.setWeatherEffect('rain')
421
+ * }
422
+ *
423
+ * // Add custom properties from external data
424
+ * map.customProperty = mapData.customValue
425
+ *
426
+ * return map
427
+ * }
428
+ * }
429
+ * ```
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * // Async example with database operations
434
+ * const mapHooks: RpgMapHooks = {
435
+ * async onBeforeUpdate(mapData, map) {
436
+ * // Load additional data from database
437
+ * const additionalData = await database.getMapExtras(map.id)
438
+ *
439
+ * // Apply modifications
440
+ * map.events = [...map.events, ...additionalData.events]
441
+ * map.npcs = additionalData.npcs
442
+ *
443
+ * return map
444
+ * }
445
+ * }
446
+ * ```
447
+ */
448
+ onBeforeUpdate<T, U = RpgMap>(mapData: T, map: U): U | Promise<U>;
226
449
  }
227
450
  export interface RpgServer {
228
451
  /**