pixi-rainman-game-engine 0.3.15 → 0.3.16

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.
@@ -149,10 +149,13 @@ export class AbstractColumnsContainer extends Container {
149
149
  frame.invokeMysteryFx(this.currentColumn.x, this.currentColumn.y);
150
150
  this.skipScatterDelay = configureSpinAction;
151
151
  await this.currentColumn.speedUpForMysterySpin(100, 1500);
152
- setTimeout(() => {
153
- this.skipScatterDelay?.();
154
- this.skipScatterDelay = null;
155
- }, RainMan.config.durationOfActions.scatterDelayerTime);
152
+ if (!RainMan.settingsStore.isAutoplayEnabled ||
153
+ (RainMan.settingsStore.isAutoplayEnabled && !this.quickReelsStop)) {
154
+ setTimeout(() => {
155
+ this.skipScatterDelay?.();
156
+ this.skipScatterDelay = null;
157
+ }, RainMan.config.durationOfActions.scatterDelayerTime);
158
+ }
156
159
  await this.currentColumn.changeVelocity(Speed.STOP, RainMan.config.durationOfActions.scatterSpinningTime, frame);
157
160
  }
158
161
  if (!indexesOfReelsToExtendSpinningTime.includes(index)) {
@@ -90,7 +90,7 @@ export class LocalConnectionWrapper {
90
90
  extra_data: {},
91
91
  reel_set_id: 1,
92
92
  round_win_amount: 0,
93
- future_balance_prediction: null
93
+ future_balance_prediction: 669.6
94
94
  };
95
95
  return Promise.resolve(new SpinData(this.config, data));
96
96
  }
@@ -26,6 +26,8 @@ export interface InitDataInterface {
26
26
  reinit_data?: SpinDataInterface[];
27
27
  extra_data: InitExtraData;
28
28
  jackpot_wins?: JackpotWins;
29
+ round_win_amount: number;
30
+ free_spins_used: number;
29
31
  }
30
32
  export interface EndDataInterface {
31
33
  action: "end";
@@ -116,7 +118,7 @@ export interface SpinDataInterface {
116
118
  balance: number;
117
119
  round_number: number;
118
120
  status: Status;
119
- future_balance_prediction: number | null;
121
+ future_balance_prediction: number;
120
122
  round_win_amount: number;
121
123
  reel_set_id: number;
122
124
  available_free_spins: number | null;
@@ -8,6 +8,7 @@ export declare class SpinData {
8
8
  readonly balance: number;
9
9
  private readonly rawData;
10
10
  private readonly config;
11
+ balanceAfterSpin: number;
11
12
  constructor(config: ApiConfig, data: SpinDataInterface);
12
13
  /**
13
14
  * Get the raw spin data from the backend server
@@ -6,10 +6,12 @@ export class SpinData {
6
6
  balance;
7
7
  rawData;
8
8
  config;
9
+ balanceAfterSpin;
9
10
  constructor(config, data) {
10
11
  this.rawData = data;
11
12
  this.config = config;
12
13
  this.balance = data.balance;
14
+ this.balanceAfterSpin = data.future_balance_prediction;
13
15
  if (data.action !== "spin" && data.action !== "buy") {
14
16
  throw new Error(`Invalid type "${data.action}" provided, "spin" or "buy" expected`);
15
17
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { ApiConfig, ButtonsEventManager, SpinLogic, SymbolId, WinTypeId } from "../application";
3
3
  import { AbstractColumnsContainer, AbstractFrame, AbstractMainContainer } from "../components";
4
- import { ExtraDataRequest, FreeSpinWin, SpinData, SpinDataInterface, StreakReelsIndexes, SubscribableConnectionWrapper } from "../connectivity";
4
+ import { ExtraDataRequest, FreeSpinWin, InitDataInterface, SpinData, SpinDataInterface, StreakReelsIndexes, SubscribableConnectionWrapper } from "../connectivity";
5
5
  import { GamePhase } from "../constants";
6
6
  import { DescribedPlayableAction } from "../DescribedPlayableAction";
7
7
  import { Nullable } from "../utils";
@@ -53,11 +53,13 @@ export declare abstract class AbstractController<T> {
53
53
  protected shouldDisableBetButtons: boolean;
54
54
  protected wasAutoplayEnabledBeforeFreeSpin: boolean;
55
55
  protected setSlowerSpeedForFreeSpins: boolean;
56
+ shouldStopMobileSpin: boolean;
56
57
  protected resolveBigWin?: () => void;
57
58
  protected resolveMysteryWin?: () => void;
58
59
  protected resolveBonusWin?: () => void;
59
60
  protected resolveSuperBonusWin?: () => void;
60
61
  clearMobileSpinTimeout: (() => void) | undefined;
62
+ protected initData: InitDataInterface;
61
63
  protected _lastWinAmount: number;
62
64
  protected constructor(buttonsEventManager: ButtonsEventManager, mainContainer: AbstractMainContainer, connection: SubscribableConnectionWrapper);
63
65
  /**
@@ -274,6 +276,12 @@ export declare abstract class AbstractController<T> {
274
276
  * @returns {void}
275
277
  */
276
278
  protected clearAndDestroyActions(): void;
279
+ /**
280
+ * Function for updating balance on special occasion ex. bonusGame
281
+ * @public
282
+ * @returns {void}
283
+ */
284
+ updateBalance(): void;
277
285
  /**
278
286
  * Function that is used to invoke take action after winning (send request to backend to save status of wallet).
279
287
  * After that action, gamble and other bonus games are blocked.
@@ -53,17 +53,20 @@ export class AbstractController {
53
53
  shouldDisableBetButtons = false;
54
54
  wasAutoplayEnabledBeforeFreeSpin = false;
55
55
  setSlowerSpeedForFreeSpins = false;
56
+ shouldStopMobileSpin = false;
56
57
  resolveBigWin;
57
58
  resolveMysteryWin;
58
59
  resolveBonusWin;
59
60
  resolveSuperBonusWin;
60
61
  clearMobileSpinTimeout;
62
+ initData;
61
63
  _lastWinAmount = 0;
62
64
  constructor(buttonsEventManager, mainContainer, connection) {
63
65
  this.buttonsEventManager = buttonsEventManager;
64
66
  this.mainContainer = mainContainer;
65
67
  this.connection = connection;
66
68
  const initData = this.connection.initData();
69
+ this.initData = initData;
67
70
  this.config = new ApiConfig(initData);
68
71
  this.quickStopController = new QuickStopController(buttonsEventManager);
69
72
  this.uiController = new UiController(this.config);
@@ -276,6 +279,7 @@ export class AbstractController {
276
279
  if (RainMan.componentRegistry.has(BUTTONS.take)) {
277
280
  this.buttonsEventManager.initTakeButton(() => {
278
281
  RainMan.settingsStore.useTakeAction?.();
282
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
279
283
  RainMan.settingsStore.isTakeActionAvailable = false;
280
284
  RainMan.settingsStore.isGambleGameAvailable = false;
281
285
  if (RainMan.componentRegistry.has(BUTTONS.gamble)) {
@@ -342,6 +346,10 @@ export class AbstractController {
342
346
  const spinLogic = this.spinLogicFactory(RainMan.settingsStore.reinitData[0], this.config);
343
347
  const spinData = new SpinData(this.config, RainMan.settingsStore.reinitData[0]);
344
348
  this._lastWinAmount = this.mysteryWinSymbol ? spinLogic.winTotalAmountWithoutMystery : spinLogic.winTotalAmount;
349
+ const availableFreeSpins = spinLogic.availableFreeSpins;
350
+ if (availableFreeSpins > 0) {
351
+ this._lastWinAmount = this.initData.round_win_amount;
352
+ }
345
353
  if (spinLogic.winTotalAmount !== 0) {
346
354
  this.uiController.recentWin = ceilToDecimal(spinLogic.winTotalAmount);
347
355
  this.uiController.totalFreeSpinWinAmount = this._lastWinAmount;
@@ -349,7 +357,6 @@ export class AbstractController {
349
357
  this.uiController.currentBalance = spinData.balance;
350
358
  this.roundNumber = spinData.getRawData().round_number;
351
359
  RainMan.settingsStore.setRoundNumber(this.roundNumber);
352
- const availableFreeSpins = spinLogic.availableFreeSpins;
353
360
  if (this._lastWinAmount !== 0) {
354
361
  RainMan.settingsStore.isTakeActionAvailable = true;
355
362
  RainMan.settingsStore.isGambleGameAvailable = true;
@@ -391,7 +398,9 @@ export class AbstractController {
391
398
  this.mobileSpinDelay = null;
392
399
  }
393
400
  };
394
- refreshButton.setOnClick(() => this.handleSpinLogic());
401
+ refreshButton.setOnClick(() => {
402
+ this.handleSpinLogic();
403
+ });
395
404
  refreshButton.on("touchend", () => {
396
405
  if (this.clearMobileSpinTimeout)
397
406
  this.clearMobileSpinTimeout();
@@ -408,6 +417,18 @@ export class AbstractController {
408
417
  if (this.clearMobileSpinTimeout)
409
418
  this.clearMobileSpinTimeout();
410
419
  });
420
+ refreshButton.on("pointerout", () => {
421
+ if (this.clearMobileSpinTimeout)
422
+ this.clearMobileSpinTimeout();
423
+ });
424
+ refreshButton.on("pointerup", () => {
425
+ if (this.clearMobileSpinTimeout)
426
+ this.clearMobileSpinTimeout();
427
+ });
428
+ refreshButton.on("pointerupoutside", () => {
429
+ if (this.clearMobileSpinTimeout)
430
+ this.clearMobileSpinTimeout();
431
+ });
411
432
  refreshButton.on("touchstart", () => {
412
433
  this.mobileSpinDelay = setTimeout(() => {
413
434
  this.mobileSpinTimeout = setInterval(() => {
@@ -416,6 +437,7 @@ export class AbstractController {
416
437
  this.summaryStop = this.skipFreeSpinSummary ? false : this.invokeFreeSpinSummaryPlateAfterWin;
417
438
  if (this.invokeFreeSpinPlateAfterWin ||
418
439
  this.summaryStop ||
440
+ this.shouldStopMobileSpin ||
419
441
  this.resolveBigWin !== undefined ||
420
442
  this.resolveSuperBonusWin !== undefined ||
421
443
  this.resolveMysteryWin !== undefined) {
@@ -766,6 +788,14 @@ export class AbstractController {
766
788
  this.winActionsQueue.length = 0;
767
789
  this.currentlyPlayedAction = undefined;
768
790
  }
791
+ /**
792
+ * Function for updating balance on special occasion ex. bonusGame
793
+ * @public
794
+ * @returns {void}
795
+ */
796
+ updateBalance() {
797
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
798
+ }
769
799
  /**
770
800
  * Function that is used to invoke take action after winning (send request to backend to save status of wallet).
771
801
  * After that action, gamble and other bonus games are blocked.
@@ -842,6 +872,7 @@ export class AbstractController {
842
872
  }
843
873
  this.changeGamePhase(gamePhases.CONFIGURING_SPIN);
844
874
  this.uiController.currentBalance = data.balance;
875
+ RainMan.settingsStore.setBalanceAfterSpin(data.balanceAfterSpin);
845
876
  this.roundNumber = data.getRawData().round_number;
846
877
  RainMan.settingsStore.setRoundNumber(data.getRawData().round_number);
847
878
  return {
@@ -1066,6 +1097,7 @@ export class AbstractController {
1066
1097
  this.uiController.messageBox.hideCurrentWinText();
1067
1098
  this.uiController.messageBox.hideAutoSpinText();
1068
1099
  await this.handleFreeSpinPlateInvocation(freeSpinAward, isAdditionalFreeSpins || additionalFreeSpinsOnLastSpin);
1100
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
1069
1101
  this.uiController.triggerUiElementsUpdate();
1070
1102
  this.uiController.messageBox.showFreeSpinText();
1071
1103
  }
@@ -1149,6 +1181,7 @@ export class AbstractController {
1149
1181
  this.uiController.resetTotalFreeSpinWinAmount();
1150
1182
  this.changeGamePhase(gamePhases.IDLE);
1151
1183
  });
1184
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
1152
1185
  RainMan.settingsStore.resetTotalNumberOfFreeSpins();
1153
1186
  RainMan.settingsStore.resetFreeSpinNumberBought();
1154
1187
  this.changeGamePhase(gamePhases.IDLE);
@@ -1457,7 +1490,6 @@ export class AbstractController {
1457
1490
  }
1458
1491
  else {
1459
1492
  this.uiController.delegateUpdatingWinAndBalance(value);
1460
- this.uiController.updateShownBalance();
1461
1493
  }
1462
1494
  }
1463
1495
  /**
@@ -138,7 +138,7 @@ export class UiController {
138
138
  case "remain":
139
139
  return this.lastBet;
140
140
  case "highest":
141
- return this.config?.getHighestBet(this.currentBalance) || 0;
141
+ return this.config?.getHighestBet(this._currentBalance) || 0;
142
142
  default:
143
143
  return this.config?.getFirstBet() || 0;
144
144
  }
@@ -242,7 +242,6 @@ export class UiController {
242
242
  this.messageBox.showCurrentWinText();
243
243
  this._promisesToSetBalances = [];
244
244
  this.updateDisplayedWin(amount);
245
- this.updateDisplayedBalance(amount);
246
245
  }
247
246
  /**
248
247
  * Function for updating displayed win amount
@@ -39,6 +39,7 @@ export declare class SettingsStore {
39
39
  balancedIncreased: number;
40
40
  balancedDecreased: number;
41
41
  howManyFreeSpinsLeft: number;
42
+ balanceAfterSpin: number;
42
43
  howManyAutoSpinsLeft: number;
43
44
  freeSpinBuyTable: Record<number, number>;
44
45
  volumeLevel: number;
@@ -91,6 +92,13 @@ export declare class SettingsStore {
91
92
  * @returns {void}
92
93
  */
93
94
  addCumulativeWinAmount(amount: number): void;
95
+ /**
96
+ * Store balance after spin for updates.
97
+ * @public
98
+ * @param {number} balance to set.
99
+ * @returns {void}
100
+ */
101
+ setBalanceAfterSpin(balance: number): void;
94
102
  /**
95
103
  * Disables special buttons like gamble and take.
96
104
  * @public
@@ -43,6 +43,7 @@ export class SettingsStore {
43
43
  balancedIncreased = 0;
44
44
  balancedDecreased = 0;
45
45
  howManyFreeSpinsLeft = 0;
46
+ balanceAfterSpin = 0;
46
47
  howManyAutoSpinsLeft = INITIAL_AUTO_SPIN_COUNT;
47
48
  freeSpinBuyTable = {};
48
49
  volumeLevel = Number(getFromLocalStorage(LOCAL_STORAGE.volumeLevel, 100));
@@ -85,6 +86,7 @@ export class SettingsStore {
85
86
  }
86
87
  makeAutoObservable(this, {
87
88
  setBatteryFlag: action.bound,
89
+ setBalanceAfterSpin: action.bound,
88
90
  setShouldPlayAmbientMusic: action.bound,
89
91
  setShouldPlayFxSounds: action.bound,
90
92
  setFullScreenFlag: action.bound,
@@ -151,6 +153,15 @@ export class SettingsStore {
151
153
  addCumulativeWinAmount(amount) {
152
154
  this.cumulativeWinAmount = this.cumulativeWinAmount + amount;
153
155
  }
156
+ /**
157
+ * Store balance after spin for updates.
158
+ * @public
159
+ * @param {number} balance to set.
160
+ * @returns {void}
161
+ */
162
+ setBalanceAfterSpin(balance) {
163
+ this.balanceAfterSpin = balance;
164
+ }
154
165
  /**
155
166
  * Disables special buttons like gamble and take.
156
167
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixi-rainman-game-engine",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
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",