@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/src/RpgServer.ts
CHANGED
|
@@ -227,251 +227,20 @@ export interface RpgPlayerHooks {
|
|
|
227
227
|
canChangeMap?: (player: RpgPlayer, nextMap: RpgClassMap<RpgMap>) => boolean | Promise<boolean>
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
/**
|
|
231
|
-
* Event hooks interface for handling various event lifecycle methods
|
|
232
|
-
*
|
|
233
|
-
* @interface RpgEventHooks
|
|
234
|
-
* @since 4.0.0
|
|
235
|
-
*/
|
|
236
230
|
export interface RpgEventHooks {
|
|
237
|
-
/**
|
|
238
|
-
* Called as soon as the event is created on the map
|
|
239
|
-
*
|
|
240
|
-
* @param {RpgEvent} event - The event instance being initialized
|
|
241
|
-
* @returns {any}
|
|
242
|
-
* @memberof RpgEventHooks
|
|
243
|
-
* @example
|
|
244
|
-
* ```ts
|
|
245
|
-
* const eventHooks: RpgEventHooks = {
|
|
246
|
-
* onInit(event) {
|
|
247
|
-
* console.log(`Event ${event.name} initialized`)
|
|
248
|
-
* event.graphic('default-sprite')
|
|
249
|
-
* }
|
|
250
|
-
* }
|
|
251
|
-
* ```
|
|
252
|
-
*/
|
|
253
231
|
onInit?: (event: RpgEvent) => any,
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Called when the event collides with a player and the player presses the action key
|
|
257
|
-
*
|
|
258
|
-
* @param {RpgEvent} event - The event being interacted with
|
|
259
|
-
* @param {RpgPlayer} player - The player performing the action
|
|
260
|
-
* @returns {any}
|
|
261
|
-
* @memberof RpgEventHooks
|
|
262
|
-
* @example
|
|
263
|
-
* ```ts
|
|
264
|
-
* const eventHooks: RpgEventHooks = {
|
|
265
|
-
* onAction(event, player) {
|
|
266
|
-
* player.showText('You activated the chest!')
|
|
267
|
-
* player.addItem('POTION', 1)
|
|
268
|
-
* }
|
|
269
|
-
* }
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
232
|
onAction?: (event: RpgEvent, player: RpgPlayer) => any
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Called before an event object is created and added to the map
|
|
276
|
-
* Allows modification of event properties before instantiation
|
|
277
|
-
*
|
|
278
|
-
* @param {any} object - The event object data before creation
|
|
279
|
-
* @param {RpgMap} map - The map where the event will be created
|
|
280
|
-
* @returns {any}
|
|
281
|
-
* @memberof RpgEventHooks
|
|
282
|
-
* @example
|
|
283
|
-
* ```ts
|
|
284
|
-
* const eventHooks: RpgEventHooks = {
|
|
285
|
-
* onBeforeCreated(object, map) {
|
|
286
|
-
* // Modify event properties based on map conditions
|
|
287
|
-
* if (map.id === 'dungeon') {
|
|
288
|
-
* object.graphic = 'monster-sprite'
|
|
289
|
-
* }
|
|
290
|
-
* }
|
|
291
|
-
* }
|
|
292
|
-
* ```
|
|
293
|
-
*/
|
|
294
233
|
onBeforeCreated?: (object: any, map: RpgMap) => any
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Called when a player or another event enters a shape attached to this event
|
|
298
|
-
*
|
|
299
|
-
* @param {RpgEvent} event - The event with the attached shape
|
|
300
|
-
* @param {RpgPlayer} player - The player entering the shape
|
|
301
|
-
* @param {RpgShape} shape - The shape being entered
|
|
302
|
-
* @returns {any}
|
|
303
|
-
* @since 4.1.0
|
|
304
|
-
* @memberof RpgEventHooks
|
|
305
|
-
* @example
|
|
306
|
-
* ```ts
|
|
307
|
-
* const eventHooks: RpgEventHooks = {
|
|
308
|
-
* onDetectInShape(event, player, shape) {
|
|
309
|
-
* console.log(`Player ${player.name} entered detection zone`)
|
|
310
|
-
* player.showText('You are being watched...')
|
|
311
|
-
* }
|
|
312
|
-
* }
|
|
313
|
-
* ```
|
|
314
|
-
*/
|
|
315
234
|
onDetectInShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Called when a player or another event leaves a shape attached to this event
|
|
319
|
-
*
|
|
320
|
-
* @param {RpgEvent} event - The event with the attached shape
|
|
321
|
-
* @param {RpgPlayer} player - The player leaving the shape
|
|
322
|
-
* @param {RpgShape} shape - The shape being left
|
|
323
|
-
* @returns {any}
|
|
324
|
-
* @since 4.1.0
|
|
325
|
-
* @memberof RpgEventHooks
|
|
326
|
-
* @example
|
|
327
|
-
* ```ts
|
|
328
|
-
* const eventHooks: RpgEventHooks = {
|
|
329
|
-
* onDetectOutShape(event, player, shape) {
|
|
330
|
-
* console.log(`Player ${player.name} left detection zone`)
|
|
331
|
-
* player.showText('You escaped the watch...')
|
|
332
|
-
* }
|
|
333
|
-
* }
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
235
|
onDetectOutShape?: (event: RpgEvent, player: RpgPlayer, shape: RpgShape) => any
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Called when the event enters a shape on the map
|
|
340
|
-
*
|
|
341
|
-
* @param {RpgEvent} event - The event entering the shape
|
|
342
|
-
* @param {RpgShape} shape - The shape being entered
|
|
343
|
-
* @returns {any}
|
|
344
|
-
* @memberof RpgEventHooks
|
|
345
|
-
* @example
|
|
346
|
-
* ```ts
|
|
347
|
-
* const eventHooks: RpgEventHooks = {
|
|
348
|
-
* onInShape(event, shape) {
|
|
349
|
-
* console.log(`Event entered shape: ${shape.id}`)
|
|
350
|
-
* event.speed = 1 // Slow down in this area
|
|
351
|
-
* }
|
|
352
|
-
* }
|
|
353
|
-
* ```
|
|
354
|
-
*/
|
|
355
236
|
onInShape?: (event: RpgEvent, shape: RpgShape) => any
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Called when the event leaves a shape on the map
|
|
359
|
-
*
|
|
360
|
-
* @param {RpgEvent} event - The event leaving the shape
|
|
361
|
-
* @param {RpgShape} shape - The shape being left
|
|
362
|
-
* @returns {any}
|
|
363
|
-
* @memberof RpgEventHooks
|
|
364
|
-
* @example
|
|
365
|
-
* ```ts
|
|
366
|
-
* const eventHooks: RpgEventHooks = {
|
|
367
|
-
* onOutShape(event, shape) {
|
|
368
|
-
* console.log(`Event left shape: ${shape.id}`)
|
|
369
|
-
* event.speed = 3 // Resume normal speed
|
|
370
|
-
* }
|
|
371
|
-
* }
|
|
372
|
-
* ```
|
|
373
|
-
*/
|
|
374
237
|
onOutShape?: (event: RpgEvent, shape: RpgShape) => any
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Called when the event collides with a player (without requiring action key press)
|
|
378
|
-
*
|
|
379
|
-
* @param {RpgEvent} event - The event touching the player
|
|
380
|
-
* @param {RpgPlayer} player - The player being touched
|
|
381
|
-
* @returns {any}
|
|
382
|
-
* @memberof RpgEventHooks
|
|
383
|
-
* @example
|
|
384
|
-
* ```ts
|
|
385
|
-
* const eventHooks: RpgEventHooks = {
|
|
386
|
-
* onPlayerTouch(event, player) {
|
|
387
|
-
* player.hp -= 10 // Damage on touch
|
|
388
|
-
* player.showText('Ouch! You touched a spike!')
|
|
389
|
-
* }
|
|
390
|
-
* }
|
|
391
|
-
* ```
|
|
392
|
-
*/
|
|
393
238
|
onPlayerTouch?: (event: RpgEvent, player: RpgPlayer) => any
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Called whenever any event on the map (including itself) is executed or changes state
|
|
397
|
-
* Useful for creating reactive events that respond to map state changes
|
|
398
|
-
*
|
|
399
|
-
* @param {RpgEvent} event - The event listening for changes
|
|
400
|
-
* @param {RpgPlayer} player - The player involved in the change
|
|
401
|
-
* @returns {any}
|
|
402
|
-
* @memberof RpgEventHooks
|
|
403
|
-
* @example
|
|
404
|
-
* ```ts
|
|
405
|
-
* const eventHooks: RpgEventHooks = {
|
|
406
|
-
* onChanges(event, player) {
|
|
407
|
-
* // Change chest graphic based on game state
|
|
408
|
-
* if (player.getVariable('BATTLE_END')) {
|
|
409
|
-
* event.graphic('chest-open')
|
|
410
|
-
* } else {
|
|
411
|
-
* event.graphic('chest-close')
|
|
412
|
-
* }
|
|
413
|
-
* }
|
|
414
|
-
* }
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
239
|
onChanges?: (event: RpgEvent, player: RpgPlayer) => any
|
|
418
240
|
}
|
|
419
241
|
|
|
420
|
-
/**
|
|
421
|
-
* Map hooks interface for handling map lifecycle events
|
|
422
|
-
*
|
|
423
|
-
* @interface RpgMapHooks
|
|
424
|
-
* @since 4.0.0
|
|
425
|
-
*/
|
|
426
242
|
export interface RpgMapHooks {
|
|
427
|
-
|
|
428
|
-
* Called before a map is updated with new data
|
|
429
|
-
* Allows modification of map data before the update is applied
|
|
430
|
-
*
|
|
431
|
-
* The `mapData` parameter contains the loaded map data (retrieved from request body)
|
|
432
|
-
* You can modify the map before the update is processed
|
|
433
|
-
*
|
|
434
|
-
* @template T - Type of the incoming map data
|
|
435
|
-
* @template U - Type of the map instance (defaults to RpgMap)
|
|
436
|
-
* @param {T} mapData - The map data loaded from external source (e.g., request body)
|
|
437
|
-
* @param {U} map - The current map instance being updated
|
|
438
|
-
* @returns {U | Promise<U>} The modified map instance or a promise resolving to it
|
|
439
|
-
* @memberof RpgMapHooks
|
|
440
|
-
* @example
|
|
441
|
-
* ```ts
|
|
442
|
-
* const mapHooks: RpgMapHooks = {
|
|
443
|
-
* onBeforeUpdate(mapData, map) {
|
|
444
|
-
* // Modify map properties based on incoming data
|
|
445
|
-
* if (mapData.weather === 'rain') {
|
|
446
|
-
* map.setWeatherEffect('rain')
|
|
447
|
-
* }
|
|
448
|
-
*
|
|
449
|
-
* // Add custom properties from external data
|
|
450
|
-
* map.customProperty = mapData.customValue
|
|
451
|
-
*
|
|
452
|
-
* return map
|
|
453
|
-
* }
|
|
454
|
-
* }
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* @example
|
|
458
|
-
* ```ts
|
|
459
|
-
* // Async example with database operations
|
|
460
|
-
* const mapHooks: RpgMapHooks = {
|
|
461
|
-
* async onBeforeUpdate(mapData, map) {
|
|
462
|
-
* // Load additional data from database
|
|
463
|
-
* const additionalData = await database.getMapExtras(map.id)
|
|
464
|
-
*
|
|
465
|
-
* // Apply modifications
|
|
466
|
-
* map.events = [...map.events, ...additionalData.events]
|
|
467
|
-
* map.npcs = additionalData.npcs
|
|
468
|
-
*
|
|
469
|
-
* return map
|
|
470
|
-
* }
|
|
471
|
-
* }
|
|
472
|
-
* ```
|
|
473
|
-
*/
|
|
474
|
-
onBeforeUpdate<T, U = RpgMap>(mapData: T, map: U): U | Promise<U>
|
|
243
|
+
onBeforeUpdate<T = RpgMap>(mapData: any, map: T): T
|
|
475
244
|
}
|
|
476
245
|
|
|
477
246
|
export interface RpgServer {
|
package/src/core/context.ts
CHANGED
package/src/rooms/map.ts
CHANGED
|
@@ -220,7 +220,6 @@ export class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoin {
|
|
|
220
220
|
})
|
|
221
221
|
|
|
222
222
|
const { x, y, event } = eventObj;
|
|
223
|
-
|
|
224
223
|
let id = eventObj.id || generateShortUUID()
|
|
225
224
|
let eventInstance: RpgPlayer;
|
|
226
225
|
|
|
@@ -292,83 +291,16 @@ export class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoin {
|
|
|
292
291
|
delete this.events()[eventId]
|
|
293
292
|
}
|
|
294
293
|
|
|
295
|
-
|
|
296
|
-
* Display a component animation at a specific position on the map
|
|
297
|
-
*
|
|
298
|
-
* This method broadcasts a component animation to all clients connected to the map,
|
|
299
|
-
* allowing temporary visual effects to be displayed at any location on the map.
|
|
300
|
-
* Component animations are custom Canvas Engine components that can display
|
|
301
|
-
* complex effects with custom logic and parameters.
|
|
302
|
-
*
|
|
303
|
-
* @param id - The ID of the component animation to display
|
|
304
|
-
* @param position - The x, y coordinates where to display the animation
|
|
305
|
-
* @param params - Parameters to pass to the component animation
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* ```ts
|
|
309
|
-
* // Show explosion at specific coordinates
|
|
310
|
-
* map.showComponentAnimation("explosion", { x: 300, y: 400 }, {
|
|
311
|
-
* intensity: 2.5,
|
|
312
|
-
* duration: 1500
|
|
313
|
-
* });
|
|
314
|
-
*
|
|
315
|
-
* // Show area damage effect
|
|
316
|
-
* map.showComponentAnimation("area-damage", { x: player.x, y: player.y }, {
|
|
317
|
-
* radius: 100,
|
|
318
|
-
* color: "red",
|
|
319
|
-
* damage: 50
|
|
320
|
-
* });
|
|
321
|
-
*
|
|
322
|
-
* // Show treasure spawn effect
|
|
323
|
-
* map.showComponentAnimation("treasure-spawn", { x: 150, y: 200 }, {
|
|
324
|
-
* sparkle: true,
|
|
325
|
-
* sound: "treasure-appear"
|
|
326
|
-
* });
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
showComponentAnimation(id: string, position: { x: number, y: number }, params: any) {
|
|
294
|
+
showAnimation(animationName: string, object: RpgPlayer) {
|
|
330
295
|
this.$broadcast({
|
|
331
|
-
type:
|
|
296
|
+
type: 'showEffect',
|
|
332
297
|
value: {
|
|
333
|
-
id,
|
|
334
|
-
params
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Display a spritesheet animation at a specific position on the map
|
|
342
|
-
*
|
|
343
|
-
* This method displays a temporary visual animation using a spritesheet at any
|
|
344
|
-
* location on the map. It's a convenience method that internally uses showComponentAnimation
|
|
345
|
-
* with the built-in 'animation' component. This is useful for spell effects, environmental
|
|
346
|
-
* animations, or any visual feedback that uses predefined spritesheets.
|
|
347
|
-
*
|
|
348
|
-
* @param position - The x, y coordinates where to display the animation
|
|
349
|
-
* @param graphic - The ID of the spritesheet to use for the animation
|
|
350
|
-
* @param animationName - The name of the animation within the spritesheet (default: 'default')
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```ts
|
|
354
|
-
* // Show explosion at specific coordinates
|
|
355
|
-
* map.showAnimation({ x: 100, y: 200 }, "explosion");
|
|
356
|
-
*
|
|
357
|
-
* // Show spell effect at player position
|
|
358
|
-
* const playerPos = { x: player.x, y: player.y };
|
|
359
|
-
* map.showAnimation(playerPos, "spell-effects", "lightning");
|
|
360
|
-
*
|
|
361
|
-
* // Show environmental effect
|
|
362
|
-
* map.showAnimation({ x: 300, y: 150 }, "nature-effects", "wind-gust");
|
|
363
|
-
*
|
|
364
|
-
* // Show portal opening animation
|
|
365
|
-
* map.showAnimation({ x: 500, y: 400 }, "portals", "opening");
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
showAnimation(position: { x: number, y: number }, graphic: string, animationName: string = 'default') {
|
|
369
|
-
this.showComponentAnimation('animation', position, {
|
|
370
|
-
graphic,
|
|
371
|
-
animationName,
|
|
298
|
+
id: 'animation',
|
|
299
|
+
params: {
|
|
300
|
+
name: animationName
|
|
301
|
+
},
|
|
302
|
+
object: object.id
|
|
303
|
+
}
|
|
372
304
|
})
|
|
373
305
|
}
|
|
374
306
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,31 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,22 +0,0 @@
|
|
|
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>>;
|
|
@@ -1,176 +0,0 @@
|
|
|
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
|
-
}
|