Add Pathfinder 2e game system mode
All checks were successful
CI / check (push) Successful in 2m21s
CI / build-image (push) Successful in 24s

Implements PF2e as an alternative game system alongside D&D 5e/5.5e.
Settings modal "Game System" selector switches conditions, bestiary,
stat block layout, and initiative calculation between systems.

- Valued conditions with increment/decrement UX (Clumsy 2, Frightened 3)
- 2,502 PF2e creatures from bundled search index (77 sources)
- PF2e stat block: level, traits, Perception, Fort/Ref/Will, ability mods
- Perception-based initiative rolling
- System-scoped source cache (D&D and PF2e sources don't collide)
- Backwards-compatible condition rehydration (ConditionId[] → ConditionEntry[])
- Difficulty indicator hidden in PF2e mode (excluded from MVP)

Closes dostulata/initiative#19

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-07 01:26:22 +02:00
parent 8f6eebc43b
commit e62c49434c
67 changed files with 27758 additions and 527 deletions

View File

@@ -46,17 +46,17 @@ describe("bestiary-cache fallback (IndexedDB unavailable)", () => {
it("cacheSource falls back to in-memory store", async () => {
const creatures = [makeCreature("mm:goblin", "Goblin")];
await cacheSource("MM", "Monster Manual", creatures);
await cacheSource("dnd", "MM", "Monster Manual", creatures);
expect(await isSourceCached("MM")).toBe(true);
expect(await isSourceCached("dnd", "MM")).toBe(true);
});
it("isSourceCached returns false for uncached source", async () => {
expect(await isSourceCached("XGE")).toBe(false);
expect(await isSourceCached("dnd", "XGE")).toBe(false);
});
it("getCachedSources returns sources from in-memory store", async () => {
await cacheSource("MM", "Monster Manual", [
await cacheSource("dnd", "MM", "Monster Manual", [
makeCreature("mm:goblin", "Goblin"),
]);
@@ -68,7 +68,7 @@ describe("bestiary-cache fallback (IndexedDB unavailable)", () => {
it("loadAllCachedCreatures assembles creatures from in-memory store", async () => {
const goblin = makeCreature("mm:goblin", "Goblin");
await cacheSource("MM", "Monster Manual", [goblin]);
await cacheSource("dnd", "MM", "Monster Manual", [goblin]);
const map = await loadAllCachedCreatures();
expect(map.size).toBe(1);
@@ -76,17 +76,17 @@ describe("bestiary-cache fallback (IndexedDB unavailable)", () => {
});
it("clearSource removes a single source from in-memory store", async () => {
await cacheSource("MM", "Monster Manual", []);
await cacheSource("VGM", "Volo's Guide", []);
await cacheSource("dnd", "MM", "Monster Manual", []);
await cacheSource("dnd", "VGM", "Volo's Guide", []);
await clearSource("MM");
await clearSource("dnd", "MM");
expect(await isSourceCached("MM")).toBe(false);
expect(await isSourceCached("VGM")).toBe(true);
expect(await isSourceCached("dnd", "MM")).toBe(false);
expect(await isSourceCached("dnd", "VGM")).toBe(true);
});
it("clearAll removes all data from in-memory store", async () => {
await cacheSource("MM", "Monster Manual", []);
await cacheSource("dnd", "MM", "Monster Manual", []);
await clearAll();
const sources = await getCachedSources();