fix: melee attacks now apply enemy defenses (armor/barrier/dodge)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m17s

Bug: Melee sword attacks passed null as the enemy to applyEnemyDefenses,
causing all enemy defenses (armor, barrier, dodge) to be bypassed.
Spell damage and DoT effects correctly went through defenses.

Fix: In combat-actions.ts melee loop, get the current target enemy
from currentRoom.enemies (lowest HP, matching focus-fire targeting)
and pass it to applyEnemyDefenses instead of null.

Added 7 regression tests in melee-defense-bypass.test.ts to verify:
- Melee damage is reduced by armor
- Melee damage is reduced by barrier
- Unarmored enemies take more damage than armored ones
- Full damage dealt when no defenses
- Focus-fire targeting (lowest HP enemy)
- Graceful handling of empty enemy list
- Comparison proving defense application

All 948 tests pass (49 test files).
This commit is contained in:
2026-06-06 17:33:31 +02:00
parent 4b7aa82953
commit 325949cc5f
5 changed files with 431 additions and 13 deletions
+33 -11
View File
@@ -1,6 +1,6 @@
{
"_meta": {
"generated": "2026-06-05T13:36:29.562Z",
"generated": "2026-06-06T14:50:38.455Z",
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
},
@@ -454,27 +454,44 @@
"data/golems/base-golems.ts": [
"data/golems/types.ts"
],
"data/golems/cores.ts": [
"data/golems/types.ts"
],
"data/golems/elemental-golems.ts": [
"data/golems/types.ts"
],
"data/golems/frames.ts": [
"data/golems/types.ts"
],
"data/golems/golemEnchantments.ts": [
"data/golems/types.ts"
],
"data/golems/golems-data.ts": [
"data/golems/base-golems.ts",
"data/golems/elemental-golems.ts",
"data/golems/hybrid-golems.ts"
"data/golems/cores.ts",
"data/golems/frames.ts",
"data/golems/golemEnchantments.ts",
"data/golems/mindCircuits.ts"
],
"data/golems/hybrid-golems.ts": [
"data/golems/types.ts"
],
"data/golems/index.ts": [
"data/golems/golems-data.ts",
"data/golems/types.ts",
"data/golems/utils.ts"
"data/golems/cores.ts",
"data/golems/frames.ts",
"data/golems/golemEnchantments.ts",
"data/golems/mindCircuits.ts",
"data/golems/types.ts"
],
"data/golems/mindCircuits.ts": [
"data/golems/types.ts"
],
"data/golems/types.ts": [
"types.ts"
],
"data/golems/utils.ts": [
"data/golems/golems-data.ts",
"data/golems/cores.ts",
"data/golems/frames.ts",
"data/golems/mindCircuits.ts",
"data/golems/types.ts"
],
"data/guardian-data.ts": [
@@ -564,6 +581,7 @@
"stores/combat-actions.ts",
"stores/combat-descent-actions.ts",
"stores/combat-state.types.ts",
"stores/golemancy-actions.ts",
"stores/non-combat-room-actions.ts",
"types.ts",
"utils/activity-log.ts",
@@ -705,8 +723,11 @@
"stores/golem-combat-actions.ts": [
"constants.ts",
"data/golems/index.ts",
"types.ts",
"utils/index.ts"
"data/golems/utils.ts",
"types.ts"
],
"stores/golemancy-actions.ts": [
"types/game.ts"
],
"stores/index.ts": [
"constants.ts",
@@ -742,6 +763,7 @@
"data/guardian-encounters.ts",
"effects/special-effects.ts",
"effects/upgrade-effects.types.ts",
"stores/combat-state.types.ts",
"stores/golem-combat-actions.ts",
"types.ts"
],
@@ -763,7 +785,7 @@
"stores/uiStore.ts"
],
"stores/pipelines/golem-combat.ts": [
"stores/combat-damage.ts",
"stores/attunementStore.ts",
"stores/combatStore.ts",
"stores/golem-combat-actions.ts",
"stores/manaStore.ts",