random-tables-mcp
Version:
An MCP (Model Context Protocol) server for managing and rolling on random-table assets used in tabletop RPGs. Create, update, and roll on random tables with support for nested tables, weighted entries, and range-based results.
46 lines (45 loc) • 1.84 kB
TypeScript
import { RollResult } from '../domain/index.js';
import { RandomNumberGenerator, TableRepository } from '../ports/index.js';
/**
* Use case for rolling on a random table.
*/
export declare class RollOnTableUseCase {
private readonly repository;
private readonly rng;
/**
* Creates a new RollOnTableUseCase instance.
* @param repository The table repository to use.
* @param rng The random number generator to use.
*/
constructor(repository: TableRepository, rng: RandomNumberGenerator);
/**
* Executes the use case.
* @param tableId The ID of the table to roll on.
* @param count The number of rolls to perform (default: 1).
* @returns An array of roll results.
*/
execute(tableId: string, count?: number): Promise<RollResult[]>;
/**
* Resolves a template result by rolling on referenced tables.
* @param result The roll result to resolve.
* @param maxDepth Maximum resolution depth to prevent infinite loops.
* @param visitedTables Set of table IDs and names that have been visited in this resolution chain.
* @returns A resolved roll result.
*/
private resolveTemplateResult;
/**
* Finds a table referenced by a template reference.
* @param reference The template reference
* @returns The referenced table, or null if not found
*/
private findReferencedTable;
/**
* Rolls on a referenced table multiple times and resolves any nested templates.
* @param table The table to roll on
* @param count Number of times to roll
* @param maxDepth Maximum resolution depth for nested templates
* @param visitedTables Set of table IDs and names that have been visited in this resolution chain
* @returns Array of roll result contents
*/
private rollOnReferencedTable;
}