UNPKG

@zerospacegg/iolin

Version:

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

89 lines 2.04 kB
/** * Map - RTS map class for ZeroSpace maps * Using functional constructor pattern */ import { Entity } from "./entity.js"; /** * RTS Map class - extends Entity with map-specific properties * Usage: new Map1v1("Ascension 1v1", (map) => { map.xpTowers = 3; }) * * This is abstract - you MUST use Map1v1, Map2v2, MapFFA, or Map1p subclasses */ export class Map extends Entity { get type() { return "map"; } constructor() { super(); this.mapSize = "normal"; this.inLadderPool = true; this.tier = ""; // Maps don't have tiers // Add dynamic tagger for ladder pool this.dynamicTaggers.push([(entity) => entity.inLadderPool, "ladder"]); } /** Public subtype getter - just for JSON serialization */ get subtype() { return this.mapType; } get id() { return `map/${this.subtype}/${this.slug}`; } /** * JSON.stringify() calls this automatically */ toJSON() { return { ...super.toJSON(), xpTowers: this.xpTowers, fluxDistance: this.fluxDistance, mapSize: this.mapSize, inLadderPool: this.inLadderPool, players: this.players, }; } } export class Map1v1 extends Map { get subtype() { return "1v1"; } get mapType() { return this.subtype; } get players() { return 2; } } export class Map2v2 extends Map { get subtype() { return "2v2"; } get mapType() { return this.subtype; } get players() { return 4; } } export class MapFFA extends Map { get subtype() { return "ffa"; } get mapType() { return this.subtype; } get players() { return 4; // technically 8 with AI but eh } } export class Map1p extends Map { get subtype() { return "1p"; } get mapType() { return this.subtype; } get players() { return 1; } } //# sourceMappingURL=map.js.map