pixi-rainman-game-engine 0.2.16 → 0.2.18

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.
@@ -5,6 +5,8 @@ import React from "react";
5
5
  import { useStores } from "../../hooks";
6
6
  export const BetControls = observer(() => {
7
7
  const { settingStore } = useStores();
8
+ const { isFreeSpinsPlayEnabled, isFreeSpinsBought, betChangeDisabled } = settingStore;
9
+ const isDisabled = isFreeSpinsPlayEnabled || betChangeDisabled || isFreeSpinsBought;
8
10
  const onClick = (type) => {
9
11
  if (type === "increase") {
10
12
  settingStore.increaseBet?.();
@@ -16,13 +18,13 @@ export const BetControls = observer(() => {
16
18
  return (<div className="bet-container">
17
19
  <h2>{i18next.t("totalBet")}</h2>
18
20
  <div className="bet-container__controls">
19
- <button disabled={settingStore.isFreeSpinsPlayEnabled || settingStore.betChangeDisabled} onClick={() => onClick("decrease")} className="bet-container__button" name="bet-minus">
21
+ <button disabled={isDisabled} onClick={() => onClick("decrease")} className="bet-container__button" name="bet-minus">
20
22
  -
21
23
  </button>
22
24
  <div className="bet-container__value">
23
25
  <p>{settingStore.betText}</p>
24
26
  </div>
25
- <button disabled={settingStore.isFreeSpinsPlayEnabled || settingStore.betChangeDisabled} onClick={() => onClick("increase")} className="bet-container__button" name="bet-plus">
27
+ <button disabled={isDisabled} onClick={() => onClick("increase")} className="bet-container__button" name="bet-plus">
26
28
  +
27
29
  </button>
28
30
  </div>
@@ -144,9 +144,12 @@ export class ButtonsEventManager {
144
144
  * @param {(strategy: "first" | "increase" | "decrease") => void} setBetCallback - callback for setting bet
145
145
  */
146
146
  initBetPlusButtonEvent(setBetCallback) {
147
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
147
148
  if (this.settingsPlusButton === null) {
148
149
  this.settingsPlusButton = window.document.getElementsByName("bet-plus")[0];
149
150
  this.settingsPlusButton.addEventListener("click", () => {
151
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
152
+ return;
150
153
  setBetCallback("increase");
151
154
  });
152
155
  }
@@ -159,8 +162,11 @@ export class ButtonsEventManager {
159
162
  */
160
163
  initBetMinusButtonEvent(setBetCallback) {
161
164
  if (this.settingsMinusButton === null) {
165
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
162
166
  this.settingsMinusButton = window.document.getElementsByName("bet-minus")[0];
163
167
  this.settingsMinusButton.addEventListener("click", () => {
168
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
169
+ return;
164
170
  setBetCallback("decrease");
165
171
  });
166
172
  }
@@ -5,7 +5,8 @@ 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
- *
8
+ * @implements {SpeedAdapterInterface<SoundOverrides>}
9
+ * @class
9
10
  */
10
11
  export declare class SoundManagerInstance implements SpeedAdapterInterface<SoundOverrides> {
11
12
  private static instance;
@@ -49,6 +50,11 @@ export declare class SoundManagerInstance implements SpeedAdapterInterface<Sound
49
50
  * If sound is not playing, it will be skipped
50
51
  */
51
52
  pauseAll(): void;
53
+ /**
54
+ * Function for stopping all sounds in game
55
+ * If sound is not playing, it will be skipped
56
+ */
57
+ stopAll(): void;
52
58
  /**
53
59
  * Function for pausing sound with given name
54
60
  * @param {SoundTrack} soundName - name of the sound
@@ -6,7 +6,8 @@ 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
- *
9
+ * @implements {SpeedAdapterInterface<SoundOverrides>}
10
+ * @class
10
11
  */
11
12
  export class SoundManagerInstance {
12
13
  static instance;
@@ -69,7 +70,7 @@ export class SoundManagerInstance {
69
70
  for (const [soundName, sound] of this.musicCatalogue.entries()) {
70
71
  if (soundName === SoundTracks.music)
71
72
  continue;
72
- sound.pause();
73
+ sound.stop();
73
74
  }
74
75
  }
75
76
  /**
@@ -121,6 +122,13 @@ export class SoundManagerInstance {
121
122
  pauseAll() {
122
123
  this.musicCatalogue.forEach((sound) => sound.pause());
123
124
  }
125
+ /**
126
+ * Function for stopping all sounds in game
127
+ * If sound is not playing, it will be skipped
128
+ */
129
+ stopAll() {
130
+ this.musicCatalogue.forEach((sound) => sound.stop());
131
+ }
124
132
  /**
125
133
  * Function for pausing sound with given name
126
134
  * @param {SoundTrack} soundName - name of the sound
@@ -42,8 +42,10 @@ export class AbstractFrame extends ResumableContainer {
42
42
  invokeMysteryFx(x, y) {
43
43
  if (!this.mysteryFxConfig)
44
44
  return;
45
- if (this.mysteryFxHighlight)
45
+ if (this.mysteryFxHighlight) {
46
+ SoundManager.pause(SoundTracks.mysteryFxLoop);
46
47
  this.removeChild(this.mysteryFxHighlight);
48
+ }
47
49
  this.mysteryFxCoordinates = { x, y };
48
50
  const spineName = this.mysteryFxConfig.mobileSpineName && getDeviceOrientation() === "mobile-portrait"
49
51
  ? this.mysteryFxConfig.mobileSpineName
@@ -62,9 +64,11 @@ export class AbstractFrame extends ResumableContainer {
62
64
  if (!this.mysteryFxConfig)
63
65
  return;
64
66
  if (!this.mysteryFxConfig.endAnimationName) {
67
+ SoundManager.stop(SoundTracks.mysteryFxLoop);
65
68
  return;
66
69
  }
67
70
  if (this.mysteryFxHighlight) {
71
+ SoundManager.stop(SoundTracks.mysteryFxLoop);
68
72
  SoundManager.play(SoundTracks.mysteryFxEnd);
69
73
  this.resetMysteryFxCoordinates();
70
74
  this.mysteryFxHighlight.state.setAnimation(0, this.mysteryFxConfig.endAnimationName, false);
@@ -125,8 +129,10 @@ export class AbstractFrame extends ResumableContainer {
125
129
  this.addChild(this.innerFrame);
126
130
  }
127
131
  resize() {
128
- if (this.mysteryFxHighlight)
132
+ if (this.mysteryFxHighlight) {
133
+ SoundManager.pause(SoundTracks.mysteryFxLoop);
129
134
  this.removeChild(this.mysteryFxHighlight);
135
+ }
130
136
  this.changeFrameForOrientation();
131
137
  const expectedScreenDimensions = {
132
138
  width: this.transformedWidth(),
@@ -138,8 +144,10 @@ export class AbstractFrame extends ResumableContainer {
138
144
  this.width = dimensions.width;
139
145
  this.addChild(this.innerFrame);
140
146
  this.repositionMysteryFx(this.mysteryFxCoordinates.x, this.mysteryFxCoordinates.y);
141
- if (this.mysteryFxHighlight)
147
+ if (this.mysteryFxHighlight) {
148
+ SoundManager.resume(SoundTracks.mysteryFxLoop);
142
149
  this.addChild(this.mysteryFxHighlight);
150
+ }
143
151
  this.winLineAnimations.forEach((winLineAnimation) => this.addChild(winLineAnimation));
144
152
  this.reposition();
145
153
  }
@@ -152,7 +152,6 @@ export class AbstractController {
152
152
  }
153
153
  handleDisablingButtons(disabled) {
154
154
  this.disableBetButtons(disabled ?? this.shouldBetButtonsBeDisabled);
155
- this.disableAutoplayButton(disabled ?? this.shouldBetButtonsBeDisabled);
156
155
  this.disableSpeedButton(disabled ?? this.shouldButtonsBeDisabled);
157
156
  this.disableInformationButtons(disabled ?? this.shouldButtonsBeDisabled);
158
157
  }
@@ -174,6 +173,7 @@ export class AbstractController {
174
173
  });
175
174
  }
176
175
  initBetButtons() {
176
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
177
177
  this.buttonsEventManager.initBetPlusButtonEvent(this.uiController.updateBet.bind(this.uiController));
178
178
  this.buttonsEventManager.initBetMinusButtonEvent(this.uiController.updateBet.bind(this.uiController));
179
179
  if (RainMan.settingsStore.isAutoplayEnabled) {
@@ -181,14 +181,20 @@ export class AbstractController {
181
181
  }
182
182
  if (getDeviceOrientation().includes("mobile")) {
183
183
  RainMan.componentRegistry.get(BUTTONS.plus).setOnClick(() => {
184
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
185
+ return;
184
186
  RainMan.settingsStore.handleModalInvocation?.(UI_ITEMS.bet);
185
187
  });
186
188
  return;
187
189
  }
188
190
  RainMan.componentRegistry.get(BUTTONS.plus).setOnClick(() => {
191
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
192
+ return;
189
193
  this.uiController.updateBet("increase");
190
194
  });
191
195
  RainMan.componentRegistry.get(BUTTONS.neg).setOnClick(() => {
196
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
197
+ return;
192
198
  this.uiController.updateBet("decrease");
193
199
  });
194
200
  }
@@ -714,6 +720,8 @@ export class AbstractController {
714
720
  this.uiController.triggerUiElementsUpdate();
715
721
  this.uiController.messageBox.showFreeSpinText();
716
722
  }
723
+ if (availableFreeSpinsIncreased)
724
+ this.uiController.updateShownFreeSpinAmount(availableFreeSpins);
717
725
  if (this.invokeFreeSpinSummaryPlateAfterWin && !this.skipFreeSpinSummary) {
718
726
  hideLayerIfPresent();
719
727
  await this.handleFreeSpinSummaryPlateInvocation();
@@ -154,7 +154,6 @@ export class UiController {
154
154
  this.updateBet("remain");
155
155
  this.setDisplayedBalance();
156
156
  this.setDisplayedCurrentWin();
157
- this.updateShownFreeSpinAmount(RainMan.settingsStore.howManyFreeSpinsLeft);
158
157
  }
159
158
  setDisplayedBalance() {
160
159
  RainMan.componentRegistry.get(COMPONENTS.creditText).set(this.currentBalance);
@@ -7,7 +7,7 @@ import { RainMan } from "../../Rainman";
7
7
  */
8
8
  const resumeAudioContext = () => {
9
9
  if (RainMan.settingsStore.isSoundEnabled() && document.hidden) {
10
- SoundManager.pauseAll();
10
+ SoundManager.stopAll();
11
11
  return;
12
12
  }
13
13
  if (RainMan.settingsStore.isSoundEnabled() && !document.hidden) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "This repository contains all of the mechanics that used in rainman games.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",