@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,22 +1,32 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- import { RpgPlayer } from './Player';
3
- interface PlayerWithMixins extends RpgCommonPlayer {
4
- parameters: any[];
5
- getFormulas(name: string): any;
6
- hasEffect(effect: string): boolean;
7
- coefficientElements(attackerPlayer: RpgPlayer): number;
8
- hp: number;
9
- getFormulas(name: string): any;
10
- hasEffect(effect: string): boolean;
11
- }
12
- export interface IBattleManager {
13
- applyDamage(attackerPlayer: RpgPlayer, skill?: any): {
14
- damage: number;
15
- critical: boolean;
16
- elementVulnerable: boolean;
17
- guard: boolean;
18
- superGuard: boolean;
19
- };
20
- }
21
- export declare function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(Base: TBase): Constructor<IBattleManager> & TBase;
22
- export {};
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ /**
3
+ * Battle Manager Mixin
4
+ *
5
+ * Provides battle management capabilities to any class. This mixin handles
6
+ * damage calculation, critical hits, elemental vulnerabilities, and guard effects.
7
+ * It implements a comprehensive battle system with customizable formulas and effects.
8
+ *
9
+ * @param Base - The base class to extend with battle management
10
+ * @returns Extended class with battle management methods
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithBattleManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * // Battle system is automatically initialized
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * const attacker = new MyPlayer();
23
+ * const result = player.applyDamage(attacker);
24
+ * console.log(`Damage dealt: ${result.damage}`);
25
+ * ```
26
+ */
27
+ export declare function WithBattleManager<TBase extends PlayerCtor>(Base: TBase): TBase;
28
+ /**
29
+ * Type helper to extract the interface from the WithBattleManager mixin
30
+ * This provides the type without duplicating method signatures
31
+ */
32
+ export type IBattleManager = InstanceType<ReturnType<typeof WithBattleManager>>;
@@ -1,18 +1,31 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- type ClassClass = any;
3
- type ActorClass = any;
4
- interface PlayerWithMixins extends RpgCommonPlayer {
5
- databaseById(id: string): any;
6
- addParameter(name: string, { start, end }: {
7
- start: number;
8
- end: number;
9
- }): void;
10
- addItem(item: any): void;
11
- equip(item: any, equip: boolean): void;
12
- }
13
- export interface IClassManager {
14
- setClass(_class: ClassClass | string): ClassClass;
15
- setActor(actorClass: ActorClass | string): ActorClass;
16
- }
17
- export declare function WithClassManager<TBase extends Constructor<PlayerWithMixins>>(Base: TBase): Constructor<IClassManager> & TBase;
18
- export {};
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ /**
3
+ * Class Manager Mixin
4
+ *
5
+ * Provides class and actor management capabilities to any class. This mixin handles
6
+ * character class assignment and actor setup, including automatic parameter configuration,
7
+ * starting equipment, and skill progression based on class definitions.
8
+ *
9
+ * @param Base - The base class to extend with class management
10
+ * @returns Extended class with class management methods
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithClassManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * // Class system is automatically initialized
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * player.setClass(Fighter);
23
+ * player.setActor(Hero);
24
+ * ```
25
+ */
26
+ export declare function WithClassManager<TBase extends PlayerCtor>(Base: TBase): TBase;
27
+ /**
28
+ * Type helper to extract the interface from the WithClassManager mixin
29
+ * This provides the type without duplicating method signatures
30
+ */
31
+ export type IClassManager = InstanceType<ReturnType<typeof WithClassManager>>;
@@ -0,0 +1,60 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ /**
3
+ * Component Manager Mixin
4
+ *
5
+ * Provides graphic management capabilities to any class. This mixin allows
6
+ * setting single or multiple graphics for player representation, enabling
7
+ * dynamic visual changes and animation sequences.
8
+ *
9
+ * @param Base - The base class to extend with component management
10
+ * @returns Extended class with component management methods
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithComponentManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * this.setGraphic("hero");
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * player.setGraphic(["hero_idle", "hero_walk"]);
23
+ * ```
24
+ */
25
+ export declare function WithComponentManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager;
26
+ /**
27
+ * Interface for component management capabilities
28
+ * Defines the method signature that will be available on the player
29
+ */
30
+ export interface IComponentManager {
31
+ /**
32
+ * Set the graphic(s) for this player
33
+ *
34
+ * Allows setting either a single graphic or multiple graphics for the player.
35
+ * When multiple graphics are provided, they are used for animation sequences.
36
+ * The graphics system provides flexible visual representation that can be
37
+ * dynamically changed during gameplay for different states, equipment, or animations.
38
+ *
39
+ * @param graphic - Single graphic name or array of graphic names for animation sequences
40
+ * @returns void
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // Set a single graphic for static representation
45
+ * player.setGraphic("hero");
46
+ *
47
+ * // Set multiple graphics for animation sequences
48
+ * player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
49
+ *
50
+ * // Dynamic graphic changes based on equipment
51
+ * if (player.hasArmor('platemail')) {
52
+ * player.setGraphic("hero_armored");
53
+ * }
54
+ *
55
+ * // Animation sequences for different actions
56
+ * player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
57
+ * ```
58
+ */
59
+ setGraphic(graphic: string | string[]): void;
60
+ }
@@ -0,0 +1,40 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ export declare enum Effect {
3
+ CAN_NOT_SKILL = "CAN_NOT_SKILL",
4
+ CAN_NOT_ITEM = "CAN_NOT_ITEM",
5
+ CAN_NOT_STATE = "CAN_NOT_STATE",
6
+ CAN_NOT_EQUIPMENT = "CAN_NOT_EQUIPMENT",
7
+ HALF_SP_COST = "HALF_SP_COST",
8
+ GUARD = "GUARD",
9
+ SUPER_GUARD = "SUPER_GUARD"
10
+ }
11
+ /**
12
+ * Effect Manager Mixin
13
+ *
14
+ * Provides effect management capabilities to any class. This mixin handles
15
+ * player effects including restrictions, buffs, and debuffs. Effects can come
16
+ * from various sources like states, equipment, and temporary conditions.
17
+ *
18
+ * @param Base - The base class to extend with effect management
19
+ * @returns Extended class with effect management methods
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * class MyPlayer extends WithEffectManager(BasePlayer) {
24
+ * constructor() {
25
+ * super();
26
+ * // Effect system is automatically initialized
27
+ * }
28
+ * }
29
+ *
30
+ * const player = new MyPlayer();
31
+ * player.effects = [Effect.GUARD];
32
+ * console.log(player.hasEffect(Effect.GUARD)); // true
33
+ * ```
34
+ */
35
+ export declare function WithEffectManager<TBase extends PlayerCtor>(Base: TBase): TBase;
36
+ /**
37
+ * Type helper to extract the interface from the WithEffectManager mixin
38
+ * This provides the type without duplicating method signatures
39
+ */
40
+ export type IEffectManager = InstanceType<ReturnType<typeof WithEffectManager>>;
@@ -0,0 +1,31 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ /**
3
+ * Element Manager Mixin
4
+ *
5
+ * Provides elemental management capabilities to any class. This mixin handles
6
+ * elemental resistances, vulnerabilities, and attack elements. It manages both
7
+ * defensive capabilities (elementsDefense) and offensive elements from equipment,
8
+ * as well as player-specific elemental efficiency modifiers.
9
+ *
10
+ * @param Base - The base class to extend with element management
11
+ * @returns Extended class with element management methods
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * class MyPlayer extends WithElementManager(BasePlayer) {
16
+ * constructor() {
17
+ * super();
18
+ * this.elementsEfficiency = [{ rate: 0.5, element: 'fire' }];
19
+ * }
20
+ * }
21
+ *
22
+ * const player = new MyPlayer();
23
+ * const fireResistance = player.elementsDefense.find(e => e.element === 'fire');
24
+ * ```
25
+ */
26
+ export declare function WithElementManager<TBase extends PlayerCtor>(Base: TBase): TBase;
27
+ /**
28
+ * Type helper to extract the interface from the WithElementManager mixin
29
+ * This provides the type without duplicating method signatures
30
+ */
31
+ export type IElementManager = InstanceType<ReturnType<typeof WithElementManager>>;
@@ -0,0 +1,22 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ export interface GoldManager {
3
+ /**
4
+ * You can change the game money
5
+ *
6
+ * ```ts
7
+ * player.gold += 100
8
+ * ```
9
+ *
10
+ * @title Change Gold
11
+ * @prop {number} player.gold
12
+ * @default 0
13
+ * @memberof GoldManager
14
+ * */
15
+ gold: number;
16
+ }
17
+ export declare function WithGoldManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & GoldManager;
18
+ /**
19
+ * Type helper to extract the interface from the WithGoldManager mixin
20
+ * This provides the type without duplicating method signatures
21
+ */
22
+ export type IGoldManager = InstanceType<ReturnType<typeof WithGoldManager>>;
@@ -0,0 +1,176 @@
1
+ import { RpgPlayer } from './Player';
2
+ import { Gui } from '../Gui';
3
+ import { DialogOptions, Choice } from '../Gui/DialogGui';
4
+ import { PlayerCtor } from '@rpgjs/common';
5
+ /**
6
+ * GUI Manager Mixin
7
+ *
8
+ * Provides graphical user interface management capabilities to any class. This mixin handles
9
+ * dialog boxes, menus, notifications, shops, and custom GUI components. It manages the
10
+ * complete GUI system including opening, closing, and data passing between client and server.
11
+ *
12
+ * @param Base - The base class to extend with GUI management
13
+ * @returns Extended class with GUI management methods
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * class MyPlayer extends WithGuiManager(BasePlayer) {
18
+ * constructor() {
19
+ * super();
20
+ * // GUI system is automatically initialized
21
+ * }
22
+ * }
23
+ *
24
+ * const player = new MyPlayer();
25
+ * await player.showText('Hello World!');
26
+ * player.callMainMenu();
27
+ * ```
28
+ */
29
+ export declare function WithGuiManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IGuiManager;
30
+ /**
31
+ * Interface for GUI management capabilities
32
+ * Defines the methods that will be available on the player
33
+ */
34
+ export interface IGuiManager {
35
+ /**
36
+ * Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
37
+ *
38
+ * ```ts
39
+ * player.showText('Hello World')
40
+ * ```
41
+ *
42
+ * The method returns a promise. It is resolved when the dialog box is closed.
43
+ *
44
+ * ```ts
45
+ * await player.showText('Hello World')
46
+ * // dialog box is closed, then ...
47
+ * ```
48
+ *
49
+ * **Option: position**
50
+ *
51
+ * You can define how the dialog box is displayed:
52
+ * - top
53
+ * - middle
54
+ * - bottom
55
+ *
56
+ * (bottom by default)
57
+ *
58
+ * ```ts
59
+ * player.showText('Hello World', {
60
+ * position: 'top'
61
+ * })
62
+ * ```
63
+ *
64
+ * **Option: fullWidth**
65
+ *
66
+ * `boolean` (true by default)
67
+ *
68
+ * Indicate that the dialog box will take the full width of the screen.
69
+ *
70
+ * ```ts
71
+ * player.showText('Hello World', {
72
+ * fullWidth: true
73
+ * })
74
+ * ```
75
+ *
76
+ * **Option: autoClose**
77
+ *
78
+ * `boolean` (false by default)
79
+ *
80
+ * If false, the user will have to press Enter to close the dialog box.
81
+ *
82
+ * ```ts
83
+ * player.showText('Hello World', {
84
+ * autoClose: true
85
+ * })
86
+ * ```
87
+ *
88
+ * **Option: typewriterEffect**
89
+ *
90
+ * `boolean` (true by default)
91
+ *
92
+ * Performs a typewriter effect
93
+ *
94
+ * ```ts
95
+ * player.showText('Hello World', {
96
+ * typewriterEffect: false
97
+ * })
98
+ * ```
99
+ *
100
+ * **Option: talkWith**
101
+ *
102
+ * `RpgPlayer` (nothing by default)
103
+ *
104
+ * If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
105
+ *
106
+ * ```ts
107
+ * // Code in an event
108
+ * player.showText('Hello World', {
109
+ * talkWith: this
110
+ * })
111
+ * ```
112
+ *
113
+ * @title Show Text
114
+ * @method player.showText(text,options)
115
+ * @param {string} text
116
+ * @param {object} [options] the different options, see usage below
117
+ * @returns {Promise}
118
+ * @memberof GuiManager
119
+ */
120
+ showText(msg: string, options?: DialogOptions): Promise<any>;
121
+ /**
122
+ * Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
123
+ *
124
+ * ```ts
125
+ * const choice = await player.showChoices('What color do you prefer?', [
126
+ * { text: 'Black', value: 'black' },
127
+ * { text: 'Rather the blue', value: 'blue' },
128
+ * { text: 'I don\'t have a preference!', value: 'none' }
129
+ * ])
130
+ *
131
+ * // If the player selects the first
132
+ * console.log(choice) // { text: 'Black', value: 'black' }
133
+ * ```
134
+ *
135
+ * @title Show Choices
136
+ * @method player.showChoices(text,choices)
137
+ * @param {string} text
138
+ * @param {Array<{ text: string, value: any }>} choices
139
+ * @param {object} [options] Same options as the openDialog method
140
+ * @returns {Promise<Choice | null>}
141
+ * @memberof GuiManager
142
+ */
143
+ showChoices(msg: string, choices: Choice[], options?: DialogOptions): Promise<Choice | null>;
144
+ /**
145
+ * Displays a notification . Opens the GUI named `rpg-notification`
146
+ *
147
+ * @title Displays a notification
148
+ * @method player.showNotification()
149
+ * @param {string} message - The message to display in the notification
150
+ * @param {object} options - An object containing options for the notification
151
+ * @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
152
+ * @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
153
+ * @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
154
+ * @returns {void}
155
+ * @memberof GuiManager
156
+ */
157
+ showNotification(message: string, options?: {
158
+ time?: number;
159
+ icon?: string;
160
+ sound?: string;
161
+ }): Promise<any>;
162
+ /**
163
+ * Calls main menu. Opens the GUI named `rpg-main-menu`
164
+ *
165
+ * @title Call Main Menu
166
+ * @method player.callMainMenu()
167
+ * @returns {void}
168
+ * @memberof GuiManager
169
+ */
170
+ callMainMenu(): void;
171
+ callShop(items: any[]): void;
172
+ gui(guiId: string): Gui;
173
+ removeGui(guiId: string, data?: any): void;
174
+ showAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
175
+ hideAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
176
+ }
@@ -0,0 +1,6 @@
1
+ import { ItemInstance } from '@rpgjs/database';
2
+ import { PlayerCtor } from '@rpgjs/common';
3
+ export declare function WithItemFixture<TBase extends PlayerCtor>(Base: TBase): TBase;
4
+ export interface ItemFixture {
5
+ equipments: ItemInstance[];
6
+ }
@@ -1,17 +1,31 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- import { ItemClass } from '@rpgjs/database';
1
+ import { PlayerCtor } from '@rpgjs/common';
3
2
  /**
4
- * Interface defining what MoveManager adds to a class
5
- */
6
- export interface IItemManager {
7
- databaseById(id: string): ItemClass;
8
- }
9
- /**
10
- * Move Manager mixin
3
+ * Item Manager Mixin
4
+ *
5
+ * Provides comprehensive item management capabilities to any class. This mixin handles
6
+ * inventory management, item usage, equipment, buying/selling, and item effects.
7
+ * It manages the complete item system including restrictions, transactions, and equipment.
11
8
  *
12
- * Adds methods to manage player movement
9
+ * @param Base - The base class to extend with item management
10
+ * @returns Extended class with item management methods
13
11
  *
14
- * @param Base - The base class to extend
15
- * @returns A new class with move management capabilities
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithItemManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * // Item system is automatically initialized
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * player.addItem('potion', 5);
23
+ * player.useItem('potion');
24
+ * ```
25
+ */
26
+ export declare function WithItemManager<TBase extends PlayerCtor>(Base: TBase): TBase;
27
+ /**
28
+ * Type helper to extract the interface from the WithItemManager mixin
29
+ * This provides the type without duplicating method signatures
16
30
  */
17
- export declare function WithItemManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): Constructor<IItemManager> & TBase;
31
+ export type IItemManager = InstanceType<ReturnType<typeof WithItemManager>>;
@@ -1,48 +1,7 @@
1
- import { Constructor, RpgCommonPlayer, Direction, MovementStrategy, ProjectileType } from '@rpgjs/common';
1
+ import { PlayerCtor, Direction } from '@rpgjs/common';
2
2
  import { RpgPlayer } from './Player';
3
- export interface IMoveManager {
4
- addMovement(strategy: MovementStrategy): void;
5
- removeMovement(strategy: MovementStrategy): boolean;
6
- clearMovements(): void;
7
- hasActiveMovements(): boolean;
8
- getActiveMovements(): MovementStrategy[];
9
- moveTo(target: RpgCommonPlayer | {
10
- x: number;
11
- y: number;
12
- }): void;
13
- stopMoveTo(): void;
14
- dash(direction: {
15
- x: number;
16
- y: number;
17
- }, speed?: number, duration?: number): void;
18
- knockback(direction: {
19
- x: number;
20
- y: number;
21
- }, force?: number, duration?: number): void;
22
- followPath(waypoints: Array<{
23
- x: number;
24
- y: number;
25
- }>, speed?: number, loop?: boolean): void;
26
- oscillate(direction: {
27
- x: number;
28
- y: number;
29
- }, amplitude?: number, period?: number): void;
30
- applyIceMovement(direction: {
31
- x: number;
32
- y: number;
33
- }, maxSpeed?: number): void;
34
- shootProjectile(type: ProjectileType, direction: {
35
- x: number;
36
- y: number;
37
- }, speed?: number): void;
38
- moveRoutes(routes: Routes): Promise<boolean>;
39
- infiniteMoveRoute(routes: Routes): void;
40
- breakRoutes(force?: boolean): void;
41
- replayRoutes(): void;
42
- }
43
3
  type CallbackTileMove = (player: RpgPlayer, map: any) => Direction[];
44
4
  type CallbackTurnMove = (player: RpgPlayer, map: any) => string;
45
- type Routes = (string | Promise<any> | Direction | Direction[] | Function)[];
46
5
  export declare enum Frequency {
47
6
  Lowest = 600,
48
7
  Lower = 400,
@@ -173,5 +132,34 @@ export declare const Move: MoveList;
173
132
  * }
174
133
  * ```
175
134
  */
176
- export declare function WithMoveManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): Constructor<IMoveManager> & TBase;
135
+ /**
136
+ * Move Manager Mixin
137
+ *
138
+ * Provides comprehensive movement management capabilities to any class. This mixin handles
139
+ * various types of movement including pathfinding, physics-based movement, route following,
140
+ * and advanced movement strategies like dashing, knockback, and projectile movement.
141
+ *
142
+ * @param Base - The base class to extend with movement management
143
+ * @returns Extended class with movement management methods
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * class MyPlayer extends WithMoveManager(BasePlayer) {
148
+ * constructor() {
149
+ * super();
150
+ * this.frequency = Frequency.High;
151
+ * }
152
+ * }
153
+ *
154
+ * const player = new MyPlayer();
155
+ * player.moveTo({ x: 100, y: 100 });
156
+ * player.dash({ x: 1, y: 0 }, 8, 200);
157
+ * ```
158
+ */
159
+ export declare function WithMoveManager<TBase extends PlayerCtor>(Base: TBase): TBase;
160
+ /**
161
+ * Type helper to extract the interface from the WithMoveManager mixin
162
+ * This provides the type without duplicating method signatures
163
+ */
164
+ export type IMoveManager = InstanceType<ReturnType<typeof WithMoveManager>>;
177
165
  export {};
@@ -1,21 +1,4 @@
1
- import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
2
- export interface IWithParameterManager {
3
- parameters: Map<string, any>;
4
- hp: number;
5
- sp: number;
6
- exp: number;
7
- level: number;
8
- expForNextlevel: number;
9
- param: {
10
- [key: string]: number;
11
- };
12
- paramsModifier: {
13
- [key: string]: {
14
- value?: number;
15
- rate?: number;
16
- };
17
- };
18
- }
1
+ import { PlayerCtor } from '@rpgjs/common';
19
2
  /**
20
3
  * Mixin that adds parameter management functionality to a player class.
21
4
  *
@@ -39,4 +22,29 @@ export interface IWithParameterManager {
39
22
  * }
40
23
  * ```
41
24
  */
42
- export declare function WithParameterManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): TBase & Constructor<IWithParameterManager>;
25
+ /**
26
+ * Parameter Manager Mixin
27
+ *
28
+ * Provides comprehensive parameter management functionality to any class. This mixin handles
29
+ * health points (HP), skill points (SP), experience and level progression, custom parameters,
30
+ * and parameter modifiers for temporary stat changes.
31
+ *
32
+ * @param Base - The base class to extend with parameter management
33
+ * @returns Extended class with parameter management methods
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * class MyPlayer extends WithParameterManager(BasePlayer) {
38
+ * constructor() {
39
+ * super();
40
+ * this.addParameter('strength', { start: 10, end: 100 });
41
+ * }
42
+ * }
43
+ *
44
+ * const player = new MyPlayer();
45
+ * player.hp = 100;
46
+ * player.level = 5;
47
+ * ```
48
+ */
49
+ export declare function WithParameterManager<TBase extends PlayerCtor>(Base: TBase): TBase;
50
+ export type IParameterManager = InstanceType<ReturnType<typeof WithParameterManager>>;