// ─── Core Definitions ────────────────────────────────────────────────────
// Power sources for golems. Determine mana types, capacity, regen, upkeep, duration.

import type { CoreDefinition } from './types';
import { elemCost } from './types';

// ───_BASIC CORE ────────────────────────────────────────────────────────────
// Fabricator 2 — single Earth mana, modest stats
const BASIC_CORE: CoreDefinition = {
  id: 'basic',
  tier: 1,
  name: 'Basic Core',
  description: 'A simple earth-infused core. Provides modest mana capacity and single-element support.',
  manaTypes: ['earth'],
  manaCapacity: 50,
  manaRegen: 0.5,
  maxRoomDuration: 3,
  summonCost: [elemCost('earth', 10)],
  primaryManaType: 'earth',
  tierMultiplier: 1.0,
  unlockRequirement: {
    type: 'attunement_level',
    attunement: 'fabricator',
    level: 2,
  },
};

// ─── INTERMEDIATE CORE ────────────────────────────────────────────────────
// Fabricator 4 + Enchanter 2 — choose 2 mana types
const INTERMEDIATE_CORE: CoreDefinition = {
  id: 'intermediate',
  tier: 2,
  name: 'Intermediate Core',
  description: 'A refined crystal core supporting two mana types. Player selects from unlocked elements.',
  manaTypes: ['earth'], // Default; player overrides with chosen types
  manaCapacity: 100,
  manaRegen: 1.5,
  maxRoomDuration: 4,
  summonCost: [elemCost('crystal', 20)],
  primaryManaType: 'crystal',
  tierMultiplier: 1.5,
  unlockRequirement: {
    type: 'dual_attunement',
    attunements: ['fabricator', 'enchanter'],
    levels: [4, 2],
  },
};

// ─── ADVANCED CORE ───────────────────────────────────────────────────────
// Fabricator 6 + Enchanter 3 — choose 3 mana types
const ADVANCED_CORE: CoreDefinition = {
  id: 'advanced',
  tier: 3,
  name: 'Advanced Core',
  description: 'A powerful crystal core supporting three mana types. Player selects from unlocked elements.',
  manaTypes: ['earth'], // Default; player overrides with chosen types
  manaCapacity: 200,
  manaRegen: 3.0,
  maxRoomDuration: 5,
  summonCost: [elemCost('crystal', 30)],
  primaryManaType: 'crystal',
  tierMultiplier: 2.0,
  unlockRequirement: {
    type: 'dual_attunement',
    attunements: ['fabricator', 'enchanter'],
    levels: [6, 3],
  },
};

// ─── GUARDIAN CORE ───────────────────────────────────────────────────────
// Invoker 5 + Fabricator 5 + Guardian Pact — guardian-specific mana types
const GUARDIAN_CORE: CoreDefinition = {
  id: 'guardian',
  tier: 4,
  name: 'Guardian Core',
  description: 'A legendary core imbued with guardian energy. Provides all mana types granted by the chosen Guardian. Required for Guardian Constructs.',
  manaTypes: ['earth'], // Overridden by guardian-specific types when assigned
  manaCapacity: 500,
  manaRegen: 10.0,
  maxRoomDuration: 8,
  summonCost: [elemCost('earth', 50)], // Guardian-specific in practice
  primaryManaType: 'earth', // Overridden by guardian pact
  tierMultiplier: 3.0,
  unlockRequirement: {
    type: 'guardian_pact',
    attunements: ['invoker', 'fabricator'],
    levels: [5, 5],
  },
};

// ─── CORE REGISTRY ───────────────────────────────────────────────────────

export const CORES: Record<string, CoreDefinition> = {
  [BASIC_CORE.id]: BASIC_CORE,
  [INTERMEDIATE_CORE.id]: INTERMEDIATE_CORE,
  [ADVANCED_CORE.id]: ADVANCED_CORE,
  [GUARDIAN_CORE.id]: GUARDIAN_CORE,
};

export const ALL_CORES = [BASIC_CORE, INTERMEDIATE_CORE, ADVANCED_CORE, GUARDIAN_CORE];
