@rpgjs/server 4.2.2 → 5.0.0-alpha.0

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 (219) hide show
  1. package/{lib → dist}/Gui/DialogGui.d.ts +1 -2
  2. package/{lib → dist}/Gui/Gui.d.ts +1 -2
  3. package/dist/Player/BattleManager.d.ts +22 -0
  4. package/dist/Player/ClassManager.d.ts +18 -0
  5. package/dist/Player/Event.d.ts +0 -0
  6. package/dist/Player/ItemManager.d.ts +17 -0
  7. package/dist/Player/MoveManager.d.ts +177 -0
  8. package/dist/Player/ParameterManager.d.ts +42 -0
  9. package/dist/Player/Player.d.ts +73 -0
  10. package/dist/Player/SkillManager.d.ts +23 -0
  11. package/dist/Player/StateManager.d.ts +39 -0
  12. package/{lib → dist}/RpgServer.d.ts +34 -17
  13. package/dist/RpgServerEngine.d.ts +5 -0
  14. package/dist/core/context.d.ts +2 -0
  15. package/dist/core/inject.d.ts +5 -0
  16. package/dist/core/setup.d.ts +6 -0
  17. package/dist/index.d.ts +9 -0
  18. package/dist/index.js +29673 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/module.d.ts +2 -0
  21. package/dist/rooms/lobby.d.ts +6 -0
  22. package/dist/rooms/map.d.ts +110 -0
  23. package/package.json +16 -38
  24. package/src/Gui/DialogGui.ts +3 -4
  25. package/src/Gui/Gui.ts +4 -6
  26. package/src/Player/BattleManager.ts +108 -99
  27. package/src/Player/ClassManager.ts +47 -46
  28. package/src/Player/ComponentManager.ts +26 -535
  29. package/src/Player/EffectManager.ts +44 -59
  30. package/src/Player/ElementManager.ts +70 -72
  31. package/src/Player/Event.ts +0 -0
  32. package/src/Player/GoldManager.ts +24 -6
  33. package/src/Player/GuiManager.ts +106 -97
  34. package/src/Player/ItemFixture.ts +22 -17
  35. package/src/Player/ItemManager.ts +234 -225
  36. package/src/Player/MoveManager.ts +1047 -457
  37. package/src/Player/ParameterManager.ts +59 -37
  38. package/src/Player/Player.ts +272 -1058
  39. package/src/Player/SkillManager.ts +146 -137
  40. package/src/Player/StateManager.ts +124 -98
  41. package/src/Player/VariableManager.ts +23 -3
  42. package/src/RpgServer.ts +38 -14
  43. package/src/RpgServerEngine.ts +7 -0
  44. package/src/core/context.ts +3 -0
  45. package/src/core/inject.ts +17 -0
  46. package/src/core/setup.ts +20 -0
  47. package/src/index.ts +9 -31
  48. package/src/module.ts +32 -0
  49. package/src/presets/index.ts +1 -3
  50. package/src/rooms/lobby.ts +24 -0
  51. package/src/rooms/map.ts +311 -0
  52. package/tsconfig.json +26 -23
  53. package/vite.config.ts +21 -0
  54. package/CHANGELOG.md +0 -163
  55. package/LICENSE +0 -19
  56. package/browser/manifest.json +0 -7
  57. package/browser/rpg.server.js +0 -22372
  58. package/browser/rpg.server.umd.cjs +0 -22403
  59. package/lib/Game/EventManager.d.ts +0 -54
  60. package/lib/Game/EventManager.js +0 -107
  61. package/lib/Game/EventManager.js.map +0 -1
  62. package/lib/Game/Map.d.ts +0 -191
  63. package/lib/Game/Map.js +0 -414
  64. package/lib/Game/Map.js.map +0 -1
  65. package/lib/Game/WorldMaps.d.ts +0 -17
  66. package/lib/Game/WorldMaps.js +0 -28
  67. package/lib/Game/WorldMaps.js.map +0 -1
  68. package/lib/Gui/DialogGui.js +0 -57
  69. package/lib/Gui/DialogGui.js.map +0 -1
  70. package/lib/Gui/Gui.js +0 -37
  71. package/lib/Gui/Gui.js.map +0 -1
  72. package/lib/Gui/MenuGui.js +0 -23
  73. package/lib/Gui/MenuGui.js.map +0 -1
  74. package/lib/Gui/NotificationGui.js +0 -8
  75. package/lib/Gui/NotificationGui.js.map +0 -1
  76. package/lib/Gui/ShopGui.js +0 -40
  77. package/lib/Gui/ShopGui.js.map +0 -1
  78. package/lib/Gui/index.js +0 -7
  79. package/lib/Gui/index.js.map +0 -1
  80. package/lib/Interfaces/Gui.d.ts +0 -4
  81. package/lib/Interfaces/Gui.js +0 -2
  82. package/lib/Interfaces/Gui.js.map +0 -1
  83. package/lib/Interfaces/StateStore.d.ts +0 -5
  84. package/lib/Interfaces/StateStore.js +0 -2
  85. package/lib/Interfaces/StateStore.js.map +0 -1
  86. package/lib/MatchMaker.d.ts +0 -24
  87. package/lib/MatchMaker.js +0 -42
  88. package/lib/MatchMaker.js.map +0 -1
  89. package/lib/Monitor/index.d.ts +0 -17
  90. package/lib/Monitor/index.js +0 -72
  91. package/lib/Monitor/index.js.map +0 -1
  92. package/lib/Player/BattleManager.d.ts +0 -36
  93. package/lib/Player/BattleManager.js +0 -101
  94. package/lib/Player/BattleManager.js.map +0 -1
  95. package/lib/Player/ClassManager.d.ts +0 -47
  96. package/lib/Player/ClassManager.js +0 -65
  97. package/lib/Player/ClassManager.js.map +0 -1
  98. package/lib/Player/ComponentManager.d.ts +0 -397
  99. package/lib/Player/ComponentManager.js +0 -505
  100. package/lib/Player/ComponentManager.js.map +0 -1
  101. package/lib/Player/EffectManager.d.ts +0 -46
  102. package/lib/Player/EffectManager.js +0 -75
  103. package/lib/Player/EffectManager.js.map +0 -1
  104. package/lib/Player/ElementManager.d.ts +0 -108
  105. package/lib/Player/ElementManager.js +0 -120
  106. package/lib/Player/ElementManager.js.map +0 -1
  107. package/lib/Player/GoldManager.d.ts +0 -17
  108. package/lib/Player/GoldManager.js +0 -27
  109. package/lib/Player/GoldManager.js.map +0 -1
  110. package/lib/Player/GuiManager.d.ts +0 -247
  111. package/lib/Player/GuiManager.js +0 -291
  112. package/lib/Player/GuiManager.js.map +0 -1
  113. package/lib/Player/ItemFixture.d.ts +0 -7
  114. package/lib/Player/ItemFixture.js +0 -19
  115. package/lib/Player/ItemFixture.js.map +0 -1
  116. package/lib/Player/ItemManager.d.ts +0 -331
  117. package/lib/Player/ItemManager.js +0 -475
  118. package/lib/Player/ItemManager.js.map +0 -1
  119. package/lib/Player/MoveManager.d.ts +0 -333
  120. package/lib/Player/MoveManager.js +0 -450
  121. package/lib/Player/MoveManager.js.map +0 -1
  122. package/lib/Player/ParameterManager.d.ts +0 -316
  123. package/lib/Player/ParameterManager.js +0 -408
  124. package/lib/Player/ParameterManager.js.map +0 -1
  125. package/lib/Player/Player.d.ts +0 -828
  126. package/lib/Player/Player.js +0 -927
  127. package/lib/Player/Player.js.map +0 -1
  128. package/lib/Player/SkillManager.d.ts +0 -163
  129. package/lib/Player/SkillManager.js +0 -223
  130. package/lib/Player/SkillManager.js.map +0 -1
  131. package/lib/Player/StateManager.d.ts +0 -185
  132. package/lib/Player/StateManager.js +0 -228
  133. package/lib/Player/StateManager.js.map +0 -1
  134. package/lib/Player/VariableManager.d.ts +0 -46
  135. package/lib/Player/VariableManager.js +0 -52
  136. package/lib/Player/VariableManager.js.map +0 -1
  137. package/lib/Query.d.ts +0 -127
  138. package/lib/Query.js +0 -159
  139. package/lib/Query.js.map +0 -1
  140. package/lib/RpgServer.js +0 -2
  141. package/lib/RpgServer.js.map +0 -1
  142. package/lib/Scenes/Map.d.ts +0 -136
  143. package/lib/Scenes/Map.js +0 -273
  144. package/lib/Scenes/Map.js.map +0 -1
  145. package/lib/decorators/event.d.ts +0 -43
  146. package/lib/decorators/event.js +0 -13
  147. package/lib/decorators/event.js.map +0 -1
  148. package/lib/decorators/map.d.ts +0 -178
  149. package/lib/decorators/map.js +0 -43
  150. package/lib/decorators/map.js.map +0 -1
  151. package/lib/entry-point.d.ts +0 -34
  152. package/lib/entry-point.js +0 -70
  153. package/lib/entry-point.js.map +0 -1
  154. package/lib/express/api.d.ts +0 -3
  155. package/lib/express/api.js +0 -105
  156. package/lib/express/api.js.map +0 -1
  157. package/lib/express/errors/NotAuthorized.d.ts +0 -4
  158. package/lib/express/errors/NotAuthorized.js +0 -7
  159. package/lib/express/errors/NotAuthorized.js.map +0 -1
  160. package/lib/express/errors/NotFound.d.ts +0 -4
  161. package/lib/express/errors/NotFound.js +0 -7
  162. package/lib/express/errors/NotFound.js.map +0 -1
  163. package/lib/express/server.d.ts +0 -16
  164. package/lib/express/server.js +0 -65
  165. package/lib/express/server.js.map +0 -1
  166. package/lib/index.d.ts +0 -20
  167. package/lib/index.js +0 -19
  168. package/lib/index.js.map +0 -1
  169. package/lib/inject.d.ts +0 -22
  170. package/lib/inject.js +0 -29
  171. package/lib/inject.js.map +0 -1
  172. package/lib/logs/index.js +0 -6
  173. package/lib/logs/index.js.map +0 -1
  174. package/lib/logs/item.js +0 -34
  175. package/lib/logs/item.js.map +0 -1
  176. package/lib/logs/log.js +0 -7
  177. package/lib/logs/log.js.map +0 -1
  178. package/lib/logs/skill.js +0 -19
  179. package/lib/logs/skill.js.map +0 -1
  180. package/lib/logs/state.js +0 -13
  181. package/lib/logs/state.js.map +0 -1
  182. package/lib/models/Item.d.ts +0 -10
  183. package/lib/models/Item.js +0 -2
  184. package/lib/models/Item.js.map +0 -1
  185. package/lib/presets/index.js +0 -65
  186. package/lib/presets/index.js.map +0 -1
  187. package/lib/server.d.ts +0 -137
  188. package/lib/server.js +0 -443
  189. package/lib/server.js.map +0 -1
  190. package/rpg.toml +0 -14
  191. package/src/Game/EventManager.ts +0 -125
  192. package/src/Game/Map.ts +0 -495
  193. package/src/Game/WorldMaps.ts +0 -45
  194. package/src/Interfaces/Gui.ts +0 -4
  195. package/src/Interfaces/StateStore.ts +0 -5
  196. package/src/MatchMaker.ts +0 -65
  197. package/src/Monitor/index.ts +0 -78
  198. package/src/Query.ts +0 -172
  199. package/src/Scenes/Map.ts +0 -310
  200. package/src/decorators/event.ts +0 -58
  201. package/src/decorators/map.ts +0 -226
  202. package/src/entry-point.ts +0 -111
  203. package/src/express/api.ts +0 -118
  204. package/src/express/errors/NotAuthorized.ts +0 -6
  205. package/src/express/errors/NotFound.ts +0 -6
  206. package/src/express/server.ts +0 -87
  207. package/src/inject.ts +0 -33
  208. package/src/models/Item.ts +0 -11
  209. package/src/server.ts +0 -459
  210. /package/{lib → dist}/Gui/MenuGui.d.ts +0 -0
  211. /package/{lib → dist}/Gui/NotificationGui.d.ts +0 -0
  212. /package/{lib → dist}/Gui/ShopGui.d.ts +0 -0
  213. /package/{lib → dist}/Gui/index.d.ts +0 -0
  214. /package/{lib → dist}/logs/index.d.ts +0 -0
  215. /package/{lib → dist}/logs/item.d.ts +0 -0
  216. /package/{lib → dist}/logs/log.d.ts +0 -0
  217. /package/{lib → dist}/logs/skill.d.ts +0 -0
  218. /package/{lib → dist}/logs/state.d.ts +0 -0
  219. /package/{lib → dist}/presets/index.d.ts +0 -0
@@ -1,505 +0,0 @@
1
- import { Utils } from '@rpgjs/common';
2
- const defaultStyle = (style) => ({
3
- borderColor: '#000000',
4
- borderWidth: 2,
5
- bgColor: '#000000',
6
- borderRadius: 5,
7
- ...style
8
- });
9
- const bar = (current, max, style, text) => {
10
- return {
11
- id: 'bar',
12
- value: {
13
- current,
14
- max,
15
- text: text === null ? '' : text || '{$current}/{$max}',
16
- style
17
- }
18
- };
19
- };
20
- export const Components = {
21
- /**
22
- * Displays a bar
23
- *
24
- * Example:
25
- *
26
- * ```ts
27
- * import { Components } from '@rpgjs/server'
28
- * Components.bar('hp', 'param.maxHp', {
29
- * bgColor: '#ab0606'
30
- * })
31
- * ```
32
- *
33
- * For text, you can use the following variables:
34
- * - {$current} current value
35
- * - {$max} maximum value
36
- * - {$percent} percentage
37
- *
38
- * Example:
39
- *
40
- * ```ts
41
- * import { Components } from '@rpgjs/server'
42
- * Components.bar('hp', 'param.maxHp', {
43
- * bgColor: '#ab0606'
44
- * }, 'HP: {$current}/{$max}')
45
- * ```
46
- *
47
- * and you can also use the variables of player:
48
- *
49
- * ```ts
50
- * import { Components } from '@rpgjs/server'
51
- * Components.bar('hp', 'param.maxHp', {
52
- * bgColor: '#ab0606'
53
- * }, 'HP: {$current}/{$max} - {name}') // HP: 100/100 - John
54
- * ```
55
- *
56
- * @title Bar Component
57
- * @param {string} current Parameter that corresponds to the current value
58
- * @param {string} max Parameter that corresponds to the maximum value
59
- * @param {object} [style] style
60
- * @param {string} [style.bgColor] background color. Hexadecimal format.
61
- * @param {string} [style.fillColor] fill color. Hexadecimal format.
62
- * @param {string} [style.borderColor] border color. Hexadecimal format.
63
- * @param {number} [style.borderWidth] border width
64
- * @param {number} [style.height] height
65
- * @param {number} [style.width] width
66
- * @param {number} [style.borderRadius] border radius
67
- * @param {number} [style.opacity] opacity
68
- * @param {string | null} [text] text above bar. if null, no text will be displayed. You can use the variables
69
- * @returns {BarComponentObject}
70
- * @memberof Components
71
- * @since 3.3.0
72
- */
73
- bar,
74
- /**
75
- * Displays a life bar
76
- *
77
- * @title HP Bar Component
78
- * @param {object} [style] style. See bar style (Components.bar())
79
- * @param {string | null} [text] test above bar (Components.bar())
80
- * @returns {BarComponentObject}
81
- * @memberof Components
82
- * @since 3.3.0
83
- */
84
- hpBar(style, text) {
85
- return bar('hp', 'param.maxHp', {
86
- ...defaultStyle({
87
- fillColor: '#ab0606'
88
- }),
89
- ...(style || {})
90
- }, text);
91
- },
92
- /**
93
- * Displays a SP bar
94
- *
95
- * @title SP Bar Component
96
- * @param {object} [style] style. See bar style (Components.bar())
97
- * @param {string | null} [text] test above bar (Components.bar())
98
- * @returns {BarComponentObject}
99
- * @memberof Components
100
- * @since 3.3.0
101
- */
102
- spBar(style, text) {
103
- return bar('sp', 'param.maxSp', {
104
- ...defaultStyle({
105
- fillColor: '#0fa38c'
106
- }),
107
- ...(style || {}),
108
- }, text);
109
- },
110
- /**
111
- * Put on the text. You can read the content of a variable with {} format (see example below)
112
- *
113
- * Example:
114
- *
115
- * ```ts
116
- * import { Components } from '@rpgjs/server'
117
- * Components.text('Hello World')
118
- * ```
119
- *
120
- * Example with variable:
121
- *
122
- * ```ts
123
- * import { Components } from '@rpgjs/server'
124
- * Components.text('{name}')
125
- * ```
126
- *
127
- * Other example with position:
128
- *
129
- * ```ts
130
- * import { Components } from '@rpgjs/server'
131
- * Components.text('X: {position.x} Y: {position.y}')
132
- * ```
133
- *
134
- * With style:
135
- *
136
- * ```ts
137
- * import { Components } from '@rpgjs/server'
138
- * Components.text('Hello World', {
139
- * fill: '#ffffff',
140
- * fontSize: 20,
141
- * fontFamily: 'Arial',
142
- * stroke: '#000000',
143
- * fontStyle: 'italic',
144
- * fontWeight: 'bold'
145
- * })
146
- * ```
147
- *
148
- * @title Text Component
149
- * @param {string} value source
150
- * @param {object} [style] style
151
- * @param {string} [style.fill] color. Hexadecimal format.
152
- * @param {number} [style.fontSize] font size
153
- * @param {string} [style.fontFamily] font family
154
- * @param {string} [style.stroke] stroke color. Hexadecimal format.
155
- * @param {'normal' | 'italic' | 'oblique'} [style.fontStyle] font style
156
- * @param {'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'} [style.fontWeight] font weight
157
- * @param {number} [style.opacity] opacity. Between 0 and 1
158
- * @param {boolean} [style.wordWrap] word wrap
159
- * @param {'left' | 'center' | 'right' | 'justify'} [style.align] align
160
- * @returns {TextComponentObject}
161
- * @memberof Components
162
- * @since 3.3.0
163
- */
164
- text(value, style) {
165
- return {
166
- id: 'text',
167
- value: {
168
- text: value,
169
- style: {
170
- fill: '#ffffff',
171
- fontSize: 15,
172
- ...(style || {})
173
- }
174
- }
175
- };
176
- },
177
- /**
178
- * Add a shape
179
- *
180
- * Example:
181
- *
182
- * ```ts
183
- * import { Components } from '@rpgjs/server'
184
- * Components.shape({
185
- * fill: '#ffffff',
186
- * type: 'circle',
187
- * radius: 10
188
- * })
189
- * ```
190
- *
191
- * You can use parameters:
192
- *
193
- * ```ts
194
- * import { Components } from '@rpgjs/server'
195
- * Components.shape({
196
- * fill: '#ffffff',
197
- * type: 'circle',
198
- * radius: 'hp'
199
- * })
200
- * ```
201
- *
202
- * Here, the radius will be the same as the hp value
203
- *
204
- * @title Shape Component
205
- * @param {object} value
206
- * @param {string} value.fill color. Hexadecimal format.
207
- * @param {number | string} [value.opacity] opacity. Between 0 and 1
208
- * @param {string} value.type type of shape. Can be 'circle' or 'rectangle', 'ellipse' or 'polygon', 'line' or 'rounded-rectangle'
209
- * @param {number | string} [value.radius] if type is circle, radius of the circle
210
- * @param {number | string} [value.width] if type is rectangle or ellipse, width of the rectangle
211
- * @param {number | string} [value.height] if type is rectangle or ellipse, height of the rectangle
212
- * @param {number | string} [value.x1] if type is line, x1 position of the line
213
- * @param {number | string} [value.y1] if type is line, y1 position of the line
214
- * @param {number | string} [value.x2] if type is line, x2 position of the line
215
- * @param {number | string} [value.y2] if type is line, y2 position of the line
216
- * @param {number[]} [value.points] if type is polygon, points of the polygon
217
- * @param {object} [value.line] border style
218
- * @param {string} [value.line.color] border color. Hexadecimal format.
219
- * @param {number} [value.line.width] border width
220
- * @param {number} [value.line.alpha] border opacity. Between 0 and 1
221
- * @returns {ShapeComponentObject}
222
- * @memberof Components
223
- * @since 3.3.0
224
- */
225
- shape(value) {
226
- return {
227
- id: 'shape',
228
- value
229
- };
230
- },
231
- /**
232
- * Put the link to an image or the identifier of an image (if the spritesheet exists)
233
- *
234
- * Example:
235
- *
236
- * ```ts
237
- * import { Components } from '@rpgjs/server'
238
- * Components.image('mygraphic.png')
239
- * ```
240
- *
241
- * @title Image Component
242
- * @param {string} value source
243
- * @returns {ImageComponentObject}
244
- * @memberof Components
245
- * @since 3.3.0
246
- */
247
- image(value) {
248
- return {
249
- id: 'image',
250
- value
251
- };
252
- },
253
- /**
254
- * Indicates the tile ID
255
- *
256
- * Example:
257
- *
258
- * ```ts
259
- * import { Components } from '@rpgjs/server'
260
- * Components.tile(3)
261
- * ```
262
- *
263
- * @title Tile Component
264
- * @param {number} value tile ID
265
- * @returns {TileComponentObject}
266
- * @memberof Components
267
- * @since 3.3.0
268
- */
269
- tile(value) {
270
- return {
271
- id: 'tile',
272
- value
273
- };
274
- },
275
- debug() {
276
- return {
277
- id: 'debug',
278
- value: ''
279
- };
280
- }
281
- };
282
- export class ComponentManager {
283
- /**
284
- * Give the spritesheet identifier
285
- *
286
- * Since version 3.0.0-rc, you can define several graphic elements. If you put a number, it represents the tile ID in the tileset
287
- *
288
- * Example 1:
289
- * ```ts
290
- * player.setGraphic(['body', 'shield'])
291
- * ```
292
- *
293
- * Example 2:
294
- * ```ts
295
- * player.setGraphic(3) // Use tile #3
296
- * ```
297
- *
298
- * > You must, on the client side, create the spritesheet in question. Guide: [Create Sprite](/guide/create-sprite.html)
299
- *
300
- * @title Set Graphic
301
- * @method player.setGraphic(graphic)
302
- * @param {string | number | (string | number)[]} graphic
303
- * @returns {void}
304
- * @memberof ComponentManager
305
- */
306
- setGraphic(graphic) {
307
- const components = (Utils.isArray(graphic) ? graphic : [graphic]);
308
- const col = [...components.map(value => ({ id: Utils.isString(value) ? 'graphic' : 'tile', value }))];
309
- this.removeComponentById('center', 'graphic');
310
- this.mergeComponent('center', col);
311
- }
312
- /**
313
- * Delete components
314
- *
315
- * @title Remove Components
316
- * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
317
- * @memberof ComponentManager
318
- * @since 3.3.0
319
- */
320
- removeComponents(position) {
321
- this.layout[position].lines = [];
322
- }
323
- /**
324
- * Delete components by id.
325
- *
326
- * @title Remove Component By Id
327
- * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
328
- * @param {string} id Id of the component
329
- * @since 3.3.0
330
- */
331
- removeComponentById(position, id) {
332
- let lines = this.layout[position]?.lines || [];
333
- lines = lines.map(line => {
334
- line.col = line.col.filter(c => c.id !== id);
335
- return line;
336
- });
337
- lines = lines.filter(line => line.col.length > 0);
338
- this.layout[position].lines = lines;
339
- }
340
- /**
341
- * Merges components with existing components
342
- *
343
- * For use layout and options, see [setComponentsTop](/api/player.html#setcomponentstop)
344
- *
345
- * @title Merge Components
346
- * @param {string} position Position of the components. Can be: `top`, `center`, `bottom`, `left`, `right`
347
- * @param {Object} layout
348
- * @param {Object} options
349
- * @memberof ComponentManager
350
- * @since 3.3.0
351
- */
352
- mergeComponent(position, layout, options = {}) {
353
- if (!(layout instanceof Array)) {
354
- layout = [layout];
355
- }
356
- this.layout[position] = {
357
- lines: [
358
- ...(this.layout[position]?.lines || []),
359
- ...layout.map(col => {
360
- if (!Utils.isArray(col)) {
361
- col = [col];
362
- }
363
- return { col };
364
- })
365
- ],
366
- ...options
367
- };
368
- }
369
- setComponents(position, layout, options = {}) {
370
- this.layout[position].lines = [];
371
- this.mergeComponent(position, layout, options);
372
- }
373
- /**
374
- * Add components to the center of the graphic.
375
- *
376
- * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
377
- *
378
- * > Be careful, because if you assign, it deletes the graphics and if the lines are superimposed (unlike the other locations)
379
- *
380
- * @title Set Components Center
381
- * @method player.setComponentsCenter(layout,options)
382
- * @param {Object} layout
383
- * @param {Object} options
384
- * @memberof ComponentManager
385
- * @since 3.3.0
386
- */
387
- setComponentsCenter(layout, options = {}) {
388
- this.setComponents('center', layout, options);
389
- }
390
- /**
391
- * Add components to the top of the graphic. e.g. text, life bar etc. The block will be centred
392
- * The first array corresponds to the rows, and the nested table to the array in the row
393
- *
394
- * Example:
395
- *
396
- * ```ts
397
- * import { Components } from '@rpgjs/server'
398
- *
399
- * player.setComponentsTop([
400
- * [Components.text('Hello World')],
401
- * [Components.hpBar()]
402
- * ]) // 2 lines with 1 component each
403
- * ```
404
- *
405
- * or
406
- *
407
- * ```ts
408
- * import { Components } from '@rpgjs/server'
409
- *
410
- * player.setComponentsTop([
411
- * [Components.text('Hello World'), Components.hpBar()]
412
- * ]) // 1 line with 2 components
413
- * ```
414
- *
415
- * You can be faster if you only have lines
416
- *
417
- * ```ts
418
- * player.setComponentsTop([
419
- * Components.text('Hello World'),
420
- * Components.hpBar()
421
- * ]) // 2 lines with 1 component each
422
- * ```
423
- *
424
- * or one component:
425
- *
426
- * ```ts
427
- * player.setComponentsTop(Components.text('Hello World')) // 1 line with 1 component
428
- * ```
429
- *
430
- * You can add options to manage the style
431
- *
432
- * ```ts
433
- * player.setComponentsTop([
434
- * Components.text('Hello World'),
435
- * Components.hpBar()
436
- * ], {
437
- * width: 100,
438
- * height: 20,
439
- * marginTop: 10,
440
- * })
441
- * ```
442
- *
443
- * @title Set Components Top
444
- * @method player.setComponentsTop(layout,options)
445
- * @param {ComponentObject[][] | ComponentObject[] | ComponentObject} layout Components
446
- * @param {Object} [options = {}] Options
447
- * @param {number} [options.width] Width of the block
448
- * @param {number} [options.height = 20] Height of the block
449
- * @param {number} [options.marginTop] Margin top
450
- * @param {number} [options.marginBottom] Margin bottom
451
- * @param {number} [options.marginLeft] Margin left
452
- * @param {number} [options.marginRight] Margin right
453
- * @memberof ComponentManager
454
- * @since 3.3.0
455
- */
456
- setComponentsTop(layout, options = {}) {
457
- this.setComponents('top', layout, options);
458
- }
459
- /**
460
- * Add components to the bottom of the graphic.
461
- *
462
- * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
463
- *
464
- * @title Set Components Bottom
465
- * @method player.setComponentsBottom(layout,options)
466
- * @param {Object} layout
467
- * @param {Object} options
468
- * @memberof ComponentManager
469
- * @since 3.3.0
470
- */
471
- setComponentsBottom(layout, options = {}) {
472
- this.setComponents('bottom', layout, options);
473
- }
474
- /**
475
- * Add components to the left of the graphic.
476
- *
477
- * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
478
- *
479
- * @title Set Components Left
480
- * @method player.setComponentsLeft(layout,options)
481
- * @param {Object} layout
482
- * @param {Object} options
483
- * @memberof ComponentManager
484
- * @since 3.3.0
485
- */
486
- setComponentsLeft(layout, options = {}) {
487
- this.setComponents('left', layout, options);
488
- }
489
- /**
490
- * Add components to the right of the graphic.
491
- *
492
- * View [setComponentsTop](/api/player.html#setcomponentstop) for more information
493
- *
494
- * @title Set Components Right
495
- * @method player.setComponentsRight(layout,options)
496
- * @param {Object} layout
497
- * @param {Object} options
498
- * @memberof ComponentManager
499
- * @since 3.3.0
500
- */
501
- setComponentsRight(layout, options = {}) {
502
- this.setComponents('right', layout, options);
503
- }
504
- }
505
- //# sourceMappingURL=ComponentManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentManager.js","sourceRoot":"","sources":["../../src/Player/ComponentManager.ts"],"names":[],"mappings":"AAAA,OAAO,EA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,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;CACJ"}
@@ -1,46 +0,0 @@
1
- import { Effect } from '@rpgjs/database';
2
- import { ParameterManager } from './ParameterManager';
3
- export declare class EffectManager {
4
- _effects: Effect[];
5
- applyEffect(item: any): void;
6
- /**
7
- * ```ts
8
- * import { Effect } from '@rpgjs/database'
9
- *
10
- * const bool = player.hasEffect(Effect.CAN_NOT_SKILL)
11
- * ```
12
- *
13
- * @title Has Effect
14
- * @method player.hasEffect(effect)
15
- * @param {Effect} effect
16
- * @returns {boolean}
17
- * @memberof EffectManager
18
- * */
19
- hasEffect(effect: Effect): boolean;
20
- /**
21
- * Retrieves a array of effects assigned to the player, state effects and effects of weapons and armors equipped with the player's own weapons.
22
- *
23
- * ```ts
24
- * console.log(player.effects)
25
- * ```
26
- * @title Get Effects
27
- * @prop {Array<Effect>} player.effects
28
- * @memberof EffectManager
29
- * */
30
- get effects(): any[];
31
- /**
32
- * Assigns effects to the player. If you give a array, it does not change the effects of the player's states and armor/weapons equipped.
33
- *
34
- * ```ts
35
- * import { Effect } from '@rpgjs/database'
36
- *
37
- * player.effects = [Effect.CAN_NOT_SKILL]
38
- * ```
39
- * @title Set Effects
40
- * @prop {Array<Effect>} player.effects
41
- * @memberof EffectManager
42
- * */
43
- set effects(val: any[]);
44
- }
45
- export interface EffectManager extends ParameterManager {
46
- }
@@ -1,75 +0,0 @@
1
- import { Utils } from '@rpgjs/common';
2
- import { ParameterManager } from './ParameterManager.js';
3
- import { MAXHP, MAXSP } from '../presets/index.js';
4
- const { arrayUniq, arrayFlat, applyMixins } = Utils;
5
- export class EffectManager {
6
- // TODO
7
- applyEffect(item) {
8
- if (item.hpValue) {
9
- this.hp += item.hpValue;
10
- }
11
- if (item.hpRate) {
12
- this.hp += this.param[MAXHP] * item.hpRate;
13
- }
14
- if (item.spValue) {
15
- this.sp += item.spValue;
16
- }
17
- if (item.spRate) {
18
- this.sp += this.param[MAXSP] * item.spRate;
19
- }
20
- }
21
- /**
22
- * ```ts
23
- * import { Effect } from '@rpgjs/database'
24
- *
25
- * const bool = player.hasEffect(Effect.CAN_NOT_SKILL)
26
- * ```
27
- *
28
- * @title Has Effect
29
- * @method player.hasEffect(effect)
30
- * @param {Effect} effect
31
- * @returns {boolean}
32
- * @memberof EffectManager
33
- * */
34
- hasEffect(effect) {
35
- return this.effects.includes(effect);
36
- }
37
- /**
38
- * Retrieves a array of effects assigned to the player, state effects and effects of weapons and armors equipped with the player's own weapons.
39
- *
40
- * ```ts
41
- * console.log(player.effects)
42
- * ```
43
- * @title Get Effects
44
- * @prop {Array<Effect>} player.effects
45
- * @memberof EffectManager
46
- * */
47
- get effects() {
48
- const getEffects = (prop) => {
49
- return arrayFlat(this[prop]
50
- .map(el => el.effects || []));
51
- };
52
- return arrayUniq([
53
- ...this._effects,
54
- ...getEffects('states'),
55
- ...getEffects('equipments')
56
- ]);
57
- }
58
- /**
59
- * Assigns effects to the player. If you give a array, it does not change the effects of the player's states and armor/weapons equipped.
60
- *
61
- * ```ts
62
- * import { Effect } from '@rpgjs/database'
63
- *
64
- * player.effects = [Effect.CAN_NOT_SKILL]
65
- * ```
66
- * @title Set Effects
67
- * @prop {Array<Effect>} player.effects
68
- * @memberof EffectManager
69
- * */
70
- set effects(val) {
71
- this._effects = val;
72
- }
73
- }
74
- applyMixins(EffectManager, [ParameterManager]);
75
- //# sourceMappingURL=EffectManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EffectManager.js","sourceRoot":"","sources":["../../src/Player/EffectManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAO,eAAe,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EACH,KAAK,EACL,KAAK,EACR,MAAM,YAAY,CAAA;AAEnB,MAAM,EACF,SAAS,EACT,SAAS,EACT,WAAW,EACd,GAAG,KAAK,CAAA;AAET,MAAM,OAAO,aAAa;IAItB,OAAO;I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