Add PF2e weak/elite creature adjustments with stat block toggle
Weak/Normal/Elite toggle in PF2e stat block header applies standard adjustments (level, AC, HP, saves, Perception, attacks, damage) to individual combatants. Adjusted stats are highlighted blue (elite) or red (weak). Persisted via creatureAdjustment field on Combatant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,15 @@ Acceptance scenarios:
|
||||
7. **Given** no combatant has temp HP, **When** viewing the encounter, **Then** no extra space is reserved for temp HP display.
|
||||
8. **Given** one combatant has temp HP, **When** viewing the encounter, **Then** all rows reserve space for the temp HP display to maintain column alignment.
|
||||
|
||||
**Story HP-8 — HP Adjusts on Weak/Elite Toggle (P2)**
|
||||
As a game master toggling a PF2e creature between weak, normal, and elite, I want the combatant's max HP and current HP to update automatically so that the tracker reflects the adjusted creature's durability.
|
||||
|
||||
Acceptance scenarios:
|
||||
1. **Given** a combatant with 75/75 HP (Normal), **When** the DM toggles to "Elite" (HP bracket +20), **Then** maxHp becomes 95 and currentHp becomes 95.
|
||||
2. **Given** a combatant with 65/75 HP (Normal, 10 damage taken), **When** the DM toggles to "Elite" (HP bracket +20), **Then** maxHp becomes 95 and currentHp becomes 85 (shifted by +20, preserving the 10-damage deficit).
|
||||
3. **Given** a combatant with 5/75 HP (Normal), **When** the DM toggles to "Weak" (HP bracket −20), **Then** maxHp becomes 55 and currentHp becomes 0 (clamped, since 5−20 < 0).
|
||||
4. **Given** a combatant with 95/95 HP (Elite), **When** the DM toggles back to "Normal" (HP bracket −20), **Then** maxHp becomes 75 and currentHp becomes 75.
|
||||
|
||||
### Requirements
|
||||
|
||||
- **FR-001**: Each combatant MAY have an optional `maxHp` value (positive integer >= 1). HP tracking is optional per combatant.
|
||||
@@ -148,6 +157,8 @@ Acceptance scenarios:
|
||||
- **FR-029**: When any combatant in the encounter has temp HP > 0, all rows MUST reserve space for the temp HP display to maintain column alignment. When no combatant has temp HP, no space is reserved.
|
||||
- **FR-030**: The HP adjustment popover MUST include a third button (Shield icon) for setting temp HP.
|
||||
- **FR-031**: Temp HP MUST persist across page reloads via the existing persistence mechanism.
|
||||
- **FR-113**: When a PF2e weak/elite adjustment is toggled (see `specs/004-bestiary/spec.md`, FR-101), `maxHp` MUST be updated by the HP bracket delta for the creature's base level: ±10 (level ≤ 1), ±15 (level 2–4), ±20 (level 5–19), ±30 (level 20+). When switching directly between weak and elite, the full swing (reverse + apply) MUST be computed as a single delta.
|
||||
- **FR-114**: When `maxHp` changes due to a weak/elite toggle, `currentHp` MUST shift by the same delta as `maxHp`, clamped to [0, new `maxHp`]. Temp HP is unaffected.
|
||||
|
||||
### Edge Cases
|
||||
|
||||
@@ -166,6 +177,7 @@ Acceptance scenarios:
|
||||
- There is no death/unconscious game mechanic triggered at 0 HP; the system displays the state only.
|
||||
- There is no damage type tracking, resistance/vulnerability calculation, or hit log in the MVP baseline.
|
||||
- There is no undo/redo for HP changes in the MVP baseline.
|
||||
- Weak/elite toggle when combatant has temp HP: temp HP is unaffected; only maxHp and currentHp change. A combatant at 10+5/75 toggled to Elite becomes 30+5/95.
|
||||
|
||||
---
|
||||
|
||||
@@ -192,6 +204,14 @@ Acceptance scenarios:
|
||||
4. **Given** the inline AC edit is active, **When** the user presses Escape, **Then** the edit is cancelled and the original value is preserved.
|
||||
5. **Given** the inline AC edit is active, **When** the user clears the field and presses Enter, **Then** AC is unset and the shield shows an empty state.
|
||||
|
||||
**Story AC-3 — AC Adjusts on Weak/Elite Toggle (P2)**
|
||||
As a game master toggling a PF2e creature between weak, normal, and elite, I want the combatant's AC to update automatically so that the tracker reflects the adjusted creature's defenses.
|
||||
|
||||
Acceptance scenarios:
|
||||
1. **Given** a combatant with AC 22 (Normal), **When** the DM toggles to "Elite", **Then** AC becomes 24.
|
||||
2. **Given** a combatant with AC 24 (Elite), **When** the DM toggles to "Weak", **Then** AC becomes 20 (base 22, −2 for weak).
|
||||
3. **Given** a combatant with AC 20 (Weak), **When** the DM toggles to "Normal", **Then** AC becomes 22.
|
||||
|
||||
### Requirements
|
||||
|
||||
- **FR-023**: Each combatant MAY have an optional `ac` value, a non-negative integer (>= 0).
|
||||
@@ -203,6 +223,8 @@ Acceptance scenarios:
|
||||
- **FR-029**: AC MUST reject negative values. Zero is a valid AC.
|
||||
- **FR-030**: AC values MUST persist via the existing persistence mechanism.
|
||||
- **FR-031**: The AC shield MUST scale appropriately for single-digit, double-digit, and any valid AC values.
|
||||
- **FR-115**: When a PF2e weak/elite adjustment is toggled (see `specs/004-bestiary/spec.md`, FR-101), `ac` MUST be updated by ±2. When switching directly between weak and elite, the full swing (±4) MUST be applied as a single update.
|
||||
- **FR-116**: AC changes from weak/elite toggles MUST persist via the existing persistence mechanism, consistent with FR-030.
|
||||
|
||||
### Edge Cases
|
||||
|
||||
|
||||
Reference in New Issue
Block a user