Every table option is also a preference: the choice a new table starts with, shown in the panel

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:57:25 -04:00
co-authored by Claude Fable 5.1
parent 3825dfb44c
commit 74df9a253a
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
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.
// A new table starts from the preferences' table defaults, which the hall's own selectors also set.
let options = $state<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]))
);
+10 -3
View File
@@ -21,7 +21,16 @@ export const KIT_PREFERENCES: Preference[] = [
{ key: 'confirmMoves', label: 'Confirm a move before it is sent', kind: 'toggle', default: false }
];
export const PREFERENCES: Preference[] = [...KIT_PREFERENCES, ...(game.preferences ?? [])];
/** Every table option is also a preference: the choice a new table starts with. The hall reads and writes the same keys. */
const TABLE_DEFAULTS: Preference[] = (game.options ?? []).map((o) => ({
key: `table.${o.key}`,
label: `${o.label}, for a new table`,
kind: 'choice',
choices: o.choices.map((c) => ({ value: c.value, label: c.label })),
default: o.default
}));
export const PREFERENCES: Preference[] = [...KIT_PREFERENCES, ...TABLE_DEFAULTS, ...(game.preferences ?? [])];
const KEY = '__SLUG__:prefs';
@@ -38,8 +47,6 @@ function load(): Record<string, boolean | string> {
if (p.kind === 'toggle' && typeof v === 'boolean') base[p.key] = v;
if (p.kind === 'choice' && typeof v === 'string' && p.choices?.some((c) => c.value === v)) base[p.key] = v;
}
// The hall's last table options ride along under table.<key>, undeclared.
for (const [k, v] of Object.entries(saved)) if (k.startsWith('table.') && typeof v === 'string') base[k] = v;
} catch {
// Without storage the defaults apply for this visit.
}