import { timeToGain } from '@domain/services/GaugeCalculator'; import { xpForLevel } from '@domain/value-objects/XpTable'; import type { GaugeType } from '@domain/value-objects/GaugeType'; export interface XpEtaInput { currentLevel: number; target: number | null; gaugeLevels: Readonly>; activeGauges: readonly string[]; } export interface XpEtaResult { done: boolean; seconds: number; needsGauge?: GaugeType; } export class XpCalculator { computeEta(input: XpEtaInput): XpEtaResult { const { currentLevel, target, gaugeLevels, activeGauges } = input; if (target === null || target === undefined) return { done: false, seconds: 0 }; if (currentLevel >= target) return { done: true, seconds: 0 }; if (!activeGauges.includes('mangeoire')) return { done: false, seconds: Infinity, needsGauge: 'mangeoire' }; const gl = gaugeLevels['mangeoire'] ?? 0; const xpNeeded = Math.max(0, xpForLevel(target) - xpForLevel(currentLevel)); if (xpNeeded <= 0) return { done: true, seconds: 0 }; const sec = timeToGain(gl, xpNeeded); return { done: false, seconds: sec }; } }