Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwFKMuQnPAEHJ5yA1q4orh
33 lines
932 B
TypeScript
33 lines
932 B
TypeScript
// The other games of Kestrel's Hall, from the family list the kit keeps
|
|
// (family.json, one copy shipped with every game): the hall's front door, and
|
|
// the next table for a player who liked this one. This game is left out of its
|
|
// own list.
|
|
|
|
export interface FamilyGame {
|
|
slug: string;
|
|
name: string;
|
|
url: string;
|
|
pitch: string;
|
|
players: string;
|
|
origin: string;
|
|
}
|
|
|
|
/** The family list: the hall's front door and every game but this one. */
|
|
export interface Family {
|
|
hall: string;
|
|
games: FamilyGame[];
|
|
}
|
|
|
|
const NONE: Family = { hall: '', games: [] };
|
|
|
|
export async function loadFamily(self: string): Promise<Family> {
|
|
try {
|
|
const res = await fetch('/family.json', { cache: 'no-cache' });
|
|
if (!res.ok) return NONE;
|
|
const data = (await res.json()) as { hall?: string; games?: FamilyGame[] };
|
|
return { hall: data.hall ?? '', games: (data.games ?? []).filter((g) => g.slug !== self) };
|
|
} catch {
|
|
return NONE;
|
|
}
|
|
}
|