Files
initiative/apps/web/src/adapters/ports.ts
Lukas c3707cf0b6 Add PF2e attack effects, ability frequency, and perception details
Show inline on-hit effects on attack lines (e.g., "plus Grab"), frequency
limits on abilities (e.g., "(1/day)"), and perception details text alongside
senses. Strip redundant frequency lines from Foundry descriptions.

Also add resilient PF2e source fetching: batched requests with retry,
graceful handling of ad-blocker-blocked creature files (partial success
with toast warning and re-fetch prompt for missing creatures).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:37:03 +02:00

62 lines
1.6 KiB
TypeScript

import type {
AnyCreature,
BestiaryIndex,
CreatureId,
Encounter,
Pf2eBestiaryIndex,
PlayerCharacter,
UndoRedoState,
} from "@initiative/domain";
export interface EncounterPersistence {
load(): Encounter | null;
save(encounter: Encounter): void;
}
export interface UndoRedoPersistence {
load(): UndoRedoState;
save(state: UndoRedoState): void;
}
export interface PlayerCharacterPersistence {
load(): PlayerCharacter[];
save(characters: PlayerCharacter[]): void;
}
export interface CachedSourceInfo {
readonly sourceCode: string;
readonly displayName: string;
readonly creatureCount: number;
readonly cachedAt: number;
}
export interface BestiaryCachePort {
cacheSource(
system: string,
sourceCode: string,
displayName: string,
creatures: AnyCreature[],
): Promise<void>;
isSourceCached(system: string, sourceCode: string): Promise<boolean>;
getCachedSources(system?: string): Promise<CachedSourceInfo[]>;
clearSource(system: string, sourceCode: string): Promise<void>;
clearAll(): Promise<void>;
loadAllCachedCreatures(): Promise<Map<CreatureId, AnyCreature>>;
}
export interface BestiaryIndexPort {
loadIndex(): BestiaryIndex;
getAllSourceCodes(): string[];
getDefaultFetchUrl(sourceCode: string, baseUrl?: string): string;
getSourceDisplayName(sourceCode: string): string;
}
export interface Pf2eBestiaryIndexPort {
loadIndex(): Pf2eBestiaryIndex;
getAllSourceCodes(): string[];
getDefaultFetchUrl(sourceCode: string, baseUrl?: string): string;
getSourceDisplayName(sourceCode: string): string;
getCreaturePathsForSource(sourceCode: string): string[];
getCreatureNamesByPaths(paths: string[]): Map<string, string>;
}