@rpgjs/server 5.0.0-alpha.4 → 5.0.0-alpha.41

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 (101) hide show
  1. package/dist/Gui/DialogGui.d.ts +5 -0
  2. package/dist/Gui/GameoverGui.d.ts +23 -0
  3. package/dist/Gui/Gui.d.ts +6 -0
  4. package/dist/Gui/MenuGui.d.ts +22 -3
  5. package/dist/Gui/NotificationGui.d.ts +1 -2
  6. package/dist/Gui/SaveLoadGui.d.ts +13 -0
  7. package/dist/Gui/ShopGui.d.ts +28 -3
  8. package/dist/Gui/TitleGui.d.ts +23 -0
  9. package/dist/Gui/index.d.ts +10 -1
  10. package/dist/Player/BattleManager.d.ts +34 -12
  11. package/dist/Player/ClassManager.d.ts +46 -13
  12. package/dist/Player/ComponentManager.d.ts +123 -0
  13. package/dist/Player/Components.d.ts +345 -0
  14. package/dist/Player/EffectManager.d.ts +86 -0
  15. package/dist/Player/ElementManager.d.ts +104 -0
  16. package/dist/Player/GoldManager.d.ts +22 -0
  17. package/dist/Player/GuiManager.d.ts +259 -0
  18. package/dist/Player/ItemFixture.d.ts +6 -0
  19. package/dist/Player/ItemManager.d.ts +450 -9
  20. package/dist/Player/MoveManager.d.ts +324 -69
  21. package/dist/Player/ParameterManager.d.ts +344 -14
  22. package/dist/Player/Player.d.ts +460 -8
  23. package/dist/Player/SkillManager.d.ts +197 -15
  24. package/dist/Player/StateManager.d.ts +89 -25
  25. package/dist/Player/VariableManager.d.ts +74 -0
  26. package/dist/RpgServer.d.ts +502 -64
  27. package/dist/RpgServerEngine.d.ts +2 -1
  28. package/dist/decorators/event.d.ts +46 -0
  29. package/dist/decorators/map.d.ts +287 -0
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.js +21653 -20900
  32. package/dist/index.js.map +1 -1
  33. package/dist/logs/log.d.ts +2 -3
  34. package/dist/module.d.ts +43 -1
  35. package/dist/presets/index.d.ts +0 -9
  36. package/dist/rooms/BaseRoom.d.ts +132 -0
  37. package/dist/rooms/lobby.d.ts +10 -2
  38. package/dist/rooms/map.d.ts +1236 -17
  39. package/dist/services/save.d.ts +43 -0
  40. package/dist/storage/index.d.ts +1 -0
  41. package/dist/storage/localStorage.d.ts +23 -0
  42. package/package.json +14 -10
  43. package/src/Gui/DialogGui.ts +19 -4
  44. package/src/Gui/GameoverGui.ts +39 -0
  45. package/src/Gui/Gui.ts +23 -1
  46. package/src/Gui/MenuGui.ts +155 -6
  47. package/src/Gui/NotificationGui.ts +1 -2
  48. package/src/Gui/SaveLoadGui.ts +60 -0
  49. package/src/Gui/ShopGui.ts +146 -16
  50. package/src/Gui/TitleGui.ts +39 -0
  51. package/src/Gui/index.ts +15 -2
  52. package/src/Player/BattleManager.ts +91 -49
  53. package/src/Player/ClassManager.ts +118 -50
  54. package/src/Player/ComponentManager.ts +425 -19
  55. package/src/Player/Components.ts +380 -0
  56. package/src/Player/EffectManager.ts +81 -44
  57. package/src/Player/ElementManager.ts +109 -86
  58. package/src/Player/GoldManager.ts +32 -35
  59. package/src/Player/GuiManager.ts +308 -150
  60. package/src/Player/ItemFixture.ts +4 -5
  61. package/src/Player/ItemManager.ts +774 -355
  62. package/src/Player/MoveManager.ts +1544 -774
  63. package/src/Player/ParameterManager.ts +546 -104
  64. package/src/Player/Player.ts +1163 -88
  65. package/src/Player/SkillManager.ts +520 -195
  66. package/src/Player/StateManager.ts +170 -182
  67. package/src/Player/VariableManager.ts +101 -63
  68. package/src/RpgServer.ts +525 -63
  69. package/src/core/context.ts +1 -0
  70. package/src/decorators/event.ts +61 -0
  71. package/src/decorators/map.ts +327 -0
  72. package/src/index.ts +11 -1
  73. package/src/logs/log.ts +10 -3
  74. package/src/module.ts +126 -3
  75. package/src/presets/index.ts +1 -10
  76. package/src/rooms/BaseRoom.ts +232 -0
  77. package/src/rooms/lobby.ts +25 -7
  78. package/src/rooms/map.ts +2502 -194
  79. package/src/services/save.ts +147 -0
  80. package/src/storage/index.ts +1 -0
  81. package/src/storage/localStorage.ts +76 -0
  82. package/tests/battle.spec.ts +375 -0
  83. package/tests/change-map.spec.ts +72 -0
  84. package/tests/class.spec.ts +274 -0
  85. package/tests/effect.spec.ts +219 -0
  86. package/tests/element.spec.ts +221 -0
  87. package/tests/event.spec.ts +80 -0
  88. package/tests/gold.spec.ts +99 -0
  89. package/tests/item.spec.ts +609 -0
  90. package/tests/module.spec.ts +38 -0
  91. package/tests/move.spec.ts +601 -0
  92. package/tests/player-param.spec.ts +28 -0
  93. package/tests/prediction-reconciliation.spec.ts +182 -0
  94. package/tests/random-move.spec.ts +65 -0
  95. package/tests/skill.spec.ts +658 -0
  96. package/tests/state.spec.ts +467 -0
  97. package/tests/variable.spec.ts +185 -0
  98. package/tests/world-maps.spec.ts +896 -0
  99. package/vite.config.ts +16 -0
  100. package/dist/Player/Event.d.ts +0 -0
  101. package/src/Player/Event.ts +0 -0
@@ -0,0 +1,259 @@
1
+ import { RpgPlayer } from './Player';
2
+ import { Gui } from '../Gui';
3
+ import { DialogOptions, Choice } from '../Gui/DialogGui';
4
+ import { SaveLoadOptions, SaveSlot } from '../Gui/SaveLoadGui';
5
+ import { MenuGuiOptions } from '../Gui/MenuGui';
6
+ import { GameoverGuiOptions, GameoverGuiSelection } from '../Gui/GameoverGui';
7
+ import { PlayerCtor } from '../../../common/src';
8
+ /**
9
+ * GUI Manager Mixin
10
+ *
11
+ * Provides graphical user interface management capabilities to any class. This mixin handles
12
+ * dialog boxes, menus, notifications, shops, and custom GUI components. It manages the
13
+ * complete GUI system including opening, closing, and data passing between client and server.
14
+ *
15
+ * @param Base - The base class to extend with GUI management
16
+ * @returns Extended class with GUI management methods
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * class MyPlayer extends WithGuiManager(BasePlayer) {
21
+ * constructor() {
22
+ * super();
23
+ * // GUI system is automatically initialized
24
+ * }
25
+ * }
26
+ *
27
+ * const player = new MyPlayer();
28
+ * await player.showText('Hello World!');
29
+ * player.callMainMenu();
30
+ * ```
31
+ */
32
+ export declare function WithGuiManager<TBase extends PlayerCtor>(Base: TBase): new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & IGuiManager;
33
+ /**
34
+ * Interface for GUI management capabilities
35
+ * Defines the methods that will be available on the player
36
+ */
37
+ export interface IGuiManager {
38
+ /**
39
+ * Show a text. This is a graphical interface already built. Opens the GUI named `rpg-dialog`
40
+ *
41
+ * ```ts
42
+ * player.showText('Hello World')
43
+ * ```
44
+ *
45
+ * The method returns a promise. It is resolved when the dialog box is closed.
46
+ *
47
+ * ```ts
48
+ * await player.showText('Hello World')
49
+ * // dialog box is closed, then ...
50
+ * ```
51
+ *
52
+ * **Option: position**
53
+ *
54
+ * You can define how the dialog box is displayed:
55
+ * - top
56
+ * - middle
57
+ * - bottom
58
+ *
59
+ * (bottom by default)
60
+ *
61
+ * ```ts
62
+ * player.showText('Hello World', {
63
+ * position: 'top'
64
+ * })
65
+ * ```
66
+ *
67
+ * **Option: fullWidth**
68
+ *
69
+ * `boolean` (true by default)
70
+ *
71
+ * Indicate that the dialog box will take the full width of the screen.
72
+ *
73
+ * ```ts
74
+ * player.showText('Hello World', {
75
+ * fullWidth: true
76
+ * })
77
+ * ```
78
+ *
79
+ * **Option: autoClose**
80
+ *
81
+ * `boolean` (false by default)
82
+ *
83
+ * If false, the user will have to press Enter to close the dialog box.
84
+ *
85
+ * ```ts
86
+ * player.showText('Hello World', {
87
+ * autoClose: true
88
+ * })
89
+ * ```
90
+ *
91
+ * **Option: typewriterEffect**
92
+ *
93
+ * `boolean` (true by default)
94
+ *
95
+ * Performs a typewriter effect
96
+ *
97
+ * ```ts
98
+ * player.showText('Hello World', {
99
+ * typewriterEffect: false
100
+ * })
101
+ * ```
102
+ *
103
+ * **Option: talkWith**
104
+ *
105
+ * `RpgPlayer` (nothing by default)
106
+ *
107
+ * If you specify the event or another player, the other player will stop his or her movement and look in the player's direction.
108
+ *
109
+ * ```ts
110
+ * // Code in an event
111
+ * player.showText('Hello World', {
112
+ * talkWith: this
113
+ * })
114
+ * ```
115
+ *
116
+ * @title Show Text
117
+ * @method player.showText(text,options)
118
+ * @param {string} text
119
+ * @param {object} [options] the different options, see usage below
120
+ * @returns {Promise}
121
+ * @memberof GuiManager
122
+ */
123
+ showText(msg: string, options?: DialogOptions): Promise<any>;
124
+ /**
125
+ * Shows a dialog box with a choice. Opens the GUI named `rpg-dialog`
126
+ *
127
+ * ```ts
128
+ * const choice = await player.showChoices('What color do you prefer?', [
129
+ * { text: 'Black', value: 'black' },
130
+ * { text: 'Rather the blue', value: 'blue' },
131
+ * { text: 'I don\'t have a preference!', value: 'none' }
132
+ * ])
133
+ *
134
+ * // If the player selects the first
135
+ * console.log(choice) // { text: 'Black', value: 'black' }
136
+ * ```
137
+ *
138
+ * @title Show Choices
139
+ * @method player.showChoices(text,choices)
140
+ * @param {string} text
141
+ * @param {Array<{ text: string, value: any }>} choices
142
+ * @param {object} [options] Same options as the openDialog method
143
+ * @returns {Promise<Choice | null>}
144
+ * @memberof GuiManager
145
+ */
146
+ showChoices(msg: string, choices: Choice[], options?: DialogOptions): Promise<Choice | null>;
147
+ /**
148
+ * Displays a notification . Opens the GUI named `rpg-notification`
149
+ *
150
+ * @title Displays a notification
151
+ * @method player.showNotification()
152
+ * @param {string} message - The message to display in the notification
153
+ * @param {object} options - An object containing options for the notification
154
+ * @param {number} options.time - The time to display the notification for (in ms). Default: 2000ms
155
+ * @param {string} options.icon - The icon to display in the notification. Put the identifier of the spritesheet (defined on the client side)
156
+ * @param {string} options.sound - The sound to play when the notification is shown. Set the sound ID (defined on the client side)
157
+ * @returns {void}
158
+ * @memberof GuiManager
159
+ */
160
+ showNotification(message: string, options?: {
161
+ time?: number;
162
+ icon?: string;
163
+ sound?: string;
164
+ type?: "info" | "warn" | "error";
165
+ }): Promise<any>;
166
+ /**
167
+ * Display a save/load slots screen. Opens the GUI named `rpg-save`
168
+ *
169
+ * ```ts
170
+ * const index = await player.showSaveLoad(slots, { mode: 'save' })
171
+ * ```
172
+ *
173
+ * @title Show Save/Load
174
+ * @method player.showSaveLoad(slots,options)
175
+ * @param {Array<object>} slots
176
+ * @param {object} [options]
177
+ * @returns {Promise<number | null>}
178
+ * @memberof GuiManager
179
+ */
180
+ showSaveLoad(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
181
+ /**
182
+ * Display a save slots screen. Opens the GUI named `rpg-save`
183
+ *
184
+ * ```ts
185
+ * const index = await player.showSave(slots)
186
+ * ```
187
+ *
188
+ * @title Show Save
189
+ * @method player.showSave(slots,options)
190
+ * @param {Array<object>} slots
191
+ * @param {object} [options]
192
+ * @returns {Promise<number | null>}
193
+ * @memberof GuiManager
194
+ */
195
+ showSave(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
196
+ /**
197
+ * Display a load slots screen. Opens the GUI named `rpg-save`
198
+ *
199
+ * ```ts
200
+ * const index = await player.showLoad(slots)
201
+ * ```
202
+ *
203
+ * @title Show Load
204
+ * @method player.showLoad(slots,options)
205
+ * @param {Array<object>} slots
206
+ * @param {object} [options]
207
+ * @returns {Promise<number | null>}
208
+ * @memberof GuiManager
209
+ */
210
+ showLoad(slots?: SaveSlot[], options?: SaveLoadOptions): Promise<number | null>;
211
+ /**
212
+ * Calls main menu. Opens the GUI named `rpg-main-menu`
213
+ *
214
+ * @title Call Main Menu
215
+ * @method player.callMainMenu(options)
216
+ * @param {object} [options]
217
+ * @returns {void}
218
+ * @memberof GuiManager
219
+ */
220
+ callMainMenu(options?: MenuGuiOptions): void;
221
+ /**
222
+ * Calls game over menu. Opens the GUI named `rpg-gameover`
223
+ *
224
+ * ```ts
225
+ * const selection = await player.callGameover()
226
+ * if (selection?.id === 'title') {
227
+ * await player.gui('rpg-title-screen').open()
228
+ * }
229
+ * if (selection?.id === 'load') {
230
+ * await player.showLoad()
231
+ * }
232
+ * ```
233
+ *
234
+ * @title Call Game Over Menu
235
+ * @method player.callGameover(options)
236
+ * @param {object} [options]
237
+ * @returns {Promise<GameoverGuiSelection | null>}
238
+ * @memberof GuiManager
239
+ */
240
+ callGameover(options?: GameoverGuiOptions): Promise<GameoverGuiSelection | null>;
241
+ callShop(items: any[] | {
242
+ items: any[];
243
+ sell?: Record<string, number> | Array<{
244
+ id: string;
245
+ multiplier: number;
246
+ }>;
247
+ sellMultiplier?: number;
248
+ message?: string;
249
+ face?: {
250
+ id: string;
251
+ expression?: string;
252
+ };
253
+ }): void;
254
+ gui(guiId: string): Gui;
255
+ getGui(guiId: string): Gui;
256
+ removeGui(guiId: string, data?: any): void;
257
+ showAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
258
+ hideAttachedGui(players?: RpgPlayer[] | RpgPlayer): void;
259
+ }
@@ -0,0 +1,6 @@
1
+ import { ItemInstance } from '@rpgjs/database';
2
+ import { PlayerCtor } from '../../../common/src';
3
+ export declare function WithItemFixture<TBase extends PlayerCtor>(Base: TBase): TBase;
4
+ export interface ItemFixture {
5
+ equipments: ItemInstance[];
6
+ }