UNPKG

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.

33 lines 1.29 kB
import { RollTemplateEntity } from '../domain/entities/roll-template-entity.js'; import { RollTemplate } from '../domain/value-objects/roll-template.js'; import { v4 as uuidv4 } from 'uuid'; /** * Use case for creating a new roll template. */ export class CreateTemplateUseCase { /** * Creates a new CreateTemplateUseCase instance. * @param templateRepository The repository to use for template persistence. */ constructor(templateRepository) { this.templateRepository = templateRepository; } /** * Executes the use case. * @param name Template name. * @param description Template description. * @param template The template string. * @returns The ID of the created template. */ async execute(name, description, template) { // Generate a unique ID for the template const id = uuidv4(); // Create a new RollTemplate value object const rollTemplate = new RollTemplate(template); // Create a new RollTemplateEntity const templateEntity = new RollTemplateEntity(id, name, description, rollTemplate); // Save the template to the repository return await this.templateRepository.save(templateEntity); } } //# sourceMappingURL=create-template-use-case.js.map