diff --git a/src/routes/join/[code]/+page.svelte b/src/routes/join/[code]/+page.svelte index 108f683..a39df36 100644 --- a/src/routes/join/[code]/+page.svelte +++ b/src/routes/join/[code]/+page.svelte @@ -30,6 +30,16 @@ const link = $derived(`${location.origin}/join/${roomId}`); const watching = $derived(room?.spectating ?? false); + /** The tab's title: whose move it is, or how the game stands, so a glance at the tab bar says whether it is your turn. */ + const title = $derived.by(() => { + const g = room?.state; + if (!room || !g) return `table ${roomId}`; + const seat = g.seats.find((id) => g.players[id].side === g.toMove); + const toMove = seat ? g.players[seat].name : g.toMove; + if (g.over) return g.over.winner === null ? 'a draw' : g.over.winner === room.me ? 'you win' : `${g.players[g.over.winner].name} wins`; + if (watching) return `${room.others.map((s) => s.name).join(' and ')}, ${toMove} to move`; + return seat === room.me ? 'your move' : `${toMove} to move`; + }); // Return to a held seat, or take a place in the gallery and offer one. A link from the keeper carries a seat: // it leaves the address bar at once, is kept only once the server takes it, and never replaces a seat that @@ -158,7 +168,7 @@ - Wyrm: a game + Wyrm: {title}