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:
co-authored by
Claude Fable 5.1
parent
aa4f86bc56
commit
dcfbd38ae6
+10
-3
@@ -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 = 'hnefatafl: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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user