// ─── Element Distance from Raw Mana ───────────────────────────────────────────
// Every mana type has a distance from raw mana. Used for:
// 1. Calculating conversion cost ratios
// 2. Calculating meditation multiplier strength for that element's conversion
//
// Distance tiers:
//   Raw          = 0
//   Base (7)     = 1
//   Utility (1)  = 1
//   Composite(8) = 2
//   Exotic (5)   = 3
//   Time (1)     = 4

const ELEMENT_DISTANCES: Record<string, number> = {
  raw: 0,
  // Base (distance 1)
  fire: 1,
  water: 1,
  air: 1,
  earth: 1,
  light: 1,
  dark: 1,
  death: 1,
  // Utility (distance 1)
  transference: 1,
  // Composite (distance 2)
  metal: 2,
  sand: 2,
  lightning: 2,
  frost: 2,
  blackflame: 2,
  radiantflames: 2,
  miasma: 2,
  shadowglass: 2,
  // Exotic tier 1 (distance 3)
  crystal: 3,
  stellar: 3,
  void: 3,
  soul: 3,
  plasma: 3,
  // Exotic tier 2 (distance 4)
  time: 4,
};

/** Return the distance of an element from raw mana. Default 0 for unknown. */
export function getElementDistance(elementId: string): number {
  return ELEMENT_DISTANCES[elementId] ?? 0;
}

/** Return the highest distance among a list of elements. */
export function getMaxDistance(elementIds: string[]): number {
  let max = 0;
  for (const id of elementIds) {
    const d = getElementDistance(id);
    if (d > max) max = d;
  }
  return max;
}
