game.ts 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** Single guess with server feedback */
  2. export interface GuessEntry {
  3. guess: string;
  4. colors: string[];
  5. }
  6. /** Lifetime statistics */
  7. export interface GameStats {
  8. gamesPlayed: number;
  9. wins: number;
  10. histogram: number[]; // index 0=1 attempt, 5=6 attempts, 6=fail
  11. currentStreak: number;
  12. maxStreak: number;
  13. }
  14. /** All browser-persisted state */
  15. export interface PersistedState {
  16. rulesSeen: boolean;
  17. stats: GameStats;
  18. currentGame?: {
  19. wordId: number;
  20. guesses: GuessEntry[];
  21. };
  22. skillMetric: number;
  23. }
  24. /** Default persisted state for first-time visitors */
  25. export function defaultPersistedState(): PersistedState {
  26. return {
  27. rulesSeen: false,
  28. stats: {
  29. gamesPlayed: 0,
  30. wins: 0,
  31. histogram: [0, 0, 0, 0, 0, 0, 0],
  32. currentStreak: 0,
  33. maxStreak: 0,
  34. },
  35. currentGame: undefined,
  36. skillMetric: 3.0,
  37. };
  38. }