export type GaugeType = 'baffeur' | 'caresseur' | 'foudroyeur' | 'abreuvoir' | 'dragofesse' | 'mangeoire';
export type StatType = 'serenite' | 'endurance' | 'maturite' | 'amour' | 'xp';

export interface GaugeDef {
  readonly label: string;
  readonly icon: string;
  readonly cssVar: string;
  readonly stat: StatType;
  readonly dir: -1 | 1;
  readonly isXp?: true;
}

export const GAUGE_DEFS: Readonly<Record<GaugeType, GaugeDef>> = {
  baffeur:    { label: 'Baffeur',    icon: '➖', cssVar: '--ser',   stat: 'serenite',  dir: -1 },
  caresseur:  { label: 'Caresseur',  icon: '➕', cssVar: '--ser',   stat: 'serenite',  dir:  1 },
  foudroyeur: { label: 'Foudroyeur', icon: '⚡', cssVar: '--end',   stat: 'endurance', dir:  1 },
  abreuvoir:  { label: 'Abreuvoir',  icon: '💧', cssVar: '--mat',   stat: 'maturite',  dir:  1 },
  dragofesse: { label: 'Dragofesse', icon: '❤',  cssVar: '--amour', stat: 'amour',     dir:  1 },
  mangeoire:  { label: 'Mangeoire',  icon: '🍖', cssVar: '--xp',    stat: 'xp',        dir:  1, isXp: true },
};

export interface StatDef {
  readonly label: string;
  readonly min: number;
  readonly max: number;
  readonly cssVar: string;
  readonly isLevel?: true;
}

export const STAT_DEFS: Readonly<Record<StatType, StatDef>> = {
  serenite:  { label: 'Sérénité',  min: -5000, max: 5000,  cssVar: '--ser' },
  endurance: { label: 'Endurance', min: 0,     max: 20000, cssVar: '--end' },
  maturite:  { label: 'Maturité',  min: 0,     max: 20000, cssVar: '--mat' },
  amour:     { label: 'Amour',     min: 0,     max: 20000, cssVar: '--amour' },
  xp:        { label: 'Niveau',    min: 1,     max: 200,   cssVar: '--xp', isLevel: true },
};

export const DEFAULT_TARGETS: Readonly<Record<GaugeType, number>> = {
  baffeur: -5000, caresseur: 40, foudroyeur: 20000, abreuvoir: 20000, dragofesse: 20000, mangeoire: 100,
};

export function targetRange(gid: GaugeType): { min: number; max: number } {
  const def = GAUGE_DEFS[gid];
  if (def.isXp) return { min: 1, max: 200 };
  const sd = STAT_DEFS[def.stat];
  if (def.dir < 0) return { min: sd.min, max: 0 };
  if (def.dir > 0 && sd.min < 0) return { min: 0, max: sd.max };
  return { min: sd.min, max: sd.max };
}
