@rpgjs/server 5.0.0-alpha.1 → 5.0.0-alpha.10

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.
Files changed (40) hide show
  1. package/dist/Player/BattleManager.d.ts +32 -22
  2. package/dist/Player/ClassManager.d.ts +31 -18
  3. package/dist/Player/ComponentManager.d.ts +60 -0
  4. package/dist/Player/EffectManager.d.ts +40 -0
  5. package/dist/Player/ElementManager.d.ts +31 -0
  6. package/dist/Player/GoldManager.d.ts +22 -0
  7. package/dist/Player/GuiManager.d.ts +176 -0
  8. package/dist/Player/ItemFixture.d.ts +6 -0
  9. package/dist/Player/ItemManager.d.ts +27 -13
  10. package/dist/Player/MoveManager.d.ts +31 -43
  11. package/dist/Player/ParameterManager.d.ts +27 -19
  12. package/dist/Player/Player.d.ts +123 -8
  13. package/dist/Player/SkillManager.d.ts +27 -19
  14. package/dist/Player/StateManager.d.ts +28 -35
  15. package/dist/Player/VariableManager.d.ts +30 -0
  16. package/dist/RpgServer.d.ts +224 -1
  17. package/dist/index.js +1097 -636
  18. package/dist/index.js.map +1 -1
  19. package/dist/rooms/map.d.ts +70 -1
  20. package/package.json +8 -8
  21. package/src/Player/BattleManager.ts +97 -38
  22. package/src/Player/ClassManager.ts +95 -35
  23. package/src/Player/ComponentManager.ts +64 -20
  24. package/src/Player/EffectManager.ts +110 -27
  25. package/src/Player/ElementManager.ts +126 -25
  26. package/src/Player/GoldManager.ts +32 -35
  27. package/src/Player/GuiManager.ts +187 -140
  28. package/src/Player/ItemFixture.ts +4 -5
  29. package/src/Player/ItemManager.ts +39 -26
  30. package/src/Player/MoveManager.ts +40 -31
  31. package/src/Player/ParameterManager.ts +35 -25
  32. package/src/Player/Player.ts +184 -39
  33. package/src/Player/SkillManager.ts +44 -23
  34. package/src/Player/StateManager.ts +210 -95
  35. package/src/Player/VariableManager.ts +180 -48
  36. package/src/RpgServer.ts +232 -1
  37. package/src/core/context.ts +1 -0
  38. package/src/rooms/map.ts +76 -8
  39. package/dist/Player/Event.d.ts +0 -0
  40. package/src/Player/Event.ts +0 -0
@@ -102,7 +102,76 @@ export declare class RpgMap extends RpgCommonMap<RpgPlayer> implements RoomOnJoi
102
102
  getPlayer(playerId: string): RpgPlayer | undefined;
103
103
  getEvents(): RpgEvent[];
104
104
  removeEvent(eventId: string): void;
105
- showAnimation(animationName: string, object: RpgPlayer): void;
105
+ /**
106
+ * Display a component animation at a specific position on the map
107
+ *
108
+ * This method broadcasts a component animation to all clients connected to the map,
109
+ * allowing temporary visual effects to be displayed at any location on the map.
110
+ * Component animations are custom Canvas Engine components that can display
111
+ * complex effects with custom logic and parameters.
112
+ *
113
+ * @param id - The ID of the component animation to display
114
+ * @param position - The x, y coordinates where to display the animation
115
+ * @param params - Parameters to pass to the component animation
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * // Show explosion at specific coordinates
120
+ * map.showComponentAnimation("explosion", { x: 300, y: 400 }, {
121
+ * intensity: 2.5,
122
+ * duration: 1500
123
+ * });
124
+ *
125
+ * // Show area damage effect
126
+ * map.showComponentAnimation("area-damage", { x: player.x, y: player.y }, {
127
+ * radius: 100,
128
+ * color: "red",
129
+ * damage: 50
130
+ * });
131
+ *
132
+ * // Show treasure spawn effect
133
+ * map.showComponentAnimation("treasure-spawn", { x: 150, y: 200 }, {
134
+ * sparkle: true,
135
+ * sound: "treasure-appear"
136
+ * });
137
+ * ```
138
+ */
139
+ showComponentAnimation(id: string, position: {
140
+ x: number;
141
+ y: number;
142
+ }, params: any): void;
143
+ /**
144
+ * Display a spritesheet animation at a specific position on the map
145
+ *
146
+ * This method displays a temporary visual animation using a spritesheet at any
147
+ * location on the map. It's a convenience method that internally uses showComponentAnimation
148
+ * with the built-in 'animation' component. This is useful for spell effects, environmental
149
+ * animations, or any visual feedback that uses predefined spritesheets.
150
+ *
151
+ * @param position - The x, y coordinates where to display the animation
152
+ * @param graphic - The ID of the spritesheet to use for the animation
153
+ * @param animationName - The name of the animation within the spritesheet (default: 'default')
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * // Show explosion at specific coordinates
158
+ * map.showAnimation({ x: 100, y: 200 }, "explosion");
159
+ *
160
+ * // Show spell effect at player position
161
+ * const playerPos = { x: player.x, y: player.y };
162
+ * map.showAnimation(playerPos, "spell-effects", "lightning");
163
+ *
164
+ * // Show environmental effect
165
+ * map.showAnimation({ x: 300, y: 150 }, "nature-effects", "wind-gust");
166
+ *
167
+ * // Show portal opening animation
168
+ * map.showAnimation({ x: 500, y: 400 }, "portals", "opening");
169
+ * ```
170
+ */
171
+ showAnimation(position: {
172
+ x: number;
173
+ y: number;
174
+ }, graphic: string, animationName?: string): void;
106
175
  }
107
176
  export interface RpgMap {
108
177
  $send: (conn: MockConnection, data: any) => void;
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "@rpgjs/server",
3
- "version": "5.0.0-alpha.1",
3
+ "version": "5.0.0-alpha.10",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "scripts": {
10
- "dev": "vite build --watch",
11
- "build": "vite build"
12
- },
13
9
  "keywords": [],
14
10
  "author": "",
15
11
  "license": "MIT",
16
12
  "description": "",
17
13
  "dependencies": {
18
- "@rpgjs/common": "workspace:*",
14
+ "@rpgjs/common": "5.0.0-alpha.10",
19
15
  "@rpgjs/database": "^4.3.0",
20
16
  "@signe/di": "^2.3.2",
21
17
  "@signe/reactive": "^2.3.2",
@@ -27,5 +23,9 @@
27
23
  "vite": "^6.2.5",
28
24
  "vite-plugin-dts": "^4.5.3"
29
25
  },
30
- "type": "module"
31
- }
26
+ "type": "module",
27
+ "scripts": {
28
+ "dev": "vite build --watch",
29
+ "build": "vite build"
30
+ }
31
+ }
@@ -1,4 +1,4 @@
1
- import { Constructor, RpgCommonPlayer } from "@rpgjs/common";
1
+ 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";
@@ -9,41 +9,68 @@ interface PlayerWithMixins extends RpgCommonPlayer {
9
9
  hasEffect(effect: string): boolean;
10
10
  coefficientElements(attackerPlayer: RpgPlayer): number;
11
11
  hp: number;
12
- getFormulas(name: string): any;
13
- hasEffect(effect: string): boolean;
14
- }
15
-
16
- export interface IBattleManager {
17
- applyDamage(attackerPlayer: RpgPlayer, skill?: any): {
18
- damage: number;
19
- critical: boolean;
20
- elementVulnerable: boolean;
21
- guard: boolean;
22
- superGuard: boolean;
23
- };
12
+ getCurrentMap(): any;
24
13
  }
25
14
 
26
- export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
27
- Base: TBase
28
- ): Constructor<IBattleManager> & TBase {
29
- return class extends Base implements IBattleManager {
15
+ /**
16
+ * Battle Manager Mixin
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 {
30
42
  /**
31
43
  * Apply damage. Player will lose HP. the `attackerPlayer` parameter is the other player, the one who attacks.
32
44
  *
33
45
  * If you don't set the skill parameter, it will be a physical attack.
34
- * The attack formula is already defined but you can customize it in the server options
46
+ * The attack formula is already defined but you can customize it in the server options.
47
+ * This method handles all aspects of damage calculation including critical hits,
48
+ * elemental vulnerabilities, guard effects, and applies the final damage to HP.
35
49
  *
50
+ * @param attackerPlayer - The attacking player who deals the damage
51
+ * @param skill - Optional skill object for magical attacks, if not provided uses physical attack
52
+ * @returns Object containing damage details and special effects that occurred
53
+ *
54
+ * @example
36
55
  * ```ts
37
- * player.applyDamage(attackerPlayer) // returns { damage: number }
56
+ * // Physical attack
57
+ * const result = player.applyDamage(attackerPlayer);
58
+ * console.log(`Physical damage: ${result.damage}, Critical: ${result.critical}`);
59
+ *
60
+ * // Magical attack with skill
61
+ * const fireSkill = { id: 'fire', power: 50, element: 'fire' };
62
+ * const magicResult = player.applyDamage(attackerPlayer, fireSkill);
63
+ * console.log(`Magic damage: ${magicResult.damage}, Vulnerable: ${magicResult.elementVulnerable}`);
64
+ *
65
+ * // Check for guard effects
66
+ * if (result.guard) {
67
+ * console.log('Attack was partially blocked!');
68
+ * }
69
+ * if (result.superGuard) {
70
+ * console.log('Attack was heavily reduced by super guard!');
71
+ * }
38
72
  * ```
39
- *
40
- * @title Apply Damage
41
- * @method player.applyDamage(attackerPlayer,skill)
42
- * @param {RpgPlayer} attackerPlayer The attacking player
43
- * @param {any} [skill]
44
- * @returns {object}
45
- * @memberof BattleManager
46
- * */
73
+ */
47
74
  applyDamage(
48
75
  attackerPlayer: RpgPlayer,
49
76
  skill?: any
@@ -56,13 +83,13 @@ export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
56
83
  } {
57
84
  const getParam = (player: RpgPlayer) => {
58
85
  const params = {};
59
- this.parameters.forEach((val, key) => {
60
- params[key] = player.param[key];
86
+ (this as any).parameters.forEach((val, key) => {
87
+ params[key] = (player as any).param[key];
61
88
  });
62
89
  return {
63
- [ATK]: player.atk,
64
- [PDEF]: player.pdef,
65
- [SDEF]: player.sdef,
90
+ [ATK]: (player as any).atk,
91
+ [PDEF]: (player as any).pdef,
92
+ [SDEF]: (player as any).sdef,
66
93
  ...params,
67
94
  };
68
95
  };
@@ -87,7 +114,7 @@ export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
87
114
  throw new Error("Physic Formulas not exists");
88
115
  }
89
116
  damage = fn(paramA, paramB);
90
- const coef = this.coefficientElements(attackerPlayer);
117
+ const coef = (this as any).coefficientElements(attackerPlayer);
91
118
  if (coef >= 2) {
92
119
  elementVulnerable = true;
93
120
  }
@@ -101,7 +128,7 @@ export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
101
128
  damage = newDamage;
102
129
  }
103
130
  }
104
- if (this.hasEffect(Effect.GUARD)) {
131
+ if ((this as any).hasEffect(Effect.GUARD)) {
105
132
  fn = this.getFormulas("damageGuard");
106
133
  if (fn) {
107
134
  let newDamage = fn(damage, paramA, paramB);
@@ -111,11 +138,11 @@ export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
111
138
  damage = newDamage;
112
139
  }
113
140
  }
114
- if (this.hasEffect(Effect.SUPER_GUARD)) {
141
+ if ((this as any).hasEffect(Effect.SUPER_GUARD)) {
115
142
  damage /= 4;
116
143
  superGuard = true;
117
144
  }
118
- this.hp -= damage;
145
+ (this as any).hp -= damage;
119
146
  return {
120
147
  damage,
121
148
  critical,
@@ -125,9 +152,41 @@ export function WithBattleManager<TBase extends Constructor<PlayerWithMixins>>(
125
152
  };
126
153
  }
127
154
 
155
+ /**
156
+ * Get damage formulas from the current map
157
+ *
158
+ * Retrieves the damage calculation formulas defined in the current map's configuration.
159
+ * These formulas are used to calculate different types of damage including physical,
160
+ * magical, critical hits, and guard effects. The formulas provide flexibility in
161
+ * customizing the battle system's damage calculations.
162
+ *
163
+ * @param name - The name of the formula to retrieve (e.g., 'damagePhysic', 'damageSkill')
164
+ * @returns The formula function or undefined if not found
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * // Get physical damage formula
169
+ * const physicFormula = player.getFormulas('damagePhysic');
170
+ * if (physicFormula) {
171
+ * const damage = physicFormula(attackerParams, defenderParams);
172
+ * }
173
+ *
174
+ * // Get critical damage formula
175
+ * const criticalFormula = player.getFormulas('damageCritical');
176
+ * if (criticalFormula) {
177
+ * const criticalDamage = criticalFormula(baseDamage, attackerParams, defenderParams);
178
+ * }
179
+ * ```
180
+ */
128
181
  getFormulas(name: string) {
129
- const map = this.getCurrentMap();
182
+ const map = (this as any).getCurrentMap();
130
183
  return map.damageFormulas[name];
131
184
  }
132
- };
185
+ } as unknown as TBase
133
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>>;
@@ -1,4 +1,4 @@
1
- import { Constructor, isString, RpgCommonPlayer } from "@rpgjs/common";
1
+ import { Constructor, isString, PlayerCtor, RpgCommonPlayer } from "@rpgjs/common";
2
2
 
3
3
  type ClassClass = any;
4
4
  type ActorClass = any;
@@ -10,69 +10,129 @@ interface PlayerWithMixins extends RpgCommonPlayer {
10
10
  equip(item: any, equip: boolean): void;
11
11
  }
12
12
 
13
- export interface IClassManager {
14
- setClass(_class: ClassClass | string): ClassClass;
15
- setActor(actorClass: ActorClass | string): ActorClass;
16
- }
17
-
18
- export function WithClassManager<TBase extends Constructor<PlayerWithMixins>>(
19
- Base: TBase
20
- ): Constructor<IClassManager> & TBase {
21
- return class extends Base implements IClassManager {
13
+ /**
14
+ * Class Manager Mixin
15
+ *
16
+ * Provides class and actor management capabilities to any class. This mixin handles
17
+ * character class assignment and actor setup, including automatic parameter configuration,
18
+ * starting equipment, and skill progression based on class definitions.
19
+ *
20
+ * @param Base - The base class to extend with class management
21
+ * @returns Extended class with class management methods
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * class MyPlayer extends WithClassManager(BasePlayer) {
26
+ * constructor() {
27
+ * super();
28
+ * // Class system is automatically initialized
29
+ * }
30
+ * }
31
+ *
32
+ * const player = new MyPlayer();
33
+ * player.setClass(Fighter);
34
+ * player.setActor(Hero);
35
+ * ```
36
+ */
37
+ export function WithClassManager<TBase extends PlayerCtor>(Base: TBase) {
38
+ return class extends Base {
22
39
 
23
40
  /**
24
41
  * Assign a class to the player
25
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
26
52
  * ```ts
27
53
  * import { Fighter } from 'my-database/classes/fighter'
28
54
  *
29
- * player.setClass(Fighter)
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
30
69
  * ```
31
- *
32
- * @title Set Class
33
- * @method player.setClass(ClassClass)
34
- * @param {ClassClass | string} class class or id
35
- * @returns {instance of ClassClass}
36
- * @memberof ClassManager
37
- * */
70
+ */
38
71
  setClass(_class: ClassClass | string) {
39
- if (isString(_class)) _class = this.databaseById(_class);
72
+ if (isString(_class)) _class = (this as any).databaseById(_class);
40
73
  const classInstance = new (_class as ClassClass)();
41
- this["execMethod"]("onSet", [this], classInstance);
74
+ (this as any)["execMethod"]("onSet", [this], classInstance);
42
75
  return classInstance;
43
76
  }
44
77
 
45
78
  /**
46
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)
47
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
48
90
  * ```ts
49
91
  * import { Hero } from 'my-database/classes/hero'
50
92
  *
51
- * player.setActor(Hero)
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
52
112
  * ```
53
- *
54
- * @title Set Actor
55
- * @method player.setActor(ActorClass)
56
- * @param {ActorClass | string} actorClass actor class or id
57
- * @returns {instance of ActorClass}
58
- * @memberof ClassManager
59
- * */
113
+ */
60
114
  setActor(actorClass: ActorClass | string) {
61
- if (isString(actorClass)) actorClass = this.databaseById(actorClass);
115
+ if (isString(actorClass)) actorClass = (this as any).databaseById(actorClass);
62
116
  const actor = new (actorClass as ActorClass)();
63
117
  ["name", "initialLevel", "finalLevel", "expCurve"].forEach((key) => {
64
- if (actor[key]) this[key] = actor[key];
118
+ if (actor[key]) (this as any)[key] = actor[key];
65
119
  });
66
120
  for (let param in actor.parameters) {
67
- this.addParameter(param, actor.parameters[param]);
121
+ (this as any).addParameter(param, actor.parameters[param]);
68
122
  }
69
123
  for (let item of actor.startingEquipment) {
70
- this.addItem(item);
71
- this.equip(item, true);
124
+ (this as any).addItem(item);
125
+ (this as any).equip(item, true);
72
126
  }
73
127
  if (actor.class) this.setClass(actor.class);
74
- this["execMethod"]("onSet", [this], actor);
128
+ (this as any)["execMethod"]("onSet", [this], actor);
75
129
  return actor;
76
130
  }
77
- };
131
+ } as unknown as TBase;
78
132
  }
133
+
134
+ /**
135
+ * Type helper to extract the interface from the WithClassManager mixin
136
+ * This provides the type without duplicating method signatures
137
+ */
138
+ export type IClassManager = InstanceType<ReturnType<typeof WithClassManager>>;
@@ -1,29 +1,73 @@
1
- import { type Constructor } from "@rpgjs/common";
1
+ import { Constructor, PlayerCtor } from "@rpgjs/common";
2
2
  import { RpgCommonPlayer } from "@rpgjs/common";
3
3
 
4
4
  /**
5
- * Interface defining what ComponentManager adds to a class
5
+ * Component Manager Mixin
6
+ *
7
+ * Provides graphic management capabilities to any class. This mixin allows
8
+ * setting single or multiple graphics for player representation, enabling
9
+ * dynamic visual changes and animation sequences.
10
+ *
11
+ * @param Base - The base class to extend with component management
12
+ * @returns Extended class with component management methods
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * class MyPlayer extends WithComponentManager(BasePlayer) {
17
+ * constructor() {
18
+ * super();
19
+ * this.setGraphic("hero");
20
+ * }
21
+ * }
22
+ *
23
+ * const player = new MyPlayer();
24
+ * player.setGraphic(["hero_idle", "hero_walk"]);
25
+ * ```
6
26
  */
7
- export interface IComponentManager {
8
- setGraphic(graphic: string | string[]): void;
27
+ export function WithComponentManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager {
28
+ return class extends Base {
29
+ setGraphic(graphic: string | string[]): void {
30
+ if (Array.isArray(graphic)) {
31
+ this.graphics.set(graphic);
32
+ } else {
33
+ this.graphics.set([graphic]);
34
+ }
35
+ }
36
+ } as unknown as any;
9
37
  }
10
38
 
11
39
  /**
12
- * Component Manager mixin
13
- *
14
- * Adds methods to manage player graphics
15
- *
16
- * @param Base - The base class to extend
17
- * @returns A new class with component management capabilities
40
+ * Interface for component management capabilities
41
+ * Defines the method signature that will be available on the player
18
42
  */
19
- export function WithComponentManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase) {
20
- return class extends Base implements IComponentManager {
21
- setGraphic(graphic: string | string[]) {
22
- if (Array.isArray(graphic)) {
23
- this.graphics.set(graphic);
24
- } else {
25
- this.graphics.set([graphic]);
26
- }
27
- }
28
- };
43
+ export interface IComponentManager {
44
+ /**
45
+ * Set the graphic(s) for this player
46
+ *
47
+ * Allows setting either a single graphic or multiple graphics for the player.
48
+ * When multiple graphics are provided, they are used for animation sequences.
49
+ * The graphics system provides flexible visual representation that can be
50
+ * dynamically changed during gameplay for different states, equipment, or animations.
51
+ *
52
+ * @param graphic - Single graphic name or array of graphic names for animation sequences
53
+ * @returns void
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * // Set a single graphic for static representation
58
+ * player.setGraphic("hero");
59
+ *
60
+ * // Set multiple graphics for animation sequences
61
+ * player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
62
+ *
63
+ * // Dynamic graphic changes based on equipment
64
+ * if (player.hasArmor('platemail')) {
65
+ * player.setGraphic("hero_armored");
66
+ * }
67
+ *
68
+ * // Animation sequences for different actions
69
+ * player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
70
+ * ```
71
+ */
72
+ setGraphic(graphic: string | string[]): void;
29
73
  }