@rpgjs/server 5.0.0-alpha.21 → 5.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Player/BattleManager.d.ts +43 -31
- package/dist/Player/ClassManager.d.ts +23 -3
- package/dist/Player/EffectManager.d.ts +49 -3
- package/dist/Player/ElementManager.d.ts +76 -3
- package/dist/Player/ItemManager.d.ts +292 -4
- package/dist/Player/MoveManager.d.ts +145 -4
- package/dist/Player/Player.d.ts +135 -0
- package/dist/Player/SkillManager.d.ts +42 -3
- package/dist/Player/StateManager.d.ts +74 -3
- package/dist/Player/VariableManager.d.ts +47 -3
- package/dist/RpgServer.d.ts +228 -61
- package/dist/decorators/map.d.ts +89 -1
- package/dist/index.js +804 -1703
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +43 -1
- package/dist/rooms/map.d.ts +676 -12
- package/package.json +8 -8
- package/src/Player/BattleManager.ts +38 -55
- package/src/Player/ClassManager.ts +21 -71
- package/src/Player/EffectManager.ts +50 -96
- package/src/Player/ElementManager.ts +74 -152
- package/src/Player/ItemManager.ts +302 -359
- package/src/Player/MoveManager.ts +141 -438
- package/src/Player/Player.ts +217 -0
- package/src/Player/SkillManager.ts +44 -147
- package/src/Player/StateManager.ts +63 -259
- package/src/Player/VariableManager.ts +53 -150
- package/src/RpgServer.ts +237 -60
- package/src/decorators/map.ts +105 -1
- package/src/module.ts +81 -2
- package/src/rooms/map.ts +757 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/server",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.23",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"description": "",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@rpgjs/common": "5.0.0-alpha.
|
|
15
|
-
"@rpgjs/physic": "5.0.0-alpha.
|
|
14
|
+
"@rpgjs/common": "5.0.0-alpha.23",
|
|
15
|
+
"@rpgjs/physic": "5.0.0-alpha.23",
|
|
16
16
|
"@rpgjs/database": "^4.3.0",
|
|
17
|
-
"@signe/di": "^2.5.
|
|
18
|
-
"@signe/reactive": "^2.5.
|
|
19
|
-
"@signe/room": "^2.5.
|
|
20
|
-
"@signe/sync": "^2.5.
|
|
17
|
+
"@signe/di": "^2.5.2",
|
|
18
|
+
"@signe/reactive": "^2.5.2",
|
|
19
|
+
"@signe/room": "^2.5.2",
|
|
20
|
+
"@signe/sync": "^2.5.2",
|
|
21
21
|
"rxjs": "^7.8.2",
|
|
22
22
|
"zod": "^4.1.13"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"vite": "^7.2.
|
|
25
|
+
"vite": "^7.2.6",
|
|
26
26
|
"vite-plugin-dts": "^4.5.4"
|
|
27
27
|
},
|
|
28
28
|
"type": "module",
|
|
@@ -2,44 +2,21 @@ import { Constructor, PlayerCtor, RpgCommonPlayer } from "@rpgjs/common";
|
|
|
2
2
|
import { RpgPlayer } from "./Player";
|
|
3
3
|
import { ATK, PDEF, SDEF } from "../presets";
|
|
4
4
|
import { Effect } from "./EffectManager";
|
|
5
|
+
import type { IElementManager } from "./ElementManager";
|
|
6
|
+
import type { IEffectManager } from "./EffectManager";
|
|
7
|
+
import type { IParameterManager } from "./ParameterManager";
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Interface combining methods from other managers needed by BattleManager
|
|
11
|
+
* Reuses existing interfaces instead of duplicating method signatures
|
|
12
|
+
*/
|
|
13
|
+
interface PlayerWithMixins extends IElementManager, IEffectManager, Pick<IParameterManager, 'parameters' | 'hp'> {
|
|
8
14
|
getFormulas(name: string): any;
|
|
9
|
-
|
|
10
|
-
coefficientElements(attackerPlayer: RpgPlayer): number;
|
|
11
|
-
hp: number;
|
|
12
|
-
getCurrentMap(): any;
|
|
15
|
+
getCurrentMap(): ReturnType<RpgPlayer['getCurrentMap']>;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* Provides battle management capabilities to any class. This mixin handles
|
|
19
|
-
* damage calculation, critical hits, elemental vulnerabilities, and guard effects.
|
|
20
|
-
* It implements a comprehensive battle system with customizable formulas and effects.
|
|
21
|
-
*
|
|
22
|
-
* @param Base - The base class to extend with battle management
|
|
23
|
-
* @returns Extended class with battle management methods
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* class MyPlayer extends WithBattleManager(BasePlayer) {
|
|
28
|
-
* constructor() {
|
|
29
|
-
* super();
|
|
30
|
-
* // Battle system is automatically initialized
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
*
|
|
34
|
-
* const player = new MyPlayer();
|
|
35
|
-
* const attacker = new MyPlayer();
|
|
36
|
-
* const result = player.applyDamage(attacker);
|
|
37
|
-
* console.log(`Damage dealt: ${result.damage}`);
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
41
|
-
return class extends Base {
|
|
42
|
-
/**
|
|
18
|
+
export interface IBattleManager {
|
|
19
|
+
/**
|
|
43
20
|
* Apply damage. Player will lose HP. the `attackerPlayer` parameter is the other player, the one who attacks.
|
|
44
21
|
*
|
|
45
22
|
* If you don't set the skill parameter, it will be a physical attack.
|
|
@@ -71,6 +48,17 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
71
48
|
* }
|
|
72
49
|
* ```
|
|
73
50
|
*/
|
|
51
|
+
applyDamage(attackerPlayer: RpgPlayer, skill?: any): {
|
|
52
|
+
damage: number;
|
|
53
|
+
critical: boolean;
|
|
54
|
+
elementVulnerable: boolean;
|
|
55
|
+
guard: boolean;
|
|
56
|
+
superGuard: boolean;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IBattleManager {
|
|
61
|
+
return class extends Base {
|
|
74
62
|
applyDamage(
|
|
75
63
|
attackerPlayer: RpgPlayer,
|
|
76
64
|
skill?: any
|
|
@@ -81,9 +69,10 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
81
69
|
guard: boolean;
|
|
82
70
|
superGuard: boolean;
|
|
83
71
|
} {
|
|
72
|
+
const self = this as unknown as PlayerWithMixins;
|
|
84
73
|
const getParam = (player: RpgPlayer) => {
|
|
85
74
|
const params = {};
|
|
86
|
-
(
|
|
75
|
+
Object.keys(self.parameters).forEach((key) => {
|
|
87
76
|
params[key] = (player as any).param[key];
|
|
88
77
|
});
|
|
89
78
|
return {
|
|
@@ -100,26 +89,25 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
100
89
|
let superGuard = false;
|
|
101
90
|
let elementVulnerable = false;
|
|
102
91
|
const paramA = getParam(attackerPlayer);
|
|
103
|
-
const paramB = getParam(
|
|
104
|
-
console.log(paramA, paramB)
|
|
92
|
+
const paramB = getParam(self as any);
|
|
105
93
|
if (skill) {
|
|
106
|
-
fn =
|
|
94
|
+
fn = self.getFormulas("damageSkill");
|
|
107
95
|
if (!fn) {
|
|
108
96
|
throw new Error("Skill Formulas not exists");
|
|
109
97
|
}
|
|
110
98
|
damage = fn(paramA, paramB, skill);
|
|
111
99
|
} else {
|
|
112
|
-
fn =
|
|
100
|
+
fn = self.getFormulas("damagePhysic");
|
|
113
101
|
if (!fn) {
|
|
114
102
|
throw new Error("Physic Formulas not exists");
|
|
115
103
|
}
|
|
116
104
|
damage = fn(paramA, paramB);
|
|
117
|
-
const coef =
|
|
105
|
+
const coef = self.coefficientElements(attackerPlayer);
|
|
118
106
|
if (coef >= 2) {
|
|
119
107
|
elementVulnerable = true;
|
|
120
108
|
}
|
|
121
109
|
damage *= coef;
|
|
122
|
-
fn =
|
|
110
|
+
fn = self.getFormulas("damageCritical");
|
|
123
111
|
if (fn) {
|
|
124
112
|
let newDamage = fn(damage, paramA, paramB);
|
|
125
113
|
if (damage != newDamage) {
|
|
@@ -128,8 +116,8 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
128
116
|
damage = newDamage;
|
|
129
117
|
}
|
|
130
118
|
}
|
|
131
|
-
if (
|
|
132
|
-
fn =
|
|
119
|
+
if (self.hasEffect(Effect.GUARD)) {
|
|
120
|
+
fn = self.getFormulas("damageGuard");
|
|
133
121
|
if (fn) {
|
|
134
122
|
let newDamage = fn(damage, paramA, paramB);
|
|
135
123
|
if (damage != newDamage) {
|
|
@@ -138,11 +126,11 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
138
126
|
damage = newDamage;
|
|
139
127
|
}
|
|
140
128
|
}
|
|
141
|
-
if (
|
|
129
|
+
if (self.hasEffect(Effect.SUPER_GUARD)) {
|
|
142
130
|
damage /= 4;
|
|
143
131
|
superGuard = true;
|
|
144
132
|
}
|
|
145
|
-
|
|
133
|
+
self.hp -= damage;
|
|
146
134
|
return {
|
|
147
135
|
damage,
|
|
148
136
|
critical,
|
|
@@ -179,14 +167,9 @@ export function WithBattleManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
179
167
|
* ```
|
|
180
168
|
*/
|
|
181
169
|
getFormulas(name: string) {
|
|
182
|
-
const
|
|
183
|
-
|
|
170
|
+
const self = this as unknown as PlayerWithMixins;
|
|
171
|
+
const map = self.getCurrentMap();
|
|
172
|
+
return map?.damageFormulas[name];
|
|
184
173
|
}
|
|
185
|
-
} as unknown as
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Type helper to extract the interface from the WithBattleManager mixin
|
|
190
|
-
* This provides the type without duplicating method signatures
|
|
191
|
-
*/
|
|
192
|
-
export type IBattleManager = InstanceType<ReturnType<typeof WithBattleManager>>;
|
|
174
|
+
} as unknown as any;
|
|
175
|
+
}
|
|
@@ -36,38 +36,6 @@ interface PlayerWithMixins extends RpgCommonPlayer {
|
|
|
36
36
|
*/
|
|
37
37
|
export function WithClassManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
38
38
|
return class extends Base {
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Assign a class to the player
|
|
42
|
-
*
|
|
43
|
-
* Sets the player's class, which defines their combat abilities, stat growth,
|
|
44
|
-
* and available skills. The class system provides the foundation for character
|
|
45
|
-
* progression and specialization. When a class is set, it automatically triggers
|
|
46
|
-
* the class's onSet method for any additional initialization.
|
|
47
|
-
*
|
|
48
|
-
* @param _class - The class constructor or class ID to assign to the player
|
|
49
|
-
* @returns The instantiated class object
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* import { Fighter } from 'my-database/classes/fighter'
|
|
54
|
-
*
|
|
55
|
-
* // Set class using constructor
|
|
56
|
-
* const fighterClass = player.setClass(Fighter);
|
|
57
|
-
* console.log('Class set:', fighterClass.name);
|
|
58
|
-
*
|
|
59
|
-
* // Set class using string ID
|
|
60
|
-
* player.setClass('fighter');
|
|
61
|
-
*
|
|
62
|
-
* // Class affects available skills and stats
|
|
63
|
-
* console.log('Available skills:', player.skills);
|
|
64
|
-
* console.log('Class bonuses applied to stats');
|
|
65
|
-
*
|
|
66
|
-
* // Class determines level progression
|
|
67
|
-
* player.level = 5;
|
|
68
|
-
* // Skills may be automatically learned based on class definition
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
39
|
setClass(_class: ClassClass | string) {
|
|
72
40
|
if (isString(_class)) _class = (this as any).databaseById(_class);
|
|
73
41
|
const classInstance = new (_class as ClassClass)();
|
|
@@ -75,42 +43,6 @@ export function WithClassManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
75
43
|
return classInstance;
|
|
76
44
|
}
|
|
77
45
|
|
|
78
|
-
/**
|
|
79
|
-
* Allows to give a set of already defined properties to the player (default equipment, or a list of skills to learn according to the level)
|
|
80
|
-
*
|
|
81
|
-
* Sets up the player as a specific actor archetype, which includes predefined
|
|
82
|
-
* characteristics like starting equipment, parameters, level ranges, and associated class.
|
|
83
|
-
* This is typically used for creating pre-configured character templates or NPCs
|
|
84
|
-
* with specific roles and equipment loadouts.
|
|
85
|
-
*
|
|
86
|
-
* @param actorClass - The actor constructor or actor ID to assign to the player
|
|
87
|
-
* @returns The instantiated actor object
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* import { Hero } from 'my-database/classes/hero'
|
|
92
|
-
*
|
|
93
|
-
* // Set up player as Hero actor
|
|
94
|
-
* const heroActor = player.setActor(Hero);
|
|
95
|
-
* console.log('Actor configured:', heroActor.name);
|
|
96
|
-
*
|
|
97
|
-
* // Actor automatically sets up:
|
|
98
|
-
* // - Starting equipment (sword, armor, etc.)
|
|
99
|
-
* console.log('Starting equipment:', player.equipments());
|
|
100
|
-
*
|
|
101
|
-
* // - Parameter ranges and growth
|
|
102
|
-
* console.log('Level range:', player.initialLevel, '-', player.finalLevel);
|
|
103
|
-
*
|
|
104
|
-
* // - Associated class
|
|
105
|
-
* console.log('Assigned class:', player.class);
|
|
106
|
-
*
|
|
107
|
-
* // - Experience curve
|
|
108
|
-
* console.log('EXP curve:', player.expCurve);
|
|
109
|
-
*
|
|
110
|
-
* // Actor setup is comprehensive
|
|
111
|
-
* player.setActor('hero'); // Can also use string ID
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
46
|
setActor(actorClass: ActorClass | string) {
|
|
115
47
|
if (isString(actorClass)) actorClass = (this as any).databaseById(actorClass);
|
|
116
48
|
const actor = new (actorClass as ActorClass)();
|
|
@@ -132,7 +64,25 @@ export function WithClassManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
132
64
|
}
|
|
133
65
|
|
|
134
66
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
67
|
+
* Interface for Class Manager functionality
|
|
68
|
+
*
|
|
69
|
+
* Provides class and actor management capabilities including character class assignment
|
|
70
|
+
* and actor setup. This interface defines the public API of the ClassManager mixin.
|
|
137
71
|
*/
|
|
138
|
-
export
|
|
72
|
+
export interface IClassManager {
|
|
73
|
+
/**
|
|
74
|
+
* Assign a class to the player
|
|
75
|
+
*
|
|
76
|
+
* @param _class - The class constructor or class ID to assign to the player
|
|
77
|
+
* @returns The instantiated class object
|
|
78
|
+
*/
|
|
79
|
+
setClass(_class: ClassClass | string): any;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Set up the player as a specific actor archetype
|
|
83
|
+
*
|
|
84
|
+
* @param actorClass - The actor constructor or actor ID to assign to the player
|
|
85
|
+
* @returns The instantiated actor object
|
|
86
|
+
*/
|
|
87
|
+
setActor(actorClass: ActorClass | string): any;
|
|
88
|
+
}
|
|
@@ -42,70 +42,10 @@ export enum Effect {
|
|
|
42
42
|
*/
|
|
43
43
|
export function WithEffectManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
44
44
|
return class extends Base {
|
|
45
|
-
/**
|
|
46
|
-
* Check if the player has a specific effect
|
|
47
|
-
*
|
|
48
|
-
* Determines whether the player currently has the specified effect active.
|
|
49
|
-
* This includes effects from states, equipment, and temporary conditions.
|
|
50
|
-
* The effect system provides a flexible way to apply various gameplay
|
|
51
|
-
* restrictions and enhancements to the player.
|
|
52
|
-
*
|
|
53
|
-
* @param effect - The effect identifier to check for
|
|
54
|
-
* @returns true if the player has the effect, false otherwise
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* import { Effect } from '@rpgjs/database'
|
|
59
|
-
*
|
|
60
|
-
* // Check for skill restriction
|
|
61
|
-
* const cannotUseSkills = player.hasEffect(Effect.CAN_NOT_SKILL);
|
|
62
|
-
* if (cannotUseSkills) {
|
|
63
|
-
* console.log('Player cannot use skills right now');
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* // Check for guard effect
|
|
67
|
-
* const isGuarding = player.hasEffect(Effect.GUARD);
|
|
68
|
-
* if (isGuarding) {
|
|
69
|
-
* console.log('Player is in guard stance');
|
|
70
|
-
* }
|
|
71
|
-
*
|
|
72
|
-
* // Check for cost reduction
|
|
73
|
-
* const halfCost = player.hasEffect(Effect.HALF_SP_COST);
|
|
74
|
-
* const actualCost = skillCost / (halfCost ? 2 : 1);
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
45
|
hasEffect(effect: string): boolean {
|
|
78
46
|
return this.effects.includes(effect);
|
|
79
47
|
}
|
|
80
48
|
|
|
81
|
-
/**
|
|
82
|
-
* Retrieves a array of effects assigned to the player, state effects and effects of weapons and armors equipped with the player's own weapons.
|
|
83
|
-
*
|
|
84
|
-
* Gets all currently active effects on the player from multiple sources:
|
|
85
|
-
* - Direct effects assigned to the player
|
|
86
|
-
* - Effects from active states (buffs/debuffs)
|
|
87
|
-
* - Effects from equipped weapons and armor
|
|
88
|
-
* The returned array contains unique effects without duplicates.
|
|
89
|
-
*
|
|
90
|
-
* @returns Array of all active effects on the player
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* // Get all active effects
|
|
95
|
-
* console.log(player.effects); // ['GUARD', 'HALF_SP_COST', ...]
|
|
96
|
-
*
|
|
97
|
-
* // Check multiple effects
|
|
98
|
-
* const effects = player.effects;
|
|
99
|
-
* const hasRestrictions = effects.some(effect =>
|
|
100
|
-
* effect.startsWith('CAN_NOT_')
|
|
101
|
-
* );
|
|
102
|
-
*
|
|
103
|
-
* // Count beneficial effects
|
|
104
|
-
* const beneficialEffects = effects.filter(effect =>
|
|
105
|
-
* ['GUARD', 'SUPER_GUARD', 'HALF_SP_COST'].includes(effect)
|
|
106
|
-
* );
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
49
|
get effects(): any[] {
|
|
110
50
|
const getEffects = (prop) => {
|
|
111
51
|
return arrayFlat(this[prop]().map((el) => el.effects || []));
|
|
@@ -117,39 +57,6 @@ export function WithEffectManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
117
57
|
]);
|
|
118
58
|
}
|
|
119
59
|
|
|
120
|
-
/**
|
|
121
|
-
* Assigns effects to the player. If you give a array, it does not change the effects of the player's states and armor/weapons equipped.
|
|
122
|
-
*
|
|
123
|
-
* Sets the direct effects on the player. This only affects the player's own effects
|
|
124
|
-
* and does not modify effects from states or equipment. The total effects will be
|
|
125
|
-
* the combination of these direct effects plus any effects from states and equipment.
|
|
126
|
-
*
|
|
127
|
-
* @param val - Array of effect identifiers to assign to the player
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```ts
|
|
131
|
-
* import { Effect } from '@rpgjs/database'
|
|
132
|
-
*
|
|
133
|
-
* // Set direct player effects
|
|
134
|
-
* player.effects = [Effect.CAN_NOT_SKILL];
|
|
135
|
-
*
|
|
136
|
-
* // Add multiple effects
|
|
137
|
-
* player.effects = [
|
|
138
|
-
* Effect.GUARD,
|
|
139
|
-
* Effect.HALF_SP_COST,
|
|
140
|
-
* Effect.CAN_NOT_ITEM
|
|
141
|
-
* ];
|
|
142
|
-
*
|
|
143
|
-
* // Clear direct effects (equipment/state effects remain)
|
|
144
|
-
* player.effects = [];
|
|
145
|
-
*
|
|
146
|
-
* // Temporary effect application
|
|
147
|
-
* const originalEffects = player.effects;
|
|
148
|
-
* player.effects = [...originalEffects, Effect.SUPER_GUARD];
|
|
149
|
-
* // Later restore
|
|
150
|
-
* player.effects = originalEffects;
|
|
151
|
-
* ```
|
|
152
|
-
*/
|
|
153
60
|
set effects(val) {
|
|
154
61
|
this._effects.set(val);
|
|
155
62
|
}
|
|
@@ -157,7 +64,54 @@ export function WithEffectManager<TBase extends PlayerCtor>(Base: TBase) {
|
|
|
157
64
|
}
|
|
158
65
|
|
|
159
66
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
67
|
+
* Interface for Effect Manager functionality
|
|
68
|
+
*
|
|
69
|
+
* Provides effect management capabilities including restrictions, buffs, and debuffs.
|
|
70
|
+
* This interface defines the public API of the EffectManager mixin.
|
|
162
71
|
*/
|
|
163
|
-
export
|
|
72
|
+
export interface IEffectManager {
|
|
73
|
+
/**
|
|
74
|
+
* Gets all currently active effects on the player from multiple sources:
|
|
75
|
+
* - Direct effects assigned to the player
|
|
76
|
+
* - Effects from active states (buffs/debuffs)
|
|
77
|
+
* - Effects from equipped weapons and armor
|
|
78
|
+
* The returned array contains unique effects without duplicates.
|
|
79
|
+
*
|
|
80
|
+
* @returns Array of all active effects on the player
|
|
81
|
+
*/
|
|
82
|
+
effects: any[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Check if the player has a specific effect
|
|
86
|
+
*
|
|
87
|
+
* Determines whether the player currently has the specified effect active.
|
|
88
|
+
* This includes effects from states, equipment, and temporary conditions.
|
|
89
|
+
* The effect system provides a flexible way to apply various gameplay
|
|
90
|
+
* restrictions and enhancements to the player.
|
|
91
|
+
*
|
|
92
|
+
* @param effect - The effect identifier to check for
|
|
93
|
+
* @returns true if the player has the effect, false otherwise
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { Effect } from '@rpgjs/database'
|
|
98
|
+
*
|
|
99
|
+
* // Check for skill restriction
|
|
100
|
+
* const cannotUseSkills = player.hasEffect(Effect.CAN_NOT_SKILL);
|
|
101
|
+
* if (cannotUseSkills) {
|
|
102
|
+
* console.log('Player cannot use skills right now');
|
|
103
|
+
* }
|
|
104
|
+
*
|
|
105
|
+
* // Check for guard effect
|
|
106
|
+
* const isGuarding = player.hasEffect(Effect.GUARD);
|
|
107
|
+
* if (isGuarding) {
|
|
108
|
+
* console.log('Player is in guard stance');
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* // Check for cost reduction
|
|
112
|
+
* const halfCost = player.hasEffect(Effect.HALF_SP_COST);
|
|
113
|
+
* const actualCost = skillCost / (halfCost ? 2 : 1);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
hasEffect(effect: string): boolean;
|
|
117
|
+
}
|