38 lines
1.0 KiB
Markdown
38 lines
1.0 KiB
Markdown
# Domain Contract: editCombatant
|
|
|
|
## Function Signature
|
|
|
|
```
|
|
editCombatant(encounter, id, newName) → EditCombatantSuccess | DomainError
|
|
```
|
|
|
|
### Inputs
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| encounter | Encounter | Current encounter state |
|
|
| id | CombatantId | Identity of combatant to rename |
|
|
| newName | string | New name to assign |
|
|
|
|
### Success Output
|
|
|
|
| Field | Type | Description |
|
|
|-------|------|-------------|
|
|
| encounter | Encounter | Updated encounter with renamed combatant |
|
|
| events | DomainEvent[] | Exactly one `CombatantUpdated` event |
|
|
|
|
### Error Output
|
|
|
|
| Code | Condition |
|
|
|------|-----------|
|
|
| `"combatant-not-found"` | No combatant with given id exists |
|
|
| `"invalid-name"` | newName is empty or whitespace-only |
|
|
|
|
## Hook Contract
|
|
|
|
`useEncounter()` returns an additional action:
|
|
|
|
| Method | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| editCombatant | `(id: CombatantId, newName: string) => void` | Rename combatant, append events on success |
|