Welcome to the casino roulette documentation. This is the plain HTML, CSS and JS (TypeScript) casino roulette implementation that is originally written using JSX but compiles to plain JS by Babel.
Live example - https://codesandbox.io/s/casino-roulette-kl5k8m
If you need the same for your React project, take a look at - https://github.com/IvanAdmaers/react-casino-roulette
Where * means required
Optn | Type | Default value | Description |
---|---|---|---|
id* | string |
- | The wheel render element id |
type* | string |
- | The wheel type: American or European |
<div id="roulette-wheel"></div>
const wheel = new RouletteWheel({
id: 'roulette-wheel',
type: 'American',
});
Method | Arguments | Description |
---|---|---|
changeType | (type: string) |
New wheel type. American or European |
doSpin | (bet: string, onSpinningEnd?: () => void) |
Start spinning wheel function. It takes a number of a winning bet on the wheel and a function which will be called when the wheel stop spinning (optional argument) |
startButton.addEventListener('click', () => {
wheel.doSpin('0', () => console.info('done'));
});
changeWheelTypeButton.addEventListener('click', () => {
wheel.changeType('European');
});
Where * means required
Opt | Type | Default value | Description |
---|---|---|---|
id* | string |
- | The table render element id |
type* | string |
- | The table type: American or European |
bets* | object |
- | The table bets. Type: { [key: string]: { icon?: string; } } |
onBet* | (params: { bet: string; payload: string[]; id: string; }) => void |
- | Function which handles user bets |
<div id="roulette-table"></div>
const bets = {};
const handleBet = (bet) => {
bets[bet.id] = {};
table.render();
};
const table = new RouletteTable({
id: 'roulette-table',
type: 'American',
bets,
onBet: handleBet,
});
Method | Arguments | Description |
---|---|---|
changeType | (type: string) |
New table type. American or European |
render | - |
Renders the table with updated data. Call this method every time your bets object changes |
const handleBet = (bet) => {
// ...
table.render();
// ...
};
changeTableTypeButton.addEventListener('click', () => {
table.changeType('European');
});
npm test
- testsnpm run dev
- devnpm run build
- production. See for thebuild
folder
Make sure you link the roulette css & js file.