UNPKG

@zerospacegg/iolin

Version:

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

363 lines 11.5 kB
/** * Ability - Base ability class for ZeroSpace abilities * Ported from ability.pkl with functional constructor pattern */ import { Child } from "./child.js"; import type { HotKey, Id, Tier } from "./core.js"; import { Entity } from "./entity.js"; /** * Target type system for abilities */ export type DomainType = "air" | "ground"; export type AllyDomainType = "friendly:air" | "friendly:ground"; export type TargetType = DomainType | AllyDomainType | "self" | "map"; export type TargetMode = "gamepiece" | "location" | "around-self" | "strip" | "unit" | "building"; /** * Energy type system for abilities */ export type EnergyType = "classic" | "abes" | "topbar" | "health"; /** * Bonus damage structure for tag-based bonuses */ export interface BonusDamage { multiplier: number; vs: string[]; } /** * Forward declaration for Entity to avoid circular imports */ interface ApplyableEntity { abilities?: Record<string, any>; attacks?: Record<string, any>; heals?: Record<string, any>; spells?: Record<string, any>; } /** * Splash damage structure for area of effect attacks */ export interface SplashDamage { multiplier: number; range: number; } export type AbilityType = "attack" | "heal" | "spell" | "channel" | "passive" | "toggle" | "recharge-energy"; export type FactionAbilityType = "passive" | "topbar" | "talent"; export type TopbarType = "recall" | "special" | "ultimate" | "summon"; export type ActivationType = "auto" | "activated" | "permanent-effect" | "trigger"; /** * Base Ability class - extends Entity with ability-specific properties * Usage: new AttackAbility("Sting", (ability) => { ability.range = 400; }) */ export declare abstract class Ability extends Child { abstract get abilityType(): AbilityType | FactionAbilityType; parentSlug?: string; /** Public subtype getter - just for JSON serialization */ get subtype(): string; get activationType(): ActivationType; targets: TargetType[]; get sortedTargets(): TargetType[]; targetMode: TargetMode; requiresMode?: string; togglesMode?: "siege" | "attack" | "landed"; _forceAutocast?: boolean; get autocast(): boolean; set forceAutocast(value: boolean | undefined); abstract description: string; hotkey: HotKey; reverseHotKey?: HotKey; healthCost?: number; variableEnergyCost?: string; energyCost?: number; energyType?: EnergyType; cooldown?: number; cooldownBetweenShots?: number; cooldownAtBuild?: boolean; duration?: number; range?: number; delay?: number; shots?: number; volleys?: number; bonusDamage: BonusDamage[]; splash?: SplashDamage; armorPenetration?: number; closeupFirerate?: { threshold: number; speedup: number; }; internalId?: string; /** * Apply this ability's effects to the parent entity * Must be implemented by all abilities */ apply(): void; /** * Apply this ability's effects to a target entity * Used for cross-entity effects like buffs/debuffs * Defaults to no-op if not needed */ applyTo(entity: ApplyableEntity): void; abstract get slug(): string; get id(): Id; /** * JSON.stringify() calls this automatically */ toJSON(): Record<string, any>; } /** * Base FactionAbility class - extends Ability with faction ability properties * Usage: new FactionPassive("Resource Control", (ability) => { ability.abilityOf = "grell"; }) */ export declare abstract class FactionAbility extends Ability { abstract get abilityOf(): string; abstract get abilityType(): FactionAbilityType; charges?: number; teleport?: number; constructor(); get activationType(): ActivationType; toJSON(): Record<string, any>; } /** * FactionPassive - Passive faction abilities * Usage: new FactionPassive("Resource Control", (passive) => { passive.abilityOf = "grell"; }) */ export declare abstract class FactionPassive extends FactionAbility { constructor(); get slug(): string; get id(): string; get subtype(): FactionAbilityType; get abilityType(): FactionAbilityType; } /** * TopbarAbility - Topbar faction abilities * Usage: new TopbarAbility({ name: "Orbital Strike", abilityOf: "grell" }) */ export declare abstract class Topbar<T extends Topbar<T> = any> extends FactionAbility { topbarType: TopbarType; slot?: number; requiredLevel?: number; constructor(props?: Partial<T>); get slug(): string; get id(): string; get subtype(): FactionAbilityType; get abilityType(): FactionAbilityType; toJSON(): Record<string, any>; } /** * TalentAbility - Talent faction abilities * Usage: new TalentAbility("Enhanced Infusion", (talent) => { talent.abilityOf = "grell"; }) */ export declare abstract class TalentAbility extends FactionAbility { constructor(); get slug(): string; get id(): string; get subtype(): FactionAbilityType; get abilityType(): FactionAbilityType; } /** * FactionTalent - Faction-wide upgrades (not abilities) * Usage: new FactionTalent({ name: "Enhanced Bio-Growth", tier: "T2" }) */ export declare abstract class FactionTalent<T extends FactionTalent<T> = any> extends Entity { tier: string; level?: number; abstract get abilityOf(): string; name: string; abstract uuid: string; get slug(): string; get id(): string; constructor(props?: Partial<T>); get subtype(): string; apply(): void; toJSON(): Record<string, any>; } /** * AnyAbility Union Type - All concrete ability implementations * Use this instead of any for type safety */ export type AnyAbility = Attack | Heal | Spell; /** * AnyUpgrade Union Type - All concrete upgrade implementations * Use this instead of any for type safety */ export type AnyUpgrade = Upgrade; /** * Attack Ability - Child class for attack abilities embedded in units * Usage: new AttackAbility("Claws", parentId, (attack) => { attack.damage = 6; }) */ export declare class Attack extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; damage?: number; shots?: number; volleys?: number; damageOverTime?: number; get damagePerSec(): number | undefined; constructor(props?: Partial<Attack>); toJSON(): Record<string, any>; } /** * Heal Ability - Child class for heal abilities embedded in units * Usage: new HealAbility("Regeneration", parentId, (heal) => { heal.healAmount = 10; }) */ export declare class Heal extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; healAmount?: number; healing?: number; shots?: number; volleys?: number; healingOverTime?: number; get healingPerSec(): number | undefined; constructor(props: { name: string; description?: string; } & Partial<Heal>); toJSON(): Record<string, any>; } /** * Spell Ability - Child class for spell abilities embedded in units * Usage: new Spell("Teleport", parentId, (spell) => { spell.energyCost = 50; }) */ export declare class Spell extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; hotkey: HotKey; unlocked: boolean; constructor(props: { description: string; forceAutocast?: boolean; } & Partial<Spell>); damage?: number; delay?: number; healing?: number; shots?: number; volleys?: number; damageOverTime?: number; healingOverTime?: number; get damagePerSec(): number | undefined; get healingPerSec(): number | undefined; toJSON(): Record<string, any>; } /** * Death Trigger Ability - Child class for abilities that trigger on unit death * Usage: new DeathTrigger({ description: "Nuclear explosion", damage: 1000, delay: 1 }) */ export declare class DeathTrigger extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; hotkey: HotKey; unlocked: boolean; get activationType(): ActivationType; constructor(props: { description: string; } & Partial<DeathTrigger>); damage?: number; delay?: number; healing?: number; shots?: number; volleys?: number; damageOverTime?: number; healingOverTime?: number; get damagePerSec(): number | undefined; get healingPerSec(): number | undefined; splash?: SplashDamage; bonusDamage: BonusDamage[]; get subtype(): string; toJSON(): Record<string, any>; } /** * Siege Ability - Child class for siege mode toggle abilities embedded in units * Usage: new SiegeAbility("Siege Mode", parentId, (siege) => { siege.togglesMode = "siege"; }) */ export declare class Siege extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; togglesMode?: "siege" | "attack" | "landed"; hotkey: HotKey; reverseHotKey?: HotKey; constructor(props: { description: string; } & Partial<Siege>); toJSON(): Record<string, any>; } /** * Weapon Switch Ability - Child class for weapon switching toggle abilities * Usage: new WeaponSwitch("Weapon Switch", parentId, (switch) => { switch.switchBetween = ["sword", "blaster"]; }) */ export declare class WeaponSwitch extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; togglesMode?: "attack"; switchBetween?: string[]; hotkey: HotKey; constructor(props: { description: string; } & Partial<WeaponSwitch>); toJSON(): Record<string, any>; } /** * Upgrade Ability - Child class for upgrade abilities embedded in units * Usage: new UpgradeAbility("Fast Legs", parentId, (upgrade) => { upgrade.fluxCost = 70; }) */ export declare class Upgrade extends Child { get type(): string; description?: string; tier?: Tier; fluxCost?: number; hexiteCost?: number; researchTime?: number; constructor(props?: Partial<Upgrade>); /** * Apply this upgrade's effects to the parent entity * Must be implemented by all upgrades */ apply(): void; /** * Apply this upgrade's effects to a target entity * Used for cross-entity effects like auras or global buffs * Defaults to no-op if not needed */ applyTo(entity: ApplyableEntity): void; get subtype(): string; toJSON(): Record<string, any>; } /** * Passive Ability - Child class for passive abilities embedded in units * Usage: new PassiveAbility("Regeneration", parentId, (passive) => { passive.healPerSec = 2; }) */ export declare class Passive extends Ability { get type(): string; readonly abilityType: AbilityType; get slug(): string; description: string; damage?: number; healAmount?: number; healing?: number; shots?: number; volleys?: number; damageOverTime?: number; healingOverTime?: number; get damagePerSec(): number | undefined; get healingPerSec(): number | undefined; constructor(props: { description: string; } & Partial<Passive>); duration?: number; range?: number; targets: TargetType[]; unlocked: boolean; toJSON(): Record<string, any>; } export {}; //# sourceMappingURL=ability.d.ts.map