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.

47 lines 1.57 kB
import { RollTemplate } from '../value-objects/roll-template.js'; /** * Represents a roll template entity that can be persisted. * Unlike the RollTemplate value object, this entity has identity and metadata. */ export class RollTemplateEntity { /** * Creates a new RollTemplateEntity instance. * @param id Unique identifier for the template. * @param name Template name. * @param description Optional description. * @param template The RollTemplate value object. */ constructor(id, name, description, template) { this.id = id; this.name = name; this.description = description; this.template = template; if (!id) { throw new Error('Template ID is required'); } if (!name) { throw new Error('Template name is required'); } } /** * Converts this template entity to a plain object. * @returns A plain object representation of this template entity. */ toObject() { return { id: this.id, name: this.name, description: this.description, template: this.template.toString(), }; } /** * Creates a RollTemplateEntity from a plain object. * @param obj The object to create the template entity from. * @returns A new RollTemplateEntity instance. */ static fromObject(obj) { return new RollTemplateEntity(obj.id, obj.name, obj.description, new RollTemplate(obj.template)); } } //# sourceMappingURL=roll-template-entity.js.map