[High] [Bug] Elemental mana conversions incorrectly paused — rawGrossRegen compared against per-element drain instead of total #348
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?
Bug: Elemental mana conversions incorrectly paused due to wrong rawGrossRegen value
Steps to reproduce
+33.43/hr(correct)Final: 0.00/hrand⚠️ Insufficient raw regen (need 3342.95/hr, have 2.00/hr)Expected
With 3342.95 raw regen/hr available, Earth conversion (which needs ~3342.95 raw/hr at d=1 with rawCost=100) should be active and producing mana. The
havevalue should reflect the player's actual raw regen.Actual
The conversion system reports
have 2.00/hr— the base raw regen without attunement bonuses — and pauses ALL conversions even though the player has 3342.95/hr raw regen.Root Cause
Two distinct bugs:
Bug 1:
rawGrossRegenpassed tocomputeConversionRatesis wrong (gameStore.ts line ~176)In
gameStore.tstick pipeline,baseRegenis computed as:Note:
attunements: {}— empty object! This meanscomputeRegen→getTotalAttunementRegen({})returns 0, sobaseRegenis just the base 2/hr (+ prestige/equipment bonuses).This
baseRegen(≈2.00/hr) is then passed asrawGrossRegentocomputeConversionRates().However, the actual raw regen used elsewhere in the same tick (for the net raw regen calculation on line ~236) is:
This means the raw regen used for the conversion pause check (2.00/hr) is much smaller than the actual raw regen available (3342.95/hr).
Fix:
computeRegenshould be called with the actual attunements, not an empty object. The attunement raw mana regen (with level scaling) must be included inrawGrossRegen.Bug 2:
grossRegen(per-element) inbuildConversionParamsusesconversionRateinstead ofrawManaRegen(gameStore.ts line ~388-396)The
buildConversionParamsfunction buildsgrossRegenper element from attunements:But
conversionRate(0.2 for enchanter, 0.25 for fabricator) is the conversion base rate, NOT the raw mana regen. The raw mana regen israwManaRegen(0.5 for enchanter, 0.4 for fabricator).The
grossRegenper-element map is used inconversion-rates.tsline ~172 to check if component regen is sufficient:Since
grossRegenuses the wrong field (conversionRate=0.2 instead of rawManaRegen=0.5), the per-element gross regen values are wrong. For composite elements (e.g., Metal = Fire + Earth), the component check compares against tiny values.Fix:
buildConversionParamsshould usedef.rawManaRegeninstead ofdef.conversionRatefor the per-element gross regen. Also, level scaling should be applied (matchinggetTotalAttunementRegen).Affected files
src/lib/game/stores/gameStore.ts—buildConversionParams()function (line ~375-397) and the tick pipeline wherebaseRegenis computed (line ~119-122, ~171-176)src/lib/game/utils/conversion-rates.ts—computeConversionRates()pause logic (line ~155-175)Impact
elementRegenstore which is written from the same conversion result, but thefinalRateis set to 0 when paused, so the display is also wrong — the+33.43/hrin the bug report may be from a different code path or stale state)Evidence from bug report
Base: 22.29/hr= disciplineRate(22.04) + attunementBase(0.25) — correctneed 3342.95/hr= 22.29 × 1.50(attMult) × 100(rawCost) ≈ 3343.5 — correcthave 2.00/hr— WRONG, should be ~3342.95 or higherRegression test needed
A test that:
computeConversionRateswith the correctrawGrossRegenfinalRate > 0for elements with active conversion ratesInvestigation Summary
Confirmed: Two root causes identified
Bug 1 —
rawGrossRegenis ~2.00/hr instead of actual regen (gameStore.ts)In the tick pipeline (
gameStore.ts~line 119-122):attunements: {}meansgetTotalAttunementRegen({})returns 0. TherawGrossRegenpassed tocomputeConversionRatesis therefore just the base 2/hr (+ small prestige bonuses), NOT the actual regen including attunement contributions (which can be 3000+/hr).This is why the pause check says
have 2.00/hr— it's comparing conversion drain against base regen only.Bug 2 —
grossRegenper-element uses wrong field (gameStore.tsbuildConversionParams)conversionRate(0.2 enchanter, 0.25 fabricator) is the conversion base rate, NOT raw mana regen. Should berawManaRegen(0.5 enchanter, 0.4 fabricator). Also missing level scaling (1.5^(level-1)).Traced code path
gameStore.ts:tick()→ computesbaseRegenwith empty attunements → passes asrawGrossRegengameStore.ts:tick()→ callsbuildConversionParams()→ buildsgrossRegenwith wrong fieldconversion-rates.ts:computeConversionRates()→ usesrawGrossRegen(2/hr) for pause check → pauses everythingconversion-rates.ts:computeConversionRates()→ usesgrossRegen[comp](0.2) for component check → also pauses compositesgameStore.ts:tick()→ setsfinalRate: paused ? 0 : finalRate→ all rates become 0gameStore.ts:tick()→ writeselementRegento store → all zerosManaDisplay.tsx→ readselementRegenfrom store → shows 0 or stale valuesWhy the two different numbers in the bug report
+33.43/hr— this is theelementRegenvalue from the store, which may be from a previous tick before the pause logic kicked in, or from thenetRatecalculation that doesn't account for the pause correctlyhave 2.00/hr— this is therawGrossRegenvalue (base regen without attunements)Files involved
src/lib/game/stores/gameStore.ts— primary bug location (lines ~119-122, ~171-176, ~375-397)src/lib/game/utils/conversion-rates.ts— pause logic (lines ~155-175)src/lib/game/data/attunements.ts—rawManaRegenvsconversionRatefieldssrc/lib/game/utils/mana-utils.ts—computeRegenandgetTotalAttunementRegensrc/app/components/LeftPanel.tsx— display side (lines ~79-96, same bug inbuildConversionParamsequivalent)src/components/game/tabs/StatsTab/ElementStatsSection.tsx— display side (lines ~38-55, same bug)Investigating elemental mana conversion pause bug — rawGrossRegen compared against per-element drain instead of total drain.
Fix Complete — Bug #348
Root Causes Fixed
Bug 1:
rawGrossRegenwas ~2/hr instead of actual regengameStore.ts:computeRegennow receivesctx.attunement.attunementsinstead of{}, sorawGrossRegenincludes attunement contributions (0.5/hr base × 1.5^(level-1) scaling)useGameDerived.ts: Same fix — passes actual attunements tocomputeRegenfor thebaseRegencalculation used by StatsTabBug 2:
grossRegenper-element used wrong fieldgameStore.tsbuildConversionParams: Changed fromdef.conversionRate(0.2 enchanter) todef.rawManaRegen(0.5 enchanter) with level scaling× 1.5^(level-1)LeftPanel.tsx: Same fix + includes attunement regen inrawGrossRegendisplay valueElementStatsSection.tsx: Same fixFiles Changed (8 files, +290/-13)
src/lib/game/stores/gameStore.ts— primary tick pipeline fixsrc/lib/game/hooks/useGameDerived.ts— display-side baseRegen fixsrc/app/components/LeftPanel.tsx— display-side grossRegen + rawGrossRegen fixsrc/components/game/tabs/StatsTab/ElementStatsSection.tsx— display-side grossRegen fixsrc/lib/game/__tests__/conversion-pause-bug-regression.test.ts— new regression test (7 tests)Test Results
Commit
076282c— pushed to master