// ─── Discipline Types ─────────────────────────────────────────────────────────

import type { ManaType } from './elements';

// ─── Attunement Types ─────────────────────────────────────────────────────────
export enum DisciplinesAttunementType {
  BASE = 'base',
  ENCHANTER = 'enchanter',
  FABRICATOR = 'fabricator',
  INVOKER = 'invoker',
}

// ─── Perk Types ───────────────────────────────────────────────────────────────
export type PerkType = 'capped' | 'once' | 'infinite';

export interface PerkBonus {
  stat: string;
  amount: number;
}

export interface DisciplinePerk {
  id: string;
  type: PerkType;
  threshold: number;
  value: number;
  description: string;
  unlocksEffects?: string[];
  unlocksRecipes?: string[];
  bonus?: PerkBonus;
  /**
   * For capped perks: maximum number of tiers. If unset, capped perks
   * behave like infinite (no cap on tier count).
   */
  maxTier?: number;
}

// ─── Discipline Definition ────────────────────────────────────────────────────
export interface DisciplineDefinition {
  id: string;
  name: string;
  attunement: DisciplinesAttunementType;
  manaType: ManaType;
  baseCost: number;
  description: string;
  statBonus: { stat: string; baseValue: number; label: string };
  difficultyFactor: number;
  scalingFactor: number;
  drainBase: number;
  perks: DisciplinePerk[];
  requires?: string[];
  /**
   * If set, this discipline converts source mana types into the target manaType
   * instead of providing passive regen. The conversion rate is the amount of
   * target mana produced per tick (before XP scaling).
   */
  conversionRate?: number;
  /**
   * Mana types consumed as input for conversion. Always includes 'raw'.
   * For composites/exotics, also includes constituent element(s).
   * Example: ['raw'] for base, ['raw', 'fire', 'earth'] for metal.
   */
  sourceManaTypes?: ManaType[];
}

// ─── Discipline State ─────────────────────────────────────────────────────────
export interface DisciplineState {
  id: string;
  xp: number;
  paused: boolean;
  /** True when the discipline was auto-paused due to insufficient mana */
  autoPaused?: boolean;
}

// ─── Discipline Constants ─────────────────────────────────────────────────────
export const MAX_CONCURRENT_DISCIPLINES = 1;
export const BASE_CONCURRENT_DISCIPLINES = 1;