/** Single guess with server feedback */
export interface GuessEntry {
  guess: string;
  colors: string[];
}

/** Lifetime statistics */
export interface GameStats {
  gamesPlayed: number;
  wins: number;
  histogram: number[]; // index 0=1 attempt, 5=6 attempts, 6=fail
  currentStreak: number;
  maxStreak: number;
}

/** All browser-persisted state */
export interface PersistedState {
  rulesSeen: boolean;
  stats: GameStats;
  currentGame?: {
    wordId: number;
    guesses: GuessEntry[];
  };
  skillMetric: number;
}

/** Default persisted state for first-time visitors */
export function defaultPersistedState(): PersistedState {
  return {
    rulesSeen: false,
    stats: {
      gamesPlayed: 0,
      wins: 0,
      histogram: [0, 0, 0, 0, 0, 0, 0],
      currentStreak: 0,
      maxStreak: 0,
    },
    currentGame: undefined,
    skillMetric: 3.0,
  };
}
