import type { LobbyPlayer, Observation } from '../../api/types' import { Button } from '../../components/Button/Button' import styles from './GameOver.module.css' interface GameOverProps { observation: Observation players: LobbyPlayer[] isHost: boolean onShowScores: () => void onBackToLobby: () => void onLeave: () => void } export function GameOver({ observation, players, isHost, onShowScores, onBackToLobby, onLeave }: GameOverProps) { const ranking = observation.scores .map((score, seat) => ({ seat, score })) .sort((a, b) => b.score - a.score) const winners = new Set(observation.winners) const youWon = winners.has(observation.player) return (

{youWon ? 'You win! ✦' : `${players[ranking[0].seat]?.name ?? 'Someone'} wins!`}

    {ranking.map(({ seat, score }, index) => (
  1. {index + 1}. {players[seat]?.name ?? `Player ${seat + 1}`} {seat === observation.player && (you)} {score}
  2. ))}
{isHost ? ( ) : ( The host can start a new game. )}
) }