import test from "node:test"; import assert from "node:assert/strict"; import { SkillId } from "../../shared/definitions/skills.js"; import { SwordItemId } from "../../shared/definitions/swordItems.js"; import { GemItemId } from "../../shared/definitions/gemItems.js"; import { SpellId } from "../../shared/definitions/spells.js"; import { bagMaxHitDisplay, effectivePhysicalDamageLevel, isPlayerAttackDamageSpell, maxNeutralPhysicalHit, spellMaxHitDisplay } from "../../shared/combat/maxHit.js"; test("physical max hit uses quarter-tier damage roll cap", () => { assert.equal(maxNeutralPhysicalHit(99), 25); assert.equal(maxNeutralPhysicalHit(123), 31); }); test("bag max hit uses strength for a sword", () => { const display = bagMaxHitDisplay({ skillLevels: { [SkillId.strength]: 10 }, equipmentSlots: { weapon: { itemId: SwordItemId.bronzeSword, quantity: 1 } } }); assert.equal(display.statLabel, "Strength"); assert.equal(display.text, "3"); }); test("bag max hit with staff shows mind spell range from known attack spells", () => { const display = bagMaxHitDisplay({ skillLevels: { [SkillId.mind]: 20, [SkillId.strength]: 20 }, equipmentSlots: { weapon: { itemId: GemItemId.pineStaff, quantity: 1 } }, knownSpellIds: [SpellId.manaBullet, SpellId.firebolt, SpellId.hellfire] }); assert.equal(display.statLabel, "Mind"); assert.equal(display.text, "5 – 11"); }); test("spell max hit scales with spell tier", () => { assert.equal(spellMaxHitDisplay({ spellId: SpellId.manaBullet, skillLevels: { [SkillId.mind]: 20 } }), 5); assert.equal(spellMaxHitDisplay({ spellId: SpellId.firebolt, skillLevels: { [SkillId.mind]: 20 } }), 7); assert.equal(spellMaxHitDisplay({ spellId: SpellId.firebolt, skillLevels: { [SkillId.mind]: 50 } }), 15); }); test("spell max hit is shown only for damage spells", () => { assert.equal(isPlayerAttackDamageSpell(SpellId.firebolt), true); assert.equal(isPlayerAttackDamageSpell(SpellId.light), false); assert.equal(spellMaxHitDisplay({ spellId: SpellId.light, skillLevels: { [SkillId.mind]: 50 } }), null); }); test("effective physical damage level includes gear strength bonus", () => { const level = effectivePhysicalDamageLevel({ skillLevels: { [SkillId.strength]: 10 }, equipmentSlots: { weapon: { itemId: SwordItemId.bronzeSword, quantity: 1 } } }); assert.equal(level, 11); assert.equal(maxNeutralPhysicalHit(level), 3); });