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

Overview

Learn the key components to defining your game.


Setting up your game

Create a game by calling createSlotGame() and passing a configuration object. Begin by defining basic game details, then explore the comprehensive configuration options detailed below.

import { createSlotGame, SPIN_TYPE } from "@slot-engine/core"

export const game = createSlotGame({
  id: "my-game",
  name: "My Game",
  maxWinX: 5000,
  padSymbols: 1,
  scatterToFreespins: {
    [SPIN_TYPE.BASE_GAME]: {
      3: 10,
      4: 12,
      5: 15,
    },
    [SPIN_TYPE.FREE_SPINS]: {
      3: 6,
      4: 8,
      5: 10,
    },
  },
  symbols: {},
  gameModes: {},
  userState: {},
  hooks: {
    onHandleGameFlow(ctx) {},
  },
})

When using TypeScript, you will encounter a type error. This is expected because createSlotGame requires a type argument. Let's create a type for your game.

import { createSlotGame, SPIN_TYPE } from "@slot-engine/core"
import { createSlotGame, SPIN_TYPE, InferGameType } from "@slot-engine/core"

export type GameType = InferGameType<any, any, any> 

export const game = createSlotGame({}) 
export const game = createSlotGame<GameType>({}) 

The utility type InferGameType requires three type arguments: game modes, symbols, and state. Since we haven't configured these yet, you can use any for now.

You can now prepare the rest of the configuration.

import { createSlotGame, GameConfig, InferGameType } from "@slot-engine/core"
import {
  createSlotGame, 
  SPIN_TYPE, 
  InferGameType, 
  defineGameModes, 
  defineSymbols, 
  defineUserState, 
} from "@slot-engine/core"

export const gameModes = defineGameModes({}) 
export type GameModesType = typeof gameModes 

export const symbols = defineSymbols({}) 
export type SymbolsType = typeof symbols 

export const userState = defineUserState({}) 
export type UserStateType = typeof userState 

export type GameType = InferGameType<any, any, any> 
export type GameType = InferGameType<GameModesType, SymbolsType, UserStateType> 

export const game = createSlotGame<GameType>({
  /* the rest of your configuration */
  symbols: {}, 
  gameModes: {}, 
  userState: {}, 
  symbols, 
  gameModes, 
  userState, 
})

You have now completed the basic game setup. Continue by configuring symbols, game modes,and state.

At the heart of your game lies the actual implementation.

Finally, simulate your game, tweak settings to improve the feel of it, and optimize results to achieve your desired RTP.

createSlotGame() Options

PropertyTypeDescriptionRequired
idstringA unique identifier for your game.yes
namestringThe name of your game.yes
maxWinXnumberThe maximum bet multiplier payout. Wins exceeding this number will be capped.yes
gameModesRecord<string, GameMode>See: Game Configuration: Game Modesyes
symbolsRecord<string, GameSymbol>See: Game Configuration: Symbolsyes
padSymbolsnumberAmount of padding symbol rows above and below the active board.
Used to display partially visible symbols in the frontend at the top and bottom of the board.

Defaults to 1
yes
scatterToFreespinsRecord<string, Record<number, number>>A mapping from spin type to scatter counts to the number of free spins awarded.yes
userStateRecord<string, any>See: Game Configuration: User Stateyes
hooksRecord<string, (ctx) => unknown>See: Game Configuration: Hooksyes
rootDirstringNormally you would cd into the game directory and run it from there. If you run your game from a different file or process.cwd() is not where your game lies, specify this option and provide a path. __dirname should work fine.

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