Implement the 023-clear-encounter feature that adds a clear encounter button with confirmation dialog to remove all combatants and reset round/turn counters, with the cleared state persisting across page refreshes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
specs/023-clear-encounter/data-model.md
Normal file
43
specs/023-clear-encounter/data-model.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Data Model: 023-clear-encounter
|
||||
|
||||
## Entities
|
||||
|
||||
### Encounter (existing — no schema changes)
|
||||
|
||||
The `Encounter` type is unchanged. The clear operation produces an encounter with:
|
||||
|
||||
| Field | Cleared Value | Notes |
|
||||
|---------------|---------------|--------------------------------|
|
||||
| `combatants` | `[]` | Empty readonly array |
|
||||
| `activeIndex` | `0` | Reset to initial |
|
||||
| `roundNumber` | `1` | Reset to initial |
|
||||
|
||||
No new fields or types are added to the data model.
|
||||
|
||||
## Events
|
||||
|
||||
### EncounterCleared (new)
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------------------|----------|--------------------------------------------------|
|
||||
| `type` | `string` | Discriminant: `"EncounterCleared"` |
|
||||
| `combatantCount` | `number` | Number of combatants that were removed |
|
||||
|
||||
Minimal event shape — captures the count of cleared combatants for observability. No need to record the full pre-clear state (MVP baseline does not include undo).
|
||||
|
||||
## State Transitions
|
||||
|
||||
```
|
||||
clearEncounter(encounter: Encounter) → ClearEncounterSuccess | DomainError
|
||||
|
||||
Input: Any Encounter with combatants.length > 0
|
||||
Output: { encounter: { combatants: [], activeIndex: 0, roundNumber: 1 },
|
||||
events: [EncounterCleared] }
|
||||
|
||||
Error: encounter.combatants.length === 0 → DomainError("encounter-already-empty")
|
||||
```
|
||||
|
||||
## Persistence Impact
|
||||
|
||||
- `saveEncounter()`: No changes — already serializes any `Encounter` to JSON.
|
||||
- `loadEncounter()`: Must handle `combatants: []` case by returning the empty encounter directly instead of routing through `createEncounter()` (which rejects empty combatant arrays).
|
||||
Reference in New Issue
Block a user