Context
Useful functions and state available in the core
Introduction
The context (or game context) provides access to the underlying state.
It also provides many utility functions that ease game implementation.
The context is typically accessed via the ctx parameter in hooks.
type Context = GameContext<GameModesType, SymbolsType, UserStateType>
export function onHandleGameFlow(ctx: Context) {
const reels = ctx.services.board.getRandomReelset()
ctx.services.board.drawBoardWithRandomStops(reels)
// type safe! ⤵
const scatter = ctx.config.symbols.get("S")!
const [count] = ctx.services.board.countSymbolsOnBoard(scatter)
}Properties
config
You can access the complete game configuration through the context. Keep in mind that you shouldn't do any modifications to your game config inside your game implementation.
const config = ctx.configservices
Services are cohesive function groups that encapsulate and manage specific parts of the game state. You will use them often when implementing your game.
state
The core game state exposes some underlying state and information about the current simulation.
Use of AI on this page: All texts were initially written by hand and many were later revised by AI for improved flow. All AI generated revisions were carefully reviewed and edited as needed.