[Medium] [Bug] Recovery room regen delta can be negative — mana loss instead of gain #363

Closed
opened 2026-06-10 19:28:20 +02:00 by Anexim · 1 comment
Owner

Severity: Medium
File: src/lib/game/stores/gameStore.ts (lines 315-325)

Description:
The recovery room code computes regenDelta = netBoostedRegen - netRawRegen. If conversionResult.totalRawDrain is very high (close to or exceeding boostedRegen * (1 - incursionStrength) * meditationMultiplier), then netBoostedRegen could be 0 (clamped by Math.max(0, ...)), while netRawRegen was already computed as a positive value. In that case, regenDelta would be negative, and the code would subtract raw mana from the player.

Impact: Players in recovery rooms with high conversion drains could lose raw mana instead of gaining it. This is incorrect behavior — recovery rooms should always provide a net benefit.

Fix needed: Clamp regenDelta to a minimum of 0, or ensure the recovery room always provides net positive regen.

**Severity:** Medium **File:** `src/lib/game/stores/gameStore.ts` (lines 315-325) **Description:** The recovery room code computes `regenDelta = netBoostedRegen - netRawRegen`. If `conversionResult.totalRawDrain` is very high (close to or exceeding `boostedRegen * (1 - incursionStrength) * meditationMultiplier`), then `netBoostedRegen` could be 0 (clamped by `Math.max(0, ...)`), while `netRawRegen` was already computed as a positive value. In that case, `regenDelta` would be **negative**, and the code would subtract raw mana from the player. **Impact:** Players in recovery rooms with high conversion drains could **lose** raw mana instead of gaining it. This is incorrect behavior — recovery rooms should always provide a net benefit. **Fix needed:** Clamp `regenDelta` to a minimum of 0, or ensure the recovery room always provides net positive regen.
Anexim added the ai:todo label 2026-06-10 19:28:20 +02:00
n8n-gitea was assigned by Anexim 2026-06-10 19:28:20 +02:00
Anexim added ai:done and removed ai:todo labels 2026-06-11 11:38:07 +02:00
Author
Owner

Fixed: Added Math.max(0, ...) clamp to regenDelta in recovery room code to prevent negative mana drain.

Fixed: Added Math.max(0, ...) clamp to regenDelta in recovery room code to prevent negative mana drain.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#363