import { calculateDamage } from './combat-damage'; describe('calculateDamage', () => { it('applies the established armor mitigation formula', () => { // raw = 12 + 15 = 27; 27 * 60 / (60 + 20) = 20.25 -> rounds to 20 expect(calculateDamage({ attack: 12, weaponDamage: 15 }, 20)).toBe(20); }); it('never returns less than 1 damage, even against extreme armor', () => { expect(calculateDamage({ attack: 1, weaponDamage: 0 }, 100_000)).toBe(1); }); it('treats an attacker with no weaponDamage as having attack alone as its raw damage', () => { // raw = 9; 9 * 60 / (60 + 5) = 8.307... -> rounds to 8 expect(calculateDamage({ attack: 9 }, 5)).toBe(8); }); it('applies a damage multiplier before the minimum-1 floor', () => { // raw = 27; mitigated = 20.25; *1.6 = 32.4 -> rounds to 32 expect(calculateDamage({ attack: 12, weaponDamage: 15 }, 20, 1.6)).toBe(32); }); it('still floors at 1 damage even with a small multiplier', () => { expect(calculateDamage({ attack: 1, weaponDamage: 0 }, 100_000, 0.5)).toBe( 1, ); }); });