Implement the 025-display-initiative feature that adds initiative modifier and passive initiative display to creature stat blocks, calculated as DEX modifier + (proficiency multiplier × proficiency bonus) from bestiary data, shown in MM 2024 format on the AC line
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
35
specs/025-display-initiative/quickstart.md
Normal file
35
specs/025-display-initiative/quickstart.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# 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)".
|
||||
Reference in New Issue
Block a user