The default rules and side for a new table are preferences in the panel, and the hall's selectors set the same

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 18:58:51 -04:00
co-authored by Claude Fable 5.1
parent aa4f86bc56
commit dcfbd38ae6
2 changed files with 13 additions and 9 deletions
+3 -6
View File
@@ -16,13 +16,10 @@
let name = $state(playerName());
let code = $state('');
/** The host's choices for the next table, from the game's declared options. */
// The host's last choices come back as the defaults; a regular does not re-pick them each visit.
let options = $state<Record<string, string>>(
// A new table starts from the preferences' table defaults; the hall's selectors set the same keys.
const options = $derived<Record<string, string>>(
Object.fromEntries((game.options ?? []).map((o) => [o.key, o.choices.some((c) => c.value === prefs[`table.${o.key}`]) ? String(prefs[`table.${o.key}`]) : o.default]))
);
$effect(() => {
for (const o of game.options ?? []) if (prefs[`table.${o.key}`] !== options[o.key]) setPref(`table.${o.key}`, options[o.key]);
});
let prefsOpen = $state(false);
/** The hall's still of the opening position, on whichever board the selector names. */
@@ -192,7 +189,7 @@
<div class="option-block">
<label class="option">
<span>{o.label}</span>
<select bind:value={options[o.key]}>
<select value={options[o.key]} onchange={(e) => setPref(`table.${o.key}`, e.currentTarget.value)}>
{#each o.choices as c (c.value)}<option value={c.value}>{c.label}</option>{/each}
</select>
</label>