@rpgjs/server 5.0.0-alpha.2 → 5.0.0-alpha.20
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/Gui/DialogGui.d.ts +4 -0
- package/dist/Gui/index.d.ts +1 -0
- package/dist/Player/BattleManager.d.ts +32 -22
- package/dist/Player/ClassManager.d.ts +31 -18
- package/dist/Player/ComponentManager.d.ts +123 -0
- package/dist/Player/Components.d.ts +345 -0
- package/dist/Player/EffectManager.d.ts +40 -0
- package/dist/Player/ElementManager.d.ts +31 -0
- package/dist/Player/GoldManager.d.ts +22 -0
- package/dist/Player/GuiManager.d.ts +176 -0
- package/dist/Player/ItemFixture.d.ts +6 -0
- package/dist/Player/ItemManager.d.ts +164 -10
- package/dist/Player/MoveManager.d.ts +32 -44
- package/dist/Player/ParameterManager.d.ts +343 -14
- package/dist/Player/Player.d.ts +266 -8
- package/dist/Player/SkillManager.d.ts +27 -19
- package/dist/Player/StateManager.d.ts +28 -35
- package/dist/Player/VariableManager.d.ts +30 -0
- package/dist/RpgServer.d.ts +227 -1
- package/dist/decorators/event.d.ts +46 -0
- package/dist/decorators/map.d.ts +177 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +17436 -18167
- package/dist/index.js.map +1 -1
- package/dist/rooms/map.d.ts +486 -8
- package/package.json +17 -15
- package/src/Gui/DialogGui.ts +7 -2
- package/src/Gui/index.ts +3 -1
- package/src/Player/BattleManager.ts +97 -38
- package/src/Player/ClassManager.ts +95 -35
- package/src/Player/ComponentManager.ts +425 -19
- package/src/Player/Components.ts +380 -0
- package/src/Player/EffectManager.ts +110 -27
- package/src/Player/ElementManager.ts +126 -25
- package/src/Player/GoldManager.ts +32 -35
- package/src/Player/GuiManager.ts +187 -140
- package/src/Player/ItemFixture.ts +4 -5
- package/src/Player/ItemManager.ts +363 -48
- package/src/Player/MoveManager.ts +323 -308
- package/src/Player/ParameterManager.ts +499 -99
- package/src/Player/Player.ts +719 -80
- package/src/Player/SkillManager.ts +44 -23
- package/src/Player/StateManager.ts +210 -95
- package/src/Player/VariableManager.ts +180 -48
- package/src/RpgServer.ts +236 -1
- package/src/core/context.ts +1 -0
- package/src/decorators/event.ts +61 -0
- package/src/decorators/map.ts +198 -0
- package/src/index.ts +5 -1
- package/src/module.ts +24 -0
- package/src/rooms/map.ts +1054 -54
- package/dist/Player/Event.d.ts +0 -0
- package/src/Player/Event.ts +0 -0
package/dist/Gui/DialogGui.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface DialogOptions {
|
|
|
17
17
|
tranparent?: boolean;
|
|
18
18
|
typewriterEffect?: boolean;
|
|
19
19
|
talkWith?: RpgPlayer;
|
|
20
|
+
face?: {
|
|
21
|
+
id: string;
|
|
22
|
+
expression: string;
|
|
23
|
+
};
|
|
20
24
|
}
|
|
21
25
|
export declare class DialogGui extends Gui {
|
|
22
26
|
constructor(player: RpgPlayer);
|
package/dist/Gui/index.d.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { PlayerCtor } from '@rpgjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Battle Manager Mixin
|
|
4
|
+
*
|
|
5
|
+
* Provides battle management capabilities to any class. This mixin handles
|
|
6
|
+
* damage calculation, critical hits, elemental vulnerabilities, and guard effects.
|
|
7
|
+
* It implements a comprehensive battle system with customizable formulas and effects.
|
|
8
|
+
*
|
|
9
|
+
* @param Base - The base class to extend with battle management
|
|
10
|
+
* @returns Extended class with battle management methods
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* class MyPlayer extends WithBattleManager(BasePlayer) {
|
|
15
|
+
* constructor() {
|
|
16
|
+
* super();
|
|
17
|
+
* // Battle system is automatically initialized
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* const player = new MyPlayer();
|
|
22
|
+
* const attacker = new MyPlayer();
|
|
23
|
+
* const result = player.applyDamage(attacker);
|
|
24
|
+
* console.log(`Damage dealt: ${result.damage}`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function WithBattleManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
28
|
+
/**
|
|
29
|
+
* Type helper to extract the interface from the WithBattleManager mixin
|
|
30
|
+
* This provides the type without duplicating method signatures
|
|
31
|
+
*/
|
|
32
|
+
export type IBattleManager = InstanceType<ReturnType<typeof WithBattleManager>>;
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { PlayerCtor } from '@rpgjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Class Manager Mixin
|
|
4
|
+
*
|
|
5
|
+
* Provides class and actor management capabilities to any class. This mixin handles
|
|
6
|
+
* character class assignment and actor setup, including automatic parameter configuration,
|
|
7
|
+
* starting equipment, and skill progression based on class definitions.
|
|
8
|
+
*
|
|
9
|
+
* @param Base - The base class to extend with class management
|
|
10
|
+
* @returns Extended class with class management methods
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* class MyPlayer extends WithClassManager(BasePlayer) {
|
|
15
|
+
* constructor() {
|
|
16
|
+
* super();
|
|
17
|
+
* // Class system is automatically initialized
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* const player = new MyPlayer();
|
|
22
|
+
* player.setClass(Fighter);
|
|
23
|
+
* player.setActor(Hero);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function WithClassManager<TBase extends PlayerCtor>(Base: TBase): TBase;
|
|
27
|
+
/**
|
|
28
|
+
* Type helper to extract the interface from the WithClassManager mixin
|
|
29
|
+
* This provides the type without duplicating method signatures
|
|
30
|
+
*/
|
|
31
|
+
export type IClassManager = InstanceType<ReturnType<typeof WithClassManager>>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Constructor, RpgCommonPlayer } from '@rpgjs/common';
|
|
2
|
+
import { ComponentInput, ComponentLayout } from './Components';
|
|
3
|
+
type ComponentPosition = 'top' | 'center' | 'bottom' | 'left' | 'right';
|
|
4
|
+
/**
|
|
5
|
+
* Component Manager Mixin
|
|
6
|
+
*
|
|
7
|
+
* Provides graphic and component 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. It also provides methods to
|
|
10
|
+
* display UI components around the player graphic (top, bottom, center, left, right).
|
|
11
|
+
*
|
|
12
|
+
* Components are stored as JSON strings for efficient synchronization.
|
|
13
|
+
*
|
|
14
|
+
* @param Base - The base class to extend with component management
|
|
15
|
+
* @returns Extended class with component management methods
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* class MyPlayer extends WithComponentManager(BasePlayer) {
|
|
20
|
+
* constructor() {
|
|
21
|
+
* super();
|
|
22
|
+
* this.setGraphic("hero");
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const player = new MyPlayer();
|
|
27
|
+
* player.setGraphic(["hero_idle", "hero_walk"]);
|
|
28
|
+
* player.setComponentsTop(Components.text('{name}'));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function WithComponentManager<TBase extends Constructor<RpgCommonPlayer>>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IComponentManager;
|
|
32
|
+
/**
|
|
33
|
+
* Interface for component management capabilities
|
|
34
|
+
* Defines the method signatures that will be available on the player
|
|
35
|
+
*/
|
|
36
|
+
export interface IComponentManager {
|
|
37
|
+
/**
|
|
38
|
+
* Set the graphic(s) for this player
|
|
39
|
+
*
|
|
40
|
+
* Allows setting either a single graphic or multiple graphics for the player.
|
|
41
|
+
* When multiple graphics are provided, they are used for animation sequences.
|
|
42
|
+
* The graphics system provides flexible visual representation that can be
|
|
43
|
+
* dynamically changed during gameplay for different states, equipment, or animations.
|
|
44
|
+
*
|
|
45
|
+
* @param graphic - Single graphic name or array of graphic names for animation sequences
|
|
46
|
+
* @returns void
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* // Set a single graphic for static representation
|
|
51
|
+
* player.setGraphic("hero");
|
|
52
|
+
*
|
|
53
|
+
* // Set multiple graphics for animation sequences
|
|
54
|
+
* player.setGraphic(["hero_idle", "hero_walk", "hero_run"]);
|
|
55
|
+
*
|
|
56
|
+
* // Dynamic graphic changes based on equipment
|
|
57
|
+
* if (player.hasArmor('platemail')) {
|
|
58
|
+
* player.setGraphic("hero_armored");
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* // Animation sequences for different actions
|
|
62
|
+
* player.setGraphic(["mage_cast_1", "mage_cast_2", "mage_cast_3"]);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
setGraphic(graphic: string | string[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Set components to display above the player graphic
|
|
68
|
+
*
|
|
69
|
+
* @param layout - Component(s) to display, can be single, array, or 2D array
|
|
70
|
+
* @param options - Optional layout options for positioning and sizing
|
|
71
|
+
* @returns void
|
|
72
|
+
*/
|
|
73
|
+
setComponentsTop(layout: ComponentInput, options?: ComponentLayout): void;
|
|
74
|
+
/**
|
|
75
|
+
* Set components to display below the player graphic
|
|
76
|
+
*
|
|
77
|
+
* @param layout - Component(s) to display, can be single, array, or 2D array
|
|
78
|
+
* @param options - Optional layout options for positioning and sizing
|
|
79
|
+
* @returns void
|
|
80
|
+
*/
|
|
81
|
+
setComponentsBottom(layout: ComponentInput, options?: ComponentLayout): void;
|
|
82
|
+
/**
|
|
83
|
+
* Set components to display at the center of the player graphic
|
|
84
|
+
*
|
|
85
|
+
* @param layout - Component(s) to display, can be single, array, or 2D array
|
|
86
|
+
* @param options - Optional layout options for positioning and sizing
|
|
87
|
+
* @returns void
|
|
88
|
+
*/
|
|
89
|
+
setComponentsCenter(layout: ComponentInput, options?: ComponentLayout): void;
|
|
90
|
+
/**
|
|
91
|
+
* Set components to display to the left of the player graphic
|
|
92
|
+
*
|
|
93
|
+
* @param layout - Component(s) to display, can be single, array, or 2D array
|
|
94
|
+
* @param options - Optional layout options for positioning and sizing
|
|
95
|
+
* @returns void
|
|
96
|
+
*/
|
|
97
|
+
setComponentsLeft(layout: ComponentInput, options?: ComponentLayout): void;
|
|
98
|
+
/**
|
|
99
|
+
* Set components to display to the right of the player graphic
|
|
100
|
+
*
|
|
101
|
+
* @param layout - Component(s) to display, can be single, array, or 2D array
|
|
102
|
+
* @param options - Optional layout options for positioning and sizing
|
|
103
|
+
* @returns void
|
|
104
|
+
*/
|
|
105
|
+
setComponentsRight(layout: ComponentInput, options?: ComponentLayout): void;
|
|
106
|
+
/**
|
|
107
|
+
* Remove components from a specific position
|
|
108
|
+
*
|
|
109
|
+
* @param position - Position of the components: 'top', 'center', 'bottom', 'left', or 'right'
|
|
110
|
+
* @returns void
|
|
111
|
+
*/
|
|
112
|
+
removeComponents(position: ComponentPosition): void;
|
|
113
|
+
/**
|
|
114
|
+
* Merge components with existing components at a specific position
|
|
115
|
+
*
|
|
116
|
+
* @param position - Position of the components: 'top', 'center', 'bottom', 'left', or 'right'
|
|
117
|
+
* @param layout - Component(s) to merge, can be single, array, or 2D array
|
|
118
|
+
* @param options - Optional layout options for positioning and sizing
|
|
119
|
+
* @returns void
|
|
120
|
+
*/
|
|
121
|
+
mergeComponents(position: ComponentPosition, layout: ComponentInput, options?: ComponentLayout): void;
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component definitions for player UI elements
|
|
3
|
+
*
|
|
4
|
+
* This module provides factory functions to create component definitions
|
|
5
|
+
* that can be displayed above or below player graphics. Components are
|
|
6
|
+
* synchronized from server to client and rendered using CanvasEngine.
|
|
7
|
+
*
|
|
8
|
+
* ## Design
|
|
9
|
+
*
|
|
10
|
+
* Components are defined as data structures that describe UI elements
|
|
11
|
+
* (text, bars, shapes) with their properties and layout options. The
|
|
12
|
+
* server creates these definitions and they are automatically synchronized
|
|
13
|
+
* to all clients on the map.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { Components } from '@rpgjs/server';
|
|
18
|
+
*
|
|
19
|
+
* // Create a text component
|
|
20
|
+
* const nameComponent = Components.text('{name}');
|
|
21
|
+
*
|
|
22
|
+
* // Create an HP bar
|
|
23
|
+
* const hpBar = Components.hpBar();
|
|
24
|
+
*
|
|
25
|
+
* // Set components on player
|
|
26
|
+
* player.setComponentsTop([nameComponent, hpBar]);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface ComponentLayout {
|
|
30
|
+
/** Width of the component block in pixels */
|
|
31
|
+
width?: number;
|
|
32
|
+
/** Height of the component block in pixels */
|
|
33
|
+
height?: number;
|
|
34
|
+
/** Margin from the top of the player in pixels */
|
|
35
|
+
marginTop?: number;
|
|
36
|
+
/** Margin from the bottom of the player in pixels */
|
|
37
|
+
marginBottom?: number;
|
|
38
|
+
/** Margin from the left of the player in pixels */
|
|
39
|
+
marginLeft?: number;
|
|
40
|
+
/** Margin from the right of the player in pixels */
|
|
41
|
+
marginRight?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface TextComponentOptions {
|
|
44
|
+
/** Text color in hexadecimal format (e.g., '#000000') */
|
|
45
|
+
fill?: string;
|
|
46
|
+
/** Font size in pixels */
|
|
47
|
+
fontSize?: number;
|
|
48
|
+
/** Font family */
|
|
49
|
+
fontFamily?: string;
|
|
50
|
+
/** Font style: 'normal', 'italic', 'oblique' */
|
|
51
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
52
|
+
/** Font weight: 'normal', 'bold', 'bolder', 'lighter', or numeric values */
|
|
53
|
+
fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number;
|
|
54
|
+
/** Stroke color in hexadecimal format */
|
|
55
|
+
stroke?: string;
|
|
56
|
+
/** Opacity between 0 and 1 */
|
|
57
|
+
opacity?: number;
|
|
58
|
+
/** Word wrap */
|
|
59
|
+
wordWrap?: boolean;
|
|
60
|
+
/** Text alignment */
|
|
61
|
+
align?: 'left' | 'center' | 'right' | 'justify';
|
|
62
|
+
}
|
|
63
|
+
export interface BarComponentOptions {
|
|
64
|
+
/** Background color in hexadecimal format */
|
|
65
|
+
bgColor?: string;
|
|
66
|
+
/** Fill color in hexadecimal format */
|
|
67
|
+
fillColor?: string;
|
|
68
|
+
/** Border color in hexadecimal format */
|
|
69
|
+
borderColor?: string;
|
|
70
|
+
/** Border width */
|
|
71
|
+
borderWidth?: number;
|
|
72
|
+
/** Height of the bar in pixels */
|
|
73
|
+
height?: number;
|
|
74
|
+
/** Width of the bar in pixels */
|
|
75
|
+
width?: number;
|
|
76
|
+
/** Border radius */
|
|
77
|
+
borderRadius?: number;
|
|
78
|
+
/** Opacity between 0 and 1 */
|
|
79
|
+
opacity?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface ShapeComponentOptions {
|
|
82
|
+
/** Fill color in hexadecimal format */
|
|
83
|
+
fill: string;
|
|
84
|
+
/** Type of shape */
|
|
85
|
+
type: 'circle' | 'rectangle' | 'ellipse' | 'polygon' | 'line' | 'rounded-rectangle';
|
|
86
|
+
/** Radius (for circle) */
|
|
87
|
+
radius?: number | string;
|
|
88
|
+
/** Width (for rectangle, ellipse) */
|
|
89
|
+
width?: number | string;
|
|
90
|
+
/** Height (for rectangle, ellipse) */
|
|
91
|
+
height?: number | string;
|
|
92
|
+
/** X1 position (for line) */
|
|
93
|
+
x1?: number | string;
|
|
94
|
+
/** Y1 position (for line) */
|
|
95
|
+
y1?: number | string;
|
|
96
|
+
/** X2 position (for line) */
|
|
97
|
+
x2?: number | string;
|
|
98
|
+
/** Y2 position (for line) */
|
|
99
|
+
y2?: number | string;
|
|
100
|
+
/** Points array (for polygon) */
|
|
101
|
+
points?: number[];
|
|
102
|
+
/** Opacity between 0 and 1 */
|
|
103
|
+
opacity?: number | string;
|
|
104
|
+
/** Line/border style */
|
|
105
|
+
line?: {
|
|
106
|
+
color?: string;
|
|
107
|
+
width?: number;
|
|
108
|
+
alpha?: number;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export type ComponentDefinition = {
|
|
112
|
+
type: 'text';
|
|
113
|
+
value: string;
|
|
114
|
+
style?: TextComponentOptions;
|
|
115
|
+
} | {
|
|
116
|
+
type: 'hpBar';
|
|
117
|
+
style?: BarComponentOptions;
|
|
118
|
+
text?: string | null;
|
|
119
|
+
} | {
|
|
120
|
+
type: 'spBar';
|
|
121
|
+
style?: BarComponentOptions;
|
|
122
|
+
text?: string | null;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'bar';
|
|
125
|
+
current: string;
|
|
126
|
+
max: string;
|
|
127
|
+
style?: BarComponentOptions;
|
|
128
|
+
text?: string | null;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'shape';
|
|
131
|
+
value: ShapeComponentOptions;
|
|
132
|
+
} | {
|
|
133
|
+
type: 'image';
|
|
134
|
+
value: string;
|
|
135
|
+
} | {
|
|
136
|
+
type: 'tile';
|
|
137
|
+
value: number | string;
|
|
138
|
+
};
|
|
139
|
+
export type ComponentInput = ComponentDefinition | ComponentDefinition[] | ComponentDefinition[][];
|
|
140
|
+
/**
|
|
141
|
+
* Components factory for creating component definitions
|
|
142
|
+
*
|
|
143
|
+
* Provides factory methods to create various UI components that can be
|
|
144
|
+
* displayed above or below player graphics. Components support template
|
|
145
|
+
* strings with placeholders like {name}, {hp}, etc. that are replaced
|
|
146
|
+
* with actual player property values on the client.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* // Create a text component
|
|
151
|
+
* Components.text('Player: {name}');
|
|
152
|
+
*
|
|
153
|
+
* // Create an HP bar with custom text
|
|
154
|
+
* Components.hpBar({}, '{$percent}%');
|
|
155
|
+
*
|
|
156
|
+
* // Create a custom bar
|
|
157
|
+
* Components.bar('wood', 'param.maxWood');
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare const Components: {
|
|
161
|
+
/**
|
|
162
|
+
* Create a text component
|
|
163
|
+
*
|
|
164
|
+
* Creates a text component that displays text with optional styling.
|
|
165
|
+
* Supports template strings with placeholders like {name}, {hp}, etc.
|
|
166
|
+
* that are replaced with actual player property values.
|
|
167
|
+
*
|
|
168
|
+
* ## Design
|
|
169
|
+
*
|
|
170
|
+
* Text components use template strings to allow dynamic content without
|
|
171
|
+
* resending the entire component structure when values change. Only the
|
|
172
|
+
* property values are synchronized, reducing bandwidth usage.
|
|
173
|
+
*
|
|
174
|
+
* @param text - Text to display, can include placeholders like {name}, {hp}
|
|
175
|
+
* @param options - Text styling options
|
|
176
|
+
* @returns Component definition for text
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* // Simple text
|
|
181
|
+
* Components.text('Player Name');
|
|
182
|
+
*
|
|
183
|
+
* // Text with placeholder
|
|
184
|
+
* Components.text('{name}');
|
|
185
|
+
*
|
|
186
|
+
* // Text with styling
|
|
187
|
+
* Components.text('{name}', {
|
|
188
|
+
* fill: '#000000',
|
|
189
|
+
* fontSize: 20
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
text(value: string, style?: TextComponentOptions): ComponentDefinition;
|
|
194
|
+
/**
|
|
195
|
+
* Create an HP bar component
|
|
196
|
+
*
|
|
197
|
+
* Creates a health point bar that automatically displays the player's
|
|
198
|
+
* current HP relative to their maximum HP. The bar updates automatically
|
|
199
|
+
* as HP changes.
|
|
200
|
+
*
|
|
201
|
+
* ## Design
|
|
202
|
+
*
|
|
203
|
+
* HP bars read from the player's hp and param.maxHp properties. The
|
|
204
|
+
* bar can optionally display text above it showing current, max, or
|
|
205
|
+
* percentage values.
|
|
206
|
+
*
|
|
207
|
+
* @param options - Bar styling options
|
|
208
|
+
* @param text - Optional text to display above the bar. Can use placeholders:
|
|
209
|
+
* - {$current} - Current HP value
|
|
210
|
+
* - {$max} - Maximum HP value
|
|
211
|
+
* - {$percent} - Percentage value
|
|
212
|
+
* Set to null to hide text
|
|
213
|
+
* @returns Component definition for HP bar
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* // Simple HP bar
|
|
218
|
+
* Components.hpBar();
|
|
219
|
+
*
|
|
220
|
+
* // HP bar with percentage text
|
|
221
|
+
* Components.hpBar({}, '{$percent}%');
|
|
222
|
+
*
|
|
223
|
+
* // HP bar with custom styling
|
|
224
|
+
* Components.hpBar({
|
|
225
|
+
* fillColor: '#ff0000',
|
|
226
|
+
* height: 8
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
hpBar(style?: BarComponentOptions, text?: string | null): ComponentDefinition;
|
|
231
|
+
/**
|
|
232
|
+
* Create an SP bar component
|
|
233
|
+
*
|
|
234
|
+
* Creates a skill point bar that automatically displays the player's
|
|
235
|
+
* current SP relative to their maximum SP. The bar updates automatically
|
|
236
|
+
* as SP changes.
|
|
237
|
+
*
|
|
238
|
+
* @param style - Bar styling options
|
|
239
|
+
* @param text - Optional text to display above the bar. Can use placeholders:
|
|
240
|
+
* - {$current} - Current SP value
|
|
241
|
+
* - {$max} - Maximum SP value
|
|
242
|
+
* - {$percent} - Percentage value
|
|
243
|
+
* Set to null to hide text
|
|
244
|
+
* @returns Component definition for SP bar
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* // Simple SP bar
|
|
249
|
+
* Components.spBar();
|
|
250
|
+
*
|
|
251
|
+
* // SP bar with text
|
|
252
|
+
* Components.spBar({}, 'SP: {$current}/{$max}');
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
spBar(style?: BarComponentOptions, text?: string | null): ComponentDefinition;
|
|
256
|
+
/**
|
|
257
|
+
* Create a custom bar component
|
|
258
|
+
*
|
|
259
|
+
* Creates a bar that displays a custom property value relative to a maximum.
|
|
260
|
+
* Useful for displaying custom resources like wood, mana, energy, etc.
|
|
261
|
+
*
|
|
262
|
+
* @param current - Property path for current value (e.g., 'wood', 'mana')
|
|
263
|
+
* @param max - Property path for maximum value (e.g., 'param.maxWood', 'param.maxMana')
|
|
264
|
+
* @param style - Bar styling options
|
|
265
|
+
* @param text - Optional text to display above the bar. Can use placeholders:
|
|
266
|
+
* - {$current} - Current value
|
|
267
|
+
* - {$max} - Maximum value
|
|
268
|
+
* - {$percent} - Percentage value
|
|
269
|
+
* Set to null to hide text
|
|
270
|
+
* @returns Component definition for custom bar
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* // Bar for custom property
|
|
275
|
+
* Components.bar('wood', 'param.maxWood');
|
|
276
|
+
*
|
|
277
|
+
* // Bar with text
|
|
278
|
+
* Components.bar('mana', 'param.maxMana', {}, 'Mana: {$current}/{$max}');
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
bar(current: string, max: string, style?: BarComponentOptions, text?: string | null): ComponentDefinition;
|
|
282
|
+
/**
|
|
283
|
+
* Create a shape component
|
|
284
|
+
*
|
|
285
|
+
* Creates a geometric shape that can be displayed above or below the player.
|
|
286
|
+
* Useful for visual indicators, backgrounds, or decorative elements.
|
|
287
|
+
*
|
|
288
|
+
* @param value - Shape configuration options
|
|
289
|
+
* @returns Component definition for shape
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* // Circle shape
|
|
294
|
+
* Components.shape({
|
|
295
|
+
* fill: '#ffffff',
|
|
296
|
+
* type: 'circle',
|
|
297
|
+
* radius: 10
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Rectangle shape
|
|
301
|
+
* Components.shape({
|
|
302
|
+
* fill: '#ff0000',
|
|
303
|
+
* type: 'rectangle',
|
|
304
|
+
* width: 32,
|
|
305
|
+
* height: 32
|
|
306
|
+
* });
|
|
307
|
+
*
|
|
308
|
+
* // Using parameters
|
|
309
|
+
* Components.shape({
|
|
310
|
+
* fill: '#ffffff',
|
|
311
|
+
* type: 'circle',
|
|
312
|
+
* radius: 'hp' // radius will be the same as hp value
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
shape(value: ShapeComponentOptions): ComponentDefinition;
|
|
317
|
+
/**
|
|
318
|
+
* Create an image component
|
|
319
|
+
*
|
|
320
|
+
* Displays an image from a URL or spritesheet identifier.
|
|
321
|
+
*
|
|
322
|
+
* @param value - Image source URL or spritesheet identifier
|
|
323
|
+
* @returns Component definition for image
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* Components.image('mygraphic.png');
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
image(value: string): ComponentDefinition;
|
|
331
|
+
/**
|
|
332
|
+
* Create a tile component
|
|
333
|
+
*
|
|
334
|
+
* Displays a tile from a tileset by ID.
|
|
335
|
+
*
|
|
336
|
+
* @param value - Tile ID in the tileset
|
|
337
|
+
* @returns Component definition for tile
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* Components.tile(3); // Use tile #3
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
tile(value: number | string): ComponentDefinition;
|
|
345
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
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>>;
|