| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { mobCanFight, mobIsBoss, mobMeleeAttackProfile } from "../../shared/definitions/mobCombat.js"; |
| 4 | import { MobId, mobDefinition } from "../../shared/definitions/mobs.js"; |
| 5 | import { SkillId } from "../../shared/definitions/skills.js"; |
| 6 | |
| 7 | test("living targetable mobs can fight except pigeons", () => |
| 8 | { |
| 9 | assert.equal(mobCanFight(mobDefinition(MobId.deer)), true); |
| 10 | assert.equal(mobCanFight(mobDefinition(MobId.rat)), true); |
| 11 | assert.equal(mobCanFight(mobDefinition(MobId.pigeon)), false); |
| 12 | }); |
| 13 | |
| 14 | test("mobIsBoss is false for normal mobs", () => |
| 15 | { |
| 16 | assert.equal(mobIsBoss(mobDefinition(MobId.rat)), false); |
| 17 | assert.equal(mobIsBoss({ boss: true }), true); |
| 18 | }); |
| 19 | |
| 20 | test("mob attack profile uses one attackSkill for hit and damage rolls", () => |
| 21 | { |
| 22 | const profile = mobMeleeAttackProfile(mobDefinition(MobId.rat)); |
| 23 | assert.equal(profile.mobAttackSkill, 1); |
| 24 | assert.equal(profile.baseDamage, undefined); |
| 25 | }); |
| 26 | |
| 27 | test("goblins can fight and default to level 5 with slashing melee", () => |
| 28 | { |
| 29 | assert.equal(mobCanFight(mobDefinition(MobId.goblin)), true); |
| 30 | const profile = mobMeleeAttackProfile(mobDefinition(MobId.goblin), 5); |
| 31 | assert.equal(profile.mobAttackSkill, 5); |
| 32 | assert.equal(profile.mode, "melee"); |
| 33 | assert.equal(profile.attackType, "slashing"); |
| 34 | assert.equal(profile.hitSkillId, SkillId.swordfighting); |
| 35 | }); |