UNPKG

@zerospacegg/iolin

Version:

Pure TypeScript implementation of ZeroSpace game data processing (PKL-free)

66 lines 1.74 kB
/** * Game Mechanic Engine - Base classes for game mechanics * * This module provides the foundational classes for defining and managing * game mechanics in ZeroSpace. Mechanics represent core gameplay systems * and rules that apply across factions and units. */ import { dedent } from "ts-dedent"; import { Entity } from "./entity.js"; /** * Base class for all game mechanics * Represents a core gameplay system or rule */ export class GameMechanic extends Entity { get wiki() { return this._wiki; } set wiki(value) { this._wiki = value ? dedent(value) : undefined; } get type() { return "mechanic"; } get subtype() { return "mechanic"; } constructor() { super(); this.references = []; // Required properties must be set by subclasses in their constructors } /** * Get a summary of this mechanic */ get summary() { return `${this.name}: ${this.description?.slice(0, 100) || ""}...`; } /** * Check if this mechanic matches a search term */ matches(searchTerm) { const term = searchTerm.toLowerCase(); // Check name if (this.name.toLowerCase().includes(term)) { return true; } // Check description if (this.description?.toLowerCase().includes(term)) { return true; } return false; } /** * Get mechanic data as a plain object */ toJSON() { return { name: this.name, uuid: this.uuid, description: this.description, wiki: this.wiki, references: this.references, }; } } //# sourceMappingURL=mechanic.js.map