export type PlayerId = 'p1' | 'p2';

export interface Player {
  id: PlayerId;
  name: string;
  alias: string;
}

/** Five Crowns and golf are lowWins; most games are highWins. */
export type ScoringMode = 'highWins' | 'lowWins';

export interface Game {
  id: string;
  name: string;
  emoji: string;
  scoring: ScoringMode;
}

/** 'score-stands' = dispute rejected, original result kept. 'overturned' = winner flipped. */
export type DisputeStatus = 'open' | 'score-stands' | 'overturned';

export interface Dispute {
  statement: string;
  filedBy: PlayerId;
  status: DisputeStatus;
  filedAt: string;
}

export interface Match {
  id: string;
  gameId: string;
  scores: Record<PlayerId, number>;
  /** null = tie */
  winnerId: PlayerId | null;
  note?: string;
  playedAt: string;
  /** true when cheat-check randomly demanded a confirmation for this match */
  cheatCheckFlagged?: boolean;
  dispute?: Dispute;
}

export type ChaosLevel = 'off' | 'mild' | 'medium' | 'spicy';

export interface AppSettings {
  chaos: ChaosLevel;
  /** which player is using this phone */
  currentPlayerId: PlayerId;
}

export interface AppState {
  players: Record<PlayerId, Player>;
  games: Game[];
  /** newest first */
  matches: Match[];
  settings: AppSettings;
}
