// ─── Elemental Capacity Disciplines ──────────────────────────────────────────────
// One discipline per mana type that increases that element's capacity.
// All are BASE attunement so they are available to every role once the element is unlocked.

import { DisciplinesAttunementType } from '../../types/disciplines';
import type { DisciplineDefinition } from '../../types/disciplines';

interface ManaCapacityConfig {
  id: string;
  name: string;
  manaType: DisciplineDefinition['manaType'];
  cost: number;
  baseValue: number;
  difficultyFactor: number;
  scalingFactor: number;
  drainBase: number;
}

function createManaCapacityDiscipline(cfg: ManaCapacityConfig): DisciplineDefinition {
  return {
    id: cfg.id,
    name: `${cfg.name} Mana Capacity`,
    attunement: DisciplinesAttunementType.BASE,
    manaType: cfg.manaType,
    baseCost: cfg.cost,
    description: `Increase your ${cfg.name.toLowerCase()} mana capacity.`,
    requires: [cfg.manaType],
    statBonus: { stat: `elementCap_${cfg.manaType}`, baseValue: cfg.baseValue, label: `${cfg.name} Mana Capacity` },
    difficultyFactor: cfg.difficultyFactor,
    scalingFactor: cfg.scalingFactor,
    drainBase: cfg.drainBase,
    perks: [
      {
        id: `${cfg.id}-1`,
        type: 'once',
        threshold: 200,
        value: 0,
        description: `+10 ${cfg.name} Capacity`,
        bonus: { stat: `elementCap_${cfg.manaType}`, amount: 10 },
      },
    ],
  };
}

const MANA_CAPACITY_CONFIGS: ManaCapacityConfig[] = [
  // ── Base Elements ──────────────────────────────────────────────────────────
  { id: 'attune-fire',     name: 'Fire',     manaType: 'fire',     cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-water',    name: 'Water',    manaType: 'water',    cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-air',      name: 'Air',      manaType: 'air',      cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-earth',    name: 'Earth',    manaType: 'earth',    cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-light',    name: 'Light',    manaType: 'light',    cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-dark',     name: 'Dark',     manaType: 'dark',     cost: 10, baseValue: 5,  difficultyFactor: 150, scalingFactor: 75,  drainBase: 2 },
  { id: 'attune-death',    name: 'Death',    manaType: 'death',    cost: 12, baseValue: 4,  difficultyFactor: 180, scalingFactor: 90,  drainBase: 3 },

  // ── Utility Element ────────────────────────────────────────────────────────
  { id: 'attune-transference', name: 'Transference', manaType: 'transference', cost: 8,  baseValue: 5,  difficultyFactor: 120, scalingFactor: 60,  drainBase: 1.5 },

  // ── Composite Elements ─────────────────────────────────────────────────────
  { id: 'attune-metal',        name: 'Metal',        manaType: 'metal',        cost: 15, baseValue: 4,  difficultyFactor: 180, scalingFactor: 90,  drainBase: 2.5 },
  { id: 'attune-sand',         name: 'Sand',         manaType: 'sand',         cost: 15, baseValue: 4,  difficultyFactor: 180, scalingFactor: 90,  drainBase: 2.5 },
  { id: 'attune-lightning',    name: 'Lightning',    manaType: 'lightning',    cost: 15, baseValue: 4,  difficultyFactor: 180, scalingFactor: 90,  drainBase: 2.5 },
  { id: 'attune-frost',        name: 'Frost',        manaType: 'frost',        cost: 15, baseValue: 4,  difficultyFactor: 180, scalingFactor: 90,  drainBase: 2.5 },
  { id: 'attune-blackflame',   name: 'BlackFlame',   manaType: 'blackflame',   cost: 16, baseValue: 4,  difficultyFactor: 190, scalingFactor: 95,  drainBase: 2.5 },
  { id: 'attune-radiantflames', name: 'Radiant Flames', manaType: 'radiantflames', cost: 16, baseValue: 4, difficultyFactor: 190, scalingFactor: 95, drainBase: 2.5 },
  { id: 'attune-miasma',       name: 'Miasma',       manaType: 'miasma',       cost: 16, baseValue: 4,  difficultyFactor: 190, scalingFactor: 95,  drainBase: 2.5 },
  { id: 'attune-shadowglass',  name: 'Shadow Glass',  manaType: 'shadowglass',  cost: 17, baseValue: 4,  difficultyFactor: 200, scalingFactor: 100, drainBase: 2.5 },

  // ── Exotic Elements ────────────────────────────────────────────────────────
  { id: 'attune-crystal',  name: 'Crystal',  manaType: 'crystal',  cost: 20, baseValue: 3,  difficultyFactor: 240, scalingFactor: 120, drainBase: 3 },
  { id: 'attune-stellar',  name: 'Stellar',  manaType: 'stellar',  cost: 20, baseValue: 3,  difficultyFactor: 240, scalingFactor: 120, drainBase: 3 },
  { id: 'attune-void',     name: 'Void',     manaType: 'void',     cost: 22, baseValue: 3,  difficultyFactor: 260, scalingFactor: 130, drainBase: 3.5 },
  { id: 'attune-soul',     name: 'Soul',     manaType: 'soul',     cost: 22, baseValue: 3,  difficultyFactor: 260, scalingFactor: 130, drainBase: 3.5 },
  { id: 'attune-time',     name: 'Time',     manaType: 'time',     cost: 24, baseValue: 3,  difficultyFactor: 280, scalingFactor: 140, drainBase: 4 },
  { id: 'attune-plasma',   name: 'Plasma',   manaType: 'plasma',   cost: 22, baseValue: 3,  difficultyFactor: 250, scalingFactor: 125, drainBase: 3.5 },
];

export const elementalAttunementDisciplines: DisciplineDefinition[] =
  MANA_CAPACITY_CONFIGS.map(createManaCapacityDiscipline);
