---
name: defense-graded-rage
description: Design readable, rewarding enemy rage mechanics for turn-based RPGs and roguelike deckbuilders where boss/mob ultimate damage grades the player's defense instead of rolling opaque RNG or punishing slow turns: fixed 3-beat cycle (Beat 1 Atk 3 -> Beat 2 Atk 2 + Block 3 -> Beat 3 Ultimate = 3 + current_rage), true HP-damage rage trigger (base +1 per beat, if (hp_damage > 0) rage += 1 so full block/evade caps the ultimate at 5 while eating HP damage spikes it to 7), and immediate post-ultimate rage reset (0/4) + self Vulnerable (+50% damage taken next turn) to hand the player a juicy counterattack window.
---

# Defense-Graded Enemy Rage & 3-Beat Counterattack Contract

When an enemy's big attack feels randomly weak on one run and lethal on the next, players blame RNG. When enemy rage climbs unconditionally every turn, players feel punished for playing defensively.

Turn enemy rage into a **transparent defensive performance grade** (as built for *Frenzied Beast* / `狂躁兽` in *Zhaoshi Wulin* / `《招式武林》`) using 3 hard rules:

## 1. The 3 Mandatory Rules

1. **Rule 01 — Fixed 3-Beat Tempo & Deterministic Ultimate Formula**:
   - Lock the enemy onto a readable 3-beat loop — never random ultimate rolls:
     - **Beat 1 (`蓄怒扑咬` / Rage Pounce)**: Attack `3`, guaranteed `+1` rage.
     - **Beat 2 (`压步蓄怒` / Press & Charge)**: Attack `2` + Enemy Block `3`, guaranteed `+1` rage.
     - **Beat 3 (`怒扑放泄` / Fury Unleash)**: Deterministic ultimate damage `ult_damage = 3 + current_rage` (max rage `4`).
   - Only 2 beats of charge before release keeps tension snappy without dragging fights out.

2. **Rule 02 — True HP-Damage Grading (`if (hp_damage > 0) rage += 1`)**:
   - Base charge per buildup beat is `+1`.
   - Grant the bonus `+1` rage **ONLY** when the attack pierces defense and deals real HP damage:
     ```ts
     const hpDamage = evaded ? 0 : Math.max(0, incomingAttack - playerShield);
     rage = Math.min(4, rage + 1 + (hpDamage > 0 ? 1 : 0));
     ```
   - **Full Block / Evade (Guard Track)**: Beats 1–2 yield `1 + 1 = 2/4` rage → Beat 3 ultimate compressed to **`3 + 2 = 5`**.
   - **Eating HP Hits (Greedy Track)**: Beats 1–2 yield `2 + 2 = 4/4` rage → Beat 3 ultimate spikes to **`3 + 4 = 7`**.
   - Good defense immediately pays out as a 2-tier ultimate reduction instead of feeling passive.

3. **Rule 03 — Post-Ultimate Reset & Self-Vulnerable Counterattack Window**:
   - Immediately after Beat 3 resolves:
     - Reset `rage = 0` (`0/4`).
     - Inflict self **Vulnerable `+1`** (`破绽 +1`, `+50%` damage taken on the player's next turn, e.g. `floor(8 * 1.5) = 12`).
   - Surviving the big hit automatically hands the player an explosive punish turn, creating a tight **Defend → Survive → Punish** rhythm.

## 2. Verification Checklist
- [ ] Enemy follows the exact 3-beat loop (`Beat 1 -> Beat 2 -> Beat 3 -> Beat 1`) with Beat 3 damage strictly equal to `3 + rage`.
- [ ] Blocking or evading Beat 1 & Beat 2 cleanly (`hp_damage === 0`) leaves rage at `2/4` and caps Beat 3 ultimate at `5`.
- [ ] Taking `>= 1` HP damage on Beat 1 & Beat 2 (`hp_damage > 0`) triggers `+2` rage per beat, reaching `4/4` and dealing `7` on Beat 3.
- [ ] Beat 3 immediately clears rage to `0` and applies `vulnerable = 1` (`+50%` damage taken on the player's follow-up turn).
- [ ] Never apply bonus rage on blocked shield damage; always check post-shield true HP loss (`hp_damage > 0`).
