npm i @public/client-core mobx
import { createStore } from '@public/client-core';
import { autorun } from 'mobx';
const store = createStore({
gameType: 'chicken-road',
});
autorun(() => {
console.log(store.isReady);
});
The client URL must include all required parameters.
index.html.store.bet
store.game
store.user
store.wallet
Detailed information about the available types and methods is provided in typebook.
// Set the bet amount in the active currency
store.bet.amount = '25.0';
// Start a game
store.game
.play({
difficulty: 'MEDIUM', // Game-specific parameter
})
.then(result => console.log(result));
store.game.state is updated automatically whenever a game method is called. Each method returns a Promise.
// Advance to the next step in step-based games
store.game
.step()
.then(result => console.log(result));
// Cash out the current winnings
store.game
.payout()
.then(result => console.log(result));
The following utility methods are also available and return a Promise:
store.game
.getGameHistory()
.then(result => console.log(result));
store.game
.getGameSeeds()
.then(result => console.log(result));