test(combat): cover DEFEND mitigating a resolving Heavy Attack

This commit is contained in:
Bastian Wagner
2026-08-20 21:37:36 +02:00
parent b3dac8f61c
commit 6eb0f21360

View File

@@ -266,4 +266,24 @@ describe('CombatEngineService', () => {
expect(first).toEqual(second);
});
it('DEFEND mitigates a resolving Heavy Attack by half', () => {
const state = baseState({
monster: {
currentHp: 45,
maxHp: 45,
stats: { attack: 5, armor: 0, pendingAction: 'HEAVY_ATTACK' },
},
});
const result = engine.resolveAction(state, { action: CombatAction.DEFEND });
// raw = 5; mitigated = 4.545...; heavy * 1.6 = 7.27; * defend 0.5 = 3.636 -> rounds to 4
expect(result.events).toEqual([
{ source: Combatant.PLAYER, target: Combatant.PLAYER, type: CombatEventType.DEFEND },
{ source: Combatant.MONSTER, target: Combatant.PLAYER, type: CombatEventType.DAMAGE, amount: 4 },
]);
expect(result.state.monster.stats.pendingAction).toBeUndefined();
expect(result.state.player.currentHp).toBe(100 - 4);
});
});