[High] [Bug] Enchanting: Hasty Enchanter applies wrong bonus (6.25% instead of 25%) #301

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

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

Problem: The spec says time *= 0.75 (25% faster) for repeat designs with Hasty Enchanter. The code has two issues:

  1. src/lib/game/crafting-design.ts:63-67getDesignTimeWithHaste() correctly multiplies time by 0.75, but this function is never called (dead code).

  2. src/lib/game/crafting-design.ts:122-128calculateDesignProgress() applies Hasty Enchanter per-tick as an additive bonus: timeBonus = DESIGN_PROGRESS_PER_TICK * 0.25 = 0.01 hours/tick. This is a ~6.25% speed increase, not 25%.

  3. src/lib/game/crafting-actions/design-actions.ts:55startDesigningEnchantment() calls calculateDesignTime(effects) without passing isRepeatDesign, so the required time is never reduced.

Files:

  • src/lib/game/crafting-design.ts:63-67 (dead code)
  • src/lib/game/crafting-design.ts:122-128 (wrong formula)
  • src/lib/game/crafting-actions/design-actions.ts:55 (never applies reduction)
**Spec:** docs/specs/attunements/enchanter/systems/enchanting-spec.md §3.3 **Severity:** Wrong formula **Problem:** The spec says `time *= 0.75` (25% faster) for repeat designs with Hasty Enchanter. The code has two issues: 1. `src/lib/game/crafting-design.ts:63-67` — `getDesignTimeWithHaste()` correctly multiplies time by 0.75, but this function is **never called** (dead code). 2. `src/lib/game/crafting-design.ts:122-128` — `calculateDesignProgress()` applies Hasty Enchanter per-tick as an additive bonus: `timeBonus = DESIGN_PROGRESS_PER_TICK * 0.25 = 0.01` hours/tick. This is a ~6.25% speed increase, not 25%. 3. `src/lib/game/crafting-actions/design-actions.ts:55` — `startDesigningEnchantment()` calls `calculateDesignTime(effects)` without passing `isRepeatDesign`, so the required time is never reduced. **Files:** - `src/lib/game/crafting-design.ts:63-67` (dead code) - `src/lib/game/crafting-design.ts:122-128` (wrong formula) - `src/lib/game/crafting-actions/design-actions.ts:55` (never applies reduction)
Anexim added the ai:todo label 2026-06-07 17:42:17 +02:00
n8n-gitea was assigned by Anexim 2026-06-07 17:42:17 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-08 11:43:39 +02:00
Author
Owner

Starting investigation of Hasty Enchanter bug. Will read the three affected files and the spec to reproduce the issue.

Starting investigation of Hasty Enchanter bug. Will read the three affected files and the spec to reproduce the issue.
Author
Owner

Fix applied and verified.

Root cause: calculateDesignProgress() applied Hasty Enchanter as an additive per-tick bonus (DESIGN_PROGRESS_PER_TICK * 0.25 = 0.01 hours/tick), giving only ~6.25% speed increase instead of the spec-defined 25%.

Changes made to src/lib/game/crafting-design.ts:

  1. Removed dead code getDesignTimeWithHaste() — was never called.
  2. Changed the haste formula from additive (+0.01/tick) to multiplicative (×4/3 progress per tick), which is mathematically equivalent to time *= 0.75 (25% less time).
  3. Renamed constant from HASTY_ENCHANTER_BONUS_MULTIPLIER to HASTY_ENCHANTER_SPEED_MULTIPLIER with value 4/3.

No changes needed in design-actions.tsisRepeatDesign is computed at tick time in enchanting-tick.ts, and the haste bonus is correctly applied per-tick in calculateDesignProgress().

Regression test added: src/lib/game/__tests__/hasty-enchanter.test.ts — 5 tests covering:

  • Correct 4/3 progress per tick for repeat designs
  • Total ticks reduced to 75% of original
  • No haste for first-time designs
  • No haste without the special effect
  • Correct timeBonus value

Verification:

  • All 56 test files pass (1056 tests)
  • Regression tests FAIL on pre-fix code (3 of 5 detect the bug)
  • Regression tests PASS on fixed code
  • Pre-commit hooks pass (file sizes OK, tests OK)
**Fix applied and verified.** **Root cause:** `calculateDesignProgress()` applied Hasty Enchanter as an additive per-tick bonus (`DESIGN_PROGRESS_PER_TICK * 0.25 = 0.01` hours/tick), giving only ~6.25% speed increase instead of the spec-defined 25%. **Changes made to `src/lib/game/crafting-design.ts`:** 1. Removed dead code `getDesignTimeWithHaste()` — was never called. 2. Changed the haste formula from additive (`+0.01/tick`) to multiplicative (`×4/3` progress per tick), which is mathematically equivalent to `time *= 0.75` (25% less time). 3. Renamed constant from `HASTY_ENCHANTER_BONUS_MULTIPLIER` to `HASTY_ENCHANTER_SPEED_MULTIPLIER` with value `4/3`. **No changes needed in `design-actions.ts`** — `isRepeatDesign` is computed at tick time in `enchanting-tick.ts`, and the haste bonus is correctly applied per-tick in `calculateDesignProgress()`. **Regression test added:** `src/lib/game/__tests__/hasty-enchanter.test.ts` — 5 tests covering: - Correct 4/3 progress per tick for repeat designs - Total ticks reduced to 75% of original - No haste for first-time designs - No haste without the special effect - Correct timeBonus value **Verification:** - All 56 test files pass (1056 tests) - Regression tests FAIL on pre-fix code (3 of 5 detect the bug) - Regression tests PASS on fixed code - Pre-commit hooks pass (file sizes OK, tests OK)
Anexim added ai:done and removed ai:in-progress labels 2026-06-08 11:52:50 +02:00
Author
Owner

Fix complete. Hasty Enchanter now correctly applies a 25% design speed increase (4/3 progress per tick) instead of the previous 6.25% (additive 0.01 per tick).

Fix complete. Hasty Enchanter now correctly applies a 25% design speed increase (4/3 progress per tick) instead of the previous 6.25% (additive 0.01 per tick).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#301