Slot Engine is in Beta - Stable, but may contain minor bugs
Slot EngineSlot Engine
Configuration Options

Hooks

Inject custom logic into the Core library


Introduction

Hooks are a way of adding your own code on top of Slot Engine. They allow you to execute code or update state at specific points of the program.

List of Hooks

These are the hooks you can define in your game configuration.

onHandleGameFlow

PropertyTypeRequired
onHandleGameFlow(ctx: GameContext) => voidyes

The complete game logic must be implemented in this hook.

onSimulationAccepted

PropertyTypeRequired
onSimulationAccepted(ctx: GameContext) => void

This hook is called after a simulation is accepted and the payout has been written to the book. Useful to run code after completing a simulation and before continuing with the next.

Important

No payouts or results should be altered using this hook! But adding additional data with ctx.services.data.tag() is perfectly fine.

onGameModeComplete

PropertyTypeRequired
onGameModeComplete(info: GameModeCompleteInfo) => void | Promise<void>

This hook is called after a game mode has been fully simulated and all of its files have been written. It only runs on the main thread, and is awaited.

It receives the completed mode name, all file paths of the build directory, and the game metadata. A common use case is feeding the lookup table paths into the optimize() function of @slot-engine/optimizer.

const game = createSlotGame({
  // ...
  hooks: {
    onHandleGameFlow,
    onGameModeComplete: async ({ mode, paths, metadata }) => {
      console.log(`Mode ${mode} done:`, paths.lookupTable(mode))
    },
  },
})

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