export type CharacterClass =
  | "WARRIOR"
  | "MAGE"
  | "ROGUE"
  | "RANGER"
  | "PALADIN"
  | "ENGINEER"
  | "MERCHANT"
  | "SCHOLAR"
  | "BERSERKER"
  | "NECROMANCER";

export interface CharacterClassConfig {
  value: CharacterClass;
  name: string;
  icon: string;
  desc?: string;
}

export const CHARACTER_CLASSES: CharacterClassConfig[] = [
  {
    value: "WARRIOR",
    name: "Guerrier",
    icon: "⚔️",
    desc: "Maître du combat au corps à corps",
  },
  {
    value: "MAGE",
    name: "Mage",
    icon: "🔮",
    desc: "Manipulateur des arcanes",
  },
  {
    value: "ROGUE",
    name: "Voleur",
    icon: "🗡️",
    desc: "Furtif et mortel",
  },
  {
    value: "RANGER",
    name: "Rôdeur",
    icon: "🏹",
    desc: "Chasseur des terres sauvages",
  },
  {
    value: "PALADIN",
    name: "Paladin",
    icon: "🛡️",
    desc: "Protecteur sacré",
  },
  {
    value: "ENGINEER",
    name: "Ingénieur",
    icon: "⚙️",
    desc: "Créateur d'artefacts",
  },
  {
    value: "MERCHANT",
    name: "Marchand",
    icon: "💰",
    desc: "Maître du commerce",
  },
  {
    value: "SCHOLAR",
    name: "Érudit",
    icon: "📚",
    desc: "Gardien du savoir",
  },
  {
    value: "BERSERKER",
    name: "Berserker",
    icon: "🔥",
    desc: "Rage destructrice",
  },
  {
    value: "NECROMANCER",
    name: "Nécromancien",
    icon: "💀",
    desc: "Maître des morts",
  },
];

export const CHARACTER_CLASS_MAP: Record<CharacterClass, CharacterClassConfig> =
  CHARACTER_CLASSES.reduce(
    (acc, cls) => {
      acc[cls.value] = cls;
      return acc;
    },
    {} as Record<CharacterClass, CharacterClassConfig>
  );

export function getCharacterClassIcon(
  characterClass: CharacterClass | null | undefined
): string {
  if (!characterClass) return "";
  return CHARACTER_CLASS_MAP[characterClass]?.icon || "";
}

export function getCharacterClassName(
  characterClass: CharacterClass | null | undefined
): string {
  if (!characterClass) return "";
  return CHARACTER_CLASS_MAP[characterClass]?.name || "";
}

export function getCharacterClassConfig(
  characterClass: CharacterClass | null | undefined
): CharacterClassConfig | null {
  if (!characterClass) return null;
  return CHARACTER_CLASS_MAP[characterClass] || null;
}

export function isValidCharacterClass(
  characterClass: string | null | undefined
): characterClass is CharacterClass {
  if (!characterClass) return false;
  return characterClass in CHARACTER_CLASS_MAP;
}
