pixi-rainman-game-engine 0.3.14 → 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.
@@ -37,7 +37,7 @@ export declare abstract class AbstractMainContainer extends Container {
37
37
  protected bonusWinContainer: Nullable<UpdatableSpineContainer>;
38
38
  protected superBonusWinContainer: Nullable<UpdatableSpineContainer>;
39
39
  protected overlay: Nullable<Graphics>;
40
- protected readonly buttonsEventManager: ButtonsEventManager;
40
+ protected buttonsEventManager: ButtonsEventManager;
41
41
  protected logo: Nullable<Logo>;
42
42
  protected abstract background: IResizableContainer;
43
43
  protected animatedFront: Nullable<IResizableContainer>;
@@ -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";
@@ -52,11 +52,14 @@ export declare abstract class AbstractController<T> {
52
52
  protected summaryStop: boolean;
53
53
  protected shouldDisableBetButtons: boolean;
54
54
  protected wasAutoplayEnabledBeforeFreeSpin: boolean;
55
+ protected setSlowerSpeedForFreeSpins: boolean;
56
+ shouldStopMobileSpin: boolean;
55
57
  protected resolveBigWin?: () => void;
56
58
  protected resolveMysteryWin?: () => void;
57
59
  protected resolveBonusWin?: () => void;
58
60
  protected resolveSuperBonusWin?: () => void;
59
61
  clearMobileSpinTimeout: (() => void) | undefined;
62
+ protected initData: InitDataInterface;
60
63
  protected _lastWinAmount: number;
61
64
  protected constructor(buttonsEventManager: ButtonsEventManager, mainContainer: AbstractMainContainer, connection: SubscribableConnectionWrapper);
62
65
  /**
@@ -273,6 +276,12 @@ export declare abstract class AbstractController<T> {
273
276
  * @returns {void}
274
277
  */
275
278
  protected clearAndDestroyActions(): void;
279
+ /**
280
+ * Function for updating balance on special occasion ex. bonusGame
281
+ * @public
282
+ * @returns {void}
283
+ */
284
+ updateBalance(): void;
276
285
  /**
277
286
  * Function that is used to invoke take action after winning (send request to backend to save status of wallet).
278
287
  * After that action, gamble and other bonus games are blocked.
@@ -52,17 +52,21 @@ export class AbstractController {
52
52
  summaryStop = false;
53
53
  shouldDisableBetButtons = false;
54
54
  wasAutoplayEnabledBeforeFreeSpin = false;
55
+ setSlowerSpeedForFreeSpins = false;
56
+ shouldStopMobileSpin = false;
55
57
  resolveBigWin;
56
58
  resolveMysteryWin;
57
59
  resolveBonusWin;
58
60
  resolveSuperBonusWin;
59
61
  clearMobileSpinTimeout;
62
+ initData;
60
63
  _lastWinAmount = 0;
61
64
  constructor(buttonsEventManager, mainContainer, connection) {
62
65
  this.buttonsEventManager = buttonsEventManager;
63
66
  this.mainContainer = mainContainer;
64
67
  this.connection = connection;
65
68
  const initData = this.connection.initData();
69
+ this.initData = initData;
66
70
  this.config = new ApiConfig(initData);
67
71
  this.quickStopController = new QuickStopController(buttonsEventManager);
68
72
  this.uiController = new UiController(this.config);
@@ -275,6 +279,7 @@ export class AbstractController {
275
279
  if (RainMan.componentRegistry.has(BUTTONS.take)) {
276
280
  this.buttonsEventManager.initTakeButton(() => {
277
281
  RainMan.settingsStore.useTakeAction?.();
282
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
278
283
  RainMan.settingsStore.isTakeActionAvailable = false;
279
284
  RainMan.settingsStore.isGambleGameAvailable = false;
280
285
  if (RainMan.componentRegistry.has(BUTTONS.gamble)) {
@@ -341,6 +346,10 @@ export class AbstractController {
341
346
  const spinLogic = this.spinLogicFactory(RainMan.settingsStore.reinitData[0], this.config);
342
347
  const spinData = new SpinData(this.config, RainMan.settingsStore.reinitData[0]);
343
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
+ }
344
353
  if (spinLogic.winTotalAmount !== 0) {
345
354
  this.uiController.recentWin = ceilToDecimal(spinLogic.winTotalAmount);
346
355
  this.uiController.totalFreeSpinWinAmount = this._lastWinAmount;
@@ -348,7 +357,6 @@ export class AbstractController {
348
357
  this.uiController.currentBalance = spinData.balance;
349
358
  this.roundNumber = spinData.getRawData().round_number;
350
359
  RainMan.settingsStore.setRoundNumber(this.roundNumber);
351
- const availableFreeSpins = spinLogic.availableFreeSpins;
352
360
  if (this._lastWinAmount !== 0) {
353
361
  RainMan.settingsStore.isTakeActionAvailable = true;
354
362
  RainMan.settingsStore.isGambleGameAvailable = true;
@@ -390,7 +398,9 @@ export class AbstractController {
390
398
  this.mobileSpinDelay = null;
391
399
  }
392
400
  };
393
- refreshButton.setOnClick(() => this.handleSpinLogic());
401
+ refreshButton.setOnClick(() => {
402
+ this.handleSpinLogic();
403
+ });
394
404
  refreshButton.on("touchend", () => {
395
405
  if (this.clearMobileSpinTimeout)
396
406
  this.clearMobileSpinTimeout();
@@ -407,6 +417,18 @@ export class AbstractController {
407
417
  if (this.clearMobileSpinTimeout)
408
418
  this.clearMobileSpinTimeout();
409
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
+ });
410
432
  refreshButton.on("touchstart", () => {
411
433
  this.mobileSpinDelay = setTimeout(() => {
412
434
  this.mobileSpinTimeout = setInterval(() => {
@@ -415,6 +437,7 @@ export class AbstractController {
415
437
  this.summaryStop = this.skipFreeSpinSummary ? false : this.invokeFreeSpinSummaryPlateAfterWin;
416
438
  if (this.invokeFreeSpinPlateAfterWin ||
417
439
  this.summaryStop ||
440
+ this.shouldStopMobileSpin ||
418
441
  this.resolveBigWin !== undefined ||
419
442
  this.resolveSuperBonusWin !== undefined ||
420
443
  this.resolveMysteryWin !== undefined) {
@@ -765,6 +788,14 @@ export class AbstractController {
765
788
  this.winActionsQueue.length = 0;
766
789
  this.currentlyPlayedAction = undefined;
767
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
+ }
768
799
  /**
769
800
  * Function that is used to invoke take action after winning (send request to backend to save status of wallet).
770
801
  * After that action, gamble and other bonus games are blocked.
@@ -841,6 +872,7 @@ export class AbstractController {
841
872
  }
842
873
  this.changeGamePhase(gamePhases.CONFIGURING_SPIN);
843
874
  this.uiController.currentBalance = data.balance;
875
+ RainMan.settingsStore.setBalanceAfterSpin(data.balanceAfterSpin);
844
876
  this.roundNumber = data.getRawData().round_number;
845
877
  RainMan.settingsStore.setRoundNumber(data.getRawData().round_number);
846
878
  return {
@@ -1025,10 +1057,10 @@ export class AbstractController {
1025
1057
  await this.countBigWin();
1026
1058
  await this.handleLoopingWinActionQueue();
1027
1059
  if (RainMan.settingsStore.howManyFreeSpinsLeft !== 0 &&
1028
- this.invokeFreeSpinPlateAfterWin &&
1060
+ (this.invokeFreeSpinPlateAfterWin || this.setSlowerSpeedForFreeSpins) &&
1029
1061
  RainMan.settingsStore.isFreeSpinsPlayEnabled) {
1030
1062
  RainMan.componentRegistry.setSpeedLevel(SPEED_LEVELS.slow);
1031
- this.uiController.updateShownSpeedLevel(RainMan.componentRegistry.getSpeedLevel());
1063
+ this.uiController.updateShownSpeedLevel(SPEED_LEVELS.slow);
1032
1064
  this.disableSpeedButton(false);
1033
1065
  }
1034
1066
  this.clearAndDestroyActions();
@@ -1065,6 +1097,7 @@ export class AbstractController {
1065
1097
  this.uiController.messageBox.hideCurrentWinText();
1066
1098
  this.uiController.messageBox.hideAutoSpinText();
1067
1099
  await this.handleFreeSpinPlateInvocation(freeSpinAward, isAdditionalFreeSpins || additionalFreeSpinsOnLastSpin);
1100
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
1068
1101
  this.uiController.triggerUiElementsUpdate();
1069
1102
  this.uiController.messageBox.showFreeSpinText();
1070
1103
  }
@@ -1107,6 +1140,9 @@ export class AbstractController {
1107
1140
  if (this.invokeFreeSpinPlateAfterWin) {
1108
1141
  this.invokeFreeSpinPlateAfterWin = false;
1109
1142
  }
1143
+ if (this.setSlowerSpeedForFreeSpins) {
1144
+ this.setSlowerSpeedForFreeSpins = false;
1145
+ }
1110
1146
  RainMan.settingsStore.setIsPlayingAnyAction(false);
1111
1147
  this.columnsContainer.setInteractivityForSymbols(true);
1112
1148
  }
@@ -1145,6 +1181,7 @@ export class AbstractController {
1145
1181
  this.uiController.resetTotalFreeSpinWinAmount();
1146
1182
  this.changeGamePhase(gamePhases.IDLE);
1147
1183
  });
1184
+ this.uiController.currentBalance = RainMan.settingsStore.balanceAfterSpin;
1148
1185
  RainMan.settingsStore.resetTotalNumberOfFreeSpins();
1149
1186
  RainMan.settingsStore.resetFreeSpinNumberBought();
1150
1187
  this.changeGamePhase(gamePhases.IDLE);
@@ -1453,7 +1490,6 @@ export class AbstractController {
1453
1490
  }
1454
1491
  else {
1455
1492
  this.uiController.delegateUpdatingWinAndBalance(value);
1456
- this.uiController.updateShownBalance();
1457
1493
  }
1458
1494
  }
1459
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.14",
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",