// Pure derivations for the statistics screen, extracted so they are unit-testable. import type { Stats } from './model'; /** gamesPlayed is the total finished games (wins + losses + draws). */ export function gamesPlayed(s: Stats): number { return s.wins + s.losses + s.draws; } /** winRate is the percentage of finished games won, rounded; 0 when none played. */ export function winRate(s: Stats): number { const n = gamesPlayed(s); return n > 0 ? Math.round((s.wins / n) * 100) : 0; }