[High] [Bug] Mana conversion always paused — rawCost formula makes drain exceed regen by orders of magnitude #378

Closed
opened 2026-06-12 12:05:43 +02:00 by Anexim · 2 comments
Owner

Bug Summary

Mana conversions are always paused with "Insufficient raw regen" even when the player has substantial raw mana regeneration.

Expected Behavior

Conversions should be active when the player has sufficient raw mana regeneration to sustain them.

Root Cause

The rawCost formula in src/lib/game/data/conversion-costs.ts:18 produces values that are orders of magnitude too high:

  • Base elements (distance 1): rawCost = 10^(1+1) = 100
  • Composite elements (distance 2): rawCost = 10^3 = 1,000
  • Exotic elements (distance 3): rawCost = 10^4 = 10,000

The pause check in src/lib/game/utils/conversion-rates.ts:166 compares rawDrain = finalRate * rawCost against rawGrossRegen. With discipline rates of 10-22 and rawCost of 100+, drain is 1000-2200/hr while even late-game raw regen is only ~20-50/hr.

Additionally, the per-element grossRegen map in conversion-params.ts:14 only covers Enchanter (transference) and Fabricator (earth) attunements, excluding Invoker's 0.3/hr regen because primaryManaType is undefined.

Severity

High — Makes the entire mana conversion system non-functional, blocking access to elemental mana generation.

Files Involved

File Lines Issue
src/lib/game/utils/conversion-rates.ts 162-172 Pause check compares single-element drain against total regen
src/lib/game/data/conversion-costs.ts 18 computeRawCost(distance) produces values 100-10000x too high
src/lib/game/utils/conversion-params.ts 14 Excludes Invoker regen from per-element map

Fix Direction

Rebalance the rawCost formula so achievable raw regen can sustain conversions at expected discipline rates. Alternatively, compare total raw drain from all active conversions against total raw regen.

## Bug Summary Mana conversions are always paused with "Insufficient raw regen" even when the player has substantial raw mana regeneration. ## Expected Behavior Conversions should be active when the player has sufficient raw mana regeneration to sustain them. ## Root Cause The `rawCost` formula in `src/lib/game/data/conversion-costs.ts:18` produces values that are orders of magnitude too high: - Base elements (distance 1): `rawCost = 10^(1+1) = 100` - Composite elements (distance 2): `rawCost = 10^3 = 1,000` - Exotic elements (distance 3): `rawCost = 10^4 = 10,000` The pause check in `src/lib/game/utils/conversion-rates.ts:166` compares `rawDrain = finalRate * rawCost` against `rawGrossRegen`. With discipline rates of 10-22 and rawCost of 100+, drain is 1000-2200/hr while even late-game raw regen is only ~20-50/hr. Additionally, the per-element `grossRegen` map in `conversion-params.ts:14` only covers Enchanter (transference) and Fabricator (earth) attunements, excluding Invoker's 0.3/hr regen because `primaryManaType` is `undefined`. ## Severity **High** — Makes the entire mana conversion system non-functional, blocking access to elemental mana generation. ## Files Involved | File | Lines | Issue | |------|-------|-------| | `src/lib/game/utils/conversion-rates.ts` | 162-172 | Pause check compares single-element drain against total regen | | `src/lib/game/data/conversion-costs.ts` | 18 | `computeRawCost(distance)` produces values 100-10000x too high | | `src/lib/game/utils/conversion-params.ts` | 14 | Excludes Invoker regen from per-element map | ## Fix Direction Rebalance the `rawCost` formula so achievable raw regen can sustain conversions at expected discipline rates. Alternatively, compare total raw drain from all active conversions against total raw regen.
Anexim added the ai:todo label 2026-06-12 12:05:43 +02:00
n8n-gitea was assigned by Anexim 2026-06-12 12:05:43 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-12 12:20:00 +02:00
Author
Owner

Starting investigation of mana conversion pause bug. Reading the three affected files to understand the rawCost formula, pause check logic, and per-element regen map.

Starting investigation of mana conversion pause bug. Reading the three affected files to understand the rawCost formula, pause check logic, and per-element regen map.
Anexim added ai:done and removed ai:in-progress labels 2026-06-12 12:30:42 +02:00
Author
Owner

Fix Complete

Root Cause: The rawCost formula 10^(d+1) produced values 100-100,000x too high, making mana conversion permanently paused since rawDrain = finalRate × rawCost always exceeded achievable raw regen (~2-200/hr).

Changes Made:

  1. src/lib/game/data/conversion-costs.ts — Rebalanced cost formulas:

    • rawCost: 10^(d+1)2 × distance
      • Base (d=1): 100 → 2
      • Composite (d=2): 1,000 → 4
      • Exotic (d=3): 10,000 → 6
      • Time (d=4): 100,000 → 8
    • componentCost: 10 × (d+1)3 × distance
      • Composite: 30 → 6 per component
      • Exotic: 40 → 9 per component
      • Time: 50 → 12 per component
  2. src/lib/game/__tests__/conversion-pause-bug-regression.test.ts — Updated comment referencing old rawCost=100

  3. src/lib/game/__tests__/mana-conversion-component-deduction.test.ts — Updated expected elementDrain values (0.35 × 6 = 2.1 instead of 0.35 × 30 = 10.5)

Verification: All 1186 tests pass (73 test files, 0 failures). All files under 400-line limit. No banned mechanics added.

Note on Invoker regen (#3 in original issue): Investigated and determined it's not a bug — the Invoker's rawManaRegen: 0.3/hr is already included in rawGrossRegen via computeRegengetTotalAttunementRegen. The per-element grossRegen map is only for element-specific component cost checks, and the Invoker has no primaryManaType, so it correctly doesn't appear there.

## Fix Complete ✅ **Root Cause:** The `rawCost` formula `10^(d+1)` produced values 100-100,000x too high, making mana conversion permanently paused since `rawDrain = finalRate × rawCost` always exceeded achievable raw regen (~2-200/hr). **Changes Made:** 1. **`src/lib/game/data/conversion-costs.ts`** — Rebalanced cost formulas: - `rawCost`: `10^(d+1)` → `2 × distance` - Base (d=1): 100 → 2 - Composite (d=2): 1,000 → 4 - Exotic (d=3): 10,000 → 6 - Time (d=4): 100,000 → 8 - `componentCost`: `10 × (d+1)` → `3 × distance` - Composite: 30 → 6 per component - Exotic: 40 → 9 per component - Time: 50 → 12 per component 2. **`src/lib/game/__tests__/conversion-pause-bug-regression.test.ts`** — Updated comment referencing old rawCost=100 3. **`src/lib/game/__tests__/mana-conversion-component-deduction.test.ts`** — Updated expected elementDrain values (0.35 × 6 = 2.1 instead of 0.35 × 30 = 10.5) **Verification:** All 1186 tests pass (73 test files, 0 failures). All files under 400-line limit. No banned mechanics added. **Note on Invoker regen (#3 in original issue):** Investigated and determined it's not a bug — the Invoker's `rawManaRegen: 0.3/hr` is already included in `rawGrossRegen` via `computeRegen` → `getTotalAttunementRegen`. The per-element `grossRegen` map is only for element-specific component cost checks, and the Invoker has no `primaryManaType`, so it correctly doesn't appear there.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#378