@enigma-lake/tower-play-controller-sdk 2.0.23 → 2.0.25

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.
Files changed (29) hide show
  1. package/README.md +130 -130
  2. package/dist/components/base/DifficultySelector/DifficultySelector.d.ts +4 -7
  3. package/dist/components/base/DifficultySelector/Selector.d.ts +1 -1
  4. package/dist/components/base/DifficultySelector/types.d.ts +3 -0
  5. package/dist/components/base/FreeRoundsIntroModal/FreeRoundsIntroModal.d.ts +14 -0
  6. package/dist/components/base/FreeRoundsIntroModal/freeRoundsCoin.d.ts +11 -0
  7. package/dist/components/base/FreeRoundsIntroModal/index.d.ts +3 -0
  8. package/dist/components/base/FreeRoundsSummaryModal/FreeRoundsSummaryModal.d.ts +9 -0
  9. package/dist/components/base/FreeRoundsSummaryModal/index.d.ts +3 -0
  10. package/dist/components/base/GroupRow/GroupRow.d.ts +2 -1
  11. package/dist/components/base/Input/Input.d.ts +3 -1
  12. package/dist/components/base/InputWithSwitch/InputWithSwitch.d.ts +2 -1
  13. package/dist/components/base/PlayController/PlayController.d.ts +2 -1
  14. package/dist/components/base/PlayValueInput/PlayValueInput.d.ts +2 -1
  15. package/dist/components/hooks/usePlayController.d.ts +8 -0
  16. package/dist/components/hooks/useSpacebarButtonTrigger.d.ts +2 -1
  17. package/dist/i18n/I18nContext.d.ts +13 -0
  18. package/dist/i18n/index.d.ts +5 -0
  19. package/dist/i18n/locales/en.d.ts +2 -0
  20. package/dist/i18n/locales/zh-CN.d.ts +2 -0
  21. package/dist/i18n/translator.d.ts +5 -0
  22. package/dist/i18n/types.d.ts +41 -0
  23. package/dist/index.d.ts +132 -11
  24. package/dist/index.mjs +595 -113
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/style.css +1 -1
  27. package/dist/types/index.d.ts +2 -2
  28. package/dist/types/playController.d.ts +52 -9
  29. package/package.json +92 -85
package/README.md CHANGED
@@ -1,130 +1,130 @@
1
- # TowerPlayController SDK
2
-
3
- `@enigma-lake/tower-play-controller-sdk` is a React SDK for Tower-style game controls.
4
-
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
13
-
14
- `PlayControllerProps` supports two modes:
15
- - Full mode (default): risk + autoplay enabled
16
- - Simplified mode: set `withoutRiskAndAutoplay: true`
17
-
18
- ## Installation
19
-
20
- ```bash
21
- npm install @enigma-lake/tower-play-controller-sdk
22
- ```
23
-
24
- ```tsx
25
- import "@enigma-lake/tower-play-controller-sdk/dist/style.css";
26
- ```
27
-
28
- ## Quickstart
29
-
30
- ```tsx
31
- import { AutoManualPlayProvider, type PlayControllerProps } from "@enigma-lake/tower-play-controller-sdk";
32
-
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
- },
43
- },
44
- leftWidgets: [],
45
- centerWidgets: [],
46
- rightWidgets: [],
47
- onPlay: () => {},
48
- onCashout: () => {},
49
- onAutoPlay: (selection, next, stop) => {
50
- // call next() when round succeeds, stop() to abort autoplay
51
- next();
52
- },
53
- playOptions: {
54
- isPlaying: false,
55
- canCashout: false,
56
- disabledCashout: false,
57
- disabledController: false,
58
- disabledMenu: false,
59
- displayController: true,
60
- disableInput: false,
61
- risks: ["LOW", "MEDIUM", "HIGH"],
62
- currentRisk: "LOW",
63
- onRiskChange: () => {},
64
- showAutoPlayToast: () => {},
65
- totalBalance: 1000,
66
- playHook: () => ({
67
- playAmount: 1,
68
- setPlayAmount: () => {},
69
- playLimits: undefined,
70
- }),
71
- autoPlayDelay: 1500,
72
- },
73
- };
74
-
75
- <AutoManualPlayProvider config={config}>
76
- {() => null}
77
- </AutoManualPlayProvider>;
78
- ```
79
-
80
- ## Cashout Behavior
81
-
82
- `canCashout` and `disabledCashout` are independent:
83
-
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.
87
-
88
- When `disabledCashout` is `true`, click handlers are blocked in:
89
- - Manual cashout button
90
- - Autoplay stop/cashout button
91
-
92
- ## Full Mode vs Simplified Mode
93
-
94
- Full mode (default):
95
- - Requires `onAutoPlay`
96
- - Includes risk configuration in `playOptions`
97
- - `dropdown.riskColorConfig` is required
98
-
99
- Simplified mode:
100
-
101
- ```ts
102
- withoutRiskAndAutoplay: true;
103
- ```
104
-
105
- In simplified mode:
106
- - `onAutoPlay` and `onAutoPlayStop` are not required
107
- - Risk configuration is removed from `playOptions`
108
- - `dropdown.riskColorConfig` is not required
109
-
110
- ## Double Or Nothing (Optional)
111
-
112
- ```ts
113
- doubleOrNothing?: {
114
- disabled: boolean;
115
- display: boolean;
116
- onDoubleOrNothingOpen: () => void;
117
- onDoubleOrNothingClose: () => void;
118
- };
119
- ```
120
-
121
- Behavior:
122
- - Shown only when `display` is `true`
123
- - Sits beside Cashout (cashout width shrinks accordingly)
124
- - Fully optional and backwards compatible
125
-
126
- ## Notes
127
-
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
+ # TowerPlayController SDK
2
+
3
+ `@enigma-lake/tower-play-controller-sdk` is a React SDK for Tower-style game controls.
4
+
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
13
+
14
+ `PlayControllerProps` supports two modes:
15
+ - Full mode (default): risk + autoplay enabled
16
+ - Simplified mode: set `withoutRiskAndAutoplay: true`
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @enigma-lake/tower-play-controller-sdk
22
+ ```
23
+
24
+ ```tsx
25
+ import "@enigma-lake/tower-play-controller-sdk/dist/style.css";
26
+ ```
27
+
28
+ ## Quickstart
29
+
30
+ ```tsx
31
+ import { AutoManualPlayProvider, type PlayControllerProps } from "@enigma-lake/tower-play-controller-sdk";
32
+
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
+ },
43
+ },
44
+ leftWidgets: [],
45
+ centerWidgets: [],
46
+ rightWidgets: [],
47
+ onPlay: () => {},
48
+ onCashout: () => {},
49
+ onAutoPlay: (selection, next, stop) => {
50
+ // call next() when round succeeds, stop() to abort autoplay
51
+ next();
52
+ },
53
+ playOptions: {
54
+ isPlaying: false,
55
+ canCashout: false,
56
+ disabledCashout: false,
57
+ disabledController: false,
58
+ disabledMenu: false,
59
+ displayController: true,
60
+ disableInput: false,
61
+ risks: ["LOW", "MEDIUM", "HIGH"],
62
+ currentRisk: "LOW",
63
+ onRiskChange: () => {},
64
+ showAutoPlayToast: () => {},
65
+ totalBalance: 1000,
66
+ playHook: () => ({
67
+ playAmount: 1,
68
+ setPlayAmount: () => {},
69
+ playLimits: undefined,
70
+ }),
71
+ autoPlayDelay: 1500,
72
+ },
73
+ };
74
+
75
+ <AutoManualPlayProvider config={config}>
76
+ {() => null}
77
+ </AutoManualPlayProvider>;
78
+ ```
79
+
80
+ ## Cashout Behavior
81
+
82
+ `canCashout` and `disabledCashout` are independent:
83
+
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.
87
+
88
+ When `disabledCashout` is `true`, click handlers are blocked in:
89
+ - Manual cashout button
90
+ - Autoplay stop/cashout button
91
+
92
+ ## Full Mode vs Simplified Mode
93
+
94
+ Full mode (default):
95
+ - Requires `onAutoPlay`
96
+ - Includes risk configuration in `playOptions`
97
+ - `dropdown.riskColorConfig` is required
98
+
99
+ Simplified mode:
100
+
101
+ ```ts
102
+ withoutRiskAndAutoplay: true;
103
+ ```
104
+
105
+ In simplified mode:
106
+ - `onAutoPlay` and `onAutoPlayStop` are not required
107
+ - Risk configuration is removed from `playOptions`
108
+ - `dropdown.riskColorConfig` is not required
109
+
110
+ ## Double Or Nothing (Optional)
111
+
112
+ ```ts
113
+ doubleOrNothing?: {
114
+ disabled: boolean;
115
+ display: boolean;
116
+ onDoubleOrNothingOpen: () => void;
117
+ onDoubleOrNothingClose: () => void;
118
+ };
119
+ ```
120
+
121
+ Behavior:
122
+ - Shown only when `display` is `true`
123
+ - Sits beside Cashout (cashout width shrinks accordingly)
124
+ - Fully optional and backwards compatible
125
+
126
+ ## Notes
127
+
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,14 +1,11 @@
1
1
  import { PlaySettingsProps } from "../../../types/playController";
2
2
  import { RiskTypes } from "./types";
3
- declare const DifficultySelector: ({ playOptions, dropdownConfig, }: {
3
+ declare const DifficultySelector: ({ playOptions, dropdownConfig, isClassicGame, }: {
4
4
  playOptions: PlaySettingsProps;
5
5
  dropdownConfig: {
6
- bgColorHex: string;
7
- riskColorConfig: {
8
- [RiskTypes.LOW]: string;
9
- [RiskTypes.MEDIUM]: string;
10
- [RiskTypes.HIGH]: string;
11
- };
6
+ bgColorHex?: string;
7
+ riskColorConfig?: Partial<Record<RiskTypes, string>>;
12
8
  };
9
+ isClassicGame?: boolean;
13
10
  }) => import("react/jsx-runtime").JSX.Element;
14
11
  export default DifficultySelector;
@@ -1,3 +1,3 @@
1
1
  import { SelectorProps } from "./types";
2
- declare const Selector: <T>({ currentValue, label, riskColor, values, onSelect, disabled, }: SelectorProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ declare const Selector: <T>({ currentValue, label, riskColor, values, onSelect, disabled, isClassicGame, formatDisplay, }: SelectorProps<T>) => import("react/jsx-runtime").JSX.Element;
3
3
  export default Selector;
@@ -5,6 +5,8 @@ export interface SelectorProps<T> {
5
5
  riskColor: string;
6
6
  disabled: boolean;
7
7
  currentValue: T;
8
+ isClassicGame?: boolean;
9
+ formatDisplay?: (value: T) => string;
8
10
  }
9
11
  export declare enum SELECTORS {
10
12
  RISK = "Risk"
@@ -14,3 +16,4 @@ export declare enum RiskTypes {
14
16
  MEDIUM = "MEDIUM",
15
17
  HIGH = "HIGH"
16
18
  }
19
+ export declare const DEFAULT_RISK_COLORS: Record<RiskTypes, string>;
@@ -0,0 +1,14 @@
1
+ export interface FreeRoundsIntroModalProps {
2
+ open: boolean;
3
+ roundsRemaining: number;
4
+ totalRounds: number;
5
+ stakeCents: number;
6
+ coinType?: number;
7
+ currency?: string;
8
+ decimals?: number;
9
+ expiresAt?: string | number | Date;
10
+ onPlayNow?: () => void;
11
+ onPlayLater?: () => void;
12
+ }
13
+ declare const FreeRoundsIntroModal: ({ open, roundsRemaining, stakeCents, coinType, currency, decimals, expiresAt, onPlayNow, onPlayLater, }: FreeRoundsIntroModalProps) => import("react/jsx-runtime").JSX.Element;
14
+ export default FreeRoundsIntroModal;
@@ -0,0 +1,11 @@
1
+ export declare const resolveFreeRoundsCoinLabel: ({ coinType, currency, }: {
2
+ coinType?: number;
3
+ currency?: string;
4
+ }) => string;
5
+ export declare const resolveFreeRoundsDecimals: ({ coinType, currency, fallback, }: {
6
+ coinType?: number;
7
+ currency?: string;
8
+ fallback: number;
9
+ }) => number;
10
+ export declare const resolveCoinLabelDecimals: (coin: string) => number;
11
+ export declare const computeExpiresInDays: (expiresAt: string | number | Date | null | undefined, now?: number) => number | null;
@@ -0,0 +1,3 @@
1
+ import FreeRoundsIntroModal from "./FreeRoundsIntroModal";
2
+ export type { FreeRoundsIntroModalProps } from "./FreeRoundsIntroModal";
3
+ export default FreeRoundsIntroModal;
@@ -0,0 +1,9 @@
1
+ export interface FreeRoundsSummaryModalProps {
2
+ totalWinAmount: number;
3
+ coin: string;
4
+ roundsPlayed: number;
5
+ decimals?: number;
6
+ onClose: () => void;
7
+ }
8
+ declare const FreeRoundsSummaryModal: ({ totalWinAmount, coin, roundsPlayed, decimals, onClose, }: FreeRoundsSummaryModalProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default FreeRoundsSummaryModal;
@@ -0,0 +1,3 @@
1
+ import FreeRoundsSummaryModal from "./FreeRoundsSummaryModal";
2
+ export type { FreeRoundsSummaryModalProps } from "./FreeRoundsSummaryModal";
3
+ export default FreeRoundsSummaryModal;
@@ -1,6 +1,7 @@
1
1
  import { ComponentProps } from "react";
2
2
  export type Props = ComponentProps<"div"> & {
3
+ isClassicGame?: boolean;
3
4
  label?: string;
4
5
  };
5
- declare const GroupRow: ({ children, label, className, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ declare const GroupRow: ({ children, label, className, isClassicGame, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
6
7
  export default GroupRow;
@@ -1,3 +1,5 @@
1
1
  import React from "react";
2
- declare const Input: ({ onChange, disabled, className, max, ...restProps }: React.ComponentProps<"input">) => import("react/jsx-runtime").JSX.Element;
2
+ declare const Input: ({ onChange, disabled, className, max, isClassicGame, ...restProps }: React.ComponentProps<"input"> & {
3
+ isClassicGame?: boolean;
4
+ }) => import("react/jsx-runtime").JSX.Element;
3
5
  export default Input;
@@ -6,6 +6,7 @@ export type Props = PropsWithChildren<ComponentProps<"input">> & {
6
6
  enabled: boolean;
7
7
  disabled: boolean;
8
8
  };
9
+ isClassicGame?: boolean;
9
10
  };
10
- declare const InputWithSwitch: ({ children, switcherConfig, disabled, className, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ declare const InputWithSwitch: ({ children, switcherConfig, disabled, className, isClassicGame, ...restProps }: Props) => import("react/jsx-runtime").JSX.Element;
11
12
  export default InputWithSwitch;
@@ -1,6 +1,7 @@
1
1
  interface PlayAmountControlProps {
2
2
  isDisabled: () => boolean;
3
3
  forceRefresh: () => void;
4
+ lockCurrency?: boolean;
4
5
  }
5
- declare const PlayAmountControl: ({ isDisabled, forceRefresh, }: PlayAmountControlProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const PlayAmountControl: ({ isDisabled, forceRefresh, lockCurrency, }: PlayAmountControlProps) => import("react/jsx-runtime").JSX.Element;
6
7
  export default PlayAmountControl;
@@ -3,6 +3,7 @@ export type Props = PropsWithChildren<ComponentProps<"div">> & {
3
3
  disabled: boolean;
4
4
  onClick: () => void;
5
5
  value: string;
6
+ isClassicGame?: boolean;
6
7
  };
7
- declare const PlayValueInput: ({ disabled, children, className, value, onClick, }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ declare const PlayValueInput: ({ disabled, children, className, value, onClick, isClassicGame, }: Props) => import("react/jsx-runtime").JSX.Element;
8
9
  export default PlayValueInput;
@@ -29,4 +29,12 @@ export declare const usePlayController: () => {
29
29
  setDisplayPlayAmountView: (v: boolean) => void;
30
30
  togglePlayAmountView: () => void;
31
31
  };
32
+ freeRounds: {
33
+ isEngaged: boolean;
34
+ roundsRemaining: number;
35
+ totalRounds: number;
36
+ stakeCents: number;
37
+ coinType: number | undefined;
38
+ currency: string | undefined;
39
+ };
32
40
  };
@@ -3,6 +3,7 @@ type UseSpacebarButtonTriggerParams = {
3
3
  roleButton: GAME_MODE;
4
4
  activeClassName: string;
5
5
  canTrigger: () => boolean;
6
+ suppressed?: boolean;
6
7
  };
7
- export declare const useSpacebarButtonTrigger: ({ roleButton, activeClassName, canTrigger, }: UseSpacebarButtonTriggerParams) => void;
8
+ export declare const useSpacebarButtonTrigger: ({ roleButton, activeClassName, canTrigger, suppressed, }: UseSpacebarButtonTriggerParams) => void;
8
9
  export {};
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from "react";
2
+ import { SupportedLanguage } from "./types";
3
+ import { Translator } from "./translator";
4
+ interface I18nContextValue {
5
+ language: SupportedLanguage;
6
+ t: Translator;
7
+ }
8
+ export declare const I18nProvider: ({ language, children, }: {
9
+ language?: string;
10
+ children: ReactNode;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const useTranslation: () => I18nContextValue;
13
+ export {};
@@ -0,0 +1,5 @@
1
+ export type { Messages, MessageKey, SupportedLanguage, TranslationParams, } from "./types";
2
+ export { SUPPORTED_LANGUAGE_CODES } from "./types";
3
+ export { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, resolveLanguage, createTranslator, } from "./translator";
4
+ export type { Translator } from "./translator";
5
+ export { I18nProvider, useTranslation } from "./I18nContext";
@@ -0,0 +1,2 @@
1
+ import type { Messages } from "../types";
2
+ export declare const en: Messages;
@@ -0,0 +1,2 @@
1
+ import type { Messages } from "../types";
2
+ export declare const zhCN: Messages;
@@ -0,0 +1,5 @@
1
+ import { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, resolveLanguage, type SupportedLanguage, type Translator as GenericTranslator } from "@enigma-lake/zoot-platform-sdk";
2
+ import { MessageKey } from "./types";
3
+ export type Translator = GenericTranslator<MessageKey>;
4
+ export declare const createTranslator: (language: SupportedLanguage) => Translator;
5
+ export { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, resolveLanguage };
@@ -0,0 +1,41 @@
1
+ export { SUPPORTED_LANGUAGE_CODES } from "@enigma-lake/zoot-platform-sdk";
2
+ export type { SupportedLanguage, TranslationParams, } from "@enigma-lake/zoot-platform-sdk";
3
+ export type Messages = {
4
+ playNow: string;
5
+ playFreeRound: string;
6
+ selectPlayAmount: string;
7
+ cashout: string;
8
+ collect: string;
9
+ doubleTitle: string;
10
+ doubleSubtitle: string;
11
+ startAutoplay: string;
12
+ stopAutoplay: string;
13
+ numberOfPlays: string;
14
+ selectPlayAmountAria: string;
15
+ playAmountLabel: string;
16
+ autoLabel: string;
17
+ selectTileToast: string;
18
+ riskLabel: string;
19
+ riskLow: string;
20
+ riskMedium: string;
21
+ riskHigh: string;
22
+ freeRoundLeftOne: string;
23
+ freeRoundLeftOther: string;
24
+ freeRoundsModalTitle: string;
25
+ freeRoundsHave: string;
26
+ freeRoundsUnitOne: string;
27
+ freeRoundsUnitOther: string;
28
+ freeRoundsPerRound: string;
29
+ freeRoundsExpiresIn: string;
30
+ dayUnitOne: string;
31
+ dayUnitOther: string;
32
+ freeRoundsModalPlayNow: string;
33
+ freeRoundsModalPlayLater: string;
34
+ freeRoundsSummaryWon: string;
35
+ freeRoundsSummaryIn: string;
36
+ freeRoundsSummaryUnitOne: string;
37
+ freeRoundsSummaryUnitOther: string;
38
+ freeRoundsSummaryCredited: string;
39
+ freeRoundsSummaryClose: string;
40
+ };
41
+ export type MessageKey = keyof Messages;