feat(offline): per-seat medals in local games; drop the you-won text + lobby medal
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 1m6s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m42s

For a local (offline) game the outcome is not always about a single
'you' (hotseat is 2-4 players), so:
- Game.svelte: a finished local game no longer shows the viewer-centric
  'you won/lost/draw' status; instead each seat plaque shows a per-seat
  place medal, left of the name (result.seatMedal — trophy for the winner,
  then places by score; a draw medals everyone).
- Lobby.svelte: a local game shows no lobby medal (resultBadge is
  viewer-centric and no seat matches the account) — its result lives on
  the in-game plaques.
- result.ts: seatMedal(game, seat), unit-tested.
This commit is contained in:
Ilia Denisov
2026-07-07 14:54:44 +02:00
parent 52d0c559f9
commit 0ed34c7720
4 changed files with 57 additions and 5 deletions
+17
View File
@@ -30,3 +30,20 @@ export function resultBadge(game: GameView, myId: string): ResultBadge {
if (rank === 3) return { key: 'result.place3', emoji: '🥉' };
return { key: 'result.place4', emoji: '🏅' };
}
/**
* seatMedal returns a per-SEAT place emoji for a finished game (empty while it is still in progress),
* so a local (offline) game can show each player's medal on their plaque instead of a single
* viewer-centric "you won/lost". The winner takes the trophy; the rest place by score (a draw — no
* winner — gives every seat the medal). Mirrors the ranking in resultBadge, keyed by seat not viewer.
*/
export function seatMedal(game: GameView, seat: number): string {
if (game.status !== 'finished') return '';
const s = game.seats.find((x) => x.seat === seat);
if (!s) return '';
if (s.isWinner) return '🏆';
if (!game.seats.some((x) => x.isWinner)) return '🏅'; // a draw: no winner
const ahead = game.seats.filter((x) => !x.isWinner && x.seat !== seat && x.score > s.score).length;
const rank = 2 + ahead;
return rank === 2 ? '🥈' : rank === 3 ? '🥉' : '🏅';
}