Implement the 002-add-combatant feature that adds the possibility to add new combatants to an encounter

This commit is contained in:
Lukas
2026-03-03 23:11:07 +01:00
parent 187f98fc52
commit 0de68100c8
15 changed files with 914 additions and 16 deletions

View File

@@ -0,0 +1,47 @@
# Quickstart: Add Combatant
**Feature**: 002-add-combatant
## Prerequisites
```bash
pnpm install
```
## Development
```bash
pnpm test:watch # Watch all tests
pnpm vitest run packages/domain/src/__tests__/add-combatant.test.ts # Run feature tests
pnpm --filter web dev # Dev server at localhost:5173
```
## Merge Gate
```bash
pnpm check # Must pass before commit (format + lint + typecheck + test)
```
## Implementation Order
1. **Domain event** — Add `CombatantAdded` to `events.ts` and the `DomainEvent` union
2. **Domain function** — Create `add-combatant.ts` with the pure `addCombatant` function
3. **Domain exports** — Update `index.ts` to re-export new items
4. **Domain tests** — Create `add-combatant.test.ts` with all 6 acceptance scenarios + invariant checks
5. **Application use case** — Create `add-combatant-use-case.ts`
6. **Application exports** — Update `index.ts` to re-export
7. **Web hook** — Update `use-encounter.ts` to expose `addCombatant` callback
8. **Web UI** — Update `App.tsx` with name input and add button
## Key Files
| File | Action | Purpose |
|------|--------|---------|
| `packages/domain/src/events.ts` | Edit | Add CombatantAdded event type |
| `packages/domain/src/add-combatant.ts` | Create | Pure addCombatant function |
| `packages/domain/src/index.ts` | Edit | Export new items |
| `packages/domain/src/__tests__/add-combatant.test.ts` | Create | Acceptance + invariant tests |
| `packages/application/src/add-combatant-use-case.ts` | Create | Use case orchestration |
| `packages/application/src/index.ts` | Edit | Export new use case |
| `apps/web/src/hooks/use-encounter.ts` | Edit | Add combatant hook callback |
| `apps/web/src/App.tsx` | Edit | Name input + add button UI |