import { basisTotal, etaDays, paceDays, playerEstimatedTotal } from '../estimate' import type { EstimateResult } from '../estimate' import { fmtEta, fmtHours } from '../format' import type { EstimateBasis, Filters, PaceVsHLTB, WebStateInfo } from '../types' interface Props { result: EstimateResult filters: Filters state: WebStateInfo presets: number[] defaultQualifying: number paceVsHltb: PaceVsHLTB | null } interface CardData { basis: EstimateBasis title: string blurb: string } const CARDS: CardData[] = [ { basis: 'rush', title: 'Rush', blurb: 'Typical fast completionist' }, { basis: 'leisure', title: 'Leisure', blurb: 'Slow, comfortable 100%' }, { basis: 'worst', title: 'Worst case', blurb: 'Max recorded time' }, { basis: 'pace', title: 'At your pace', blurb: 'Based on games finished' }, ] const STYLE_LABELS: Record = { faster_than_rush: 'Faster than rush', rush_to_leisure: 'Between rush and leisure', slower_than_leisure: 'Slower than leisure', unknown: 'Unknown', } function TargetBanner({ result, filters }: Props) { if (!filters.targetDate) return null const now = new Date() const target = new Date(filters.targetDate) const days = Math.max(1, Math.ceil((target.getTime() - now.getTime()) / 86400000)) let need: string if (filters.basis === 'pace') { const perDay = result.remainingGames / days need = `${perDay.toFixed(2)} games/day` } else { const total = basisTotal(result, filters.basis) as number need = `${(total / days).toFixed(1)} h/day` } return (
To finish {result.remainingGames} games by{' '} {filters.targetDate} ({days} days) on the{' '} {filters.basis} model, you need {need}.
) } function PlayerSpeedInsight({ result, paceVsHltb, presets, }: Pick) { const pace = paceVsHltb const estimated = playerEstimatedTotal(result.rushTotal, result.leisureTotal, pace) if (!pace || pace.calibration_count === 0) { return (
Your Play Style vs HLTB

No calibration data yet. Finish games (100% achievements) and re-run{' '} stats to see your pace estimate.

) } return (
Your Play Style vs HLTB
Calibration games {pace.calibration_count} {pace.ratio_vs_rush !== -1 && ( <> vs Rush speed {pace.ratio_vs_rush.toFixed(2)}× )} {pace.ratio_vs_leisure !== -1 && ( <> vs Leisure speed {pace.ratio_vs_leisure.toFixed(2)}× )} {pace.interpolation_t !== -1 && ( <> Interpolation t {pace.interpolation_t.toFixed(3)} )} Play style {STYLE_LABELS[pace.player_style] ?? pace.player_style}
{estimated !== null && (
Estimated total at your pace:{' '} {fmtHours(estimated)}
{presets.map((h) => { const days = estimated > 0 ? Math.floor(estimated / h) : null return (
{h} h/day {fmtEta(days)}
) })}
)}
) } export function SummaryCards(props: Props) { const { result, filters, state, presets, paceVsHltb } = props return (
{result.remainingGames.toLocaleString()} games in scope
CLI default qualifies {props.defaultQualifying} {result.remainingGames === props.defaultQualifying && ( ✓ match )}
{CARDS.map((c) => { const active = filters.basis === c.basis const isPace = c.basis === 'pace' const total = basisTotal(result, c.basis) const headlineEta = isPace ? paceDays(result.remainingGames, state.pace_games_per_day) : etaDays(total as number, filters.dailyHours) return (
{c.title}
{c.blurb}
{isPace ? `${state.pace_games_per_day || 0} games/day` : fmtHours(total as number)}
{isPace && !state.pace_games_per_day ? 'No start date set' : fmtEta(headlineEta)}
{!isPace && (
{presets.map((h) => (
{h} h/day {fmtEta(etaDays(total as number, h))}
))}
)}
) })}
) }