[Critical] [Bug] Mana Conversion: Attunement base rate uses exponential scaling instead of flat + linear multiplier #292
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec: docs/specs/mana-conversion-spec.md §3, §5
Severity: High
Problem:
getAttunementConversionRate()insrc/lib/game/data/attunements.ts:104-110applies exponential scaling (1.5^(level-1)) to the base conversion rate. The spec says the base rate should be flat (0.2 for Enchanter, 0.25 for Fabricator) and only the multiplier should scale with level via1 + level × 0.5.Additionally,
conversion-rates.ts:108uses a linear1 + level × 0.5multiplier instead of the spec's exponential1.5^(level-1). At level 10:0.2 × 1.5^9 = 7.69/hr0.2 × (1 + 10×0.5) = 1.2/hr— 6.4× under-scaleFiles:
src/lib/game/data/attunements.ts:104-110— exponential on base ratesrc/lib/game/utils/conversion-rates.ts:103-117— linear instead of exponential multipliersrc/lib/game/stores/gameStore.ts:357-368— correct values computed but only used for pause-checking, not actual conversionStarting investigation. Will read the spec and all three affected files to understand the discrepancy before making changes.
Fix applied — all 1009 tests pass (52/52 files).
Changes made:
src/lib/game/data/attunements.ts:104-110—getAttunementConversionRate()now returns the flat base rate (def.conversionRate) instead of applyingMath.pow(1.5, level-1)exponential scaling. The level multiplier is already handled separately bycomputeConversionRates()viaattMult = 1 + (attunementBonuses[elem] || 0)wherebonus = level * 0.5.src/lib/game/stores/gameStore.ts:362-372—buildConversionParams()now usesdef.conversionRate(flat) directly instead ofgetAttunementConversionRate()forgrossRegen. Removed the unused import ofgetAttunementConversionRate.src/components/game/tabs/StatsTab/ElementStatsSection.tsx:36-42— Same fix: usesdef.conversionRatedirectly instead of the removed function call. Removed unused import.src/lib/game/__tests__/bug-fixes.test.ts:67-76— Updated the test that previously asserted exponential growth (level5Rate > level1Rate) to assert flat rate equality (level5Rate === level1Rate), matching the new spec-correct behavior.Behavior change:
0.2 × 1.5^9 ≈ 7.69/hr(exponential)0.2(flat base) ×(1 + 10×0.5) = 1.2/hrvia the multiplier incomputeConversionRates()1 + level×0.5multiplier applied separately.Completed. All changes verified with 1009/1009 tests passing. See previous comment for details.