1.7 KiB
1.7 KiB
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 anyEncounterto JSON.loadEncounter(): Must handlecombatants: []case by returning the empty encounter directly instead of routing throughcreateEncounter()(which rejects empty combatant arrays).