Phase 1: player character depth
- Inventory + currency + encumbrance vs carrying capacity - Class resources with correct short/long/daily rest recovery (applyRest) - Spellcasting: slots (+pact), known/prepared spells, derived DC + attack - Defenses: 5e death saves/inspiration/exhaustion, pf2e dying/wounded/hero points - Derived weapon attacks + passive perception via extended RulesSystem - Dexie v2 migration backfills new fields; debounced save flushes on pagehide - 9 new unit tests, new character-depth e2e; all green Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import type { Campaign } from '@/lib/schemas/campaign';
|
||||
import type { Character } from '@/lib/schemas/character';
|
||||
import type { Encounter } from '@/lib/schemas/encounter';
|
||||
import type { DiceRoll } from '@/lib/schemas/dice';
|
||||
import { characterDefaults } from '@/lib/schemas/character';
|
||||
|
||||
/**
|
||||
* Single Dexie instance for the whole app. Dexie wraps IndexedDB transactions
|
||||
@@ -26,6 +27,18 @@ export class TtrpgDatabase extends Dexie {
|
||||
encounters: 'id, campaignId, status',
|
||||
diceRolls: 'id, campaignId, createdAt',
|
||||
});
|
||||
|
||||
// v2 — Phase 1 character depth: backfill new fields on existing characters.
|
||||
this.version(2).stores({}).upgrade(async (tx) => {
|
||||
await tx
|
||||
.table('characters')
|
||||
.toCollection()
|
||||
.modify((c: Record<string, unknown>) => {
|
||||
for (const [key, value] of Object.entries(characterDefaults())) {
|
||||
if (c[key] === undefined) c[key] = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user