[High] [Bug] Cast progress meter counts above 100% after enemy defeat on last descent room (floor 1, room 0) #381

Closed
opened 2026-06-12 12:05:45 +02:00 by Anexim · 2 comments
Owner

Bug Summary

When descending the spire and defeating the enemy on the last room (floor 1, room 0), the cast progress meter keeps counting up past 100% because combat processing continues after isDescentComplete is set.

Expected Behavior

Cast progress should stop accumulating when the descent is complete. The meter should never exceed 100%.

Root Cause

Multiple missing guards:

  1. combat-descent-actions.ts:55-58: advanceRoomOrFloor() early-returns with isDescentComplete: true but does NOT reset castProgress: 0 or weaponCastProgress: {}

  2. combat-actions.ts:142: Cast progress is incremented unconditionally every tick — no check for isDescentComplete

  3. combat-actions.ts:98: Early-exit guard only checks currentAction !== 'climb', does NOT check isDescentComplete

  4. gameStore.ts: Combat processing block does NOT check isDescentComplete before running combat, and writes cr.castProgress back unconditionally

Once isDescentComplete is true, processCombatTick still runs every tick, incrementing weaponCastProgress['primary'] by progressPerTick each time with no cap.

Severity

High — Visual/UX bug that cascades: cast progress exceeding 1.0 triggers the spell-casting while loop on subsequent ticks, potentially causing phantom spell casts with stale floorHP values and unexpected mana consumption.

Fix Direction (defense in depth)

  1. In combat-descent-actions.ts:55, add castProgress: 0 and weaponCastProgress: {} to the set() call
  2. In processCombatTick(), add isDescentComplete to the early-exit guard

Files Involved

File Lines Issue
src/lib/game/stores/combat-descent-actions.ts 55-58 Missing castProgress reset on descent completion
src/lib/game/stores/combat-actions.ts 142 Unconditional cast progress increment
src/lib/game/stores/combat-actions.ts 98 Missing isDescentComplete check
## Bug Summary When descending the spire and defeating the enemy on the last room (floor 1, room 0), the cast progress meter keeps counting up past 100% because combat processing continues after `isDescentComplete` is set. ## Expected Behavior Cast progress should stop accumulating when the descent is complete. The meter should never exceed 100%. ## Root Cause Multiple missing guards: 1. **`combat-descent-actions.ts:55-58`**: `advanceRoomOrFloor()` early-returns with `isDescentComplete: true` but does NOT reset `castProgress: 0` or `weaponCastProgress: {}` 2. **`combat-actions.ts:142`**: Cast progress is incremented unconditionally every tick — no check for `isDescentComplete` 3. **`combat-actions.ts:98`**: Early-exit guard only checks `currentAction !== 'climb'`, does NOT check `isDescentComplete` 4. **`gameStore.ts`**: Combat processing block does NOT check `isDescentComplete` before running combat, and writes `cr.castProgress` back unconditionally Once `isDescentComplete` is true, `processCombatTick` still runs every tick, incrementing `weaponCastProgress['primary']` by `progressPerTick` each time with no cap. ## Severity **High** — Visual/UX bug that cascades: cast progress exceeding 1.0 triggers the spell-casting while loop on subsequent ticks, potentially causing phantom spell casts with stale floorHP values and unexpected mana consumption. ## Fix Direction (defense in depth) 1. In `combat-descent-actions.ts:55`, add `castProgress: 0` and `weaponCastProgress: {}` to the `set()` call 2. In `processCombatTick()`, add `isDescentComplete` to the early-exit guard ## Files Involved | File | Lines | Issue | |------|-------|------| | `src/lib/game/stores/combat-descent-actions.ts` | 55-58 | Missing castProgress reset on descent completion | | `src/lib/game/stores/combat-actions.ts` | 142 | Unconditional cast progress increment | | `src/lib/game/stores/combat-actions.ts` | 98 | Missing `isDescentComplete` check |
Anexim added the ai:todo label 2026-06-12 12:05:45 +02:00
n8n-gitea was assigned by Anexim 2026-06-12 12:05:45 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-12 19:01:33 +02:00
Author
Owner

Starting investigation of cast progress meter bug.

Starting investigation of cast progress meter bug.
Anexim added ai:done and removed ai:in-progress labels 2026-06-12 19:03:33 +02:00
Author
Owner

Fixed with defense-in-depth approach:

  1. combat-descent-actions.ts: Added castProgress: 0 and weaponCastProgress: {} to the isDescentComplete set() call so the meter resets immediately when descent completes.

  2. combat-actions.ts: Added isDescentComplete to the early-exit guard in processCombatTick (if (state.currentAction !== 'climb' || state.isDescentComplete)), preventing any combat processing (and phantom spell casts) after descent is complete.

All 1196 tests pass. Pre-commit checks OK.

✅ Fixed with defense-in-depth approach: 1. **combat-descent-actions.ts:** Added `castProgress: 0` and `weaponCastProgress: {}` to the `isDescentComplete` set() call so the meter resets immediately when descent completes. 2. **combat-actions.ts:** Added `isDescentComplete` to the early-exit guard in `processCombatTick` (`if (state.currentAction !== 'climb' || state.isDescentComplete)`), preventing any combat processing (and phantom spell casts) after descent is complete. All 1196 tests pass. Pre-commit checks OK.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#381