@rpgjs/server 5.0.0-alpha.27 → 5.0.0-alpha.29
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/MoveManager.d.ts +115 -50
- package/dist/Player/Player.d.ts +43 -19
- package/dist/Player/SkillManager.d.ts +157 -22
- package/dist/index.js +1007 -197
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/Player/MoveManager.ts +659 -213
- package/src/Player/Player.ts +89 -20
- package/src/Player/SkillManager.ts +401 -73
- package/src/rooms/map.ts +18 -0
- package/tests/battle.spec.ts +375 -0
- package/tests/class.spec.ts +274 -0
- package/tests/effect.spec.ts +219 -0
- package/tests/element.spec.ts +221 -0
- package/tests/gold.spec.ts +99 -0
- package/tests/skill.spec.ts +658 -0
- package/tests/state.spec.ts +467 -0
- package/tests/variable.spec.ts +185 -0
package/src/Player/Player.ts
CHANGED
|
@@ -416,36 +416,94 @@ export class RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
416
416
|
return dataLoaded
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
|
|
419
420
|
/**
|
|
421
|
+
* @deprecated Use setGraphicAnimation instead.
|
|
422
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
423
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
424
|
+
*/
|
|
425
|
+
setAnimation(animationName: string, nbTimes: number = Infinity) {
|
|
426
|
+
console.warn('setAnimation is deprecated. Use setGraphicAnimation instead.');
|
|
427
|
+
this.setGraphicAnimation(animationName, nbTimes);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @deprecated Use setGraphicAnimation instead.
|
|
432
|
+
* @param graphic - The graphic to use for the animation (e.g., 'attack', 'skill', 'walk')
|
|
433
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
434
|
+
* @param replaceGraphic - Whether to replace the player's graphic (default: false)
|
|
435
|
+
*/
|
|
436
|
+
showAnimation(graphic: string, animationName: string, replaceGraphic: boolean = false) {
|
|
437
|
+
if (replaceGraphic) {
|
|
438
|
+
console.warn('showAnimation is deprecated. Use player.setGraphicAnimation instead.');
|
|
439
|
+
this.setGraphicAnimation(animationName, graphic);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
console.warn('showAnimation is deprecated. Use map.showAnimation instead.');
|
|
443
|
+
const map = this.getCurrentMap();
|
|
444
|
+
map?.showAnimation({ x: this.x(), y: this.y() }, graphic, animationName);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
420
449
|
* Set the current animation of the player's sprite
|
|
421
|
-
*
|
|
450
|
+
*
|
|
422
451
|
* This method changes the animation state of the player's current sprite.
|
|
423
452
|
* It's used to trigger character animations like attack, skill, or custom movements.
|
|
424
453
|
* When `nbTimes` is set to a finite number, the animation will play that many times
|
|
425
454
|
* before returning to the previous animation state.
|
|
426
|
-
*
|
|
455
|
+
*
|
|
456
|
+
* If `animationFixed` is true, this method will not change the animation.
|
|
457
|
+
*
|
|
427
458
|
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
428
459
|
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
429
|
-
*
|
|
430
|
-
* @example
|
|
431
|
-
* ```ts
|
|
432
|
-
* // Set continuous walk animation
|
|
433
|
-
* player.setAnimation('walk');
|
|
434
|
-
*
|
|
435
|
-
* // Play attack animation 3 times then return to previous state
|
|
436
|
-
* player.setAnimation('attack', 3);
|
|
437
|
-
*
|
|
438
|
-
* // Play skill animation once
|
|
439
|
-
* player.setAnimation('skill', 1);
|
|
440
|
-
*
|
|
441
|
-
* // Set idle/stand animation
|
|
442
|
-
* player.setAnimation('stand');
|
|
443
|
-
* ```
|
|
444
460
|
*/
|
|
445
|
-
|
|
461
|
+
setGraphicAnimation(animationName: string, nbTimes: number): void;
|
|
462
|
+
/**
|
|
463
|
+
* Set the current animation of the player's sprite with a temporary graphic change
|
|
464
|
+
*
|
|
465
|
+
* This method changes the animation state of the player's current sprite and temporarily
|
|
466
|
+
* changes the player's graphic (sprite sheet) during the animation. The graphic is
|
|
467
|
+
* automatically reset when the animation finishes.
|
|
468
|
+
*
|
|
469
|
+
* When `nbTimes` is set to a finite number, the animation will play that many times
|
|
470
|
+
* before returning to the previous animation state and graphic.
|
|
471
|
+
*
|
|
472
|
+
* If `animationFixed` is true, this method will not change the animation.
|
|
473
|
+
*
|
|
474
|
+
* @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
|
|
475
|
+
* @param graphic - The graphic(s) to temporarily use during the animation
|
|
476
|
+
* @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
|
|
477
|
+
*/
|
|
478
|
+
setGraphicAnimation(animationName: string, graphic: string | string[], nbTimes: number): void;
|
|
479
|
+
setGraphicAnimation(animationName: string, graphic: string | string[]): void;
|
|
480
|
+
setGraphicAnimation(animationName: string, graphicOrNbTimes?: string | string[] | number, nbTimes: number = 1): void {
|
|
481
|
+
// Don't change animation if it's locked
|
|
482
|
+
if (this.animationFixed) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
let graphic: string | string[] | undefined;
|
|
487
|
+
let finalNbTimes: number = Infinity;
|
|
488
|
+
|
|
489
|
+
// Handle overloads
|
|
490
|
+
if (typeof graphicOrNbTimes === 'number') {
|
|
491
|
+
// setGraphicAnimation(animationName, nbTimes)
|
|
492
|
+
finalNbTimes = graphicOrNbTimes;
|
|
493
|
+
} else if (graphicOrNbTimes !== undefined) {
|
|
494
|
+
// setGraphicAnimation(animationName, graphic, nbTimes)
|
|
495
|
+
graphic = graphicOrNbTimes;
|
|
496
|
+
finalNbTimes = nbTimes ?? Infinity;
|
|
497
|
+
} else {
|
|
498
|
+
// setGraphicAnimation(animationName) - nbTimes remains Infinity
|
|
499
|
+
finalNbTimes = Infinity;
|
|
500
|
+
}
|
|
501
|
+
|
|
446
502
|
const map = this.getCurrentMap();
|
|
447
503
|
if (!map) return;
|
|
448
|
-
|
|
504
|
+
|
|
505
|
+
if (finalNbTimes === Infinity) {
|
|
506
|
+
if (graphic) this.setGraphic(graphic);
|
|
449
507
|
this.animationName.set(animationName);
|
|
450
508
|
}
|
|
451
509
|
else {
|
|
@@ -453,7 +511,8 @@ export class RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
453
511
|
type: "setAnimation",
|
|
454
512
|
value: {
|
|
455
513
|
animationName,
|
|
456
|
-
|
|
514
|
+
graphic,
|
|
515
|
+
nbTimes: finalNbTimes,
|
|
457
516
|
object: this.id,
|
|
458
517
|
},
|
|
459
518
|
});
|
|
@@ -1134,9 +1193,19 @@ export class RpgEvent extends RpgPlayer {
|
|
|
1134
1193
|
return ret;
|
|
1135
1194
|
}
|
|
1136
1195
|
|
|
1196
|
+
/**
|
|
1197
|
+
* Remove this event from the map
|
|
1198
|
+
*
|
|
1199
|
+
* Stops all movements before removing to prevent "unable to resolve entity" errors
|
|
1200
|
+
* from the MovementManager when the entity is destroyed while moving.
|
|
1201
|
+
*/
|
|
1137
1202
|
remove() {
|
|
1138
1203
|
const map = this.getCurrentMap();
|
|
1139
1204
|
if (!map) return;
|
|
1205
|
+
|
|
1206
|
+
// Stop all movements before removing to prevent MovementManager errors
|
|
1207
|
+
this.stopMoveTo();
|
|
1208
|
+
|
|
1140
1209
|
map.removeEvent(this.id);
|
|
1141
1210
|
}
|
|
1142
1211
|
|