Enforce maximum values for PF2e numbered conditions

Cap dying (4), doomed (3), wounded (3), and slowed (3) at their
rule-defined maximums. The domain clamps values in setConditionValue
and the condition picker disables the [+] button at the cap.

Closes #31

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-04-09 00:04:47 +02:00
parent 1c107a500b
commit 553e09f280
5 changed files with 120 additions and 20 deletions

View File

@@ -310,6 +310,16 @@ Acceptance scenarios:
9. **Given** a combatant has Clumsy 3, **When** the user hovers over the condition icon, **Then** the tooltip shows the condition name, the current value, and the PF2e rules description.
10. **Given** a valued condition counter is showing, **When** the user clicks a different valued condition, **Then** the previous counter is replaced (only one counter at a time).
**Story CC-10 — Condition Value Maximums (P2)**
As a DM running a PF2e encounter, I want valued conditions to be capped at their rule-defined maximum so I cannot accidentally increment them beyond their meaningful range.
Acceptance scenarios:
1. **Given** the game system is Pathfinder 2e, **When** a valued condition reaches its maximum (dying 4, doomed 3, wounded 3, slowed 3), **Then** the `[+]` button in the condition picker counter is disabled.
2. **Given** a combatant has Dying 4, **When** the user opens the condition picker, **Then** the counter shows 4 and `[+]` is disabled; `[-]` and `[✓]` remain active.
3. **Given** a combatant has Slowed 3, **When** the user clicks the Slowed icon tag on the row, **Then** the value decrements to 2 (decrement is unaffected by the cap).
4. **Given** the game system is D&D (5e or 5.5e), **When** interacting with conditions, **Then** no maximum enforcement is applied.
5. **Given** a PF2e valued condition without a defined maximum (e.g., Frightened, Clumsy), **When** incrementing, **Then** no cap is enforced — the value can increase without limit.
### Requirements
- **FR-032**: When a D&D game system is active, the system MUST support the following 15 standard D&D 5e/5.5e conditions: blinded, charmed, deafened, exhaustion, frightened, grappled, incapacitated, invisible, paralyzed, petrified, poisoned, prone, restrained, stunned, unconscious. When Pathfinder 2e is active, the system MUST support the PF2e condition set (see FR-103).
@@ -360,6 +370,9 @@ Acceptance scenarios:
- **FR-105**: For PF2e valued conditions, the condition icon tag MUST display the current value as a small numeric badge (e.g., "2" next to the Frightened icon). Non-valued PF2e conditions display without a badge.
- **FR-106**: The condition data model MUST use `ConditionEntry` objects (`{ id: ConditionId, value?: number }`) instead of bare `ConditionId` values. D&D conditions MUST be stored without a `value` field (backwards-compatible).
- **FR-107**: Switching the game system MUST NOT clear existing combatant conditions. Conditions from the previous game system that are not valid in the new system remain stored but are hidden from display until the user switches back.
- **FR-108**: The following PF2e valued conditions MUST have maximum values enforced: dying (max 4), doomed (max 3), wounded (max 3), slowed (max 3). All other valued conditions have no enforced maximum.
- **FR-109**: When a PF2e valued condition is at its maximum value, the `[+]` increment button in the condition picker counter MUST be disabled (visually dimmed and non-interactive).
- **FR-110**: Maximum value enforcement MUST only apply when the Pathfinder 2e game system is active. D&D conditions are unaffected.
### Edge Cases
@@ -375,7 +388,7 @@ Acceptance scenarios:
- The settings modal is app-level UI; it does not interact with encounter state.
- When the game system is switched from D&D to PF2e, existing D&D conditions on combatants are hidden (not deleted). Switching back to D&D restores them.
- PF2e valued condition at value 0 is treated as removed — it MUST NOT appear on the row.
- Dying 4 in PF2e has special mechanical significance (death), but the system does not enforce this automatically — it displays the value only.
- Dying, doomed, wounded, and slowed have enforced maximum values in PF2e (4, 3, 3, 3 respectively). The `[+]` button is disabled at the cap. The dynamic dying cap based on doomed value (dying max = 4 doomed) is not enforced — only the static maximum applies.
- Persistent damage is excluded from the PF2e MVP condition set. It can be added as a follow-up feature.
---