[Low] [Task] Combat spec gap: implement AoE target distribution and applyDamageToRoom (spec §3.2) #260
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?
Combat Spec Gap: AoE Target Distribution and applyDamageToRoom
Gap Summary
The combat tick pipeline in
processCombatTick(stores/combat-actions.ts) applies damage directly tofloorHP(a single number) rather than to individual enemies in the room. There is noapplyDamageToRoom()function, no AoE target distribution, and no focus-fire targeting logic. This means multi-enemy rooms (swarm, rooms with multiple enemies) don't work correctly — all damage is subtracted from a single pool rather than being distributed across enemies.What Exists
FloorState.enemies: EnemyState[]— rooms can have multiple enemiesSpellDefinition.aoeflag exists in spell definitionsprocessCombatTicktracksfloorHPas a single number (sum of all enemy HP)floorHP = Math.max(0, floorHP - finalDamage)— no per-enemy targetingWhat's Missing
1. applyDamageToRoom function (spec §3.2)
2. Focus-fire targeting (spec §3.2)
Non-AoE attacks must target the enemy with the lowest current HP by default:
3. Per-enemy damage application in processCombatTick
Current code applies damage to
floorHPdirectly. Must be refactored to:enemy.hpfloorHPas sum of all enemy HPonRoomCleared()4. AoE distribution (spec §3.2)
For AoE spells, damage is distributed across all enemies in the room (each enemy takes full damage, or damage is split — spec says "distribute damage across all enemies" which per the pseudocode means each enemy takes the full AoE damage).
Files to Change
stores/combat-actions.tsapplyDamageToRoom()function; refactorprocessCombatTickto apply damage per-enemy instead of tofloorHPdirectly; addlowestHPEnemy()helper; add AoE branchstores/pipelines/combat-tick.tsonDamageDealtfor per-enemy defense applicationAcceptance Criteria
onRoomCleared()is only triggered when ALL enemies reach 0 HPfloorHPis correctly recalculated as sum of all enemy HP after each damage applicationDependencies
Out of Scope
aoeflag only)Implemented per-enemy damage application (spec §3.2):
applyDamageToRoom()in newcombat-damage.tsmodule — applies damage to individual enemies with AoE distribution and focus-fire targeting (lowest HP enemy)lowestHPEnemy()helper for focus-fire targetingprocessCombatTickto use per-enemy damage for: main spell, equipment spells, melee swords, DoT effectsgolemApplyDamageToRoomingolem-combat.tspipeline to target individual enemies via focus-firecurrentRoomtoCombatTickResulttype and sync throughgameStore.tscombat writesfloorMaxHPto use tracked value fromadvanceRoomOrFloorinstead of recalculating viagetFloorMaxHPcombat-actions.test.tswith proper enemy setup for per-enemy testsmelee-auto-attack.test.tsto includecurrentRoomin mockCombatTickResultobjectsAll 937 tests pass. No circular dependencies. All files under 400 lines.