Slot Engine is in Beta - Expect bugs!
Slot EngineSlot Engine

Board Service

Service managing the game board and reels.


Methods

getBoardReels()

MethodType
ctx.services.board.getBoardReels()() => Reels

Returns the active board reels.

getPaddingTop()

MethodType
ctx.services.board.getPaddingTop()() => Reels

Returns the top padding reels.

getPaddingBottom()

MethodType
ctx.services.board.getPaddingBottom()() => Reels

Returns the bottom padding reels.

getSymbol()

MethodType
ctx.services.board.getSymbol()(reelIndex, rowIndex) => GameSymbol

Parameters

ParameterType
reelIndexnumber
rowIndexnumber

Returns the symbol at the specified position.

setSymbol()

MethodType
ctx.services.board.setSymbol()(reelIndex, rowIndex, symbol) => void

Parameters

ParameterType
reelIndexnumber
rowIndexnumber
symbolGameSymbol

Sets the symbol at the specified position.

removeSymbol()

MethodType
ctx.services.board.removeSymbol()(reelIndex, rowIndex) => boolean

Parameters

ParameterType
reelIndexnumber
rowIndexnumber

Removes the symbol from the board at the specified position. Returns a boolean, whether the symbol was removed.

setSymbolsPerReel()

MethodType
ctx.services.board.setSymbolsPerReel()(symbolsPerReel) => void

Parameters

ParameterType
symbolsPerReelnumber[]

Sets a new temporary value for symbolsPerReel. The value will be persisted until changed by the user or until the simulation is reset or the next simulation starts.

setReelsAmount()

MethodType
ctx.services.board.setReelsAmount()(reelsAmount) => void

Parameters

ParameterType
reelsAmountnumber

Sets a new temporary value for reelsAmount. The value will be persisted until changed by the user or until the simulation is reset or the next simulation starts.

resetBoard()

MethodType
ctx.services.board.resetBoard()() => void

Resets and clears the board.

getAnticipation()

MethodType
ctx.services.board.getAnticipation()() => boolean[]

Array of booleans representing anticipation for reels. Anticipation is a visual effect that usually teases potential free spins when one more scatter is needed to trigger it.

For example, an anticipation array of [false, false, false, true, true] can instruct the client to apply anticipation effects to reels 4 and 5.

setAnticipationForReel()

MethodType
ctx.services.board.setAnticipationForReel()(reelIndex, value) => void

Parameters

ParameterType
reelIndexnumber
valueboolean

Sets anticipation state for a board reel.

countSymbolsOnReel()

MethodType
ctx.services.board.countSymbolsOnReel()(symbolOrProperties, reelIndex) => number

Parameters

ParameterType
symbolOrPropertiesGameSymbol | Record<string, any>
reelIndexnumber

Counts the symbols on the specified reel.

countSymbolsOnBoard()

MethodType
ctx.services.board.countSymbolsOnBoard()(symbolOrProperties) => [number, Record<number, number>]

Parameters

ParameterType
symbolOrPropertiesGameSymbol | Record<string, any>

Counts how many symbols matching the criteria are on the board.

Returns a tuple where the first element is the total count, and the second element is a record of counts per reel index.

isSymbolOnAnyReelMultipleTimes()

MethodType
ctx.services.board.isSymbolOnAnyReelMultipleTimes()(symbol) => boolean

Parameters

ParameterType
symbolGameSymbol

Checks if the given symbol occurrs multiple times on any reel.

getReelStopsForSymbol()

MethodType
ctx.services.board.getReelStopsForSymbol()(reels, symbol) => number[][]

Parameters

ParameterType
reelsReels
symbolGameSymbol

Returns all positions of a symbol in a reel set. Useful to retrieve all possible scatter positions, for example.

combineReelStops()

MethodType
ctx.services.board.combineReelStops()(...reelStops) => number[][]

Parameters

ParameterType
reelStopsnumber[][][]

Combines multiple arrays of reel stops into a single array of reel stops. If you had multiple scatter variants, you could use this to get a single array of all scatter positions in a reel set.

Usage

const reels = ctx.services.board.getRandomReelset()
const scatter = config.symbols.get("S")!
const superScatter = config.symbols.get("SS")!

const reelStops = ctx.services.board.combineReelStops(
  ctx.services.board.getReelStopsForSymbol(reels, scatter),
  ctx.services.board.getReelStopsForSymbol(reels, superScatter),
)

getRandomReelStops()

MethodType
ctx.services.board.getRandomReelStops()(reels, reelStops, amount) => Record<string, number>

Parameters

ParameterType
reelsReels
reelStopsnumber[][]
amountnumber

From a list of reel stops on reels, selects a random stop for amount number of reels. This is mostly useful to forcibly place scatters on the board.

Usage

const reels = ctx.services.board.getRandomReelset()
const scatter = config.symbols.get("S")!

const reelStops = ctx.services.board.getReelStopsForSymbol(reels, scatter)
const scatterReelStops = ctx.services.board.getRandomReelStops(reels, reelStops, 3)

ctx.services.board.drawBoardWithForcedStops({
  reels,
  forcedStops: scatterReelStops,
})

getRandomReelset()

MethodType
ctx.services.board.getRandomReelset()() => Reels

Selects a random reel set based on the configured weights of the current result set.

drawBoardWithForcedStops()

MethodType
ctx.services.board.drawBoardWithForcedStops()(opts: { reels, forcedStops, randomOffset }) => void

Parameters

ParameterTypeDescriptionRequired
opts.reelsReelsyes
opts.forcedStopsRecord<string, number>yes
opts.randomOffsetbooleanWhether to apply a random offset to the stops. Adds a bit of randomization to where exactly your forced symbol lands on the reel.
Default: true

Draws a board using specified reel stops.

Usage

const reels = ctx.services.board.getRandomReelset()
const scatter = config.symbols.get("S")!

const reelStops = ctx.services.board.getReelStopsForSymbol(reels, scatter)
const scatterReelStops = ctx.services.board.getRandomReelStops(reels, reelStops, 3)

ctx.services.board.drawBoardWithForcedStops({
  reels,
  forcedStops: scatterReelStops,
})

drawBoardWithRandomStops()

MethodType
ctx.services.board.drawBoardWithRandomStops()(reels) => void

Parameters

ParameterType
reelsReels

Draws a board using random reel stops.

tumbleBoard()

MethodType
ctx.services.board.tumbleBoard()(symbolsToDelete) => { newBoardSymbols, newPaddingTopSymbols }

Parameters

ParameterType
symbolsToDeleteArray<{ reelIdx: number; rowIdx: number }>

Return Object

ParameterType
newBoardSymbolsRecord<string, GameSymbol[]>
newPaddingTopSymbolsRecord<string, GameSymbol[]>

Tumbles the board. All given symbols will be deleted and new symbols will fall from the top.

If you use the symbols from winCombinations returned by a win type, ensure symbols are deduped to prevent bugs during tumbling. For example, the same Wild symbol may be associated with multiple win combinations. To dedupe, use ctx.services.game.dedupeWinSymbols(). The resulting symbol positions are safe to use for tumbling.

The function returns the new symbols that were added to each reel. For example, newBoardSymbols will be an object where the keys are the reel indexes and the values are the added symbols for that reel.

tumbleBoardAndForget() - EXPERIMENTAL

This method is experimental and may be changed or replaced in the future. If you plan to use this method, ensure padSymbols is set to 0 in the game config or you will most likely experience bugs or unexpected behavior.

MethodType
ctx.services.board.tumbleBoardAndForget()(opts) => { newBoardSymbols, newPaddingTopSymbols }

Parameters

ParameterType
opts.symbolsToDeleteArray<{ reelIdx: number; rowIdx: number }>
opts.reelsReels
opts.forcedStopsnumber[]

Return Object

ParameterType
newBoardSymbolsRecord<string, GameSymbol[]>
newPaddingTopSymbolsRecord<string, GameSymbol[]>

Tumbles the board similar to tumbleBoard().

While tumbleBoard() remembers the last tumble and can seamlessly tumble multiple times in a row, tumbleBoardAndForget() will not remember what it did. This is useful to do a single one-off tumble.

While tumbleBoard() always uses the last used reel set that the board was drawn with, tumbleBoardAndForget() can tumble symbols from an arbitrary reel set and won't override any internal board state (besides the symbols on the reels).

This can be particularly useful if you need to fill a part of the board with some blocker symbols (think of the game Templar Tumble, or Temple Tumble).

If you plan to use this method, ensure padSymbols is set to 0 in the game config or you will most likely experience bugs or unexpected behavior.

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.

On this page