pixi-rainman-game-engine 0.3.0 → 0.3.1

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 (176) hide show
  1. package/dist/ComponentRegistry/ComponentRegistry.d.ts +23 -9
  2. package/dist/ComponentRegistry/ComponentRegistry.js +25 -10
  3. package/dist/ComponentRegistry/types.d.ts +0 -2
  4. package/dist/DescribedPlayableAction/DescribedPlayableAction.d.ts +2 -0
  5. package/dist/DescribedPlayableAction/DescribedPlayableAction.js +2 -0
  6. package/dist/Money/MoneyText.d.ts +5 -0
  7. package/dist/Money/MoneyText.js +5 -0
  8. package/dist/SettingsUI/hooks/useBuyFreeSpins/useBuyFreeSpins.d.ts +4 -0
  9. package/dist/SettingsUI/hooks/useBuyFreeSpins/useBuyFreeSpins.js +4 -0
  10. package/dist/SettingsUI/hooks/useDeviceOrientations.d.ts +4 -0
  11. package/dist/SettingsUI/hooks/useDeviceOrientations.js +4 -0
  12. package/dist/application/ApiConfig/ApiConfig.d.ts +2 -1
  13. package/dist/application/ApiConfig/ApiConfig.js +3 -2
  14. package/dist/application/ApiConfig/SymbolId.d.ts +1 -1
  15. package/dist/application/ButtonsEventManager/ButtonsEventManager.d.ts +35 -5
  16. package/dist/application/ButtonsEventManager/ButtonsEventManager.js +38 -7
  17. package/dist/application/SoundManager/SoundManager.d.ts +26 -1
  18. package/dist/application/SoundManager/SoundManager.js +30 -2
  19. package/dist/application/SpeedState/SpeedAdapter.d.ts +9 -0
  20. package/dist/application/SpeedState/SpeedAdapter.js +9 -0
  21. package/dist/application/SpeedState/SpeedLevel.d.ts +42 -0
  22. package/dist/application/SpeedState/SpeedLevel.js +30 -0
  23. package/dist/application/SpeedState/SpeedLevelHandler.d.ts +7 -0
  24. package/dist/application/SpeedState/SpeedLevelHandler.js +7 -0
  25. package/dist/application/SpinLogic/SpinLogic.d.ts +58 -0
  26. package/dist/application/SpinLogic/SpinLogic.js +58 -0
  27. package/dist/application/SpinLogic/SpinLogicDTO.d.ts +70 -0
  28. package/dist/application/SpinLogic/SpinLogicDTO.js +70 -0
  29. package/dist/application/SpinLogic/WinScenarios.d.ts +12 -0
  30. package/dist/application/SpinLogic/WinScenarios.js +12 -0
  31. package/dist/application/SpinLogic/types.d.ts +10 -0
  32. package/dist/application/TimedActions/IncentiveComponent.d.ts +10 -0
  33. package/dist/application/TimedActions/IncentiveComponent.js +9 -1
  34. package/dist/application/TimedActions/TimedIncentiveController.d.ts +37 -0
  35. package/dist/application/TimedActions/TimedIncentiveController.js +37 -0
  36. package/dist/application/setup.d.ts +0 -1
  37. package/dist/application/setup.js +0 -1
  38. package/dist/components/AbstractFreeSpinContainer/AbstractFreeSpinContainer.d.ts +36 -1
  39. package/dist/components/AbstractFreeSpinContainer/AbstractFreeSpinContainer.js +25 -0
  40. package/dist/components/AbstractMainContainer/AbstractMainContainer.d.ts +83 -2
  41. package/dist/components/AbstractMainContainer/AbstractMainContainer.js +97 -11
  42. package/dist/components/DoubleBorderText/DoubleBorderText.d.ts +10 -0
  43. package/dist/components/DoubleBorderText/DoubleBorderText.js +24 -0
  44. package/dist/components/DoubleBorderText/index.d.ts +1 -0
  45. package/dist/components/DoubleBorderText/index.js +1 -0
  46. package/dist/components/GambleGame/GambleGame.d.ts +39 -0
  47. package/dist/components/GambleGame/GambleGame.js +43 -3
  48. package/dist/components/GambleGame/types.d.ts +5 -0
  49. package/dist/components/buttons/BaseButton/BaseButton.d.ts +72 -1
  50. package/dist/components/buttons/BaseButton/BaseButton.js +73 -2
  51. package/dist/components/buttons/BaseButton/types.d.ts +5 -0
  52. package/dist/components/buttons/buttonGroups/LeftButtons.d.ts +11 -0
  53. package/dist/components/buttons/buttonGroups/LeftButtons.js +11 -0
  54. package/dist/components/buttons/buttonGroups/LeftButtonsLandscape.d.ts +13 -1
  55. package/dist/components/buttons/buttonGroups/LeftButtonsLandscape.js +13 -1
  56. package/dist/components/buttons/buttonGroups/LeftButtonsMobile.d.ts +19 -1
  57. package/dist/components/buttons/buttonGroups/LeftButtonsMobile.js +19 -1
  58. package/dist/components/buttons/buttonGroups/MiddleButtons.d.ts +18 -1
  59. package/dist/components/buttons/buttonGroups/MiddleButtons.js +18 -1
  60. package/dist/components/buttons/buttonGroups/RightButtons.d.ts +10 -0
  61. package/dist/components/buttons/buttonGroups/RightButtons.js +10 -0
  62. package/dist/components/buttons/buttonGroups/RightButtonsLandscape.d.ts +11 -0
  63. package/dist/components/buttons/buttonGroups/RightButtonsLandscape.js +11 -0
  64. package/dist/components/buttons/buttonGroups/RightButtonsMobile.d.ts +17 -0
  65. package/dist/components/buttons/buttonGroups/RightButtonsMobile.js +17 -0
  66. package/dist/components/buttons/default/AutoplayButton.d.ts +6 -0
  67. package/dist/components/buttons/default/AutoplayButton.js +8 -1
  68. package/dist/components/buttons/default/RefreshButton.d.ts +30 -0
  69. package/dist/components/buttons/default/RefreshButton.js +36 -3
  70. package/dist/components/buttons/default/SpeedControlButton.d.ts +2 -0
  71. package/dist/components/buttons/default/SpeedControlButton.js +2 -0
  72. package/dist/components/buttons/default/VolumeButton.d.ts +2 -0
  73. package/dist/components/buttons/default/VolumeButton.js +2 -0
  74. package/dist/components/common/AnimatedBackground.d.ts +22 -0
  75. package/dist/components/common/AnimatedBackground.js +22 -0
  76. package/dist/components/common/AnimatedNumber.d.ts +36 -0
  77. package/dist/components/common/AnimatedNumber.js +36 -0
  78. package/dist/components/common/Background.d.ts +20 -0
  79. package/dist/components/common/Background.js +22 -1
  80. package/dist/components/common/FreeSpinButton.d.ts +33 -1
  81. package/dist/components/common/FreeSpinButton.js +37 -4
  82. package/dist/components/common/IResizableContainer.d.ts +4 -0
  83. package/dist/components/common/Logo.d.ts +21 -0
  84. package/dist/components/common/Logo.js +21 -0
  85. package/dist/components/common/LogoStatic.d.ts +10 -0
  86. package/dist/components/common/LogoStatic.js +10 -0
  87. package/dist/components/common/ResponsiveComponent.d.ts +22 -0
  88. package/dist/components/common/ResponsiveComponent.js +10 -0
  89. package/dist/components/common/ResumableContainers.d.ts +6 -0
  90. package/dist/components/common/ResumableContainers.js +6 -0
  91. package/dist/components/common/ScalableSpine.d.ts +11 -0
  92. package/dist/components/common/ScalableSpine.js +11 -0
  93. package/dist/components/frame/AbstractColumnsContainer.d.ts +20 -6
  94. package/dist/components/frame/AbstractColumnsContainer.js +18 -4
  95. package/dist/components/frame/AbstractFrame.d.ts +115 -0
  96. package/dist/components/frame/AbstractFrame.js +97 -2
  97. package/dist/components/frame/AbstractInnerFrame.d.ts +5 -0
  98. package/dist/components/frame/AbstractInnerFrame.js +5 -0
  99. package/dist/components/frame/WinLineAnimation.d.ts +10 -0
  100. package/dist/components/frame/WinLineAnimation.js +12 -1
  101. package/dist/components/frame/constants.d.ts +7 -0
  102. package/dist/components/frame/constants.js +3 -0
  103. package/dist/components/index.d.ts +1 -0
  104. package/dist/components/index.js +1 -0
  105. package/dist/components/messageBox/MessageBox.d.ts +33 -0
  106. package/dist/components/messageBox/MessageBox.js +33 -0
  107. package/dist/components/symbols/AbstractSymbolBase.d.ts +146 -2
  108. package/dist/components/symbols/AbstractSymbolBase.js +137 -14
  109. package/dist/components/symbols/AbstractSymbolsColumn.d.ts +233 -3
  110. package/dist/components/symbols/AbstractSymbolsColumn.js +220 -10
  111. package/dist/components/symbols/DroppableSymbol.d.ts +16 -0
  112. package/dist/components/symbols/DroppableSymbol.js +16 -0
  113. package/dist/components/symbols/DroppableSymbolsColumn.d.ts +51 -0
  114. package/dist/components/symbols/DroppableSymbolsColumn.js +57 -3
  115. package/dist/components/symbols/types.d.ts +8 -0
  116. package/dist/components/symbols/types.js +4 -0
  117. package/dist/components/updatable/GambleUpdatableText.d.ts +5 -0
  118. package/dist/components/updatable/GambleUpdatableText.js +5 -0
  119. package/dist/components/updatable/StylefulUpdatableText.d.ts +23 -0
  120. package/dist/components/updatable/StylefulUpdatableText.js +25 -1
  121. package/dist/components/updatable/UpdatableValueComponent.d.ts +71 -0
  122. package/dist/components/updatable/UpdatableValueComponent.js +77 -4
  123. package/dist/connectivity/ConnectionWrapper.d.ts +20 -1
  124. package/dist/connectivity/ConnectionWrapper.js +23 -3
  125. package/dist/connectivity/LocalConnectionWrapper.d.ts +2 -2
  126. package/dist/connectivity/LocalConnectionWrapper.js +2 -2
  127. package/dist/connectivity/serverConnection.d.ts +59 -0
  128. package/dist/connectivity/serverData.d.ts +3 -1
  129. package/dist/connectivity/spinData.d.ts +15 -0
  130. package/dist/connectivity/spinData.js +15 -0
  131. package/dist/constants/gamePhase.d.ts +4 -0
  132. package/dist/controllers/AbstractController.d.ts +114 -5
  133. package/dist/controllers/AbstractController.js +143 -22
  134. package/dist/controllers/QuickStopController.d.ts +3 -0
  135. package/dist/controllers/QuickStopController.js +3 -0
  136. package/dist/controllers/UiController.d.ts +163 -1
  137. package/dist/controllers/UiController.js +170 -5
  138. package/dist/errors/LanguageNotDefinedError.d.ts +4 -0
  139. package/dist/errors/LanguageNotDefinedError.js +4 -0
  140. package/dist/errors/SpineDataNotFound.d.ts +4 -0
  141. package/dist/errors/SpineDataNotFound.js +4 -0
  142. package/dist/errors/TextureNotFound.d.ts +4 -0
  143. package/dist/errors/TextureNotFound.js +4 -0
  144. package/dist/loading/AbstractLoadingContainer.d.ts +16 -0
  145. package/dist/loading/AbstractLoadingContainer.js +16 -0
  146. package/dist/loading/SpriteLoadingContainer.d.ts +18 -0
  147. package/dist/loading/SpriteLoadingContainer.js +18 -0
  148. package/dist/localStorage/localStorage.d.ts +23 -0
  149. package/dist/localStorage/localStorage.js +19 -0
  150. package/dist/stores/SettingsStore.d.ts +269 -3
  151. package/dist/stores/SettingsStore.js +289 -13
  152. package/dist/stores/types.d.ts +4 -0
  153. package/dist/utils/assets/assetGetter.js +6 -3
  154. package/dist/utils/common/deviceOrientation.js +2 -1
  155. package/dist/utils/common/functions.d.ts +57 -1
  156. package/dist/utils/common/functions.js +63 -4
  157. package/dist/utils/common/logger.js +4 -2
  158. package/dist/utils/common/placementHelpers.d.ts +14 -0
  159. package/dist/utils/common/placementHelpers.js +20 -1
  160. package/dist/utils/common/screenHelpers.d.ts +28 -0
  161. package/dist/utils/common/screenHelpers.js +34 -3
  162. package/dist/utils/common/sound.d.ts +1 -0
  163. package/dist/utils/common/sound.js +2 -0
  164. package/dist/utils/common/stats.d.ts +1 -0
  165. package/dist/utils/common/stats.js +2 -0
  166. package/dist/winComponents/AnimableParticlesEmitter.d.ts +6 -0
  167. package/dist/winComponents/AnimableParticlesEmitter.js +6 -0
  168. package/dist/winComponents/BaseWinContainer.d.ts +64 -0
  169. package/dist/winComponents/BaseWinContainer.js +66 -1
  170. package/dist/winComponents/PositioningFrame.d.ts +7 -0
  171. package/dist/winComponents/PositioningFrame.js +7 -0
  172. package/dist/winComponents/TexturedText.d.ts +23 -0
  173. package/dist/winComponents/TexturedText.js +23 -0
  174. package/dist/winComponents/UpdatableSpineContainer.d.ts +25 -0
  175. package/dist/winComponents/UpdatableSpineContainer.js +25 -0
  176. package/package.json +1 -1
@@ -9,7 +9,6 @@ import { SPEED_LEVELS } from "../SpeedState";
9
9
  export const SPEED_PREFIX = "speed-";
10
10
  /**
11
11
  * Class for managing buttons in games
12
- *
13
12
  * This class includes methods for enabling/disabling buttons in game.
14
13
  *
15
14
  * The buttons that include each game:
@@ -20,6 +19,7 @@ export const SPEED_PREFIX = "speed-";
20
19
  * - More Button
21
20
  * - Autoplay Button
22
21
  * - Volume Button
22
+ * @class ButtonsEventManager
23
23
  */
24
24
  export class ButtonsEventManager {
25
25
  settingsPlusButton = null;
@@ -30,16 +30,19 @@ export class ButtonsEventManager {
30
30
  settingsSpeedCheetah = null;
31
31
  /**
32
32
  * Last layer invoked
33
+ * @private
33
34
  * @memberof ButtonsEventManager
34
35
  */
35
36
  lastLayerInvoked = "";
36
37
  /**
37
38
  * Speed popup shown at for measuring time of showing speed popup
39
+ * @public
38
40
  * @memberof ButtonsEventManager
39
41
  */
40
42
  speedPopupShownAt = 0;
41
43
  /**
42
44
  * Function for enabling/disabling buttons in game
45
+ * @private
43
46
  * @param {boolean} makeDisabled - flag for enabling/disabling buttons
44
47
  * @returns {() => void} function for enabling/disabling buttons
45
48
  */
@@ -53,7 +56,19 @@ export class ButtonsEventManager {
53
56
  buttonsToDisable.forEach((buttonRegistryName) => RainMan.componentRegistry.get(buttonRegistryName).flipDisabledFlag(makeDisabled));
54
57
  RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume();
55
58
  };
59
+ /**
60
+ * Function for enabling buttons in the game
61
+ * In some game phases, games need to have buttons enabled.
62
+ * @public
63
+ * @returns {void}
64
+ */
56
65
  enableButtons = this.setButtonAvailability(false);
66
+ /**
67
+ * Function for disabling buttons in the game
68
+ * In some game phases, games need to have buttons disabled.
69
+ * @public
70
+ * @returns {void}
71
+ */
57
72
  disableButtons = this.setButtonAvailability(true);
58
73
  constructor() {
59
74
  RainMan.settingsStore.handleModalInvocation = this.handleModalInvocation.bind(this);
@@ -62,7 +77,9 @@ export class ButtonsEventManager {
62
77
  }
63
78
  /**
64
79
  * Method for initializing events in Settings UI
80
+ * This method also change the incentive text based on the selected speed level
65
81
  * @public
82
+ * @returns {void}
66
83
  */
67
84
  initSettingsEvents() {
68
85
  const messageBox = RainMan.componentRegistry.get(MessageBox.registryName);
@@ -131,6 +148,7 @@ export class ButtonsEventManager {
131
148
  /**
132
149
  * Method for setting up animated background
133
150
  * @public
151
+ * @returns {void}
134
152
  */
135
153
  setUpUIElementsInteractivity() {
136
154
  const animatedBackground = RainMan.componentRegistry.get(Background.registryName);
@@ -147,7 +165,8 @@ export class ButtonsEventManager {
147
165
  * Method for initializing Plus button
148
166
  * This method changes bet in game based on given strategy
149
167
  * @public
150
- * @param {(strategy: "first" | "increase" | "decrease") => void} setBetCallback - callback for setting bet
168
+ * @param {(strategy: BetStrategy) => void} setBetCallback - callback for setting bet
169
+ * @returns {void}
151
170
  */
152
171
  initBetPlusButtonEvent(setBetCallback) {
153
172
  const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
@@ -164,15 +183,17 @@ export class ButtonsEventManager {
164
183
  * Method for initializing Neg button
165
184
  * This method changes bet in game based on given strategy
166
185
  * @public
167
- * @param {(strategy: "first" | "increase" | "decrease") => void} setBetCallback - callback for setting bet
186
+ * @param {(strategy: BetStrategy) => void} setBetCallback - callback for setting bet
187
+ * @returns {void}
168
188
  */
169
189
  initBetMinusButtonEvent(setBetCallback) {
170
190
  if (this.settingsMinusButton === null) {
171
191
  const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
172
192
  this.settingsMinusButton = window.document.getElementsByName("bet-minus")[0];
173
193
  this.settingsMinusButton.addEventListener("click", () => {
174
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
194
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled) {
175
195
  return;
196
+ }
176
197
  setBetCallback("decrease");
177
198
  });
178
199
  }
@@ -180,6 +201,7 @@ export class ButtonsEventManager {
180
201
  /**
181
202
  * Method for enabling ability to buy free spins in game
182
203
  * @public
204
+ * @returns {void}
183
205
  */
184
206
  initFreeSpinModal() {
185
207
  RainMan.componentRegistry
@@ -191,6 +213,7 @@ export class ButtonsEventManager {
191
213
  * This method changes texture of Volume button based on volume level
192
214
  * If music was muted, it will be resumed
193
215
  * @public
216
+ * @returns {void}
194
217
  */
195
218
  initVolumeButtonEvent() {
196
219
  RainMan.settingsStore.setUpdateVolumeButtonTexture(() => RainMan.componentRegistry.get(VolumeButton.registryName).changeTextureDependOnVolume());
@@ -209,6 +232,7 @@ export class ButtonsEventManager {
209
232
  /**
210
233
  * Method for initializing button with information about mechanics in game
211
234
  * @public
235
+ * @returns {void} - void
212
236
  */
213
237
  initInfoButtonEvent() {
214
238
  RainMan.componentRegistry.get(BUTTONS.info).setOnClick(() => {
@@ -221,6 +245,7 @@ export class ButtonsEventManager {
221
245
  /**
222
246
  * Method for initializing more button
223
247
  * @public
248
+ * @returns {void} - void
224
249
  */
225
250
  initMoreButtonEvent() {
226
251
  RainMan.componentRegistry.get(BUTTONS.more).setOnClick(() => {
@@ -233,6 +258,7 @@ export class ButtonsEventManager {
233
258
  /**
234
259
  * Method for initializing Autoplay button
235
260
  * @public
261
+ * @returns {void} - void
236
262
  */
237
263
  initAutoplayButtonEvent() {
238
264
  RainMan.componentRegistry.get(AutoplayButton.registryName).setOnClick(() => {
@@ -255,11 +281,12 @@ export class ButtonsEventManager {
255
281
  * @public
256
282
  * @param {() => void} onClick - callback for gamble game
257
283
  * @param {boolean} disabled - flag for enabling/disabling button
284
+ * @returns {void}
258
285
  */
259
286
  initGambleButton(onClick, disabled) {
260
- if (!RainMan.componentRegistry.has(BUTTONS.gamble) && RainMan.settingsStore.gambleGameUsed)
287
+ if (!RainMan.componentRegistry.has(BUTTONS.gamble) && RainMan.settingsStore.gambleGameUsed) {
261
288
  return;
262
- RainMan.componentRegistry.get(BUTTONS.gamble).setOnClick(onClick);
289
+ }
263
290
  RainMan.componentRegistry.get(BUTTONS.gamble).flipDisabledFlag(disabled);
264
291
  }
265
292
  /**
@@ -267,6 +294,7 @@ export class ButtonsEventManager {
267
294
  * This modal is used while doing turbo spin
268
295
  * @public
269
296
  * @param {("flex" | "none")} displayValue - flag for displaying modal
297
+ * @returns {void}
270
298
  */
271
299
  setSpeedPopupVisibility(displayValue) {
272
300
  if (displayValue === "flex")
@@ -281,6 +309,7 @@ export class ButtonsEventManager {
281
309
  * Function for handling autostart conformation
282
310
  * @public
283
311
  * @param {() => void} confirmAutoplayButtonCallback - callback for confirming autoplay
312
+ * @returns {void}
284
313
  */
285
314
  setConfirmAutoplayButton(confirmAutoplayButtonCallback) {
286
315
  const confirmAutoplayButton = window.document.getElementById(COMPONENTS.autoSpinConfirm);
@@ -323,10 +352,12 @@ export class ButtonsEventManager {
323
352
  * Function for displaying modal layer with given name
324
353
  * @private
325
354
  * @param {string} layerName - name of layer
355
+ * @returns {void}
326
356
  */
327
357
  handleModalInvocation(layerName) {
328
- if (this.checkAnyLayerIsPresent(layerName) && RainMan.globals.shouldShowModals)
358
+ if (this.checkAnyLayerIsPresent(layerName) && RainMan.globals.shouldShowModals) {
329
359
  return;
360
+ }
330
361
  if (this.checkAnyLayerIsPresent(layerName)) {
331
362
  this.closeOtherModals(layerName);
332
363
  }
@@ -5,8 +5,9 @@ export declare const pixiSoundContext: typeof sound.context;
5
5
  /**
6
6
  * Class for managing sound in game, uses the pixi sound library
7
7
  * The class uses SoundTrack enum to access specified sounds
8
+ * This class is a singleton class
9
+ * @class SoundManagerInstance
8
10
  * @implements {SpeedAdapterInterface<SoundOverrides>}
9
- * @class
10
11
  */
11
12
  export declare class SoundManagerInstance implements SpeedAdapterInterface<SoundOverrides> {
12
13
  private static instance;
@@ -17,62 +18,86 @@ export declare class SoundManagerInstance implements SpeedAdapterInterface<Sound
17
18
  constructor();
18
19
  /**
19
20
  * Function for loading sounds into pixi
21
+ * @public
20
22
  * @param {Record<string, string>} assets - sound assets
23
+ * @returns {Promise<void>} - promise that resolves when all sounds are loaded
21
24
  */
22
25
  loadSounds(assets: Record<string, string>): Promise<void>;
23
26
  /**
24
27
  * Function for setting volume level for each sound in game
28
+ * @public
25
29
  * @param {number} volumeLevel - volume level from 0-1
30
+ * @returns {void}
26
31
  */
27
32
  setVolume(volumeLevel: number): void;
28
33
  /**
29
34
  * Function for stopping sound effect in game
35
+ * @public
36
+ * @returns {void}
30
37
  */
31
38
  stopPlayingFxSounds(): void;
32
39
  /**
33
40
  * Function for resuming and pausing sound in game
41
+ * @public
34
42
  * @param {SoundTrack} soundName - sound name
35
43
  * @param {boolean} flag - flag for playing or pausing sound
44
+ * @returns {void}
36
45
  */
37
46
  setPlayStatus(soundName: SoundTrack, flag: boolean): void;
38
47
  /**
39
48
  * Function for playing sound with given name
49
+ * @public
40
50
  * @param {SoundTrack} soundName - name of the sound
51
+ * @returns {void}
41
52
  */
42
53
  play(soundName: SoundTrack): void;
43
54
  /**
44
55
  * Function for resuming all sounds in game
45
56
  * If sound is not playing, it will be skipped
57
+ * @public
58
+ * @returns {void}
46
59
  */
47
60
  resumeAll(): void;
48
61
  /**
49
62
  * Function for pausing all sounds in game
50
63
  * If sound is not playing, it will be skipped
64
+ * @public
65
+ * @returns {void}
51
66
  */
52
67
  pauseAll(): void;
53
68
  /**
54
69
  * Function for stopping all sounds in game
55
70
  * If sound is not playing, it will be skipped
71
+ * @public
72
+ * @returns {void}
56
73
  */
57
74
  stopAll(): void;
58
75
  /**
59
76
  * Function for pausing sound with given name
77
+ * @public
60
78
  * @param {SoundTrack} soundName - name of the sound
79
+ * @returns {void}
61
80
  */
62
81
  pause(soundName: SoundTrack): void;
63
82
  /**
64
83
  * Function for resuming sound with given name
84
+ * @public
65
85
  * @param {SoundTrack} soundName - name of the sound
86
+ * @returns {void}
66
87
  */
67
88
  resume(soundName: SoundTrack): void;
68
89
  /**
69
90
  * Function for adapting sound into the speed of animations
91
+ * @public
70
92
  * @param {SpeedLevel} speedLevel - speed level
93
+ * @returns {void}
71
94
  */
72
95
  adaptToSpeed(speedLevel: SpeedLevel): void;
73
96
  /**
74
97
  * Function for stopping sound with given name
98
+ * @public
75
99
  * @param {SoundTrack} soundName - name of the sound
100
+ * @returns {void}
76
101
  */
77
102
  stop(soundName: SoundTrack): void;
78
103
  }
@@ -6,8 +6,9 @@ export const pixiSoundContext = sound.context;
6
6
  /**
7
7
  * Class for managing sound in game, uses the pixi sound library
8
8
  * The class uses SoundTrack enum to access specified sounds
9
+ * This class is a singleton class
10
+ * @class SoundManagerInstance
9
11
  * @implements {SpeedAdapterInterface<SoundOverrides>}
10
- * @class
11
12
  */
12
13
  export class SoundManagerInstance {
13
14
  static instance;
@@ -29,7 +30,9 @@ export class SoundManagerInstance {
29
30
  }
30
31
  /**
31
32
  * Function for loading sounds into pixi
33
+ * @public
32
34
  * @param {Record<string, string>} assets - sound assets
35
+ * @returns {Promise<void>} - promise that resolves when all sounds are loaded
33
36
  */
34
37
  async loadSounds(assets) {
35
38
  const loadingSoundsPromises = [];
@@ -51,7 +54,9 @@ export class SoundManagerInstance {
51
54
  }
52
55
  /**
53
56
  * Function for setting volume level for each sound in game
57
+ * @public
54
58
  * @param {number} volumeLevel - volume level from 0-1
59
+ * @returns {void}
55
60
  */
56
61
  setVolume(volumeLevel) {
57
62
  this.musicCatalogue.forEach((sound) => {
@@ -65,6 +70,8 @@ export class SoundManagerInstance {
65
70
  }
66
71
  /**
67
72
  * Function for stopping sound effect in game
73
+ * @public
74
+ * @returns {void}
68
75
  */
69
76
  stopPlayingFxSounds() {
70
77
  for (const [soundName, sound] of this.musicCatalogue.entries()) {
@@ -75,15 +82,19 @@ export class SoundManagerInstance {
75
82
  }
76
83
  /**
77
84
  * Function for resuming and pausing sound in game
85
+ * @public
78
86
  * @param {SoundTrack} soundName - sound name
79
87
  * @param {boolean} flag - flag for playing or pausing sound
88
+ * @returns {void}
80
89
  */
81
90
  setPlayStatus(soundName, flag) {
82
91
  flag ? this.play(soundName) : this.pause(soundName);
83
92
  }
84
93
  /**
85
94
  * Function for playing sound with given name
95
+ * @public
86
96
  * @param {SoundTrack} soundName - name of the sound
97
+ * @returns {void}
87
98
  */
88
99
  play(soundName) {
89
100
  if (!RainMan.settingsStore.shouldPlayFxSounds) {
@@ -102,15 +113,20 @@ export class SoundManagerInstance {
102
113
  !RainMan.settingsStore.shouldPlayAmbientMusic) {
103
114
  return;
104
115
  }
116
+ const soundLevel = RainMan.settingsStore.volumeLevel / 100;
105
117
  sound.play({
106
118
  loop: soundsToLoop.includes(soundName),
107
119
  singleInstance: true,
108
- volume: soundName === SoundTracks.music || soundName === SoundTracks.freeSpinsMusic ? 0.5 : 1
120
+ volume: soundName === SoundTracks.music || soundName === SoundTracks.freeSpinsMusic
121
+ ? soundLevel * 0.5
122
+ : soundLevel
109
123
  });
110
124
  }
111
125
  /**
112
126
  * Function for resuming all sounds in game
113
127
  * If sound is not playing, it will be skipped
128
+ * @public
129
+ * @returns {void}
114
130
  */
115
131
  resumeAll() {
116
132
  this.musicCatalogue.forEach((sound, soundName) => {
@@ -134,6 +150,8 @@ export class SoundManagerInstance {
134
150
  /**
135
151
  * Function for pausing all sounds in game
136
152
  * If sound is not playing, it will be skipped
153
+ * @public
154
+ * @returns {void}
137
155
  */
138
156
  pauseAll() {
139
157
  this.musicCatalogue.forEach((sound) => sound.pause());
@@ -141,34 +159,44 @@ export class SoundManagerInstance {
141
159
  /**
142
160
  * Function for stopping all sounds in game
143
161
  * If sound is not playing, it will be skipped
162
+ * @public
163
+ * @returns {void}
144
164
  */
145
165
  stopAll() {
146
166
  this.musicCatalogue.forEach((sound) => sound.stop());
147
167
  }
148
168
  /**
149
169
  * Function for pausing sound with given name
170
+ * @public
150
171
  * @param {SoundTrack} soundName - name of the sound
172
+ * @returns {void}
151
173
  */
152
174
  pause(soundName) {
153
175
  this.musicCatalogue.get(soundName)?.pause();
154
176
  }
155
177
  /**
156
178
  * Function for resuming sound with given name
179
+ * @public
157
180
  * @param {SoundTrack} soundName - name of the sound
181
+ * @returns {void}
158
182
  */
159
183
  resume(soundName) {
160
184
  this.musicCatalogue.get(soundName)?.resume();
161
185
  }
162
186
  /**
163
187
  * Function for adapting sound into the speed of animations
188
+ * @public
164
189
  * @param {SpeedLevel} speedLevel - speed level
190
+ * @returns {void}
165
191
  */
166
192
  adaptToSpeed(speedLevel) {
167
193
  this.overrides = this.speedLevelMapper[speedLevel];
168
194
  }
169
195
  /**
170
196
  * Function for stopping sound with given name
197
+ * @public
171
198
  * @param {SoundTrack} soundName - name of the sound
199
+ * @returns {void}
172
200
  */
173
201
  stop(soundName) {
174
202
  this.musicCatalogue.get(soundName)?.stop();
@@ -1,6 +1,15 @@
1
1
  import { SpeedLevel, SpeedLevelDirectory } from "./SpeedLevel";
2
+ /**
3
+ * Interface for SpeedAdapter, which is used to adapt the speed level to the specific implementation.
4
+ * @template T - Type of overrides that the adapter will use.
5
+ */
2
6
  export interface SpeedAdapterInterface<T> {
3
7
  readonly speedLevelMapper: SpeedLevelDirectory<T>;
4
8
  adaptToSpeed(speedLevel: SpeedLevel): void;
5
9
  }
10
+ /**
11
+ * Type guard for SpeedAdapterInterface.
12
+ * @param {unknown} obj object to verify if it's an instance of SpeedAdapterInterface
13
+ * @returns {obj is SpeedAdapterInterface<unknown>} true if obj is SpeedAdapterInterface, false otherwise
14
+ */
6
15
  export declare const isSpeedAdapterInterface: (obj: unknown) => obj is SpeedAdapterInterface<unknown>;
@@ -1,8 +1,17 @@
1
1
  import { z } from "zod";
2
+ /**
3
+ * Zod schema for validating SpeedAdapterInterface.
4
+ * This schema checks if the object has a speedLevelMapper of type object and an adaptToSpeed function.
5
+ */
2
6
  const speedAdapterInterfaceSchema = z.object({
3
7
  speedLevelMapper: z.object({}),
4
8
  adaptToSpeed: z.function()
5
9
  });
10
+ /**
11
+ * Type guard for SpeedAdapterInterface.
12
+ * @param {unknown} obj object to verify if it's an instance of SpeedAdapterInterface
13
+ * @returns {obj is SpeedAdapterInterface<unknown>} true if obj is SpeedAdapterInterface, false otherwise
14
+ */
6
15
  export const isSpeedAdapterInterface = (obj) => {
7
16
  return speedAdapterInterfaceSchema.safeParse(obj).success;
8
17
  };
@@ -1,15 +1,57 @@
1
+ /**
2
+ * Speed levels for the game.
3
+ * - slow: slow speed level
4
+ * - normal: normal speed level
5
+ * - fast: fast speed level
6
+ */
1
7
  export declare const SPEED_LEVELS: {
2
8
  readonly slow: "slow";
3
9
  readonly normal: "normal";
4
10
  readonly fast: "fast";
5
11
  };
12
+ /**
13
+ * All speed levels available in the game.
14
+ * - slow: slow speed level
15
+ * - normal: normal speed level
16
+ * - fast: fast speed level
17
+ * @typedef {typeof SPEED_LEVELS} SpeedLevels
18
+ */
6
19
  export type SpeedLevel = (typeof SPEED_LEVELS)[keyof typeof SPEED_LEVELS];
20
+ /**
21
+ * Directory for mapping speed levels to specific overrides.
22
+ * @template T - Type of overrides that the directory will use.
23
+ * @typedef {Record<SpeedLevel, T>} SpeedLevelDirectory
24
+ */
7
25
  export type SpeedLevelDirectory<T> = Record<SpeedLevel, T>;
26
+ /**
27
+ * Default speed level for the game.
28
+ * This is used when no specific speed level is set.
29
+ * @constant {SpeedLevel} DEFAULT_SPEED
30
+ */
8
31
  export declare const DEFAULT_SPEED: "slow";
32
+ /**
33
+ * Default speed configuration for the game.
34
+ * This is used when no specific speed configuration is set.
35
+ * @constant {object} defaultSpeedConfig
36
+ */
9
37
  export declare const defaultSpeedConfig: {
10
38
  turtleButton: string;
11
39
  symbolsColumnsSpeed: number;
12
40
  animationDefaultSpeedScale: number;
13
41
  };
42
+ /**
43
+ * Speed levels for spin speed in the game.
44
+ * - slow: 1
45
+ * - normal: 0.5
46
+ * - fast: 0
47
+ * @constant {SpeedLevelDirectory<number>} spinSpeedLevels
48
+ */
14
49
  export declare const spinSpeedLevels: SpeedLevelDirectory<number>;
50
+ /**
51
+ * Speed levels for animations in the game.
52
+ * - slow: 1
53
+ * - normal: 1.5
54
+ * - fast: 1.8
55
+ * @constant {SpeedLevelDirectory<number>} animationsSpeedLevels
56
+ */
15
57
  export declare const animationsSpeedLevels: SpeedLevelDirectory<number>;
@@ -1,19 +1,49 @@
1
+ /**
2
+ * Speed levels for the game.
3
+ * - slow: slow speed level
4
+ * - normal: normal speed level
5
+ * - fast: fast speed level
6
+ */
1
7
  export const SPEED_LEVELS = {
2
8
  slow: "slow",
3
9
  normal: "normal",
4
10
  fast: "fast"
5
11
  };
12
+ /**
13
+ * Default speed level for the game.
14
+ * This is used when no specific speed level is set.
15
+ * @constant {SpeedLevel} DEFAULT_SPEED
16
+ */
6
17
  export const DEFAULT_SPEED = SPEED_LEVELS.slow;
18
+ /**
19
+ * Default speed configuration for the game.
20
+ * This is used when no specific speed configuration is set.
21
+ * @constant {object} defaultSpeedConfig
22
+ */
7
23
  export const defaultSpeedConfig = {
8
24
  turtleButton: "clicked/speed-turtle.png",
9
25
  symbolsColumnsSpeed: 1,
10
26
  animationDefaultSpeedScale: 1
11
27
  };
28
+ /**
29
+ * Speed levels for spin speed in the game.
30
+ * - slow: 1
31
+ * - normal: 0.5
32
+ * - fast: 0
33
+ * @constant {SpeedLevelDirectory<number>} spinSpeedLevels
34
+ */
12
35
  export const spinSpeedLevels = {
13
36
  slow: 1,
14
37
  normal: 0.5,
15
38
  fast: 0
16
39
  };
40
+ /**
41
+ * Speed levels for animations in the game.
42
+ * - slow: 1
43
+ * - normal: 1.5
44
+ * - fast: 1.8
45
+ * @constant {SpeedLevelDirectory<number>} animationsSpeedLevels
46
+ */
17
47
  export const animationsSpeedLevels = {
18
48
  slow: 1,
19
49
  normal: 1.5,
@@ -1,6 +1,8 @@
1
1
  import { SpeedLevel } from "./SpeedLevel";
2
2
  /**
3
3
  * Class for handling speed levels
4
+ * This class provides methods for getting and setting the current speed level,
5
+ * as well as for cycling through the available speed levels.
4
6
  */
5
7
  export declare class SpeedLevelHandler {
6
8
  private chosenSpeedLevel;
@@ -14,11 +16,13 @@ export declare class SpeedLevelHandler {
14
16
  constructor(chosenSpeedLevel: number, speedLevels: SpeedLevel[]);
15
17
  /**
16
18
  * Getter for current speed level
19
+ * @public
17
20
  * @returns {SpeedLevel} current speed level
18
21
  */
19
22
  get currentSpeed(): SpeedLevel;
20
23
  /**
21
24
  * Setter for speed level
25
+ * @public
22
26
  * @param {SpeedLevel} newSpeedLevel - new speed level
23
27
  * @throws {Error} - if no matched speed level
24
28
  */
@@ -27,10 +31,13 @@ export declare class SpeedLevelHandler {
27
31
  * Function for setting next speed level
28
32
  * This will after switching speed level check if the speed level is normal or fast
29
33
  * and if so, it will disable the speed popup
34
+ * @public
35
+ * @returns {void}
30
36
  */
31
37
  nextSpeed(): void;
32
38
  /**
33
39
  * Helper function for checking if speed options loop should be reset
40
+ * @private
34
41
  * @returns {boolean} - true if speed options loop should be reset
35
42
  */
36
43
  private shouldResetSpeedOptionsLoop;
@@ -2,6 +2,8 @@ import { RainMan } from "../../Rainman";
2
2
  import { DEFAULT_SPEED, SPEED_LEVELS } from "./SpeedLevel";
3
3
  /**
4
4
  * Class for handling speed levels
5
+ * This class provides methods for getting and setting the current speed level,
6
+ * as well as for cycling through the available speed levels.
5
7
  */
6
8
  export class SpeedLevelHandler {
7
9
  chosenSpeedLevel;
@@ -22,6 +24,7 @@ export class SpeedLevelHandler {
22
24
  }
23
25
  /**
24
26
  * Getter for current speed level
27
+ * @public
25
28
  * @returns {SpeedLevel} current speed level
26
29
  */
27
30
  get currentSpeed() {
@@ -29,6 +32,7 @@ export class SpeedLevelHandler {
29
32
  }
30
33
  /**
31
34
  * Setter for speed level
35
+ * @public
32
36
  * @param {SpeedLevel} newSpeedLevel - new speed level
33
37
  * @throws {Error} - if no matched speed level
34
38
  */
@@ -51,6 +55,8 @@ export class SpeedLevelHandler {
51
55
  * Function for setting next speed level
52
56
  * This will after switching speed level check if the speed level is normal or fast
53
57
  * and if so, it will disable the speed popup
58
+ * @public
59
+ * @returns {void}
54
60
  */
55
61
  nextSpeed() {
56
62
  RainMan.globals.disableSpeedPopup?.(true);
@@ -62,6 +68,7 @@ export class SpeedLevelHandler {
62
68
  }
63
69
  /**
64
70
  * Helper function for checking if speed options loop should be reset
71
+ * @private
65
72
  * @returns {boolean} - true if speed options loop should be reset
66
73
  */
67
74
  shouldResetSpeedOptionsLoop() {