Player preferences: art set, auto-grab, flourishes

A ⚙ preferences slip in the masthead, saved to this device:
- Token art, all or nothing: the photographed cardboard or the
  hand-drawn vectors (the workshop's per-category query params stay as
  the undocumented editing override).
- Ending a turn on a lone grabbable treasure picks it up on the way
  out — never on your own home, never when two share the square.
- Spell flourishes on or off, honored by the live board and the
  replay reel alike (trap notices still fire; they are information).
Preferences change what you see or what routine commands the client
sends for you — never what is legal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138A8CjeQRpvzKxuMfz1Bqc
This commit is contained in:
Eric Wagoner
2026-08-19 09:45:12 -04:00
co-authored by Claude Fable 5
parent 5310fbdca9
commit 6aae40ad5f
4 changed files with 110 additions and 11 deletions
+41
View File
@@ -0,0 +1,41 @@
// Player preferences: purely client-side taste, saved on this device.
// Nothing here touches the rules — a preference may change what you SEE
// or what routine commands the client sends on your behalf, never what
// is legal.
export interface Prefs {
/** Token art: the photographed cardboard, or the hand-drawn vectors. */
art: "photo" | "drawn";
/** Standing on lone grabbable gold at end of turn: pick it up first. */
autoGrab: boolean;
/** Spell flourishes (the animated effects layer). */
flourishes: boolean;
}
const KEY = "wizwar-prefs";
function load(): Prefs {
const fallback: Prefs = { art: "photo", autoGrab: false, flourishes: true };
try {
const raw = localStorage.getItem(KEY);
if (!raw) return fallback;
const p = JSON.parse(raw) as Partial<Prefs>;
return {
art: p.art === "drawn" ? "drawn" : "photo",
autoGrab: p.autoGrab === true,
flourishes: p.flourishes !== false,
};
} catch {
return fallback;
}
}
export const prefs = $state<Prefs>(load());
export function savePrefs(): void {
try {
localStorage.setItem(KEY, JSON.stringify(prefs));
} catch {
// A full or blocked localStorage loses persistence, not the session.
}
}