@rpgjs/server 5.0.0-beta.2 → 5.0.0-beta.4
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/SkillManager.d.ts +13 -4
- package/dist/RpgServer.d.ts +8 -0
- package/dist/index.js +337 -885
- package/dist/index.js.map +1 -1
- package/dist/{module-CaCW1SDh.js → module-BmvXIvlE.js} +97 -69
- package/dist/{module-CaCW1SDh.js.map → module-BmvXIvlE.js.map} +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +6 -6
- package/src/Gui/MenuGui.ts +30 -20
- package/src/Player/ParameterManager.ts +4 -1
- package/src/Player/Player.ts +2 -0
- package/src/Player/SkillManager.ts +42 -5
- package/src/RpgServer.ts +9 -0
- package/src/rooms/lobby.ts +6 -1
- package/src/rooms/map.ts +17 -0
- package/tests/gui.spec.ts +76 -0
- package/tests/skill.spec.ts +48 -0
|
@@ -3,9 +3,19 @@ import { RpgPlayer } from './Player';
|
|
|
3
3
|
/**
|
|
4
4
|
* Type for skill class constructor
|
|
5
5
|
*/
|
|
6
|
-
type SkillClass = {
|
|
6
|
+
export type SkillClass = {
|
|
7
7
|
new (...args: any[]): any;
|
|
8
8
|
};
|
|
9
|
+
export type SkillChangeAction = "learn" | "forget";
|
|
10
|
+
export interface SkillChangeOptions {
|
|
11
|
+
source?: "manual" | "level" | "class" | "studio" | string;
|
|
12
|
+
level?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SkillChangePayload extends SkillChangeOptions {
|
|
15
|
+
action: SkillChangeAction;
|
|
16
|
+
skill: SkillClass | SkillObject | string;
|
|
17
|
+
skillId: string;
|
|
18
|
+
}
|
|
9
19
|
/**
|
|
10
20
|
* Interface defining the hooks that can be implemented on skill classes or objects
|
|
11
21
|
*
|
|
@@ -180,7 +190,7 @@ export interface ISkillManager {
|
|
|
180
190
|
* @returns The learned skill data
|
|
181
191
|
* @throws SkillLog.alreadyLearned if the player already knows the skill
|
|
182
192
|
*/
|
|
183
|
-
learnSkill(skillInput: SkillClass | SkillObject | string): any;
|
|
193
|
+
learnSkill(skillInput: SkillClass | SkillObject | string, options?: SkillChangeOptions): any;
|
|
184
194
|
/**
|
|
185
195
|
* Forget a skill
|
|
186
196
|
*
|
|
@@ -188,7 +198,7 @@ export interface ISkillManager {
|
|
|
188
198
|
* @returns The forgotten skill data
|
|
189
199
|
* @throws SkillLog.notLearned if trying to forget a skill not learned
|
|
190
200
|
*/
|
|
191
|
-
forgetSkill(skillInput: SkillClass | SkillObject | string): any;
|
|
201
|
+
forgetSkill(skillInput: SkillClass | SkillObject | string, options?: SkillChangeOptions): any;
|
|
192
202
|
/**
|
|
193
203
|
* Use a skill
|
|
194
204
|
*
|
|
@@ -202,4 +212,3 @@ export interface ISkillManager {
|
|
|
202
212
|
*/
|
|
203
213
|
useSkill(skillInput: SkillClass | SkillObject | string, otherPlayer?: RpgPlayer | RpgPlayer[]): any;
|
|
204
214
|
}
|
|
205
|
-
export {};
|
package/dist/RpgServer.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RpgPlayer, RpgEvent } from './Player/Player';
|
|
|
3
3
|
import { RpgMap } from './rooms/map';
|
|
4
4
|
import { RpgServerEngine } from './RpgServerEngine';
|
|
5
5
|
import { WorldMapConfig, RpgShape, MapPhysicsInitContext, MapPhysicsEntityContext } from '../../common/src';
|
|
6
|
+
import { SkillChangePayload } from './Player/SkillManager';
|
|
6
7
|
type RpgClassMap<T> = new () => T;
|
|
7
8
|
type RpgClassEvent<T> = RpgEvent;
|
|
8
9
|
type MatchMakerOption = any;
|
|
@@ -196,6 +197,13 @@ export interface RpgPlayerHooks {
|
|
|
196
197
|
*/
|
|
197
198
|
onLevelUp?: (player: RpgPlayer, nbLevel: number) => any;
|
|
198
199
|
/**
|
|
200
|
+
* When a player learns or forgets a skill
|
|
201
|
+
*
|
|
202
|
+
* @prop { (player: RpgPlayer, payload: SkillChangePayload) => any } [onSkillChange]
|
|
203
|
+
* @memberof RpgPlayerHooks
|
|
204
|
+
*/
|
|
205
|
+
onSkillChange?: (player: RpgPlayer, payload: SkillChangePayload) => any;
|
|
206
|
+
/**
|
|
199
207
|
* When the player's HP drops to 0
|
|
200
208
|
*
|
|
201
209
|
* @prop { (player: RpgPlayer) => any } [onDead]
|