Skip to main content

Quickstart

This code snippet very briefly illustrates the 3 core concepts of Kalamba SDK:

// Create Kalamba SDK instance
const sdk = new KalambaSdk({ messagePort: window.parent })

// Initialize Game with Kalamba SDK
const myGame = new Game(sdk)

// Configure wrapper
sdk.configure({ gameName: myGame.name, gameVersion: myGame.version })

// Open game
const openGameResponse = await sdk.openGame()

// sdk.config is available
console.log('config', sdk.config)

// Notify Kalamba SDK about initial game settings
sdk.send('settings', myGame.settings)

// React to Kalamba SDK paytable event
sdk.on('paytable', ({ show }: { show: boolean }) => {
myGame.togglePaytable(show)
})

// Notify Kalamba SDK that the game has started loading
sdk.send('loadStart')
await myGame.load()
// Notify Kalamba SDK that the game has finished loading
sdk.send('loadEnd')

// Play game
const playResponse = await sdk.play({ bet: { base: 10, multiplier: 2 } })

// Notify Kalamba SDK about bet change
sdk.send('bet', { base: 10, multiplier: 3 })

// Play game
const playResponse = await sdk.play({ bet: { base: 10, multiplier: 3 } })