@rpgjs/server 5.0.0-alpha.10 → 5.0.0-alpha.3
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/CHANGELOG.md +9 -0
- package/dist/Player/BattleManager.d.ts +22 -32
- package/dist/Player/ClassManager.d.ts +18 -31
- package/dist/Player/Event.d.ts +0 -0
- package/dist/Player/ItemManager.d.ts +13 -27
- package/dist/Player/MoveManager.d.ts +43 -31
- package/dist/Player/ParameterManager.d.ts +19 -27
- package/dist/Player/Player.d.ts +8 -123
- package/dist/Player/SkillManager.d.ts +19 -27
- package/dist/Player/StateManager.d.ts +35 -28
- package/dist/RpgServer.d.ts +1 -224
- package/dist/index.js +647 -1108
- package/dist/index.js.map +1 -1
- package/dist/rooms/map.d.ts +1 -70
- package/package.json +8 -8
- package/src/Player/BattleManager.ts +38 -97
- package/src/Player/ClassManager.ts +35 -95
- package/src/Player/ComponentManager.ts +20 -64
- package/src/Player/EffectManager.ts +27 -110
- package/src/Player/ElementManager.ts +25 -126
- package/src/Player/Event.ts +0 -0
- package/src/Player/GoldManager.ts +35 -32
- package/src/Player/GuiManager.ts +140 -187
- package/src/Player/ItemFixture.ts +5 -4
- package/src/Player/ItemManager.ts +26 -39
- package/src/Player/MoveManager.ts +31 -40
- package/src/Player/ParameterManager.ts +25 -35
- package/src/Player/Player.ts +39 -184
- package/src/Player/SkillManager.ts +23 -44
- package/src/Player/StateManager.ts +95 -210
- package/src/Player/VariableManager.ts +48 -180
- package/src/RpgServer.ts +1 -232
- package/src/core/context.ts +0 -1
- package/src/rooms/map.ts +8 -76
- package/dist/Player/ComponentManager.d.ts +0 -60
- package/dist/Player/EffectManager.d.ts +0 -40
- package/dist/Player/ElementManager.d.ts +0 -31
- package/dist/Player/GoldManager.d.ts +0 -22
- package/dist/Player/GuiManager.d.ts +0 -176
- package/dist/Player/ItemFixture.d.ts +0 -6
- package/dist/Player/VariableManager.d.ts +0 -30
package/CHANGELOG.md
ADDED
|
@@ -1,32 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
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,31 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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>>;
|
|
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 {};
|
|
File without changes
|
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
|
|
2
|
+
import { ItemClass } from '@rpgjs/database';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
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.
|
|
8
|
-
*
|
|
9
|
-
* @param Base - The base class to extend with item management
|
|
10
|
-
* @returns Extended class with item management methods
|
|
11
|
-
*
|
|
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
|
-
* ```
|
|
4
|
+
* Interface defining what MoveManager adds to a class
|
|
25
5
|
*/
|
|
26
|
-
export
|
|
6
|
+
export interface IItemManager {
|
|
7
|
+
databaseById(id: string): ItemClass;
|
|
8
|
+
}
|
|
27
9
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
10
|
+
* Move Manager mixin
|
|
11
|
+
*
|
|
12
|
+
* Adds methods to manage player movement
|
|
13
|
+
*
|
|
14
|
+
* @param Base - The base class to extend
|
|
15
|
+
* @returns A new class with move management capabilities
|
|
30
16
|
*/
|
|
31
|
-
export
|
|
17
|
+
export declare function WithItemManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): Constructor<IItemManager> & TBase;
|
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Constructor, RpgCommonPlayer, Direction, MovementStrategy, ProjectileType } 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
|
+
}
|
|
3
43
|
type CallbackTileMove = (player: RpgPlayer, map: any) => Direction[];
|
|
4
44
|
type CallbackTurnMove = (player: RpgPlayer, map: any) => string;
|
|
45
|
+
type Routes = (string | Promise<any> | Direction | Direction[] | Function)[];
|
|
5
46
|
export declare enum Frequency {
|
|
6
47
|
Lowest = 600,
|
|
7
48
|
Lower = 400,
|
|
@@ -132,34 +173,5 @@ export declare const Move: MoveList;
|
|
|
132
173
|
* }
|
|
133
174
|
* ```
|
|
134
175
|
*/
|
|
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>>;
|
|
176
|
+
export declare function WithMoveManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): Constructor<IMoveManager> & TBase;
|
|
165
177
|
export {};
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {
|
|
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
|
+
}
|
|
2
19
|
/**
|
|
3
20
|
* Mixin that adds parameter management functionality to a player class.
|
|
4
21
|
*
|
|
@@ -22,29 +39,4 @@ import { PlayerCtor } from '@rpgjs/common';
|
|
|
22
39
|
* }
|
|
23
40
|
* ```
|
|
24
41
|
*/
|
|
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>>;
|
|
42
|
+
export declare function WithParameterManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): TBase & Constructor<IWithParameterManager>;
|
package/dist/Player/Player.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RpgCommonPlayer } from '@rpgjs/common';
|
|
1
|
+
import { RpgCommonPlayer, ShowAnimationParams, Constructor, ZoneOptions } from '@rpgjs/common';
|
|
2
2
|
import { IComponentManager } from './ComponentManager';
|
|
3
3
|
import { RpgMap } from '../rooms/map';
|
|
4
4
|
import { Context } from '@signe/di';
|
|
@@ -6,43 +6,12 @@ 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 {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
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;
|
|
9
|
+
import { IWithVariableManager } from './VariableManager';
|
|
10
|
+
import { IWithParameterManager } from './ParameterManager';
|
|
11
|
+
import { IWithSkillManager } from './SkillManager';
|
|
12
|
+
declare const RpgPlayer_base: Constructor<RpgCommonPlayer>;
|
|
28
13
|
/**
|
|
29
14
|
* 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
|
-
* ```
|
|
46
15
|
*/
|
|
47
16
|
export declare class RpgPlayer extends RpgPlayer_base {
|
|
48
17
|
map: RpgMap | null;
|
|
@@ -78,33 +47,7 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
78
47
|
}): Promise<false | undefined>;
|
|
79
48
|
getCurrentMap<T extends RpgMap = RpgMap>(): T | null;
|
|
80
49
|
emit(type: string, value?: any): 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;
|
|
50
|
+
showAnimation(params: ShowAnimationParams): void;
|
|
108
51
|
/**
|
|
109
52
|
* 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
|
|
110
53
|
* The method calls the `onChanges` method on events and synchronizes all map data with the client.
|
|
@@ -118,71 +61,13 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
118
61
|
databaseById(id: string): any;
|
|
119
62
|
private _eventChanges;
|
|
120
63
|
attachShape(id: string, options: ZoneOptions): 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;
|
|
64
|
+
broadcastEffect(id: string, params: any): void;
|
|
174
65
|
showHit(text: string): void;
|
|
175
66
|
}
|
|
176
67
|
export declare class RpgEvent extends RpgPlayer {
|
|
177
68
|
execMethod(methodName: string, methodData?: any[], instance?: this): Promise<any>;
|
|
178
69
|
remove(): void;
|
|
179
70
|
}
|
|
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 {
|
|
71
|
+
export interface RpgPlayer extends RpgCommonPlayer, IComponentManager, IGuiManager, IMoveManager, IGoldManager, IWithVariableManager, IWithParameterManager, IWithSkillManager {
|
|
187
72
|
}
|
|
188
73
|
export {};
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
|
|
2
|
+
import { RpgPlayer } from './Player';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
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
|
-
* ```
|
|
4
|
+
* Interface defining dependencies from other mixins that SkillManager needs
|
|
25
5
|
*/
|
|
26
|
-
|
|
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
|
+
}
|
|
27
13
|
/**
|
|
28
|
-
*
|
|
29
|
-
* This provides the type without duplicating method signatures
|
|
14
|
+
* Interface defining what SkillManager adds to a class
|
|
30
15
|
*/
|
|
31
|
-
export
|
|
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 {};
|
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
import {
|
|
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
|
+
}
|
|
2
10
|
/**
|
|
3
|
-
*
|
|
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.
|
|
9
|
-
*
|
|
10
|
-
* @param Base - The base class to extend with state management
|
|
11
|
-
* @returns Extended class with state management methods
|
|
12
|
-
*
|
|
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
|
-
* ```
|
|
11
|
+
* Interface defining what MoveManager adds to a class
|
|
26
12
|
*/
|
|
27
|
-
export
|
|
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
|
+
};
|
|
28
30
|
/**
|
|
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
|
|
31
37
|
*/
|
|
32
|
-
export
|
|
38
|
+
export declare function WithStateManager<TBase extends Constructor<RpgCommonPlayer & StateManagerDependencies>>(Base: TBase): Constructor<IStateManager> & TBase;
|
|
39
|
+
export {};
|