[Low] [Bug] Enchanting: Prep time mana-per-tick calculation doesn't apply floor(capacity/50) #305

Closed
opened 2026-06-07 17:42:19 +02:00 by Anexim · 2 comments
Owner

Spec: docs/specs/attunements/enchanter/systems/enchanting-spec.md §4.2
Severity: Wrong formula

Problem: src/lib/game/stores/pipelines/enchanting-tick.ts:99 computes mana per tick as:

const manaPerTick = (instance.totalCapacity * 10) / (2 + instance.totalCapacity / 50) * HOURS_PER_TICK;

The denominator 2 + instance.totalCapacity / 50 does NOT apply Math.floor to instance.totalCapacity / 50. For capacity 65, this gives 2 + 1.3 = 3.3 instead of the spec's 2 + floor(65/50) = 3.

File: src/lib/game/stores/pipelines/enchanting-tick.ts:99

**Spec:** docs/specs/attunements/enchanter/systems/enchanting-spec.md §4.2 **Severity:** Wrong formula **Problem:** `src/lib/game/stores/pipelines/enchanting-tick.ts:99` computes mana per tick as: ``` const manaPerTick = (instance.totalCapacity * 10) / (2 + instance.totalCapacity / 50) * HOURS_PER_TICK; ``` The denominator `2 + instance.totalCapacity / 50` does NOT apply `Math.floor` to `instance.totalCapacity / 50`. For capacity 65, this gives `2 + 1.3 = 3.3` instead of the spec's `2 + floor(65/50) = 3`. **File:** `src/lib/game/stores/pipelines/enchanting-tick.ts:99`
Anexim added the ai:todo label 2026-06-07 17:42:19 +02:00
n8n-gitea was assigned by Anexim 2026-06-07 17:42:19 +02:00
Anexim removed the ai:todo label 2026-06-08 15:01:55 +02:00
Author
Owner

Starting work on prep time mana-per-tick floor calculation fix.

Starting work on prep time mana-per-tick floor calculation fix.
Anexim added the ai:done label 2026-06-08 15:04:17 +02:00
Author
Owner

Fix applied and pushed. Added Math.floor() to capacity/50 in prep time mana-per-tick calculation.

Root cause: Code used 2 + instance.totalCapacity / 50 but spec says 2 + floor(capacity/50).

Fix: Changed to 2 + Math.floor(instance.totalCapacity / 50) per spec §4.2.

Tests: 1069 passed (58 files).

**Fix applied and pushed.** Added `Math.floor()` to capacity/50 in prep time mana-per-tick calculation. **Root cause:** Code used `2 + instance.totalCapacity / 50` but spec says `2 + floor(capacity/50)`. **Fix:** Changed to `2 + Math.floor(instance.totalCapacity / 50)` per spec §4.2. **Tests:** 1069 passed (58 files).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#305