@rpgjs/server 5.0.0-alpha.5 → 5.0.0-alpha.7

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.
@@ -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,30 @@
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): TBase;
26
+ /**
27
+ * Type helper to extract the interface from the WithComponentManager mixin
28
+ * This provides the type without duplicating method signatures
29
+ */
30
+ export type IComponentManager = InstanceType<ReturnType<typeof WithComponentManager>>;
@@ -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,31 @@
1
+ import { PlayerCtor } from '@rpgjs/common';
2
+ /**
3
+ * GUI Manager Mixin
4
+ *
5
+ * Provides graphical user interface management capabilities to any class. This mixin handles
6
+ * dialog boxes, menus, notifications, shops, and custom GUI components. It manages the
7
+ * complete GUI system including opening, closing, and data passing between client and server.
8
+ *
9
+ * @param Base - The base class to extend with GUI management
10
+ * @returns Extended class with GUI management methods
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * class MyPlayer extends WithGuiManager(BasePlayer) {
15
+ * constructor() {
16
+ * super();
17
+ * // GUI system is automatically initialized
18
+ * }
19
+ * }
20
+ *
21
+ * const player = new MyPlayer();
22
+ * await player.showText('Hello World!');
23
+ * player.callMainMenu();
24
+ * ```
25
+ */
26
+ export declare function WithGuiManager<TBase extends PlayerCtor>(Base: TBase): TBase;
27
+ /**
28
+ * Type helper to extract the interface from the WithGuiManager mixin
29
+ * This provides the type without duplicating method signatures
30
+ */
31
+ export type IGuiManager = InstanceType<ReturnType<typeof WithGuiManager>>;
@@ -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>>;
@@ -1,4 +1,4 @@
1
- import { RpgCommonPlayer, ShowAnimationParams, Constructor, ZoneOptions } from '@rpgjs/common';
1
+ import { RpgCommonPlayer, ShowAnimationParams } 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;
@@ -68,6 +99,12 @@ export declare class RpgEvent extends RpgPlayer {
68
99
  execMethod(methodName: string, methodData?: any[], instance?: this): Promise<any>;
69
100
  remove(): void;
70
101
  }
71
- export interface RpgPlayer extends RpgCommonPlayer, IComponentManager, IGuiManager, IMoveManager, IGoldManager, IWithVariableManager, IWithParameterManager, IWithSkillManager {
102
+ /**
103
+ * Interface extension for RpgPlayer
104
+ *
105
+ * Extends the RpgPlayer class with additional interfaces from mixins.
106
+ * This provides proper TypeScript support for all mixin methods and properties.
107
+ */
108
+ export interface RpgPlayer extends IVariableManager, IMoveManager, IGoldManager, IComponentManager, IGuiManager, IItemManager, IEffectManager, IParameterManager, IElementManager, ISkillManager, IBattleManager, IClassManager, IStateManager {
72
109
  }
73
110
  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>>;