Table options: the host's choices when opening a table, declared by the game, recorded on the room line

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
Eric Wagoner
2026-09-23 12:45:42 -04:00
co-authored by Claude Fable 5.1
parent 2ab6dc4b5f
commit 63bd154798
10 changed files with 89 additions and 27 deletions
+29 -2
View File
@@ -13,6 +13,8 @@
let name = $state(playerName());
let code = $state('');
/** The host's choices for the next table, from the game's declared options. */
let options = $state<Record<string, string>>(Object.fromEntries((game.options ?? []).map((o) => [o.key, o.default])));
let busy = $state(false);
let error = $state('');
let seats = $state(allSeats());
@@ -157,9 +159,21 @@
<span>Your name</span>
<input type="text" bind:value={name} maxlength={NAME_MAX} placeholder="e.g. Morwenna" autocomplete="nickname" />
</label>
<button type="button" class="commit primary" disabled={!ready || busy} onclick={() => open(() => Room.createWithBot(name.trim()))}>Play now against the bot</button>
{#if game.options?.length}
<div class="options">
{#each game.options as o (o.key)}
<label class="option">
<span>{o.label}</span>
<select bind:value={options[o.key]}>
{#each o.choices as c (c.value)}<option value={c.value}>{c.label}</option>{/each}
</select>
</label>
{/each}
</div>
{/if}
<button type="button" class="commit primary" disabled={!ready || busy} onclick={() => open(() => Room.createWithBot(name.trim(), options))}>Play now against the bot</button>
<div class="ways">
<button type="button" class="quiet" disabled={!ready || busy} onclick={() => open(() => Room.create(name.trim(), game.seatIds.length))}>Open a table</button>
<button type="button" class="quiet" disabled={!ready || busy} onclick={() => open(() => Room.create(name.trim(), game.seatIds.length, options))}>Open a table</button>
<form class="joinform" onsubmit={join}>
<span class="or">or join one</span>
<input type="text" class="code" bind:value={code} maxlength="4" placeholder="CODE" autocapitalize="characters" autocomplete="off" aria-label="room code" />
@@ -551,4 +565,17 @@
.family li + li {
margin-top: 0.3rem;
}
.options {
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1.2rem;
margin: 0.2rem 0 0.6rem;
}
.option {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.9rem;
}
</style>