Implement the 004-edit-combatant feature that adds the possibility to change a combatants name
This commit is contained in:
37
specs/004-edit-combatant/contracts/domain-contract.md
Normal file
37
specs/004-edit-combatant/contracts/domain-contract.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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 |
|
||||
Reference in New Issue
Block a user