A table's tab says whose move it is, who is playing, or who won, in place of "a game"
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CCLa2PaEeCj8njQZSWGqHx
This commit is contained in:
1 parent
65bdf4ecfb
commit
9a43952ad1
1 file changed
+11
-1
@@ -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 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Wyrm: a game</title>
|
||||
<title>Wyrm: {title}</title>
|
||||
</svelte:head>
|
||||
|
||||
<header class="masthead">
|
||||
|
||||
Reference in new issue
Block a user