@enigma-lake/tower-play-controller-sdk
v2.0.12
Published
A React component library for building gameplay interfaces
Downloads
714
Keywords
Readme
TowerPlayController SDK
The TowerPlayController SDK provides a fully-configurable wager & play-control interface for Tower-style games.
It supports manual play, optional autoplay, optional risk selection, currency management, play amount input, and custom widgets.
Configuration is driven by the PlayControllerProps type, which supports two modes:
- Full Mode (default) — risk & autoplay enabled (flag omitted or
false) - Simplified Mode — risk & autoplay disabled when
withoutRiskAndAutoplay: true
This keeps backwards compatibility with existing games (they don't need to pass the flag), and lets new games opt into a simpler controller by setting the flag.
🚀 Installation
npm install @enigma-lake/tower-play-controller-sdkImport styles:
import "@enigma-lake/tower-play-controller-sdk/dist/style.css";🧠 AutoManualPlayProvider
Wrap your game UI inside:
<AutoManualPlayProvider config={config}>
{({ autoPlay, manual, mode }) => (
// your UI
)}
</AutoManualPlayProvider>The provider manages all logic:
| Feature | Full Mode (default) | Simplified Mode (withoutRiskAndAutoplay: true) |
|------------------------|------------------------------------------|--------------------------------------------------|
| Autoplay | ✅ Enabled (requires onAutoPlay) | ❌ Disabled |
| Risk Difficulty | ✅ Enabled (risks/currentRisk/onRiskChange) | ❌ Hidden |
| Dropdown Risk Colors | ✅ Required | ❌ Not used |
| Manual Play | ✅ Enabled | ✅ Enabled |
| Play Amount | ✅ Enabled | ✅ Enabled |
🔧 Prop Structure
Below is an overview of the configuration props.
1. currencyOptions
{
current: Currency;
available: Currency[];
}2. Styling (Conditional)
Panel
panel: {
bottom?: string;
bgColorHex: string;
bgColorOpacity?: number;
}Dropdown
Full Mode (default)withoutRiskAndAutoplay omitted or false:
dropdown: {
bgColorHex: string;
riskColorConfig: {
LOW: string;
MEDIUM: string;
HIGH: string;
};
}Simplified ModewithoutRiskAndAutoplay: true:
dropdown: {
bgColorHex: string;
}3. Actions
Shared (both modes):
onPlay: () => void;
onCashout: () => void;Only required in Full Mode (withoutRiskAndAutoplay omitted or false):
onAutoPlay: (selection: number[], next: () => void, stop: () => void) => void;
onAutoPlayStop?: () => void;In Simplified Mode, onAutoPlay and onAutoPlayStop are not required and are effectively ignored.
4. Play Options (Conditional)
Full Mode (default)
playOptions: {
isPlaying: boolean;
canCashout: boolean;
disabledController: boolean;
displayController: boolean;
// RISK SYSTEM
risks: RiskTypes[];
currentRisk: RiskTypes;
onRiskChange(risk: RiskTypes): void;
// AUTOPLAY SYSTEM
autoPlayDelay?: number;
showAutoPlayToast({ type, message }): void;
disabledMenu: boolean;
playHook(): {
playLimits?: PlayLimits;
playAmount: number;
setPlayAmount(value: number): void;
};
totalBalance: number;
}Simplified Mode
withoutRiskAndAutoplay: true:
playOptions: {
isPlaying: boolean;
canCashout: boolean;
disabledController: boolean;
displayController: boolean;
disabledMenu: boolean;
playHook(): {
playLimits?: PlayLimits;
playAmount: number;
setPlayAmount(value: number): void;
};
totalBalance: number;
}Risk/autoplay properties (risks, currentRisk, onRiskChange, autoPlayDelay, showAutoPlayToast) are not part of the simplified mode.
5. Widgets
leftWidgets: Widget[];
centerWidgets: Widget[];
rightWidgets: Widget[];🎮 Example Usage
Example 1 — Full Mode (default: risk + autoplay enabled)
import {
AutoManualPlayProvider,
} from "@enigma-lake/tower-play-controller-sdk";
import { Currency } from "@enigma-lake/zoot-platform-sdk";
const config = {
// withoutRiskAndAutoplay omitted or false => FULL mode
currencyOptions: {
current: Currency.SWEEPS,
available: [Currency.SWEEPS, Currency.GOLD],
},
onPlay: () => console.log("Play"),
onAutoPlay: (selection, next, stop) => {
console.log("Autoplay selection:", selection);
next(); // continue to next round
},
onAutoPlayStop: () => console.log("Autoplay stopped"),
onCashout: () => console.log("Cashout"),
playOptions: {
displayController: true,
isPlaying: false,
canCashout: false,
disabledController: false,
disableInput: false,
// Risk controls
risks: [RiskTypes.LOW, RiskTypes.MEDIUM, RiskTypes.HIGH],
currentRisk: RiskTypes.LOW,
onRiskChange: (risk) => console.log("Risk:", risk),
// Autoplay
autoPlayDelay: 1000,
showAutoPlayToast: ({ type, message }) =>
console.log(`${type}: ${message}`),
disabledMenu: false,
playHook: () => ({
playLimits: { min: 1, max: 100 },
playAmount: 10,
setPlayAmount: (v) => console.log("Amount:", v),
}),
totalBalance: 100,
},
panel: {
bottom: "60px",
bgColorHex: "#08643F",
bgColorOpacity: 0.8,
},
dropdown: {
bgColorHex: "#123456",
riskColorConfig: {
LOW: "#1AE380",
MEDIUM: "#FAEB78",
HIGH: "#FF5646",
},
},
leftWidgets: [],
centerWidgets: [],
rightWidgets: [],
};
export const GameExampleFull = () => (
<AutoManualPlayProvider config={config}>
{({ mode }) => (
<div>Mode: {mode}</div>
)}
</AutoManualPlayProvider>
);Example 2 — Simplified Mode (withoutRiskAndAutoplay: true)
import {
AutoManualPlayProvider,
} from "@enigma-lake/tower-play-controller-sdk";
import { Currency } from "@enigma-lake/zoot-platform-sdk";
const config = {
withoutRiskAndAutoplay: true, // simplified mode
currencyOptions: {
current: Currency.SWEEPS,
available: [Currency.SWEEPS],
},
onPlay: () => console.log("Play"),
onCashout: () => console.log("Cashout"),
playOptions: {
displayController: true,
isPlaying: false,
canCashout: false,
disabledController: false,
disableInput: false,
disabledMenu: false,
playHook: () => ({
playLimits: { min: 1, max: 20 },
playAmount: 5,
setPlayAmount: (value) => console.log("New amount:", value),
}),
totalBalance: 50,
},
panel: {
bgColorHex: "#0A3F2F",
},
dropdown: {
bgColorHex: "#10243F", // no riskColorConfig here
},
leftWidgets: [],
centerWidgets: [],
rightWidgets: [],
};
export const GameExampleSimplified = () => (
<AutoManualPlayProvider config={config}>
{({ mode }) => (
<div>Mode: {mode}</div>
)}
</AutoManualPlayProvider>
);⭐ Features
- Optional Risk System – enabled by default; disabled when
withoutRiskAndAutoplay: true - Optional Autoplay – fully controlled via callbacks and delay (full mode only)
- Dynamic Currency Management – multiple currencies supported
- Wager Controls – validated against play limits
- UI Widgets – customizable left/center/right areas
- Flexible Styling – configurable colors, bottom positioning, and opacity
- Responsive Layout – suitable for desktop and mobile
🛠 Development Notes
onAutoPlay/onAutoPlayStopare only required in full mode.dropdown.riskColorConfigis only allowed/required in full mode.- Risk-related and autoplay-related fields in
playOptionsare removed in simplified mode. - Use
withoutRiskAndAutoplay: trueto explicitly opt into the simplified experience.
