// ─── Frame Definitions ───────────────────────────────────────────────────
// Physical combat characteristics for golems: damage, speed, armor pierce, magic affinity, special.

import type { FrameDefinition } from './types';
import { elemCost, rawCost } from './types';

const EARTH_FRAME: FrameDefinition = {
  id: 'earth',
  name: 'Earth Frame',
  description: 'A sturdy construct of stone and soil. Balanced but unremarkable.',
  baseDamage: 6,
  attackSpeed: 1.2,
  armorPierce: 0.05,
  magicAffinity: 0.3,
  aoeTargets: 1,
  element: 'earth',
  specialEffect: 'none',
  summonCost: [rawCost(5)],
  unlockRequirement: {
    type: 'attunement_level',
    attunement: 'fabricator',
    level: 2,
  },
};

const SAND_FRAME: FrameDefinition = {
  id: 'sand',
  name: 'Sand Frame',
  description: 'A shifting construct of sand particles. Hits multiple enemies with high armor pierce.',
  baseDamage: 8,
  attackSpeed: 1.0,
  armorPierce: 0.6,
  magicAffinity: 0.5,
  aoeTargets: 2,
  element: 'sand',
  specialEffect: 'aoe',
  summonCost: [elemCost('sand', 8)],
  unlockRequirement: {
    type: 'mana_unlocked',
    manaType: 'sand',
  },
};

const FROST_FRAME: FrameDefinition = {
  id: 'frost',
  name: 'Frost Frame',
  description: 'An icy construct that slows enemies on hit. High magic affinity.',
  baseDamage: 10,
  attackSpeed: 1.2,
  armorPierce: 0.25,
  magicAffinity: 0.8,
  aoeTargets: 1,
  element: 'frost',
  specialEffect: 'slow',
  summonCost: [elemCost('frost', 10)],
  unlockRequirement: {
    type: 'mana_unlocked',
    manaType: 'frost',
  },
};

const CRYSTAL_FRAME: FrameDefinition = {
  id: 'crystal',
  name: 'Crystal Frame',
  description: 'A prismatic construct dealing high damage with precision. Very high magic affinity.',
  baseDamage: 14,
  attackSpeed: 1.8,
  armorPierce: 0.15,
  magicAffinity: 0.9,
  aoeTargets: 1,
  element: 'crystal',
  specialEffect: 'none',
  summonCost: [elemCost('crystal', 12)],
  unlockRequirement: {
    type: 'mana_unlocked',
    manaType: 'crystal',
  },
};

const STEEL_FRAME: FrameDefinition = {
  id: 'steel',
  name: 'Steel Frame',
  description: 'Forged from metal, this frame delivers devastating attacks with high armor pierce.',
  baseDamage: 18,
  attackSpeed: 1.6,
  armorPierce: 0.5,
  magicAffinity: 0.5,
  aoeTargets: 1,
  element: 'metal',
  specialEffect: 'none',
  summonCost: [elemCost('metal', 14)],
  unlockRequirement: {
    type: 'mana_unlocked',
    manaType: 'metal',
  },
};

const SHADOWGLASS_FRAME: FrameDefinition = {
  id: 'shadowglass',
  name: 'Shadowglass Frame',
  description: 'Volcanic glass animated by shadow. Extremely fast AoE attacks with devastating magic affinity.',
  baseDamage: 20,
  attackSpeed: 2.5,
  armorPierce: 0.65,
  magicAffinity: 0.95,
  aoeTargets: 2,
  element: 'shadowglass',
  specialEffect: 'aoe',
  summonCost: [elemCost('shadowglass', 18), rawCost(10)],
  unlockRequirement: {
    type: 'mana_unlocked',
    manaType: 'shadowglass',
  },
};

const CRYSTAL_STEEL_HYBRID_FRAME: FrameDefinition = {
  id: 'crystalSteelHybrid',
  name: 'Crystal-Steel Hybrid Frame',
  description: 'An advanced hybrid frame capable of housing Guardian Cores. Highest combined stats. Required for Guardian Constructs.',
  baseDamage: 22,
  attackSpeed: 2.8,
  armorPierce: 0.7,
  magicAffinity: 1.0,
  aoeTargets: 1,
  element: 'crystal',
  specialEffect: 'guardianConstruct',
  summonCost: [elemCost('crystal', 20), elemCost('metal', 15), rawCost(15)],
  unlockRequirement: {
    type: 'attunement_level',
    attunement: 'fabricator',
    level: 5,
  },
};

// ─── FRAME REGISTRY ─────────────────────────────────────────────────────

export const FRAMES: Record<string, FrameDefinition> = {
  [EARTH_FRAME.id]: EARTH_FRAME,
  [SAND_FRAME.id]: SAND_FRAME,
  [FROST_FRAME.id]: FROST_FRAME,
  [CRYSTAL_FRAME.id]: CRYSTAL_FRAME,
  [STEEL_FRAME.id]: STEEL_FRAME,
  [SHADOWGLASS_FRAME.id]: SHADOWGLASS_FRAME,
  [CRYSTAL_STEEL_HYBRID_FRAME.id]: CRYSTAL_STEEL_HYBRID_FRAME,
};

export const ALL_FRAMES = [
  EARTH_FRAME,
  SAND_FRAME,
  FROST_FRAME,
  CRYSTAL_FRAME,
  STEEL_FRAME,
  SHADOWGLASS_FRAME,
  CRYSTAL_STEEL_HYBRID_FRAME,
];
