pixi-rainman-game-engine 0.3.1 → 0.3.2

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.
@@ -1,4 +1,4 @@
1
- import { AbstractColumnsContainer, AbstractFrame, AbstractInnerFrame, AutoplayButton, Background, BaseButton, BUTTONS, COMPONENTS, FreeSpinButton, InfoButton, MessageBox, MoreButton, NegButton, PlusButton, RefreshButton, SpeedControlButton, StylefulUpdatableText, UpdatableTextComponent, UpdatableValueComponent, VolumeButton } from "../components";
1
+ import { AbstractColumnsContainer, AbstractFrame, AbstractInnerFrame, AutoplayButton, Background, BUTTONS, COMPONENTS, FreeSpinButton, GambleButton, InfoButton, MessageBox, MoreButton, NegButton, PlusButton, RefreshButton, SpeedControlButton, StylefulUpdatableText, TakeButton, UpdatableTextComponent, UpdatableValueComponent, VolumeButton } from "../components";
2
2
  /**
3
3
  * RegistryMap is a map of all components that are registered in the ComponentRegistry.
4
4
  * It is used to type-check the components that are registered in the ComponentRegistry.
@@ -22,7 +22,8 @@ export interface RegistryMap {
22
22
  [NegButton.registryName]: NegButton;
23
23
  [InfoButton.registryName]: InfoButton;
24
24
  [MoreButton.registryName]: MoreButton;
25
- [BUTTONS.gamble]: BaseButton;
25
+ [BUTTONS.gamble]: GambleButton;
26
+ [BUTTONS.take]: TakeButton;
26
27
  [COMPONENTS.betText]: UpdatableTextComponent;
27
28
  [COMPONENTS.creditText]: UpdatableTextComponent;
28
29
  [COMPONENTS.bigWin]: StylefulUpdatableText;
@@ -18,6 +18,7 @@ export const defaultAppConfig = {
18
18
  disableFreeSpinText: false,
19
19
  winLineIndicatorSymbolScale: 0.75,
20
20
  disableBigWinOnBonus: false,
21
+ gambleGameEnabled: false,
21
22
  durationOfActions: {
22
23
  eachColumnsSpinDelay: [0, 200, 700, 1200, 1800],
23
24
  spinBaseTime: 800,
@@ -25,6 +25,7 @@ export type OptionalAppConfig = {
25
25
  winLineIndicatorSymbolScale: number;
26
26
  disableFreeSpinText: boolean;
27
27
  disableBigWinOnBonus?: boolean;
28
+ gambleGameEnabled?: boolean;
28
29
  durationOfActions: {
29
30
  eachColumnsSpinDelay: number[];
30
31
  spinBaseTime: number;
@@ -126,6 +126,13 @@ export declare class ButtonsEventManager {
126
126
  * @returns {void}
127
127
  */
128
128
  initGambleButton(onClick: () => void, disabled: boolean): void;
129
+ /**
130
+ * Initializing take button
131
+ * @public
132
+ * @param {() => void} onClick - callback for take action
133
+ * @param {boolean} disabled - flag for enabling/disabling button
134
+ */
135
+ initTakeButton(onClick: () => void, disabled: boolean): void;
129
136
  /**
130
137
  * Function for displaying speed modal
131
138
  * This modal is used while doing turbo spin
@@ -169,11 +169,11 @@ export class ButtonsEventManager {
169
169
  * @returns {void}
170
170
  */
171
171
  initBetPlusButtonEvent(setBetCallback) {
172
- const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
172
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled } = RainMan.settingsStore;
173
173
  if (this.settingsPlusButton === null) {
174
174
  this.settingsPlusButton = window.document.getElementsByName("bet-plus")[0];
175
175
  this.settingsPlusButton.addEventListener("click", () => {
176
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
176
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled)
177
177
  return;
178
178
  setBetCallback("increase");
179
179
  });
@@ -188,10 +188,10 @@ export class ButtonsEventManager {
188
188
  */
189
189
  initBetMinusButtonEvent(setBetCallback) {
190
190
  if (this.settingsMinusButton === null) {
191
- const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
191
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled } = RainMan.settingsStore;
192
192
  this.settingsMinusButton = window.document.getElementsByName("bet-minus")[0];
193
193
  this.settingsMinusButton.addEventListener("click", () => {
194
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled) {
194
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled) {
195
195
  return;
196
196
  }
197
197
  setBetCallback("decrease");
@@ -284,11 +284,22 @@ export class ButtonsEventManager {
284
284
  * @returns {void}
285
285
  */
286
286
  initGambleButton(onClick, disabled) {
287
- if (!RainMan.componentRegistry.has(BUTTONS.gamble) && RainMan.settingsStore.gambleGameUsed) {
287
+ if (!RainMan.componentRegistry.has(BUTTONS.gamble) && !RainMan.settingsStore.isGambleGameAvailable) {
288
288
  return;
289
289
  }
290
+ RainMan.componentRegistry.get(BUTTONS.gamble).setOnClick(onClick);
290
291
  RainMan.componentRegistry.get(BUTTONS.gamble).flipDisabledFlag(disabled);
291
292
  }
293
+ /**
294
+ * Initializing take button
295
+ * @public
296
+ * @param {() => void} onClick - callback for take action
297
+ * @param {boolean} disabled - flag for enabling/disabling button
298
+ */
299
+ initTakeButton(onClick, disabled) {
300
+ RainMan.componentRegistry.get(BUTTONS.take).setOnClick(onClick);
301
+ RainMan.componentRegistry.get(BUTTONS.take).flipDisabledFlag(disabled);
302
+ }
292
303
  /**
293
304
  * Function for displaying speed modal
294
305
  * This modal is used while doing turbo spin
@@ -108,6 +108,7 @@ export class GambleGame extends Container {
108
108
  * @returns {Promise<void>}
109
109
  */
110
110
  async loseDoubleAndWinFields() {
111
+ RainMan.settingsStore.disableSpecialButtons();
111
112
  return Promise.all([this.gambleWin.loseUpdate(), this.currentWin.loseUpdate()]);
112
113
  }
113
114
  /**
@@ -16,7 +16,7 @@ export declare class BaseButton extends Sprite {
16
16
  private isActive;
17
17
  private isOver;
18
18
  private isDisabled;
19
- private _onClick;
19
+ protected _onClick: () => void;
20
20
  private _customClickHandler;
21
21
  constructor(name: string, textureMap: TextureMap, stateful?: boolean, clickSound?: Nullable<SoundTrack>);
22
22
  /**
@@ -1,6 +1,6 @@
1
1
  import { Graphics } from "pixi.js";
2
2
  import { ResponsiveContainer } from "../../common";
3
- import { AutoplayButton, PlusButton, RefreshButton } from "../default";
3
+ import { AutoplayButton, GambleButton, PlusButton, RefreshButton, TakeButton } from "../default";
4
4
  /**
5
5
  * Class for managing middle buttons in game (MOBILE ONLY).
6
6
  * The class uses {@link AutoplayButton}, {@link PlusButton}, {@link RefreshButton}.
@@ -12,6 +12,8 @@ export declare class MiddleButtons extends ResponsiveContainer {
12
12
  protected readonly betButton: PlusButton;
13
13
  protected readonly refreshButton: RefreshButton;
14
14
  protected readonly positioningFrame: Graphics;
15
+ protected readonly gambleButton: GambleButton;
16
+ protected readonly takeButton: TakeButton;
15
17
  constructor(landscape?: boolean);
16
18
  /**
17
19
  * Function for removing children from the registry
@@ -19,6 +21,12 @@ export declare class MiddleButtons extends ResponsiveContainer {
19
21
  * @returns {void}
20
22
  */
21
23
  removeChildrenFromRegistry(): void;
24
+ /**
25
+ * Function for adding Gamble and Take buttons if they are defined
26
+ * @protected
27
+ * @returns {void}
28
+ */
29
+ protected addGambleAndTakeButtons(): void;
22
30
  /**
23
31
  * Function for initializing child positions
24
32
  * @private
@@ -2,7 +2,7 @@ import { Graphics } from "pixi.js";
2
2
  import { UXLayer } from "../../../layers";
3
3
  import { RainMan } from "../../../Rainman";
4
4
  import { ResponsiveContainer } from "../../common";
5
- import { AutoplayButton, PlusButton, RefreshButton } from "../default";
5
+ import { AutoplayButton, GambleButton, PlusButton, RefreshButton, TakeButton } from "../default";
6
6
  import { REGISTRY } from "../registrynames";
7
7
  /**
8
8
  * Class for managing middle buttons in game (MOBILE ONLY).
@@ -15,6 +15,8 @@ export class MiddleButtons extends ResponsiveContainer {
15
15
  betButton = new PlusButton(true);
16
16
  refreshButton = new RefreshButton(true);
17
17
  positioningFrame = new Graphics();
18
+ gambleButton = new GambleButton(true);
19
+ takeButton = new TakeButton(true);
18
20
  constructor(landscape = false) {
19
21
  super();
20
22
  this.landscape = landscape;
@@ -23,21 +25,28 @@ export class MiddleButtons extends ResponsiveContainer {
23
25
  const buttons = [this.autoplayButton, this.betButton, this.refreshButton];
24
26
  this.addChild(...buttons);
25
27
  RainMan.componentRegistry.addMany(buttons);
28
+ this.addGambleAndTakeButtons();
26
29
  this.positioningFrame.beginFill(0x000000, 0);
27
30
  this.positioningFrame.drawRect(0, 0, 800, 250);
28
31
  this.addChild(this.positioningFrame);
29
32
  this.refreshButton.scale.set(0.75);
30
33
  this.autoplayButton.scale.set(0.75);
31
34
  this.betButton.scale.set(0.75);
35
+ this.takeButton.scale.set(0.75);
36
+ this.gambleButton.scale.set(0.75);
32
37
  if (this.landscape) {
33
38
  this.betButton.anchor.set(0.5, 2);
34
39
  this.refreshButton.anchor.set(0.5, 0.5);
35
40
  this.autoplayButton.anchor.set(0.5, -1);
41
+ this.takeButton.anchor.set(0.5, 2);
42
+ this.gambleButton.anchor.set(0.5, -1);
36
43
  }
37
44
  else {
38
45
  this.autoplayButton.anchor.set(2, 0.5);
39
46
  this.refreshButton.anchor.set(0.5, 0.5);
40
47
  this.betButton.anchor.set(-1, 0.5);
48
+ this.takeButton.anchor.set(-1, 0.5);
49
+ this.gambleButton.anchor.set(2, 0.5);
41
50
  }
42
51
  this.initChildPositions();
43
52
  if (this.landscape) {
@@ -54,9 +63,26 @@ export class MiddleButtons extends ResponsiveContainer {
54
63
  this.refreshButton,
55
64
  this.autoplayButton,
56
65
  this.betButton,
57
- this.positioningFrame
66
+ this.positioningFrame,
67
+ ...(this.gambleButton && RainMan.config.gambleGameEnabled ? [this.gambleButton] : []),
68
+ ...(this.takeButton ? [this.takeButton] : [])
58
69
  ]);
59
70
  }
71
+ /**
72
+ * Function for adding Gamble and Take buttons if they are defined
73
+ * @protected
74
+ * @returns {void}
75
+ */
76
+ addGambleAndTakeButtons() {
77
+ if (this.gambleButton && RainMan.config.gambleGameEnabled) {
78
+ this.addChild(this.gambleButton);
79
+ RainMan.componentRegistry.add(this.gambleButton);
80
+ }
81
+ if (this.takeButton) {
82
+ this.addChild(this.takeButton);
83
+ RainMan.componentRegistry.add(this.takeButton);
84
+ }
85
+ }
60
86
  /**
61
87
  * Function for initializing child positions
62
88
  * @private
@@ -1,7 +1,6 @@
1
1
  import { Nullable } from "../../../utils";
2
2
  import { ResponsiveContainer } from "../../common";
3
- import { BaseButton } from "../BaseButton";
4
- import { AutoplayButton, NegButton, PlusButton, RefreshButton, SpeedControlButton } from "../default";
3
+ import { AutoplayButton, GambleButton, NegButton, PlusButton, RefreshButton, SpeedControlButton, TakeButton } from "../default";
5
4
  /**
6
5
  * Class for managing right buttons in game. The class uses {@link AutoplayButton}, {@link NegButton}, {@link PlusButton},
7
6
  * {@link RefreshButton}, {@link SpeedControlButton} and gamble button {@link BaseButton} if exists.
@@ -15,7 +14,8 @@ export declare class RightButtons extends ResponsiveContainer {
15
14
  protected readonly plusButton: PlusButton;
16
15
  protected readonly refreshButton: RefreshButton;
17
16
  protected readonly speedControlButton: SpeedControlButton;
18
- protected readonly gambleButton: Nullable<BaseButton>;
17
+ protected readonly gambleButton: Nullable<GambleButton>;
18
+ protected readonly takeButton: Nullable<TakeButton>;
19
19
  constructor();
20
20
  /**
21
21
  * Function for removing the components from the registry
@@ -29,4 +29,10 @@ export declare class RightButtons extends ResponsiveContainer {
29
29
  * @returns {void}
30
30
  */
31
31
  protected reposition(): void;
32
+ /**
33
+ * Function for adding Gamble and Take buttons if they are defined
34
+ * @protected
35
+ * @returns {void}
36
+ */
37
+ protected addGambleAndTakeButtons(): void;
32
38
  }
@@ -17,6 +17,7 @@ export class RightButtons extends ResponsiveContainer {
17
17
  refreshButton = new RefreshButton();
18
18
  speedControlButton = new SpeedControlButton();
19
19
  gambleButton = null;
20
+ takeButton = null;
20
21
  constructor() {
21
22
  super(-1);
22
23
  this.name = REGISTRY.rightButtons;
@@ -42,7 +43,9 @@ export class RightButtons extends ResponsiveContainer {
42
43
  this.negButton,
43
44
  this.plusButton,
44
45
  this.refreshButton,
45
- this.speedControlButton
46
+ this.speedControlButton,
47
+ ...(this.gambleButton ? [this.gambleButton] : []),
48
+ ...(this.takeButton ? [this.takeButton] : [])
46
49
  ]);
47
50
  }
48
51
  /**
@@ -54,4 +57,19 @@ export class RightButtons extends ResponsiveContainer {
54
57
  this.y = RainMan.app.screen.height;
55
58
  this.x = RainMan.app.screen.width;
56
59
  }
60
+ /**
61
+ * Function for adding Gamble and Take buttons if they are defined
62
+ * @protected
63
+ * @returns {void}
64
+ */
65
+ addGambleAndTakeButtons() {
66
+ if (this.gambleButton && RainMan.config.gambleGameEnabled) {
67
+ this.addChild(this.gambleButton);
68
+ RainMan.componentRegistry.add(this.gambleButton);
69
+ }
70
+ if (this.takeButton) {
71
+ this.addChild(this.takeButton);
72
+ RainMan.componentRegistry.add(this.takeButton);
73
+ }
74
+ }
57
75
  }
@@ -0,0 +1,13 @@
1
+ import { BaseButton } from "../BaseButton";
2
+ /**
3
+ * Class for a Gamble button in the game.
4
+ * Textures names should be "gamble.png", "gamble-over.png", and "gamble-clicked.png".
5
+ * @class TakeButton
6
+ * @augments {BaseButton}
7
+ */
8
+ export declare class GambleButton extends BaseButton {
9
+ static readonly registryName = "gambleButton";
10
+ private mobile;
11
+ constructor(mobile?: boolean);
12
+ flipDisabledFlag(disabled: boolean): void;
13
+ }
@@ -0,0 +1,43 @@
1
+ import { RainMan } from "../../../Rainman";
2
+ import { getTexture } from "../../../utils";
3
+ import { BaseButton, ButtonStates } from "../BaseButton";
4
+ import { BUTTONS } from "../registrynames";
5
+ /**
6
+ * Class for a Gamble button in the game.
7
+ * Textures names should be "gamble.png", "gamble-over.png", and "gamble-clicked.png".
8
+ * @class TakeButton
9
+ * @augments {BaseButton}
10
+ */
11
+ export class GambleButton extends BaseButton {
12
+ static registryName = "gambleButton";
13
+ mobile;
14
+ constructor(mobile = false) {
15
+ const textureMap = mobile
16
+ ? {
17
+ [ButtonStates.NORMAL]: getTexture("mobile-gamble.png")
18
+ }
19
+ : {
20
+ [ButtonStates.NORMAL]: getTexture("gamble.png"),
21
+ [ButtonStates.OVER]: getTexture("gamble-over.png"),
22
+ [ButtonStates.CLICKED]: getTexture("gamble-clicked.png")
23
+ };
24
+ super(GambleButton.registryName, textureMap);
25
+ this.mobile = mobile;
26
+ }
27
+ flipDisabledFlag(disabled) {
28
+ super.flipDisabledFlag(disabled);
29
+ this.alpha = disabled ? 0 : 1;
30
+ if (!disabled && this.mobile) {
31
+ RainMan.componentRegistry.get(BUTTONS.autoplay).alpha = 0;
32
+ }
33
+ else {
34
+ RainMan.componentRegistry.get(BUTTONS.autoplay).alpha = 1;
35
+ }
36
+ if (!disabled && !this.mobile) {
37
+ RainMan.componentRegistry.get(BUTTONS.neg).alpha = 0;
38
+ }
39
+ else {
40
+ RainMan.componentRegistry.get(BUTTONS.neg).alpha = 1;
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseButton } from "../BaseButton";
2
+ /**
3
+ * Class for a Take button in the game.
4
+ * Textures names should be "take.png", "take-over.png", and "take-clicked.png".
5
+ * @class TakeButton
6
+ * @augments {BaseButton}
7
+ */
8
+ export declare class TakeButton extends BaseButton {
9
+ static readonly registryName = "takeButton";
10
+ private mobile;
11
+ constructor(mobile?: boolean);
12
+ flipDisabledFlag(disabled: boolean): void;
13
+ }
@@ -0,0 +1,37 @@
1
+ import { RainMan } from "../../../Rainman";
2
+ import { getTexture } from "../../../utils";
3
+ import { BaseButton, ButtonStates } from "../BaseButton";
4
+ import { BUTTONS } from "../registrynames";
5
+ /**
6
+ * Class for a Take button in the game.
7
+ * Textures names should be "take.png", "take-over.png", and "take-clicked.png".
8
+ * @class TakeButton
9
+ * @augments {BaseButton}
10
+ */
11
+ export class TakeButton extends BaseButton {
12
+ static registryName = "takeButton";
13
+ mobile;
14
+ constructor(mobile = false) {
15
+ const textureMap = mobile
16
+ ? {
17
+ [ButtonStates.NORMAL]: getTexture("mobile-take.png")
18
+ }
19
+ : {
20
+ [ButtonStates.NORMAL]: getTexture("take.png"),
21
+ [ButtonStates.OVER]: getTexture("take-over.png"),
22
+ [ButtonStates.CLICKED]: getTexture("take-clicked.png")
23
+ };
24
+ super(TakeButton.registryName, textureMap);
25
+ this.mobile = mobile;
26
+ }
27
+ flipDisabledFlag(disabled) {
28
+ super.flipDisabledFlag(disabled);
29
+ this.alpha = disabled ? 0 : 1;
30
+ if (!disabled) {
31
+ RainMan.componentRegistry.get(BUTTONS.plus).alpha = 0;
32
+ }
33
+ else {
34
+ RainMan.componentRegistry.get(BUTTONS.plus).alpha = 1;
35
+ }
36
+ }
37
+ }
@@ -1,6 +1,7 @@
1
1
  export * from "./AutoplayButton";
2
2
  export * from "./BlackButton";
3
3
  export * from "./CollectButton";
4
+ export * from "./GambleButton";
4
5
  export * from "./InfoButton";
5
6
  export * from "./MoreButton";
6
7
  export * from "./NegButton";
@@ -9,4 +10,5 @@ export * from "./RedButton";
9
10
  export * from "./RefreshButton";
10
11
  export * from "./SpeedControlButton";
11
12
  export * from "./SpinConfirmationButton";
13
+ export * from "./TakeButton";
12
14
  export * from "./VolumeButton";
@@ -1,6 +1,7 @@
1
1
  export * from "./AutoplayButton";
2
2
  export * from "./BlackButton";
3
3
  export * from "./CollectButton";
4
+ export * from "./GambleButton";
4
5
  export * from "./InfoButton";
5
6
  export * from "./MoreButton";
6
7
  export * from "./NegButton";
@@ -9,4 +10,5 @@ export * from "./RedButton";
9
10
  export * from "./RefreshButton";
10
11
  export * from "./SpeedControlButton";
11
12
  export * from "./SpinConfirmationButton";
13
+ export * from "./TakeButton";
12
14
  export * from "./VolumeButton";
@@ -9,7 +9,9 @@ export declare const BUTTONS: {
9
9
  readonly info: "infoButton";
10
10
  readonly more: "moreButton";
11
11
  readonly gamble: "gambleButton";
12
+ readonly take: "takeButton";
12
13
  readonly volume: "volumeButton";
14
+ readonly autoplay: "autoplayButton";
13
15
  };
14
16
  /**
15
17
  * Button groups in Rainman Registry
@@ -9,7 +9,9 @@ export const BUTTONS = {
9
9
  info: "infoButton",
10
10
  more: "moreButton",
11
11
  gamble: "gambleButton",
12
- volume: "volumeButton"
12
+ take: "takeButton",
13
+ volume: "volumeButton",
14
+ autoplay: "autoplayButton"
13
15
  };
14
16
  /**
15
17
  * Button groups in Rainman Registry
@@ -218,7 +218,7 @@ export class MessageBox extends Container {
218
218
  return;
219
219
  }
220
220
  this.autoSpinShown = true;
221
- this.autoSpinText.set(RainMan.settingsStore.howManyAutoSpinsLeft);
221
+ this.autoSpinText.setStringValue(RainMan.settingsStore.infinitySpinsEnabled ? "∞" : RainMan.settingsStore.howManyAutoSpinsLeft.toString());
222
222
  this.centerTextOnX(this.autoSpinText);
223
223
  this.addChild(this.autoSpinText);
224
224
  }
@@ -94,8 +94,9 @@ export class AbstractController {
94
94
  this.buttonsEventManager.initFreeSpinModal();
95
95
  this.buttonsEventManager.setUpUIElementsInteractivity();
96
96
  this.buttonsEventManager.setConfirmAutoplayButton(() => {
97
- if (RainMan.settingsStore.isAutoplayEnabled)
97
+ if (RainMan.settingsStore.isAutoplayEnabled) {
98
98
  return;
99
+ }
99
100
  RainMan.settingsStore.setAutoPlayEnabledFlag(true);
100
101
  RainMan.componentRegistry.get(AutoplayButton.registryName).activate(true);
101
102
  RainMan.componentRegistry.get(BUTTONS.plus).flipDisabledFlag(true);
@@ -231,9 +232,22 @@ export class AbstractController {
231
232
  this.buttonsEventManager.initAutoplayButtonEvent();
232
233
  if (RainMan.componentRegistry.has(BUTTONS.gamble)) {
233
234
  this.buttonsEventManager.initGambleButton(() => {
234
- RainMan.settingsStore.gambleGameUsed = true;
235
+ RainMan.settingsStore.isGambleGameAvailable = false;
235
236
  this.mainContainer.invokeGambleGame();
236
- }, this.lastWinAmount === 0);
237
+ }, this.lastWinAmount === 0 || !RainMan.settingsStore.isGambleGameAvailable);
238
+ }
239
+ if (RainMan.componentRegistry.has(BUTTONS.take)) {
240
+ this.buttonsEventManager.initTakeButton(() => {
241
+ RainMan.settingsStore.useTakeAction?.();
242
+ RainMan.settingsStore.isTakeActionAvailable = false;
243
+ RainMan.settingsStore.isGambleGameAvailable = false;
244
+ if (RainMan.componentRegistry.has(BUTTONS.gamble)) {
245
+ RainMan.componentRegistry.get(BUTTONS.gamble).flipDisabledFlag(true);
246
+ }
247
+ RainMan.componentRegistry
248
+ .get(BUTTONS.take)
249
+ .flipDisabledFlag(!RainMan.settingsStore.isTakeActionAvailable);
250
+ }, !RainMan.settingsStore.isTakeActionAvailable);
237
251
  }
238
252
  RainMan.componentRegistry.get(SpeedControlButton.registryName).setOnClick(() => {
239
253
  this.quickStopController.speedPopupDisabled = true;
@@ -248,7 +262,7 @@ export class AbstractController {
248
262
  * @returns {void}
249
263
  */
250
264
  initBetButtons() {
251
- const { isFreeSpinsBought, isFreeSpinsPlayEnabled, betChangeDisabled } = RainMan.settingsStore;
265
+ const { isFreeSpinsBought, isFreeSpinsPlayEnabled } = RainMan.settingsStore;
252
266
  this.buttonsEventManager.initBetPlusButtonEvent(this.uiController.updateBet.bind(this.uiController));
253
267
  this.buttonsEventManager.initBetMinusButtonEvent(this.uiController.updateBet.bind(this.uiController));
254
268
  if (RainMan.settingsStore.isAutoplayEnabled) {
@@ -256,19 +270,19 @@ export class AbstractController {
256
270
  }
257
271
  if (getDeviceOrientation().includes("mobile")) {
258
272
  RainMan.componentRegistry.get(BUTTONS.plus).setOnClick(() => {
259
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
273
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled)
260
274
  return;
261
275
  RainMan.settingsStore.handleModalInvocation?.(UI_ITEMS.bet);
262
276
  });
263
277
  return;
264
278
  }
265
279
  RainMan.componentRegistry.get(BUTTONS.plus).setOnClick(() => {
266
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
280
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled)
267
281
  return;
268
282
  this.uiController.updateBet("increase");
269
283
  });
270
284
  RainMan.componentRegistry.get(BUTTONS.neg).setOnClick(() => {
271
- if (isFreeSpinsBought || isFreeSpinsPlayEnabled || betChangeDisabled)
285
+ if (isFreeSpinsBought || isFreeSpinsPlayEnabled)
272
286
  return;
273
287
  this.uiController.updateBet("decrease");
274
288
  });
@@ -425,8 +439,9 @@ export class AbstractController {
425
439
  setMessageBoxBasedOnPhase(phase) {
426
440
  if (RainMan.settingsStore.isFreeSpinsPlayEnabled) {
427
441
  this.uiController.messageBox.showCurrentWinText();
428
- if (!this.hideFreeSpinsMessageBox)
442
+ if (!this.hideFreeSpinsMessageBox) {
429
443
  this.uiController.messageBox.showFreeSpinText();
444
+ }
430
445
  return;
431
446
  }
432
447
  switch (phase) {
@@ -443,13 +458,9 @@ export class AbstractController {
443
458
  }
444
459
  if (RainMan.settingsStore.isAutoplayEnabled) {
445
460
  const autoSpinText = RainMan.componentRegistry.get(MessageBox.autoSpinTextRegistryName);
446
- if (RainMan.settingsStore.infinitySpinsEnabled) {
447
- autoSpinText.setStringValue("∞");
448
- }
449
- else {
450
- autoSpinText.set(RainMan.settingsStore.howManyAutoSpinsLeft);
451
- }
461
+ autoSpinText.setStringValue(RainMan.settingsStore.infinitySpinsEnabled ? "∞" : RainMan.settingsStore.howManyAutoSpinsLeft.toString());
452
462
  this.uiController.messageBox.showAutoSpinText();
463
+ return;
453
464
  }
454
465
  }
455
466
  /**
@@ -628,6 +639,8 @@ export class AbstractController {
628
639
  */
629
640
  autoplaySpin() {
630
641
  RainMan.globals.shouldShowModals = false;
642
+ const autoSpinText = RainMan.componentRegistry.get(MessageBox.autoSpinTextRegistryName);
643
+ autoSpinText.setStringValue(RainMan.settingsStore.infinitySpinsEnabled ? "∞" : RainMan.settingsStore.howManyAutoSpinsLeft.toString());
631
644
  if (!RainMan.settingsStore.howManyAutoSpinsLeft) {
632
645
  return;
633
646
  }
@@ -771,11 +784,16 @@ export class AbstractController {
771
784
  * @returns {void}
772
785
  */
773
786
  gambleGameEnabler(winAmount) {
774
- if (RainMan.componentRegistry.has(BUTTONS.gamble) && !RainMan.settingsStore.gambleGameUsed) {
787
+ if (RainMan.componentRegistry.has(BUTTONS.gamble) && RainMan.settingsStore.isGambleGameAvailable) {
775
788
  RainMan.componentRegistry
776
789
  .get(BUTTONS.gamble)
777
790
  .flipDisabledFlag(RainMan.settingsStore.isFreeSpinsPlayEnabled || winAmount === 0);
778
791
  }
792
+ if (RainMan.componentRegistry.has(BUTTONS.take) && RainMan.settingsStore.isTakeActionAvailable) {
793
+ RainMan.componentRegistry
794
+ .get(BUTTONS.take)
795
+ .flipDisabledFlag(RainMan.settingsStore.isFreeSpinsPlayEnabled || winAmount === 0);
796
+ }
779
797
  }
780
798
  /**
781
799
  * Function for spin logic of the game
@@ -839,6 +857,7 @@ export class AbstractController {
839
857
  this.changeGamePhase(gamePhases.SPINNING);
840
858
  this.uiController.resetWinAmount();
841
859
  await this.onSpinningStart();
860
+ RainMan.settingsStore.disableSpecialButtons();
842
861
  this.columnsContainer.clearQuickReelsStop();
843
862
  this.columnsContainer.blindSpin();
844
863
  this.clearAndDestroyActions();
@@ -849,9 +868,11 @@ export class AbstractController {
849
868
  this.hideFreeSpinsMessageBox = availableFreeSpinsIncreased;
850
869
  if (this._lastWinAmount !== 0) {
851
870
  RainMan.settingsStore.isTakeActionAvailable = true;
871
+ RainMan.settingsStore.isGambleGameAvailable = true;
852
872
  }
853
873
  else {
854
874
  RainMan.settingsStore.isTakeActionAvailable = false;
875
+ RainMan.settingsStore.isGambleGameAvailable = false;
855
876
  }
856
877
  if (!availableFreeSpinsIncreased) {
857
878
  this.uiController.updateShownFreeSpinAmount(availableFreeSpins);
@@ -898,6 +919,7 @@ export class AbstractController {
898
919
  logInfo("🔴 spinning end");
899
920
  logGroupEnd();
900
921
  await this.onSpinningEnd(spinLogic);
922
+ this.gambleGameEnabler(this.lastWinAmount);
901
923
  this.winActionsQueue = [];
902
924
  this.spinning = false;
903
925
  this.isSpinThrottled = false;
@@ -28,7 +28,7 @@ export declare class SettingsStore {
28
28
  roundNumber: number;
29
29
  HiResolutionFlag: boolean;
30
30
  batterySaverFlag: boolean;
31
- gambleGameUsed: boolean;
31
+ isGambleGameAvailable: boolean;
32
32
  isGambleGameActive: boolean;
33
33
  gambleGameWin: number;
34
34
  containersWithSpines: (ResumableContainer | SpineWithResumableContainer | SpriteWithResumableContainer)[];
@@ -84,6 +84,12 @@ export declare class SettingsStore {
84
84
  * @returns {void}
85
85
  */
86
86
  addCumulativeWinAmount(amount: number): void;
87
+ /**
88
+ * Disables special buttons like gamble and take.
89
+ * @public
90
+ * @returns {void}
91
+ */
92
+ disableSpecialButtons(): void;
87
93
  /**
88
94
  * Swaps the bet change disabled flag.
89
95
  * @public
@@ -1,6 +1,7 @@
1
1
  import { first, last, range } from "lodash";
2
2
  import { action, computed, makeAutoObservable } from "mobx";
3
3
  import { SoundManager, SoundTracks } from "../application";
4
+ import { BUTTONS } from "../components";
4
5
  import { PaytableTypes } from "../constants";
5
6
  import { getFromLocalStorage, LOCAL_STORAGE, removeFromLocalStorage, setToLocalStorage } from "../localStorage";
6
7
  import { RainMan } from "../Rainman";
@@ -31,7 +32,7 @@ export class SettingsStore {
31
32
  roundNumber = 0;
32
33
  HiResolutionFlag = getFromLocalStorage(LOCAL_STORAGE.hiResolution, true);
33
34
  batterySaverFlag = getFromLocalStorage(LOCAL_STORAGE.batterySaver, false);
34
- gambleGameUsed = false;
35
+ isGambleGameAvailable = true;
35
36
  isGambleGameActive = false;
36
37
  gambleGameWin = 0;
37
38
  containersWithSpines = [];
@@ -142,6 +143,21 @@ export class SettingsStore {
142
143
  addCumulativeWinAmount(amount) {
143
144
  this.cumulativeWinAmount = this.cumulativeWinAmount + amount;
144
145
  }
146
+ /**
147
+ * Disables special buttons like gamble and take.
148
+ * @public
149
+ * @returns {void}
150
+ */
151
+ disableSpecialButtons() {
152
+ if (RainMan.componentRegistry.has(BUTTONS.gamble)) {
153
+ RainMan.settingsStore.isGambleGameAvailable = false;
154
+ RainMan.componentRegistry.get(BUTTONS.gamble).flipDisabledFlag(true);
155
+ }
156
+ if (RainMan.componentRegistry.has(BUTTONS.take)) {
157
+ RainMan.settingsStore.isTakeActionAvailable = false;
158
+ RainMan.componentRegistry.get(BUTTONS.take).flipDisabledFlag(true);
159
+ }
160
+ }
145
161
  /**
146
162
  * Swaps the bet change disabled flag.
147
163
  * @public
@@ -479,6 +495,9 @@ export class SettingsStore {
479
495
  * @returns {void}
480
496
  */
481
497
  decreaseAutoSpinsCount() {
498
+ if (this.infinitySpinsEnabled) {
499
+ return;
500
+ }
482
501
  this.howManyAutoSpinsLeft -= 1;
483
502
  }
484
503
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
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",