UNPKG

@zerospacegg/iolin

Version:

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

134 lines 3.84 kB
"use strict"; /** * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.AdvancedTransformationMechanic = exports.TransformationMechanic = exports.BasicMechanic = exports.GameMechanic = void 0; /** * Base class for all game mechanics * Represents a core gameplay system or rule */ class GameMechanic { constructor(name, builder) { this.uuid = ""; this.keywords = []; this.description = ""; this.name = name; if (builder) { builder(this); } } /** * 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 keywords if (this.keywords.some(keyword => keyword.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, keywords: this.keywords, description: this.description.trim(), }; } } exports.GameMechanic = GameMechanic; /** * Basic mechanic - represents fundamental gameplay concepts */ class BasicMechanic extends GameMechanic { constructor(name, builder) { super(name, builder); } } exports.BasicMechanic = BasicMechanic; /** * Transformation mechanic - represents complex multi-phase systems */ class TransformationMechanic extends GameMechanic { constructor(name, builder) { super(name); this.category = ""; this.stackable = false; this.maxStacks = 1; this.conflictsWith = []; this.hasPhases = false; this.triggersOnDeath = false; this.tagsAdded = []; this.tagsRemoved = []; this.notes = ""; if (builder) { builder(this); } } /** * Get transformation mechanic data as a plain object */ toJSON() { return { ...super.toJSON(), category: this.category, stackable: this.stackable, maxStacks: this.maxStacks, conflictsWith: this.conflictsWith, hasPhases: this.hasPhases, triggersOnDeath: this.triggersOnDeath, tagsAdded: this.tagsAdded, tagsRemoved: this.tagsRemoved, notes: this.notes.trim(), }; } } exports.TransformationMechanic = TransformationMechanic; /** * Advanced transformation mechanic with detailed rules */ class AdvancedTransformationMechanic extends TransformationMechanic { constructor(name, builder) { super(name); if (builder) { builder(this); } } /** * Get advanced transformation mechanic data as a plain object */ toJSON() { return { ...super.toJSON(), requirements: this.requirements, statModifications: this.statModifications, preDeathPhase: this.preDeathPhase, postDeathPhase: this.postDeathPhase, }; } } exports.AdvancedTransformationMechanic = AdvancedTransformationMechanic; //# sourceMappingURL=mechanic.js.map