import type { SpellCost } from '@/lib/game/types';
import { Flame, Droplet, Wind, Mountain, Sun, Moon, Leaf, Skull } from 'lucide-react';

// Format spell cost for display
export function formatSpellCost(cost: SpellCost): string {
  if (cost.type === 'raw') {
    return `${cost.amount} raw`;
  }
  const elemDef = ELEMENTS[cost.element || ''];
  return `${cost.amount} ${elemDef?.sym || '?'}`;
}

// Format time (hour to HH:MM)
export function formatTime(hour: number): string {
  const h = Math.floor(hour);
  const m = Math.floor((hour % 1) * 60);
  return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}`;
}

// Format study time
export function formatStudyTime(hours: number): string {
  if (hours < 1) return `${Math.round(hours * 60)}m`;
  return `${hours.toFixed(1)}h`;
}

// Element icons mapping
export const ELEMENT_ICONS: Record<string, typeof Flame> = {
  fire: Flame,
  water: Droplet,
  wind: Wind,
  earth: Mountain,
  light: Sun,
  shadow: Moon,
  nature: Leaf,
  death: Skull,
};

// Import ELEMENTS at the bottom to avoid circular deps
import { ELEMENTS } from '@/lib/game/constants';

// Get cost color
export function getSpellCostColor(cost: SpellCost): string {
  if (cost.type === 'raw') {
    return '#60A5FA'; // Blue for raw mana
  }
  return ELEMENTS[cost.element || '']?.color || '#9CA3AF';
}
