BlueGit

timfa questward

Files

questward / server / tests / mobCombat.test.js

mobCombat.test.js

mobCombat.test.js 1.3 KiB Download Raw
1import test from "node:test";
2import assert from "node:assert/strict";
3import { mobCanFight, mobIsBoss, mobMeleeAttackProfile } from "../../shared/definitions/mobCombat.js";
4import { MobId, mobDefinition } from "../../shared/definitions/mobs.js";
5import { SkillId } from "../../shared/definitions/skills.js";
6
7test("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
14test("mobIsBoss is false for normal mobs", () =>
15{
16 assert.equal(mobIsBoss(mobDefinition(MobId.rat)), false);
17 assert.equal(mobIsBoss({ boss: true }), true);
18});
19
20test("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
27test("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});