BUG: getMeditationBonus called with wrong arguments in 3 locations (meditation shows 0x) #212

Closed
opened 2026-05-30 14:56:09 +02:00 by Anexim · 3 comments
Owner

Summary

getMeditationBonus() is called with 4 arguments in 3 locations, but the function only accepts 3 parameters. The second argument is {} (empty object) which coerces to NaN, causing the meditation multiplier to display as "0x" and effective regen to show "0/hr".

Root Cause

The function signature in src/lib/game/utils/mana-utils.ts:117-123:

export function getMeditationBonus(
  meditateTicks: number,
  meditationEfficiency: number = 1,
  disciplineMeditationCap: number = 0,
): number {

But it's called with 4 arguments:

getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus)

The {} empty object gets assigned to meditationEfficiency (expects number), and all subsequent arguments are shifted. Since {} coerces to NaN in arithmetic, the entire function returns NaN, which displays as 0.

Affected Files

  1. src/lib/game/hooks/useGameDerived.ts line 59
  2. src/app/page.tsx line 94
  3. src/app/components/LeftPanel.tsx line 61

Note: src/lib/game/stores/gameHooks.ts line 77 and src/lib/game/stores/gameStore.ts line 155 call it correctly with 3 args.

Fix

Change all 3 affected call sites from:

getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus)

To:

getMeditationBonus(meditateTicks, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus)

Playwright Evidence

Playwright test found mana regen patterns: ["+0", "+1"] — the +0 is the broken meditation/hourly regen value.

Reproduction

  1. Start a new game
  2. Open Stats tab
  3. Observe "Meditation Multiplier: 0x" (should be "1.00x")
  4. Observe "Effective Regen: 0/hr" (should be ~"2.00/hr")

Severity

High - Affects core mana regeneration display and likely the actual regen calculation.

## Summary `getMeditationBonus()` is called with 4 arguments in 3 locations, but the function only accepts 3 parameters. The second argument is `{}` (empty object) which coerces to `NaN`, causing the meditation multiplier to display as "0x" and effective regen to show "0/hr". ## Root Cause The function signature in `src/lib/game/utils/mana-utils.ts:117-123`: ```ts export function getMeditationBonus( meditateTicks: number, meditationEfficiency: number = 1, disciplineMeditationCap: number = 0, ): number { ``` But it's called with 4 arguments: ```ts getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus) ``` The `{}` empty object gets assigned to `meditationEfficiency` (expects number), and all subsequent arguments are shifted. Since `{}` coerces to `NaN` in arithmetic, the entire function returns `NaN`, which displays as `0`. ## Affected Files 1. `src/lib/game/hooks/useGameDerived.ts` line 59 2. `src/app/page.tsx` line 94 3. `src/app/components/LeftPanel.tsx` line 61 Note: `src/lib/game/stores/gameHooks.ts` line 77 and `src/lib/game/stores/gameStore.ts` line 155 call it correctly with 3 args. ## Fix Change all 3 affected call sites from: ```ts getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus) ``` To: ```ts getMeditationBonus(meditateTicks, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus) ``` ## Playwright Evidence Playwright test found mana regen patterns: `["+0", "+1"]` — the `+0` is the broken meditation/hourly regen value. ## Reproduction 1. Start a new game 2. Open Stats tab 3. Observe "Meditation Multiplier: 0x" (should be "1.00x") 4. Observe "Effective Regen: 0/hr" (should be ~"2.00/hr") ## Severity **High** - Affects core mana regeneration display and likely the actual regen calculation.
Anexim added the ai:todo label 2026-05-30 14:56:09 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 14:56:09 +02:00
Author
Owner

Playwright Test Ref

The Playwright test e2e/playtest.spec.ts15 - Deep Bug Hunting → mana regen values in ManaDisplay are correct detected the broken regen by scanning for regen patterns in the page body. It found ["+0", "+1"] where the +0 is the broken hourly regen.

After fixing the 3 call sites, the test should be updated to verify the regen shows a positive value like +2.00/hr at game start.

## Playwright Test Ref The Playwright test `e2e/playtest.spec.ts` → `15 - Deep Bug Hunting → mana regen values in ManaDisplay are correct` detected the broken regen by scanning for regen patterns in the page body. It found `["+0", "+1"]` where the `+0` is the broken hourly regen. After fixing the 3 call sites, the test should be updated to verify the regen shows a positive value like `+2.00/hr` at game start.
Author
Owner

Fix Applied

Fixed getMeditationBonus called with 4 arguments (including spurious {} as 2nd arg) in all 3 affected files:

Files changed:

  1. src/lib/game/hooks/useGameDerived.ts — removed extra {} argument
  2. src/app/page.tsx — removed extra {} argument
  3. src/app/components/LeftPanel.tsx — removed extra {} argument
// Before (all 3 sites):
getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus)

// After (all 3 sites):
getMeditationBonus(meditateTicks, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus)

The meditation multiplier will now correctly show "1.00x" at game start instead of "0x", and effective regen will show proper values instead of "0/hr".

Build: passing

## ✅ Fix Applied Fixed `getMeditationBonus` called with 4 arguments (including spurious `{}` as 2nd arg) in all 3 affected files: **Files changed:** 1. `src/lib/game/hooks/useGameDerived.ts` — removed extra `{}` argument 2. `src/app/page.tsx` — removed extra `{}` argument 3. `src/app/components/LeftPanel.tsx` — removed extra `{}` argument ```ts // Before (all 3 sites): getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus) // After (all 3 sites): getMeditationBonus(meditateTicks, upgradeEffects.meditationEfficiency, disciplineEffects.meditationCapBonus) ``` The meditation multiplier will now correctly show "1.00x" at game start instead of "0x", and effective regen will show proper values instead of "0/hr". Build: ✅ passing
Author
Owner

Fixed — removed erroneous {} argument from all 3 getMeditationBonus call sites. Meditation multiplier now correctly shows 1.00x at game start.

Fixed — removed erroneous `{}` argument from all 3 getMeditationBonus call sites. Meditation multiplier now correctly shows 1.00x at game start.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#212