Interface RuntimeOptions<TState>

Options for configuring runtime behavior.

interface RuntimeOptions<TState> {
    conditionHooks?: Record<string, ((state) => boolean)>;
    expressionEvaluator?: ((expr, state) => boolean);
}

Type Parameters

  • TState

    The type of game state used for condition evaluation

Properties

conditionHooks?: Record<string, ((state) => boolean)>

Map of condition hook names to evaluation functions. Used when choices have condition: { type: 'hook', name: 'hookName' }.

Type declaration

    • (state): boolean
    • Parameters

      Returns boolean

Example

conditionHooks: {
hasKey: (state) => state.inventory.includes('key'),
isHealthy: (state) => state.health > 50
}
expressionEvaluator?: ((expr, state) => boolean)

Function to evaluate expression strings. Used when choices have condition: { type: 'expression', expr: 'level >= 5' }.

Type declaration

    • (expr, state): boolean
    • Parameters

      Returns boolean

Example

expressionEvaluator: (expr, state) => {
// Implement your expression parser here
return eval(expr.replace(/level/g, state.level.toString()));
}