Files
initiative/specs/025-display-initiative/quickstart.md

36 lines
1.3 KiB
Markdown

# Quickstart: Display Initiative
## Overview
Add initiative display to creature stat blocks. Three layers touched:
1. **Domain**: New `calculateInitiative` pure function + `initiativeProficiency` field on `Creature`
2. **Adapter**: Parse `initiative.proficiency` from raw 5etools JSON
3. **UI**: Show "Initiative +X (Y)" next to AC in stat block header
## Key Files
| File | Change |
|------|--------|
| `packages/domain/src/creature-types.ts` | Add `initiativeProficiency: number` to `Creature` |
| `packages/domain/src/initiative.ts` | New file: `calculateInitiative`, `formatInitiativeModifier` |
| `packages/domain/src/index.ts` | Export new function/types |
| `packages/domain/src/__tests__/initiative.test.ts` | New file: unit tests |
| `apps/web/src/adapters/bestiary-adapter.ts` | Parse `initiative.proficiency` from raw JSON |
| `apps/web/src/components/stat-block.tsx` | Display initiative in header |
## Implementation Order
1. Add `initiativeProficiency` to `Creature` type
2. Create `calculateInitiative` + `formatInitiativeModifier` in domain with tests
3. Update bestiary adapter to parse initiative proficiency
4. Update stat block component to display initiative
## Verification
```bash
pnpm check # Must pass — knip + format + lint + typecheck + test
```
Spot-check: Aboleth should display "Initiative +7 (17)".