1a9e5e2c18
- Rules abstraction (5e + pf2e) behind one interface, fully tested - Pure combat engine: turn-order safe across add/remove/reorder/init-change - Dexie storage with real cascade deletes + Zod validation on write - Seedable dice engine with notation parser - Lazy SRD compendium (code-split), bestiary -> combat - Strict TS, 54 unit tests, Playwright e2e smoke (all green) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16 lines
511 B
TypeScript
16 lines
511 B
TypeScript
import { useLiveQuery } from 'dexie-react-hooks';
|
|
import { encountersRepo } from '@/lib/db/repositories';
|
|
import type { Encounter } from '@/lib/schemas';
|
|
|
|
export function useEncounters(campaignId: string): Encounter[] {
|
|
return useLiveQuery(() => encountersRepo.listByCampaign(campaignId), [campaignId], []);
|
|
}
|
|
|
|
export function useEncounter(id: string | null): Encounter | undefined {
|
|
return useLiveQuery(
|
|
() => (id ? encountersRepo.get(id) : Promise.resolve(undefined)),
|
|
[id],
|
|
undefined,
|
|
);
|
|
}
|