[Critical] [Bug] Golem combat wipes all mana when no enemies are alive #352
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?
Severity: Critical
File:
src/lib/game/stores/golem-combat-actions.ts(lines 242-243, 310-317) andsrc/lib/game/stores/golem-combat-helpers.ts(lines 148-192)Description:
processGolemAttacksinitializesrawMana = 0andelements = {}as local accumulators. When no golems attack, or all enemies are dead, these zero/empty values are returned. The caller incombat-actions.ts(lines 316-317) then overwrites the game's actual mana state with these zeros:Similarly,
processBasicAttackingolem-combat-helpers.tsinitializesrawMana = 0andelements = {}and returns them when no targets exist.Impact: Complete mana wipe (all elements and raw mana set to zero) whenever golems process their attack phase but find no living enemies. This is a soft-lock at minimum — the player loses all mana progress.
Reproduction:
Fix applied.
processGolemAttacksinitializedrawMana = 0andelements = {}as local accumulators. When no enemies were alive,processBasicAttacknever calledonDamageDealt, so these zero/empty values were returned. The caller incombat-actions.tsthen overwrote the game's actual mana state with these zeros.Root cause: Local accumulators initialized to zero instead of current mana values.
Fix:
processGolemAttacksnow acceptscurrentRawManaandcurrentElementsas parameters and initializes from themprocessBasicAttacknow accepts and usescurrentRawMana/currentElementsinstead of0/{}processGolemAttacksFromStorepasses through the current mana valuescombat-actions.tscaller passesrawManaandelementsto the golem attack pipelineAll 1141 tests pass.
Review complete — fix verified.
The golem combat mana wipe is fixed.
processGolemAttacks,processGolemAttacksFromStore, andprocessBasicAttackall now accept and initialize fromcurrentRawMana/currentElementsinstead of0/{}. When no enemies are alive, the original mana values pass through unchanged instead of being zeroed out.The data flow is unbroken:
combat-actions.ts→processGolemAttacksFromStore→processGolemAttacks→processBasicAttack, with current mana threaded through every level.bug-352-golem-mana-wipe.test.ts: 7/7 tests passNo remaining issues.