@zerospacegg/iolin
Version:
Pure TypeScript implementation of ZeroSpace game data processing (PKL-free)
70 lines • 1.92 kB
JavaScript
;
/**
* 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.GameMechanic = void 0;
const ts_dedent_1 = require("ts-dedent");
const entity_js_1 = require("./entity.cjs");
/**
* Base class for all game mechanics
* Represents a core gameplay system or rule
*/
class GameMechanic extends entity_js_1.Entity {
get wiki() {
return this._wiki;
}
set wiki(value) {
this._wiki = value ? (0, ts_dedent_1.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,
};
}
}
exports.GameMechanic = GameMechanic;
//# sourceMappingURL=mechanic.js.map