@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/README.md
CHANGED
|
@@ -1,358 +1,130 @@
|
|
|
1
1
|
# TowerPlayController SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It supports **manual play**, **optional autoplay**, **optional risk selection**, **currency management**, **play amount input**, and **custom widgets**.
|
|
3
|
+
`@enigma-lake/tower-play-controller-sdk` is a React SDK for Tower-style game controls.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
It includes:
|
|
6
|
+
- Manual play
|
|
7
|
+
- Optional autoplay
|
|
8
|
+
- Optional risk selection
|
|
9
|
+
- Play amount controls
|
|
10
|
+
- Currency-aware UI
|
|
11
|
+
- Optional Double Or Nothing button
|
|
12
|
+
- Custom widget slots
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
-
|
|
14
|
+
`PlayControllerProps` supports two modes:
|
|
15
|
+
- Full mode (default): risk + autoplay enabled
|
|
16
|
+
- Simplified mode: set `withoutRiskAndAutoplay: true`
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 🚀 Installation
|
|
18
|
+
## Installation
|
|
16
19
|
|
|
17
20
|
```bash
|
|
18
21
|
npm install @enigma-lake/tower-play-controller-sdk
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
Import styles:
|
|
22
|
-
|
|
23
24
|
```tsx
|
|
24
25
|
import "@enigma-lake/tower-play-controller-sdk/dist/style.css";
|
|
25
26
|
```
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## 🧠 AutoManualPlayProvider
|
|
30
|
-
|
|
31
|
-
Wrap your game UI inside:
|
|
28
|
+
## Quickstart
|
|
32
29
|
|
|
33
30
|
```tsx
|
|
34
|
-
|
|
35
|
-
{({ autoPlay, manual, mode }) => (
|
|
36
|
-
// your UI
|
|
37
|
-
)}
|
|
38
|
-
</AutoManualPlayProvider>
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The provider manages all logic:
|
|
42
|
-
|
|
43
|
-
| Feature | Full Mode (default) | Simplified Mode (`withoutRiskAndAutoplay: true`) |
|
|
44
|
-
|------------------------|------------------------------------------|--------------------------------------------------|
|
|
45
|
-
| Autoplay | ✅ Enabled (requires onAutoPlay) | ❌ Disabled |
|
|
46
|
-
| Risk Difficulty | ✅ Enabled (risks/currentRisk/onRiskChange) | ❌ Hidden |
|
|
47
|
-
| Dropdown Risk Colors | ✅ Required | ❌ Not used |
|
|
48
|
-
| Manual Play | ✅ Enabled | ✅ Enabled |
|
|
49
|
-
| Play Amount | ✅ Enabled | ✅ Enabled |
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## 🔧 Prop Structure
|
|
54
|
-
|
|
55
|
-
Below is an overview of the configuration props.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
### 1. `currencyOptions`
|
|
60
|
-
|
|
61
|
-
```ts
|
|
62
|
-
{
|
|
63
|
-
current: Currency;
|
|
64
|
-
available: Currency[];
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
### 2. Styling (Conditional)
|
|
71
|
-
|
|
72
|
-
#### Panel
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
panel: {
|
|
76
|
-
bottom?: string;
|
|
77
|
-
bgColorHex: string;
|
|
78
|
-
bgColorOpacity?: number;
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### Dropdown
|
|
83
|
-
|
|
84
|
-
**Full Mode (default)**
|
|
85
|
-
`withoutRiskAndAutoplay` omitted or `false`:
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
dropdown: {
|
|
89
|
-
bgColorHex: string;
|
|
90
|
-
riskColorConfig: {
|
|
91
|
-
LOW: string;
|
|
92
|
-
MEDIUM: string;
|
|
93
|
-
HIGH: string;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
**Simplified Mode**
|
|
99
|
-
`withoutRiskAndAutoplay: true`:
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
dropdown: {
|
|
103
|
-
bgColorHex: string;
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
### 3. Actions
|
|
110
|
-
|
|
111
|
-
**Shared (both modes)**:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
onPlay: () => void;
|
|
115
|
-
onCashout: () => void;
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**Only required in Full Mode (`withoutRiskAndAutoplay` omitted or `false`)**:
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
onAutoPlay: (selection: number[], next: () => void, stop: () => void) => void;
|
|
122
|
-
onAutoPlayStop?: () => void;
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
In Simplified Mode, `onAutoPlay` and `onAutoPlayStop` are not required and are effectively ignored.
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
### 4. Play Options (Conditional)
|
|
130
|
-
|
|
131
|
-
#### Full Mode (default)
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
playOptions: {
|
|
135
|
-
isPlaying: boolean;
|
|
136
|
-
canCashout: boolean;
|
|
137
|
-
disabledController: boolean;
|
|
138
|
-
displayController: boolean;
|
|
139
|
-
|
|
140
|
-
// RISK SYSTEM
|
|
141
|
-
risks: RiskTypes[];
|
|
142
|
-
currentRisk: RiskTypes;
|
|
143
|
-
onRiskChange(risk: RiskTypes): void;
|
|
144
|
-
|
|
145
|
-
// AUTOPLAY SYSTEM
|
|
146
|
-
autoPlayDelay?: number;
|
|
147
|
-
showAutoPlayToast({ type, message }): void;
|
|
148
|
-
|
|
149
|
-
disabledMenu: boolean;
|
|
150
|
-
|
|
151
|
-
playHook(): {
|
|
152
|
-
playLimits?: PlayLimits;
|
|
153
|
-
playAmount: number;
|
|
154
|
-
setPlayAmount(value: number): void;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
totalBalance: number;
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
#### Simplified Mode
|
|
162
|
-
`withoutRiskAndAutoplay: true`:
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
playOptions: {
|
|
166
|
-
isPlaying: boolean;
|
|
167
|
-
canCashout: boolean;
|
|
168
|
-
disabledController: boolean;
|
|
169
|
-
displayController: boolean;
|
|
170
|
-
|
|
171
|
-
disabledMenu: boolean;
|
|
172
|
-
|
|
173
|
-
playHook(): {
|
|
174
|
-
playLimits?: PlayLimits;
|
|
175
|
-
playAmount: number;
|
|
176
|
-
setPlayAmount(value: number): void;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
totalBalance: number;
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
Risk/autoplay properties (`risks`, `currentRisk`, `onRiskChange`, `autoPlayDelay`, `showAutoPlayToast`) are not part of the simplified mode.
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
### 5. Widgets
|
|
31
|
+
import { AutoManualPlayProvider, type PlayControllerProps } from "@enigma-lake/tower-play-controller-sdk";
|
|
188
32
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### Example 1 — Full Mode (default: risk + autoplay enabled)
|
|
200
|
-
|
|
201
|
-
```tsx
|
|
202
|
-
import {
|
|
203
|
-
AutoManualPlayProvider,
|
|
204
|
-
} from "@enigma-lake/tower-play-controller-sdk";
|
|
205
|
-
import { Currency } from "@enigma-lake/zoot-platform-sdk";
|
|
206
|
-
|
|
207
|
-
const config = {
|
|
208
|
-
// withoutRiskAndAutoplay omitted or false => FULL mode
|
|
209
|
-
currencyOptions: {
|
|
210
|
-
current: Currency.SWEEPS,
|
|
211
|
-
available: [Currency.SWEEPS, Currency.GOLD],
|
|
33
|
+
const config: PlayControllerProps = {
|
|
34
|
+
currencyOptions,
|
|
35
|
+
panel: { bgColorHex: "#01243A", bgColorOpacity: 0.5 },
|
|
36
|
+
dropdown: {
|
|
37
|
+
bgColorHex: "#01243A",
|
|
38
|
+
riskColorConfig: {
|
|
39
|
+
LOW: "#4CAF50",
|
|
40
|
+
MEDIUM: "#FF9800",
|
|
41
|
+
HIGH: "#F44336",
|
|
42
|
+
},
|
|
212
43
|
},
|
|
213
|
-
|
|
214
|
-
|
|
44
|
+
leftWidgets: [],
|
|
45
|
+
centerWidgets: [],
|
|
46
|
+
rightWidgets: [],
|
|
47
|
+
onPlay: () => {},
|
|
48
|
+
onCashout: () => {},
|
|
215
49
|
onAutoPlay: (selection, next, stop) => {
|
|
216
|
-
|
|
217
|
-
next();
|
|
50
|
+
// call next() when round succeeds, stop() to abort autoplay
|
|
51
|
+
next();
|
|
218
52
|
},
|
|
219
|
-
onAutoPlayStop: () => console.log("Autoplay stopped"),
|
|
220
|
-
onCashout: () => console.log("Cashout"),
|
|
221
|
-
|
|
222
53
|
playOptions: {
|
|
223
|
-
displayController: true,
|
|
224
54
|
isPlaying: false,
|
|
225
55
|
canCashout: false,
|
|
56
|
+
disabledCashout: false,
|
|
226
57
|
disabledController: false,
|
|
227
|
-
disableInput: false,
|
|
228
|
-
|
|
229
|
-
// Risk controls
|
|
230
|
-
risks: [RiskTypes.LOW, RiskTypes.MEDIUM, RiskTypes.HIGH],
|
|
231
|
-
currentRisk: RiskTypes.LOW,
|
|
232
|
-
onRiskChange: (risk) => console.log("Risk:", risk),
|
|
233
|
-
|
|
234
|
-
// Autoplay
|
|
235
|
-
autoPlayDelay: 1000,
|
|
236
|
-
showAutoPlayToast: ({ type, message }) =>
|
|
237
|
-
console.log(`${type}: ${message}`),
|
|
238
|
-
|
|
239
58
|
disabledMenu: false,
|
|
240
|
-
|
|
59
|
+
displayController: true,
|
|
60
|
+
disableInput: false,
|
|
61
|
+
risks: ["LOW", "MEDIUM", "HIGH"],
|
|
62
|
+
currentRisk: "LOW",
|
|
63
|
+
onRiskChange: () => {},
|
|
64
|
+
showAutoPlayToast: () => {},
|
|
65
|
+
totalBalance: 1000,
|
|
241
66
|
playHook: () => ({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
67
|
+
playAmount: 1,
|
|
68
|
+
setPlayAmount: () => {},
|
|
69
|
+
playLimits: undefined,
|
|
245
70
|
}),
|
|
246
|
-
|
|
247
|
-
totalBalance: 100,
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
panel: {
|
|
251
|
-
bottom: "60px",
|
|
252
|
-
bgColorHex: "#08643F",
|
|
253
|
-
bgColorOpacity: 0.8,
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
dropdown: {
|
|
257
|
-
bgColorHex: "#123456",
|
|
258
|
-
riskColorConfig: {
|
|
259
|
-
LOW: "#1AE380",
|
|
260
|
-
MEDIUM: "#FAEB78",
|
|
261
|
-
HIGH: "#FF5646",
|
|
262
|
-
},
|
|
71
|
+
autoPlayDelay: 1500,
|
|
263
72
|
},
|
|
264
|
-
|
|
265
|
-
leftWidgets: [],
|
|
266
|
-
centerWidgets: [],
|
|
267
|
-
rightWidgets: [],
|
|
268
73
|
};
|
|
269
74
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
<div>Mode: {mode}</div>
|
|
274
|
-
)}
|
|
275
|
-
</AutoManualPlayProvider>
|
|
276
|
-
);
|
|
75
|
+
<AutoManualPlayProvider config={config}>
|
|
76
|
+
{() => null}
|
|
77
|
+
</AutoManualPlayProvider>;
|
|
277
78
|
```
|
|
278
79
|
|
|
279
|
-
|
|
80
|
+
## Cashout Behavior
|
|
280
81
|
|
|
281
|
-
|
|
82
|
+
`canCashout` and `disabledCashout` are independent:
|
|
282
83
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
} from "@enigma-lake/tower-play-controller-sdk";
|
|
287
|
-
import { Currency } from "@enigma-lake/zoot-platform-sdk";
|
|
84
|
+
- `canCashout: false`: cashout button state is not shown.
|
|
85
|
+
- `canCashout: true` + `disabledCashout: false`: cashout is visible and clickable.
|
|
86
|
+
- `canCashout: true` + `disabledCashout: true`: cashout is visible but disabled.
|
|
288
87
|
|
|
289
|
-
|
|
290
|
-
|
|
88
|
+
When `disabledCashout` is `true`, click handlers are blocked in:
|
|
89
|
+
- Manual cashout button
|
|
90
|
+
- Autoplay stop/cashout button
|
|
291
91
|
|
|
292
|
-
|
|
293
|
-
current: Currency.SWEEPS,
|
|
294
|
-
available: [Currency.SWEEPS],
|
|
295
|
-
},
|
|
92
|
+
## Full Mode vs Simplified Mode
|
|
296
93
|
|
|
297
|
-
|
|
298
|
-
|
|
94
|
+
Full mode (default):
|
|
95
|
+
- Requires `onAutoPlay`
|
|
96
|
+
- Includes risk configuration in `playOptions`
|
|
97
|
+
- `dropdown.riskColorConfig` is required
|
|
299
98
|
|
|
300
|
-
|
|
301
|
-
displayController: true,
|
|
302
|
-
isPlaying: false,
|
|
303
|
-
canCashout: false,
|
|
304
|
-
disabledController: false,
|
|
305
|
-
disableInput: false,
|
|
306
|
-
disabledMenu: false,
|
|
99
|
+
Simplified mode:
|
|
307
100
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
setPlayAmount: (value) => console.log("New amount:", value),
|
|
312
|
-
}),
|
|
313
|
-
|
|
314
|
-
totalBalance: 50,
|
|
315
|
-
},
|
|
101
|
+
```ts
|
|
102
|
+
withoutRiskAndAutoplay: true;
|
|
103
|
+
```
|
|
316
104
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
105
|
+
In simplified mode:
|
|
106
|
+
- `onAutoPlay` and `onAutoPlayStop` are not required
|
|
107
|
+
- Risk configuration is removed from `playOptions`
|
|
108
|
+
- `dropdown.riskColorConfig` is not required
|
|
320
109
|
|
|
321
|
-
|
|
322
|
-
bgColorHex: "#10243F", // no riskColorConfig here
|
|
323
|
-
},
|
|
110
|
+
## Double Or Nothing (Optional)
|
|
324
111
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
112
|
+
```ts
|
|
113
|
+
doubleOrNothing?: {
|
|
114
|
+
disabled: boolean;
|
|
115
|
+
display: boolean;
|
|
116
|
+
onDoubleOrNothingOpen: () => void;
|
|
117
|
+
onDoubleOrNothingClose: () => void;
|
|
328
118
|
};
|
|
329
|
-
|
|
330
|
-
export const GameExampleSimplified = () => (
|
|
331
|
-
<AutoManualPlayProvider config={config}>
|
|
332
|
-
{({ mode }) => (
|
|
333
|
-
<div>Mode: {mode}</div>
|
|
334
|
-
)}
|
|
335
|
-
</AutoManualPlayProvider>
|
|
336
|
-
);
|
|
337
119
|
```
|
|
338
120
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
- **Optional Risk System** – enabled by default; disabled when `withoutRiskAndAutoplay: true`
|
|
344
|
-
- **Optional Autoplay** – fully controlled via callbacks and delay (full mode only)
|
|
345
|
-
- **Dynamic Currency Management** – multiple currencies supported
|
|
346
|
-
- **Wager Controls** – validated against play limits
|
|
347
|
-
- **UI Widgets** – customizable left/center/right areas
|
|
348
|
-
- **Flexible Styling** – configurable colors, bottom positioning, and opacity
|
|
349
|
-
- **Responsive Layout** – suitable for desktop and mobile
|
|
350
|
-
|
|
351
|
-
---
|
|
121
|
+
Behavior:
|
|
122
|
+
- Shown only when `display` is `true`
|
|
123
|
+
- Sits beside Cashout (cashout width shrinks accordingly)
|
|
124
|
+
- Fully optional and backwards compatible
|
|
352
125
|
|
|
353
|
-
##
|
|
126
|
+
## Notes
|
|
354
127
|
|
|
355
|
-
-
|
|
356
|
-
- `
|
|
357
|
-
-
|
|
358
|
-
- Use `withoutRiskAndAutoplay: true` to explicitly opt into the simplified experience.
|
|
128
|
+
- Import `PlayControllerProps` for strongly typed integration.
|
|
129
|
+
- Keep `playOptions` values in sync with your game engine state.
|
|
130
|
+
- `displayController: false` hides the SDK UI entirely.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GAME_MODE, AUTO_PLAY_STATE } from "../../types/gameMode";
|
|
1
|
+
import { GAME_MODE, AUTO_PLAY_STATE, DOUBLE_OR_NOTHING_STATE } from "../../types/gameMode";
|
|
2
2
|
import { PlayControllerProps } from "../../types/playController";
|
|
3
3
|
export interface AutoManualPlayStateContextType {
|
|
4
4
|
mode: GAME_MODE;
|
|
@@ -21,6 +21,14 @@ export interface AutoManualPlayStateContextType {
|
|
|
21
21
|
setSelection: (values: number[]) => void;
|
|
22
22
|
updateState: (newState: AUTO_PLAY_STATE.SELECTING | AUTO_PLAY_STATE.PLAYING) => void;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* ✅ Double Or Nothing state & controls
|
|
26
|
+
*/
|
|
27
|
+
doubleOrNothing: {
|
|
28
|
+
state: DOUBLE_OR_NOTHING_STATE;
|
|
29
|
+
startDoubleOrNothing: () => void;
|
|
30
|
+
stopDoubleOrNothing: () => void;
|
|
31
|
+
};
|
|
24
32
|
reset: () => void;
|
|
25
33
|
toggleMode: () => void;
|
|
26
34
|
playValues: {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Currency } from "@enigma-lake/zoot-platform-sdk";
|
|
2
|
+
type ButtonStyleClasses = Record<string, string>;
|
|
3
|
+
export declare const getDefaultButtonClassName: (currencyCode: Currency, styles: ButtonStyleClasses) => string;
|
|
4
|
+
export declare const getActiveButtonClassName: (currencyCode: Currency, styles: ButtonStyleClasses) => string;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AUTO_PLAY_STATE } from "../../../types";
|
|
2
|
+
export declare const isManualCashoutDisabled: ({ disabledController, isPlaying, cashoutDisabled, }: {
|
|
3
|
+
disabledController: boolean;
|
|
4
|
+
isPlaying: boolean;
|
|
5
|
+
cashoutDisabled: boolean;
|
|
6
|
+
}) => boolean;
|
|
7
|
+
export declare const createManualCashoutClickHandler: ({ cashoutDisabled, onCashout, }: {
|
|
8
|
+
cashoutDisabled: boolean;
|
|
9
|
+
onCashout: () => void;
|
|
10
|
+
}) => () => void;
|
|
11
|
+
export declare const canAutoplaySpaceTrigger: ({ state, cashoutDisabled, isDisabled, }: {
|
|
12
|
+
state: AUTO_PLAY_STATE;
|
|
13
|
+
cashoutDisabled: boolean;
|
|
14
|
+
isDisabled: boolean;
|
|
15
|
+
}) => boolean;
|
|
16
|
+
export declare const isAutoplayButtonDisabled: ({ state, cashoutDisabled, isDisabled, isValidPlayAmount, }: {
|
|
17
|
+
state: AUTO_PLAY_STATE;
|
|
18
|
+
cashoutDisabled: boolean;
|
|
19
|
+
isDisabled: boolean;
|
|
20
|
+
isValidPlayAmount: boolean;
|
|
21
|
+
}) => boolean;
|
|
22
|
+
export declare const createAutoplayButtonAction: ({ state, cashoutDisabled, onStopPlay, onPlay, }: {
|
|
23
|
+
state: AUTO_PLAY_STATE;
|
|
24
|
+
cashoutDisabled: boolean;
|
|
25
|
+
onStopPlay: () => void;
|
|
26
|
+
onPlay: () => void;
|
|
27
|
+
}) => () => void;
|
|
@@ -15,12 +15,14 @@ export declare const usePlayController: () => {
|
|
|
15
15
|
isDisabled: () => boolean;
|
|
16
16
|
onPlay: () => void;
|
|
17
17
|
canCashout: boolean;
|
|
18
|
+
cashoutDisabled: boolean;
|
|
18
19
|
};
|
|
19
20
|
autoPlay: {
|
|
20
21
|
isDisabled: () => boolean;
|
|
21
22
|
state: AUTO_PLAY_STATE;
|
|
22
23
|
onPlay: () => void;
|
|
23
24
|
onStopPlay: () => void;
|
|
25
|
+
cashoutDisabled: boolean;
|
|
24
26
|
};
|
|
25
27
|
playValues: {
|
|
26
28
|
displayPlayAmountView: boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GAME_MODE } from "../../types";
|
|
2
|
+
type UseSpacebarButtonTriggerParams = {
|
|
3
|
+
roleButton: GAME_MODE;
|
|
4
|
+
activeClassName: string;
|
|
5
|
+
canTrigger: () => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const useSpacebarButtonTrigger: ({ roleButton, activeClassName, canTrigger, }: UseSpacebarButtonTriggerParams) => void;
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AutoManualPlayProvider from "./AutoManualPlayStateProvider";
|
|
2
|
-
import { GAME_MODE, AUTO_PLAY_STATE } from "../types/gameMode";
|
|
2
|
+
import { GAME_MODE, AUTO_PLAY_STATE, DOUBLE_OR_NOTHING_STATE } from "../types/gameMode";
|
|
3
3
|
import { format } from "./utils";
|
|
4
4
|
import { PlayControllerProps, PlayControllerWithoutRisk, PlayControllerWithRisk } from "../types";
|
|
5
|
-
export { AutoManualPlayProvider, GAME_MODE, AUTO_PLAY_STATE, format };
|
|
5
|
+
export { AutoManualPlayProvider, GAME_MODE, AUTO_PLAY_STATE, DOUBLE_OR_NOTHING_STATE, format, };
|
|
6
6
|
export type { PlayControllerProps, PlayControllerWithoutRisk, PlayControllerWithRisk, };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ declare enum AUTO_PLAY_STATE {
|
|
|
10
10
|
SELECTING = "selecting",
|
|
11
11
|
PLAYING = "playing"
|
|
12
12
|
}
|
|
13
|
+
declare enum DOUBLE_OR_NOTHING_STATE {
|
|
14
|
+
IDLE = "idle",
|
|
15
|
+
PROGRESS = "progress"
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
declare enum WIDGET {
|
|
15
19
|
CENTER = "center",
|
|
@@ -80,6 +84,7 @@ type ActionsWithoutAutoplay = ActionsBase;
|
|
|
80
84
|
type PlaySettingsProps = {
|
|
81
85
|
isPlaying: boolean;
|
|
82
86
|
canCashout: boolean;
|
|
87
|
+
disabledCashout?: boolean;
|
|
83
88
|
disabledController: boolean;
|
|
84
89
|
risks: RiskTypes[];
|
|
85
90
|
currentRisk: RiskTypes;
|
|
@@ -118,6 +123,15 @@ type PlaySettingsWithRisk = PlaySettingsProps;
|
|
|
118
123
|
* Risk/autoplay-specific fields are removed.
|
|
119
124
|
*/
|
|
120
125
|
type PlaySettingsWithoutRisk = BasePlaySettings;
|
|
126
|
+
/**
|
|
127
|
+
* Double Or Nothing feature props.
|
|
128
|
+
*/
|
|
129
|
+
type DoubleOrNothingProps = {
|
|
130
|
+
disabled: boolean;
|
|
131
|
+
display: boolean;
|
|
132
|
+
onDoubleOrNothingOpen: () => void;
|
|
133
|
+
onDoubleOrNothingClose: () => void;
|
|
134
|
+
};
|
|
121
135
|
/**
|
|
122
136
|
* Common controller props that don't depend on the flag.
|
|
123
137
|
*/
|
|
@@ -126,6 +140,11 @@ type BaseControllerCommon = {
|
|
|
126
140
|
leftWidgets: Widget[];
|
|
127
141
|
rightWidgets: Widget[];
|
|
128
142
|
centerWidgets: Widget[];
|
|
143
|
+
/**
|
|
144
|
+
* Optional so existing integrations don't break.
|
|
145
|
+
* If you want it required, remove the `?`.
|
|
146
|
+
*/
|
|
147
|
+
doubleOrNothing?: DoubleOrNothingProps;
|
|
129
148
|
};
|
|
130
149
|
/**
|
|
131
150
|
* Variant when risk & autoplay are enabled (FULL mode).
|
|
@@ -165,6 +184,33 @@ type PlayControllerProps = PlayControllerWithRisk | PlayControllerWithoutRisk;
|
|
|
165
184
|
|
|
166
185
|
declare const format: (value: number | string, decimals: number) => string | number;
|
|
167
186
|
|
|
187
|
+
declare const isManualCashoutDisabled: ({ disabledController, isPlaying, cashoutDisabled, }: {
|
|
188
|
+
disabledController: boolean;
|
|
189
|
+
isPlaying: boolean;
|
|
190
|
+
cashoutDisabled: boolean;
|
|
191
|
+
}) => boolean;
|
|
192
|
+
declare const createManualCashoutClickHandler: ({ cashoutDisabled, onCashout, }: {
|
|
193
|
+
cashoutDisabled: boolean;
|
|
194
|
+
onCashout: () => void;
|
|
195
|
+
}) => () => void;
|
|
196
|
+
declare const canAutoplaySpaceTrigger: ({ state, cashoutDisabled, isDisabled, }: {
|
|
197
|
+
state: AUTO_PLAY_STATE;
|
|
198
|
+
cashoutDisabled: boolean;
|
|
199
|
+
isDisabled: boolean;
|
|
200
|
+
}) => boolean;
|
|
201
|
+
declare const isAutoplayButtonDisabled: ({ state, cashoutDisabled, isDisabled, isValidPlayAmount, }: {
|
|
202
|
+
state: AUTO_PLAY_STATE;
|
|
203
|
+
cashoutDisabled: boolean;
|
|
204
|
+
isDisabled: boolean;
|
|
205
|
+
isValidPlayAmount: boolean;
|
|
206
|
+
}) => boolean;
|
|
207
|
+
declare const createAutoplayButtonAction: ({ state, cashoutDisabled, onStopPlay, onPlay, }: {
|
|
208
|
+
state: AUTO_PLAY_STATE;
|
|
209
|
+
cashoutDisabled: boolean;
|
|
210
|
+
onStopPlay: () => void;
|
|
211
|
+
onPlay: () => void;
|
|
212
|
+
}) => () => void;
|
|
213
|
+
|
|
168
214
|
interface AutoManualPlayStateContextType {
|
|
169
215
|
mode: GAME_MODE;
|
|
170
216
|
config: PlayControllerProps;
|
|
@@ -186,6 +232,14 @@ interface AutoManualPlayStateContextType {
|
|
|
186
232
|
setSelection: (values: number[]) => void;
|
|
187
233
|
updateState: (newState: AUTO_PLAY_STATE.SELECTING | AUTO_PLAY_STATE.PLAYING) => void;
|
|
188
234
|
};
|
|
235
|
+
/**
|
|
236
|
+
* ✅ Double Or Nothing state & controls
|
|
237
|
+
*/
|
|
238
|
+
doubleOrNothing: {
|
|
239
|
+
state: DOUBLE_OR_NOTHING_STATE;
|
|
240
|
+
startDoubleOrNothing: () => void;
|
|
241
|
+
stopDoubleOrNothing: () => void;
|
|
242
|
+
};
|
|
189
243
|
reset: () => void;
|
|
190
244
|
toggleMode: () => void;
|
|
191
245
|
playValues: {
|
|
@@ -202,4 +256,4 @@ interface AutoManualPlayStateProviderProps {
|
|
|
202
256
|
}
|
|
203
257
|
declare const AutoManualPlayProvider: React.FC<AutoManualPlayStateProviderProps>;
|
|
204
258
|
|
|
205
|
-
export { AUTO_PLAY_STATE, AutoManualPlayProvider, GAME_MODE, type PlayControllerProps, type PlayControllerWithRisk, type PlayControllerWithoutRisk, WIDGET, type Widget, format };
|
|
259
|
+
export { AUTO_PLAY_STATE, AutoManualPlayProvider, DOUBLE_OR_NOTHING_STATE, GAME_MODE, type PlayControllerProps, type PlayControllerWithRisk, type PlayControllerWithoutRisk, WIDGET, type Widget, canAutoplaySpaceTrigger, createAutoplayButtonAction, createManualCashoutClickHandler, format, isAutoplayButtonDisabled, isManualCashoutDisabled };
|