/**
 * @typedef {import("./types.js").UnitDefinition} UnitDefinition
 */

import { Unit } from "./Unit.js";

/**
 * Enemy.js
 * NPC Unit controlled by the AI Controller.
 * @class
 */
export class Enemy extends Unit {
  /**
   * @param {string} id - Unique unit identifier
   * @param {string} name - Enemy name
   * @param {UnitDefinition} def - Enemy definition
   */
  constructor(id, name, def) {
    // Construct with ID, Name, Type='ENEMY', and ModelID from def
    super(id, name, "ENEMY", def.model || "MODEL_ENEMY_DEFAULT");

    // AI Logic
    /** @type {string} */
    this.archetypeId = def.ai_archetype || "BRUISER"; // e.g., 'BRUISER', 'KITER'
    /** @type {number} */
    this.aggroRange = def.aggro_range || 8;

    // Rewards
    /** @type {number} */
    this.xpValue = def.xp_value || 10;
    /** @type {string} */
    this.lootTableId = def.loot_table || "LOOT_TIER_1_COMMON";

    // Hydrate Stats
    if (def.stats) {
      this.baseStats = { ...this.baseStats, ...def.stats };
      this.currentHealth = this.baseStats.health;
      this.maxHealth = this.baseStats.health;
    }
  }
}
