// ─── Spell Types ────────────────────────────────────────────────────────────

// Spell cost can be raw mana or elemental mana
export interface SpellCost {
  type: 'raw' | 'element';  // 'raw' for raw mana, 'element' for specific elemental mana
  element?: string;          // Required if type is 'element'
  amount: number;            // Amount of mana required
}

export interface SpellOnHitEffect {
  type: 'burn' | 'poison' | 'bleed' | 'freeze' | 'slow' | 'curse' | 'armor_corrode' | 'blind';
  duration: number;       // ticks
  magnitude: number;
  bypassArmor?: boolean;
  bypassBarrier?: boolean;
  applyChance?: number;   // 0-1, defaults to 1.0
}

export interface SpellDef {
  name: string;
  elem: string;              // Element type for damage calculations
  dmg: number;
  cost: SpellCost;           // Changed from number to SpellCost object
  tier: number;
  unlock: number;            // Mana cost to start studying
  studyTime?: number;        // Hours needed to study (optional, defaults based on tier)
  castSpeed?: number;        // Casts per hour (default 1, higher = faster)
  baseCastTime?: number;     // Base cast time in seconds (default 1.0)
  desc?: string;             // Optional spell description
  effects?: SpellEffect[];   // Optional special effects
  isAoe?: boolean;           // AOE spell that hits multiple enemies
  aoeTargets?: number;       // Number of enemies hit by AOE
  isWeaponEnchant?: boolean; // Can be used as weapon enchantment (magic swords)
  grimoire?: boolean;          // Whether this spell appears in the grimoire
  onHitEffect?: SpellOnHitEffect;  // DoT/debuff applied on successful hit
}

export interface SpellEffect {
  type: 'burn' | 'freeze' | 'stun' | 'pierce' | 'multicast' | 'shield' | 'buff' | 'chain' | 'aoe' | 'armor_pierce' | 'curse' | 'slow' | 'poison' | 'armor_corrode' | 'blind' | 'defense_bypass' | 'resist_ignore' | 'raw_damage' | 'temporal_dodge_reduction' | 'mage_lock';
  value: number;            // Effect potency
  duration?: number;        // Duration in hours for timed effects
  targets?: number;         // For AOE: number of targets
  chance?: number;          // For chance-based effects (e.g., stun chance)
}

export interface SpellState {
  learned: boolean;
  level: number;
  studyProgress?: number;   // Hours studied so far (for in-progress spells)
}
