@enigma-lake/tower-play-controller-sdk 2.0.13 → 2.0.15
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.
- package/README.md +83 -311
- package/dist/components/AutoManualPlayStateProvider/AutoManualPlayStateContext.d.ts +9 -1
- package/dist/components/base/Button/buttonStyle.d.ts +5 -0
- package/dist/components/base/Cashout/cashoutBehavior.d.ts +27 -0
- package/dist/components/hooks/playAmount.d.ts +5 -0
- package/dist/components/hooks/usePlayController.d.ts +2 -0
- package/dist/components/hooks/useSpacebarButtonTrigger.d.ts +8 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/index.d.ts +55 -1
- package/dist/index.mjs +217 -138
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/gameMode.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/playController.d.ts +15 -0
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useContext, useRef,
|
|
2
|
+
import React, { createContext, useContext, useRef, useCallback, useEffect, useMemo, useState, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import cx$1 from 'classnames';
|
|
4
4
|
import { Currency, sendSetUserCurrencyEvent, sendSetUserCurrencyEventV2, setToggleGameWidgetsVisibility, setToggleGameWidgetsExpansion, getUserInformationEvent, EVENTS, sendOpenHighPlayModalEvent } from '@enigma-lake/zoot-platform-sdk';
|
|
5
5
|
import { Menu, MenuButton, MenuItems, MenuItem, Switch as Switch$1 } from '@headlessui/react';
|
|
@@ -60,6 +60,11 @@ var AUTO_PLAY_STATE;
|
|
|
60
60
|
AUTO_PLAY_STATE["SELECTING"] = "selecting";
|
|
61
61
|
AUTO_PLAY_STATE["PLAYING"] = "playing";
|
|
62
62
|
})(AUTO_PLAY_STATE || (AUTO_PLAY_STATE = {}));
|
|
63
|
+
var DOUBLE_OR_NOTHING_STATE;
|
|
64
|
+
(function (DOUBLE_OR_NOTHING_STATE) {
|
|
65
|
+
DOUBLE_OR_NOTHING_STATE["IDLE"] = "idle";
|
|
66
|
+
DOUBLE_OR_NOTHING_STATE["PROGRESS"] = "progress";
|
|
67
|
+
})(DOUBLE_OR_NOTHING_STATE || (DOUBLE_OR_NOTHING_STATE = {}));
|
|
63
68
|
|
|
64
69
|
var WIDGET;
|
|
65
70
|
(function (WIDGET) {
|
|
@@ -67,15 +72,64 @@ var WIDGET;
|
|
|
67
72
|
WIDGET["SIDE"] = "side";
|
|
68
73
|
})(WIDGET || (WIDGET = {}));
|
|
69
74
|
|
|
75
|
+
const isManualCashoutDisabled = ({ disabledController, isPlaying, cashoutDisabled, }) => disabledController || !isPlaying || cashoutDisabled;
|
|
76
|
+
const createManualCashoutClickHandler = ({ cashoutDisabled, onCashout, }) => {
|
|
77
|
+
return () => {
|
|
78
|
+
if (cashoutDisabled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
onCashout();
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const canAutoplaySpaceTrigger = ({ state, cashoutDisabled, isDisabled, }) => {
|
|
85
|
+
return state === AUTO_PLAY_STATE.PLAYING ? !cashoutDisabled : !isDisabled;
|
|
86
|
+
};
|
|
87
|
+
const isAutoplayButtonDisabled = ({ state, cashoutDisabled, isDisabled, isValidPlayAmount, }) => {
|
|
88
|
+
return state === AUTO_PLAY_STATE.PLAYING
|
|
89
|
+
? cashoutDisabled
|
|
90
|
+
: isDisabled || !isValidPlayAmount;
|
|
91
|
+
};
|
|
92
|
+
const createAutoplayButtonAction = ({ state, cashoutDisabled, onStopPlay, onPlay, }) => {
|
|
93
|
+
return () => {
|
|
94
|
+
if (state === AUTO_PLAY_STATE.PLAYING) {
|
|
95
|
+
if (cashoutDisabled) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
onStopPlay();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
onPlay();
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
70
105
|
const AutoManualPlayStateContext = createContext(undefined);
|
|
71
106
|
const useAutoManualPlayState = () => {
|
|
72
107
|
const context = useContext(AutoManualPlayStateContext);
|
|
73
108
|
if (!context) {
|
|
74
|
-
throw new Error("
|
|
109
|
+
throw new Error("useAutoManualPlayState must be used within AutoManualPlayProvider");
|
|
75
110
|
}
|
|
76
111
|
return context;
|
|
77
112
|
};
|
|
78
113
|
|
|
114
|
+
const getNextPlayAmount = ({ currentAmount, defaultBetOptions, direction, }) => {
|
|
115
|
+
if (!defaultBetOptions.length) {
|
|
116
|
+
return currentAmount;
|
|
117
|
+
}
|
|
118
|
+
const sorted = [...defaultBetOptions].sort((a, b) => a - b);
|
|
119
|
+
const currentIndex = sorted.findIndex((value) => value === currentAmount);
|
|
120
|
+
if (currentIndex !== -1) {
|
|
121
|
+
const targetIndex = currentIndex + direction;
|
|
122
|
+
if (targetIndex >= 0 && targetIndex < sorted.length) {
|
|
123
|
+
return sorted[targetIndex];
|
|
124
|
+
}
|
|
125
|
+
return sorted[currentIndex];
|
|
126
|
+
}
|
|
127
|
+
sorted.push(currentAmount);
|
|
128
|
+
sorted.sort((a, b) => a - b);
|
|
129
|
+
const insertedIndex = sorted.indexOf(currentAmount);
|
|
130
|
+
return sorted[insertedIndex + direction] ?? currentAmount;
|
|
131
|
+
};
|
|
132
|
+
|
|
79
133
|
/**
|
|
80
134
|
* Type guard: full mode (risk + autoplay enabled)
|
|
81
135
|
*
|
|
@@ -89,7 +143,7 @@ function isFullMode(config) {
|
|
|
89
143
|
const usePlayController = () => {
|
|
90
144
|
const { config, autoPlay: { setNumberOfPlays, numberOfPlays, setPlayedRounds, playedRounds, selection, setState, state, }, playValues: { displayPlayAmountView, setDisplayPlayAmountView, togglePlayAmountView, }, } = useAutoManualPlayState();
|
|
91
145
|
const { current } = config.currencyOptions;
|
|
92
|
-
const { isPlaying, canCashout, disabledController, playHook, totalBalance } = config.playOptions;
|
|
146
|
+
const { isPlaying, canCashout, disabledCashout = false, disabledController, playHook, totalBalance, } = config.playOptions;
|
|
93
147
|
// --- Autoplay-related values only valid in full mode ---
|
|
94
148
|
const autoplayEnabled = isFullMode(config);
|
|
95
149
|
const showAutoPlayToast = autoplayEnabled
|
|
@@ -158,31 +212,15 @@ const usePlayController = () => {
|
|
|
158
212
|
if (isDisabled()) {
|
|
159
213
|
return;
|
|
160
214
|
}
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
215
|
+
const options = playLimits?.[current.code]?.defaultBetOptions ?? [];
|
|
216
|
+
if (!options.length) {
|
|
163
217
|
return;
|
|
164
218
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
// If current isn't exactly in list, insert it logically
|
|
171
|
-
sorted.push(playAmount);
|
|
172
|
-
sorted.sort((a, b) => a - b);
|
|
173
|
-
const idx = sorted.indexOf(playAmount);
|
|
174
|
-
newAmount = sorted[idx + direction] ?? playAmount;
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
const targetIdx = currentIndex + direction;
|
|
178
|
-
if (targetIdx >= 0 && targetIdx < sorted.length) {
|
|
179
|
-
newAmount = sorted[targetIdx];
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
// clamp if out of bounds
|
|
183
|
-
newAmount = sorted[currentIndex];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
219
|
+
const newAmount = getNextPlayAmount({
|
|
220
|
+
currentAmount: playAmount,
|
|
221
|
+
defaultBetOptions: options,
|
|
222
|
+
direction,
|
|
223
|
+
});
|
|
186
224
|
setPlayAmount(newAmount);
|
|
187
225
|
};
|
|
188
226
|
const onChangeAmount = (playValue) => {
|
|
@@ -209,6 +247,7 @@ const usePlayController = () => {
|
|
|
209
247
|
isDisabled,
|
|
210
248
|
onPlay: config.onPlay,
|
|
211
249
|
canCashout,
|
|
250
|
+
cashoutDisabled: disabledCashout,
|
|
212
251
|
},
|
|
213
252
|
// autoplay
|
|
214
253
|
autoPlay: {
|
|
@@ -216,6 +255,7 @@ const usePlayController = () => {
|
|
|
216
255
|
state,
|
|
217
256
|
onPlay: handleAutoPlay,
|
|
218
257
|
onStopPlay: stopAutoplay,
|
|
258
|
+
cashoutDisabled: disabledCashout,
|
|
219
259
|
},
|
|
220
260
|
// UI state for play amount view
|
|
221
261
|
playValues: {
|
|
@@ -226,7 +266,7 @@ const usePlayController = () => {
|
|
|
226
266
|
};
|
|
227
267
|
};
|
|
228
268
|
|
|
229
|
-
var styles_button = {"base":"Button-module__base___muNxk","base__theme-ghost":"Button-module__base__theme-ghost___I5-LJ","base__theme-primary":"Button-module__base__theme-primary___Zuswb","base__state-disabled":"Button-module__base__state-disabled___EU5tH","buttonPlayAmount":"Button-module__buttonPlayAmount___GMy3F","buttonCashout":"Button-module__buttonCashout___LG-Yr","buttonPlayAmount__active":"Button-module__buttonPlayAmount__active___e0nGe","buttonCashout__active":"Button-module__buttonCashout__active___qnE3h","buttonSweeps":"Button-module__buttonSweeps___0snDQ","buttonSweeps__active":"Button-module__buttonSweeps__active___PXIFH","buttonGold":"Button-module__buttonGold___DAj-d","buttonGold__active":"Button-module__buttonGold__active___vsi7m","buttonDefault":"Button-module__buttonDefault___QENXy","buttonDefault__active":"Button-module__buttonDefault__active___oS6gd"};
|
|
269
|
+
var styles_button = {"base":"Button-module__base___muNxk","base__theme-ghost":"Button-module__base__theme-ghost___I5-LJ","base__theme-primary":"Button-module__base__theme-primary___Zuswb","base__state-disabled":"Button-module__base__state-disabled___EU5tH","buttonPlayAmount":"Button-module__buttonPlayAmount___GMy3F","buttonCashout":"Button-module__buttonCashout___LG-Yr","buttonPlayAmount__active":"Button-module__buttonPlayAmount__active___e0nGe","buttonCashout__active":"Button-module__buttonCashout__active___qnE3h","buttonSweeps":"Button-module__buttonSweeps___0snDQ","buttonSweeps__active":"Button-module__buttonSweeps__active___PXIFH","buttonGold":"Button-module__buttonGold___DAj-d","buttonGold__active":"Button-module__buttonGold__active___vsi7m","buttonDefault":"Button-module__buttonDefault___QENXy","buttonDefault__active":"Button-module__buttonDefault__active___oS6gd","buttonDON":"Button-module__buttonDON___ROWdX","buttonDON__active":"Button-module__buttonDON__active___QeoiQ","buttonDON__disabled":"Button-module__buttonDON__disabled___98v7-","buttonDON__title":"Button-module__buttonDON__title___sbNMd","buttonDON__subtitle":"Button-module__buttonDON__subtitle___sgpdf","buttonDON__content":"Button-module__buttonDON__content___sJ-pz","buttonRow":"Button-module__buttonRow___gYuQ0","buttonRow__cashout":"Button-module__buttonRow__cashout___8QZ-4","buttonRow__don":"Button-module__buttonRow__don___tYZKN"};
|
|
230
270
|
|
|
231
271
|
const themes = {
|
|
232
272
|
primary: "primary",
|
|
@@ -337,57 +377,45 @@ const PlayAmountControl = ({ isDisabled }) => {
|
|
|
337
377
|
state === AUTO_PLAY_STATE.PLAYING, onClick: handleTogglePlayAmount, children: jsx(SelectMenu, { disabled: isDisabled() }) }), jsx(Button, { className: styles_group.groupItem, onClick: () => adjustPlayAmount({ direction: -1 }), theme: "ghost", disabled: isDisabled(), children: jsx("span", { className: styles_group.x2, children: "-" }) }), jsx(Button, { className: styles_group.groupItem, onClick: () => adjustPlayAmount({ direction: 1 }), theme: "ghost", disabled: isDisabled(), children: jsx("span", { className: cx$1(styles_group.x2, styles_group.last), children: "+" }) })] }));
|
|
338
378
|
};
|
|
339
379
|
|
|
380
|
+
const getDefaultButtonClassName = (currencyCode, styles) => {
|
|
381
|
+
if (currencyCode === Currency.GOLD) {
|
|
382
|
+
return styles.buttonGold;
|
|
383
|
+
}
|
|
384
|
+
if (currencyCode === Currency.SWEEPS) {
|
|
385
|
+
return styles.buttonSweeps;
|
|
386
|
+
}
|
|
387
|
+
return styles.buttonDefault;
|
|
388
|
+
};
|
|
389
|
+
const getActiveButtonClassName = (currencyCode, styles) => {
|
|
390
|
+
if (currencyCode === Currency.GOLD) {
|
|
391
|
+
return styles.buttonGold__active;
|
|
392
|
+
}
|
|
393
|
+
if (currencyCode === Currency.SWEEPS) {
|
|
394
|
+
return styles.buttonSweeps__active;
|
|
395
|
+
}
|
|
396
|
+
return styles.buttonDefault__active;
|
|
397
|
+
};
|
|
398
|
+
|
|
340
399
|
var AUTOPLAY_LABEL;
|
|
341
400
|
(function (AUTOPLAY_LABEL) {
|
|
342
401
|
AUTOPLAY_LABEL["START"] = "START AUTOPLAY";
|
|
343
402
|
AUTOPLAY_LABEL["STOP"] = "STOP AUTOPLAY";
|
|
344
403
|
})(AUTOPLAY_LABEL || (AUTOPLAY_LABEL = {}));
|
|
345
404
|
|
|
346
|
-
const
|
|
347
|
-
const { config } = useAutoManualPlayState();
|
|
348
|
-
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, autoPlay: { isDisabled, state, onPlay, onStopPlay }, } = usePlayController();
|
|
349
|
-
const { current } = config.currencyOptions;
|
|
350
|
-
const roleButton = GAME_MODE.AUTOPLAY;
|
|
351
|
-
const buttonLabel = state === AUTO_PLAY_STATE.PLAYING
|
|
352
|
-
? AUTOPLAY_LABEL.STOP
|
|
353
|
-
: AUTOPLAY_LABEL.START;
|
|
354
|
-
const activeClassName = useMemo(() => {
|
|
355
|
-
if (current.code === Currency.GOLD) {
|
|
356
|
-
return styles_button.buttonGold__active;
|
|
357
|
-
}
|
|
358
|
-
if (current.code === Currency.SWEEPS) {
|
|
359
|
-
return styles_button.buttonSweeps__active;
|
|
360
|
-
}
|
|
361
|
-
return styles_button.buttonDefault__active;
|
|
362
|
-
}, [current.code]);
|
|
363
|
-
const defaultClassName = useMemo(() => {
|
|
364
|
-
if (buttonLabel === AUTOPLAY_LABEL.STOP) {
|
|
365
|
-
return styles_button.buttonCashout;
|
|
366
|
-
}
|
|
367
|
-
if (current.code === Currency.GOLD) {
|
|
368
|
-
return styles_button.buttonGold;
|
|
369
|
-
}
|
|
370
|
-
if (current.code === Currency.SWEEPS) {
|
|
371
|
-
return styles_button.buttonSweeps;
|
|
372
|
-
}
|
|
373
|
-
return styles_button.buttonDefault;
|
|
374
|
-
}, [buttonLabel, current.code]);
|
|
405
|
+
const useSpacebarButtonTrigger = ({ roleButton, activeClassName, canTrigger, }) => {
|
|
375
406
|
const handleKeyPress = useCallback((event) => {
|
|
376
407
|
if (event.code !== "Space") {
|
|
377
408
|
return;
|
|
378
409
|
}
|
|
379
410
|
const button = selectButton(roleButton);
|
|
380
|
-
if (!button) {
|
|
411
|
+
if (!button || !canTrigger()) {
|
|
381
412
|
return;
|
|
382
413
|
}
|
|
383
414
|
event.preventDefault();
|
|
384
415
|
event.stopPropagation();
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
button.click();
|
|
389
|
-
}
|
|
390
|
-
}, [activeClassName, isDisabled, roleButton, state]);
|
|
416
|
+
addPressedClass(roleButton, activeClassName);
|
|
417
|
+
button.click();
|
|
418
|
+
}, [activeClassName, canTrigger, roleButton]);
|
|
391
419
|
const handleKeyUp = useCallback((event) => {
|
|
392
420
|
if (event.code !== "Space") {
|
|
393
421
|
return;
|
|
@@ -408,10 +436,44 @@ const AutoPlayController = () => {
|
|
|
408
436
|
window.removeEventListener("keyup", handleKeyUp, true);
|
|
409
437
|
};
|
|
410
438
|
}, [handleKeyPress, handleKeyUp]);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const AutoPlayController = () => {
|
|
442
|
+
const { config } = useAutoManualPlayState();
|
|
443
|
+
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, autoPlay: { isDisabled, state, onPlay, onStopPlay, cashoutDisabled }, } = usePlayController();
|
|
444
|
+
const { current } = config.currencyOptions;
|
|
445
|
+
const roleButton = GAME_MODE.AUTOPLAY;
|
|
446
|
+
const buttonLabel = state === AUTO_PLAY_STATE.PLAYING
|
|
447
|
+
? AUTOPLAY_LABEL.STOP
|
|
448
|
+
: AUTOPLAY_LABEL.START;
|
|
449
|
+
const activeClassName = getActiveButtonClassName(current.code, styles_button);
|
|
450
|
+
const defaultClassName = useMemo(() => {
|
|
451
|
+
if (buttonLabel === AUTOPLAY_LABEL.STOP) {
|
|
452
|
+
return styles_button.buttonCashout;
|
|
453
|
+
}
|
|
454
|
+
return getDefaultButtonClassName(current.code, styles_button);
|
|
455
|
+
}, [buttonLabel, current.code]);
|
|
456
|
+
useSpacebarButtonTrigger({
|
|
457
|
+
roleButton,
|
|
458
|
+
activeClassName,
|
|
459
|
+
canTrigger: () => canAutoplaySpaceTrigger({
|
|
460
|
+
state,
|
|
461
|
+
cashoutDisabled,
|
|
462
|
+
isDisabled: isDisabled(),
|
|
463
|
+
}),
|
|
464
|
+
});
|
|
465
|
+
const isButtonDisabled = isAutoplayButtonDisabled({
|
|
466
|
+
state,
|
|
467
|
+
cashoutDisabled,
|
|
468
|
+
isDisabled: isDisabled(),
|
|
469
|
+
isValidPlayAmount,
|
|
470
|
+
});
|
|
471
|
+
const buttonAction = useMemo(() => createAutoplayButtonAction({
|
|
472
|
+
state,
|
|
473
|
+
cashoutDisabled,
|
|
474
|
+
onStopPlay,
|
|
475
|
+
onPlay,
|
|
476
|
+
}), [cashoutDisabled, onPlay, onStopPlay, state]);
|
|
415
477
|
const handleTogglePlayAmount = useCallback(() => {
|
|
416
478
|
setToggleGameWidgetsVisibility();
|
|
417
479
|
togglePlayAmountView();
|
|
@@ -457,80 +519,71 @@ const useIsRunningExternal = () => {
|
|
|
457
519
|
};
|
|
458
520
|
|
|
459
521
|
const ManualPlayController = () => {
|
|
460
|
-
const { config } = useAutoManualPlayState();
|
|
522
|
+
const { config, doubleOrNothing } = useAutoManualPlayState();
|
|
461
523
|
const { isRunningExternal } = useIsRunningExternal();
|
|
462
|
-
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, manualPlay: { isDisabled, onPlay, canCashout }, } = usePlayController();
|
|
524
|
+
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, manualPlay: { isDisabled, onPlay, canCashout, cashoutDisabled }, } = usePlayController();
|
|
463
525
|
const { current } = config.currencyOptions;
|
|
464
526
|
const roleButton = GAME_MODE.MANUAL;
|
|
465
|
-
const activeClassName =
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return styles_button.buttonDefault__active;
|
|
473
|
-
}, [current.code]);
|
|
474
|
-
const defaultClassName = useMemo(() => {
|
|
475
|
-
if (current.code === Currency.GOLD) {
|
|
476
|
-
return styles_button.buttonGold;
|
|
477
|
-
}
|
|
478
|
-
if (current.code === Currency.SWEEPS) {
|
|
479
|
-
return styles_button.buttonSweeps;
|
|
480
|
-
}
|
|
481
|
-
return styles_button.buttonDefault;
|
|
482
|
-
}, [current.code]);
|
|
483
|
-
const handleKeyPress = useCallback((event) => {
|
|
484
|
-
if (event.code !== "Space") {
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
const button = selectButton(roleButton);
|
|
488
|
-
if (!button || isDisabled()) {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
event.preventDefault();
|
|
492
|
-
event.stopPropagation();
|
|
493
|
-
addPressedClass(roleButton, activeClassName);
|
|
494
|
-
button.click();
|
|
495
|
-
}, [roleButton, isDisabled, activeClassName]);
|
|
496
|
-
const handleKeyUp = useCallback((event) => {
|
|
497
|
-
if (event.code !== "Space") {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
const button = selectButton(roleButton);
|
|
501
|
-
if (!button) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
event.preventDefault();
|
|
505
|
-
event.stopPropagation();
|
|
506
|
-
removePressedClass(roleButton, activeClassName);
|
|
507
|
-
}, [roleButton, activeClassName]);
|
|
508
|
-
useEffect(() => {
|
|
509
|
-
window.addEventListener("keydown", handleKeyPress, true);
|
|
510
|
-
window.addEventListener("keyup", handleKeyUp, true);
|
|
511
|
-
return () => {
|
|
512
|
-
window.removeEventListener("keydown", handleKeyPress, true);
|
|
513
|
-
window.removeEventListener("keyup", handleKeyUp, true);
|
|
514
|
-
};
|
|
515
|
-
}, [handleKeyPress, handleKeyUp]);
|
|
527
|
+
const activeClassName = getActiveButtonClassName(current.code, styles_button);
|
|
528
|
+
const defaultClassName = getDefaultButtonClassName(current.code, styles_button);
|
|
529
|
+
useSpacebarButtonTrigger({
|
|
530
|
+
roleButton,
|
|
531
|
+
activeClassName,
|
|
532
|
+
canTrigger: () => !isDisabled(),
|
|
533
|
+
});
|
|
516
534
|
const isButtonDisabled = isDisabled() || !isValidPlayAmount;
|
|
517
535
|
const handleTogglePlayAmount = useCallback(() => {
|
|
518
536
|
setToggleGameWidgetsVisibility();
|
|
519
537
|
togglePlayAmountView();
|
|
520
538
|
setToggleGameWidgetsExpansion();
|
|
521
539
|
}, [togglePlayAmountView]);
|
|
540
|
+
const handleDoubleOrNothingClick = useCallback(() => {
|
|
541
|
+
if (config.playOptions.disabledController) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (!config.doubleOrNothing?.display) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (config.doubleOrNothing?.disabled) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
doubleOrNothing.startDoubleOrNothing();
|
|
551
|
+
}, [
|
|
552
|
+
config.playOptions.disabledController,
|
|
553
|
+
config.doubleOrNothing?.display,
|
|
554
|
+
config.doubleOrNothing?.disabled,
|
|
555
|
+
doubleOrNothing,
|
|
556
|
+
]);
|
|
557
|
+
const handleCashoutClick = useMemo(() => createManualCashoutClickHandler({
|
|
558
|
+
cashoutDisabled,
|
|
559
|
+
onCashout: config.onCashout,
|
|
560
|
+
}), [cashoutDisabled, config.onCashout]);
|
|
522
561
|
const renderButton = useMemo(() => {
|
|
523
562
|
if (displayPlayAmountView) {
|
|
524
563
|
return (jsx(Button, { className: styles_button.buttonPlayAmount, onClick: handleTogglePlayAmount, roleType: roleButton, children: "SELECT PLAY AMOUNT" }));
|
|
525
564
|
}
|
|
526
565
|
if (canCashout) {
|
|
527
|
-
|
|
528
|
-
|
|
566
|
+
const isCashoutDisabled = isManualCashoutDisabled({
|
|
567
|
+
disabledController: config.playOptions.disabledController,
|
|
568
|
+
isPlaying: config.playOptions.isPlaying,
|
|
569
|
+
cashoutDisabled,
|
|
570
|
+
});
|
|
571
|
+
const showDoubleOrNothing = !!config.doubleOrNothing?.display;
|
|
572
|
+
const isDoubleOrNothingDisabled = isCashoutDisabled ||
|
|
573
|
+
!!config.doubleOrNothing?.disabled ||
|
|
574
|
+
doubleOrNothing.state === DOUBLE_OR_NOTHING_STATE.PROGRESS;
|
|
575
|
+
return (jsxs("div", { className: styles_button.buttonRow, children: [jsxs(Button, { disabled: isCashoutDisabled, className: cx$1(styles_button.buttonCashout, {
|
|
576
|
+
[styles_button.buttonRow__cashout]: showDoubleOrNothing,
|
|
577
|
+
}), onClick: handleCashoutClick, roleType: roleButton, children: [isRunningExternal ? "COLLECT" : "CASHOUT", " ", format(current.possibleWin ?? 0, current.decimals), " ", current.abbr] }), showDoubleOrNothing ? (jsx(Button, { disabled: isDoubleOrNothingDisabled, className: cx$1(styles_button.buttonDON, styles_button.buttonRow__don, {
|
|
578
|
+
[styles_button.buttonDON__disabled]: isDoubleOrNothingDisabled,
|
|
579
|
+
}), onClick: handleDoubleOrNothingClick, roleType: roleButton, children: jsxs("div", { className: styles_button.buttonDON__content, children: [jsx("p", { className: styles_button.buttonDON__title, children: "DOUBLE" }), jsx("p", { className: styles_button.buttonDON__subtitle, children: "OR NOTHING" })] }) })) : null] }));
|
|
529
580
|
}
|
|
530
581
|
return (jsx(Button, { disabled: isButtonDisabled, className: defaultClassName, onClick: onPlay, roleType: roleButton, children: "PLAY NOW" }));
|
|
531
582
|
}, [
|
|
532
583
|
canCashout,
|
|
533
|
-
|
|
584
|
+
cashoutDisabled,
|
|
585
|
+
config.doubleOrNothing?.disabled,
|
|
586
|
+
config.doubleOrNothing?.display,
|
|
534
587
|
config.playOptions.disabledController,
|
|
535
588
|
config.playOptions.isPlaying,
|
|
536
589
|
current.abbr,
|
|
@@ -538,11 +591,14 @@ const ManualPlayController = () => {
|
|
|
538
591
|
current.possibleWin,
|
|
539
592
|
defaultClassName,
|
|
540
593
|
displayPlayAmountView,
|
|
594
|
+
doubleOrNothing.state,
|
|
595
|
+
handleDoubleOrNothingClick,
|
|
596
|
+
handleCashoutClick,
|
|
541
597
|
handleTogglePlayAmount,
|
|
542
598
|
isButtonDisabled,
|
|
599
|
+
isRunningExternal,
|
|
543
600
|
onPlay,
|
|
544
601
|
roleButton,
|
|
545
|
-
isRunningExternal,
|
|
546
602
|
]);
|
|
547
603
|
return (jsxs(Fragment, { children: [jsx(PlayAmountControl, { isDisabled: isDisabled || displayPlayAmountView }), renderButton] }));
|
|
548
604
|
};
|
|
@@ -827,11 +883,16 @@ const PlayValueList = () => {
|
|
|
827
883
|
const AutoManualPlayProvider = ({ children, config, }) => {
|
|
828
884
|
const [mode, setMode] = useState(GAME_MODE.MANUAL);
|
|
829
885
|
const [autoplayState, setAutoplayState] = useState(AUTO_PLAY_STATE.IDLE);
|
|
886
|
+
const [doubleOrNothingState, setDoubleOrNothingState] = useState(DOUBLE_OR_NOTHING_STATE.IDLE);
|
|
830
887
|
const [isAutoPlaying, setIsAutoPlaying] = useState(false);
|
|
831
888
|
const [playedRounds, setPlayedRounds] = useState(0);
|
|
832
889
|
const [numberOfPlays, setNumberOfPlays] = useState(AUTOPLAY_DEFAULT_PLAY_ROUNDS_COUNT);
|
|
833
890
|
const [selection, setSelection] = useState([]);
|
|
834
891
|
const [displayPlayAmountView, setDisplayPlayAmountView] = useState(false);
|
|
892
|
+
const isControllerDisabled = config.playOptions.disabledController;
|
|
893
|
+
const isGamePlaying = config.playOptions.isPlaying;
|
|
894
|
+
const isAutoplayPlaying = autoplayState === AUTO_PLAY_STATE.PLAYING;
|
|
895
|
+
const isSimplified = config.withoutRiskAndAutoplay === true;
|
|
835
896
|
const togglePlayAmountView = useCallback(() => {
|
|
836
897
|
setDisplayPlayAmountView((v) => !v);
|
|
837
898
|
}, []);
|
|
@@ -846,6 +907,20 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
846
907
|
setAutoplayState(AUTO_PLAY_STATE.IDLE);
|
|
847
908
|
setIsAutoPlaying(false);
|
|
848
909
|
}, []);
|
|
910
|
+
const startDoubleOrNothing = useCallback(() => {
|
|
911
|
+
if (config.doubleOrNothing?.disabled) {
|
|
912
|
+
return null;
|
|
913
|
+
}
|
|
914
|
+
setDoubleOrNothingState(DOUBLE_OR_NOTHING_STATE.PROGRESS);
|
|
915
|
+
config.doubleOrNothing?.onDoubleOrNothingOpen();
|
|
916
|
+
}, [config.doubleOrNothing]);
|
|
917
|
+
const stopDoubleOrNothing = useCallback(() => {
|
|
918
|
+
if (config.doubleOrNothing?.disabled) {
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
setDoubleOrNothingState(DOUBLE_OR_NOTHING_STATE.IDLE);
|
|
922
|
+
config.doubleOrNothing?.onDoubleOrNothingClose();
|
|
923
|
+
}, [config.doubleOrNothing]);
|
|
849
924
|
const updateAutoplayState = useCallback((newState) => setAutoplayState(newState), []);
|
|
850
925
|
const playManualMode = useCallback(() => {
|
|
851
926
|
setMode(GAME_MODE.MANUAL);
|
|
@@ -853,20 +928,19 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
853
928
|
}, []);
|
|
854
929
|
const resetState = useCallback(() => {
|
|
855
930
|
setMode(GAME_MODE.MANUAL);
|
|
931
|
+
setDoubleOrNothingState(DOUBLE_OR_NOTHING_STATE.IDLE);
|
|
856
932
|
setAutoplayState(AUTO_PLAY_STATE.IDLE);
|
|
857
933
|
setPlayedRounds(0);
|
|
858
934
|
setNumberOfPlays(0);
|
|
859
935
|
setSelection([]);
|
|
860
936
|
}, []);
|
|
861
937
|
const toggleMode = useCallback(() => {
|
|
862
|
-
if (
|
|
863
|
-
config.playOptions.disabledController ||
|
|
864
|
-
autoplayState === AUTO_PLAY_STATE.PLAYING) {
|
|
938
|
+
if (isGamePlaying || isControllerDisabled || isAutoplayPlaying) {
|
|
865
939
|
return;
|
|
866
940
|
}
|
|
867
941
|
setNumberOfPlays(AUTOPLAY_DEFAULT_PLAY_ROUNDS_COUNT);
|
|
868
942
|
setMode((prevMode) => prevMode === GAME_MODE.MANUAL ? GAME_MODE.AUTOPLAY : GAME_MODE.MANUAL);
|
|
869
|
-
}, [
|
|
943
|
+
}, [isAutoplayPlaying, isControllerDisabled, isGamePlaying]);
|
|
870
944
|
const updateSelection = useCallback((values) => {
|
|
871
945
|
if (!isAutoPlaying) {
|
|
872
946
|
setSelection(values);
|
|
@@ -875,6 +949,7 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
875
949
|
const contextValue = useMemo(() => ({
|
|
876
950
|
mode,
|
|
877
951
|
config,
|
|
952
|
+
withoutRiskAndAutoplay: config.withoutRiskAndAutoplay,
|
|
878
953
|
manual: { playManualMode },
|
|
879
954
|
autoPlay: {
|
|
880
955
|
state: autoplayState,
|
|
@@ -891,6 +966,11 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
891
966
|
setNumberOfPlays,
|
|
892
967
|
setState: setAutoplayState,
|
|
893
968
|
},
|
|
969
|
+
doubleOrNothing: {
|
|
970
|
+
state: doubleOrNothingState,
|
|
971
|
+
startDoubleOrNothing,
|
|
972
|
+
stopDoubleOrNothing,
|
|
973
|
+
},
|
|
894
974
|
reset: resetState,
|
|
895
975
|
toggleMode,
|
|
896
976
|
playValues: {
|
|
@@ -911,12 +991,14 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
911
991
|
stopAutoplay,
|
|
912
992
|
updateSelection,
|
|
913
993
|
updateAutoplayState,
|
|
994
|
+
doubleOrNothingState,
|
|
995
|
+
startDoubleOrNothing,
|
|
996
|
+
stopDoubleOrNothing,
|
|
914
997
|
resetState,
|
|
915
998
|
toggleMode,
|
|
916
999
|
displayPlayAmountView,
|
|
917
1000
|
togglePlayAmountView,
|
|
918
1001
|
]);
|
|
919
|
-
const isSimplified = config.withoutRiskAndAutoplay === true;
|
|
920
1002
|
return (jsxs(AutoManualPlayStateContext.Provider, { value: contextValue, children: [typeof children === "function" ? children(contextValue) : children, config.playOptions.displayController && (jsx("div", { className: cx$1(styles_ui.base, styles_ui.betForm), style: {
|
|
921
1003
|
"--play-bottom": config.panel.bottom ?? 0,
|
|
922
1004
|
"--play-panel-bg": hexToRgb(config.panel.bgColorHex ?? "#01243A"),
|
|
@@ -924,19 +1006,16 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
924
1006
|
"--play-panel-bg-opacity": config.panel.bgColorOpacity ?? 0.5,
|
|
925
1007
|
}, children: jsxs("div", { className: cx$1(styles_ui.container), children: [jsx(PlayValueList, {}), !isSimplified ? (jsxs("div", { className: cx$1(styles_ui.auto), children: [jsx(DifficultySelector, { playOptions: {
|
|
926
1008
|
...config.playOptions,
|
|
927
|
-
disabledMenu: config.playOptions.
|
|
928
|
-
|
|
929
|
-
}, dropdownConfig: config.dropdown }), jsx(InputWithSwitch, { value: numberOfPlays === Infinity ? 0 : numberOfPlays, type: "number", onChange: (e) => setNumberOfPlays(Number(e.currentTarget.value)), placeholder: "Number of Plays", min: 0, max: 99, disabled: config.playOptions.disabledController ||
|
|
930
|
-
mode === GAME_MODE.MANUAL, switcherConfig: {
|
|
1009
|
+
disabledMenu: isControllerDisabled || config.playOptions.disabledMenu,
|
|
1010
|
+
}, dropdownConfig: config.dropdown }), jsx(InputWithSwitch, { value: numberOfPlays === Infinity ? 0 : numberOfPlays, type: "number", onChange: (e) => setNumberOfPlays(Number(e.currentTarget.value)), placeholder: "Number of Plays", min: 0, max: 99, disabled: isControllerDisabled || mode === GAME_MODE.MANUAL, switcherConfig: {
|
|
931
1011
|
onSwitch: toggleMode,
|
|
932
|
-
isPlaying: isAutoPlaying ||
|
|
1012
|
+
isPlaying: isAutoPlaying || isGamePlaying,
|
|
933
1013
|
enabled: mode !== GAME_MODE.MANUAL,
|
|
934
|
-
disabled:
|
|
935
|
-
autoplayState === AUTO_PLAY_STATE.PLAYING,
|
|
1014
|
+
disabled: isControllerDisabled || isAutoplayPlaying,
|
|
936
1015
|
}, children: jsx("span", { className: cx$1({
|
|
937
1016
|
[styles_ui.disabled]: mode !== GAME_MODE.AUTOPLAY ||
|
|
938
1017
|
numberOfPlays !== Infinity ||
|
|
939
|
-
|
|
1018
|
+
isAutoplayPlaying,
|
|
940
1019
|
}), children: "\u221E" }) })] })) : null, mode === GAME_MODE.MANUAL ? (jsx(ManualPlayController, {})) : (jsx(AutoPlayController, {})), jsx(WidgetContainer, { state: autoplayState, displayPlayAmountView: displayPlayAmountView, widgets: {
|
|
941
1020
|
left: config.leftWidgets,
|
|
942
1021
|
center: config.centerWidgets,
|
|
@@ -944,5 +1023,5 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
944
1023
|
} })] }) }))] }));
|
|
945
1024
|
};
|
|
946
1025
|
|
|
947
|
-
export { AUTO_PLAY_STATE, AutoManualPlayProvider, GAME_MODE, WIDGET, format };
|
|
1026
|
+
export { AUTO_PLAY_STATE, AutoManualPlayProvider, DOUBLE_OR_NOTHING_STATE, GAME_MODE, WIDGET, canAutoplaySpaceTrigger, createAutoplayButtonAction, createManualCashoutClickHandler, format, isAutoplayButtonDisabled, isManualCashoutDisabled };
|
|
948
1027
|
//# sourceMappingURL=index.mjs.map
|