BlueGit

timfa questward

Files

questward / server / tests / maxHit.test.js

maxHit.test.js

maxHit.test.js 2.1 KiB Download Raw
1import test from "node:test";
2import assert from "node:assert/strict";
3import { SkillId } from "../../shared/definitions/skills.js";
4import { SwordItemId } from "../../shared/definitions/swordItems.js";
5import { GemItemId } from "../../shared/definitions/gemItems.js";
6import { SpellId } from "../../shared/definitions/spells.js";
7import
8{
9 bagMaxHitDisplay,
10 effectivePhysicalDamageLevel,
11 isPlayerAttackDamageSpell,
12 maxNeutralPhysicalHit,
13 spellMaxHitDisplay
14} from "../../shared/combat/maxHit.js";
15
16test("physical max hit uses quarter-tier damage roll cap", () =>
17{
18 assert.equal(maxNeutralPhysicalHit(99), 25);
19 assert.equal(maxNeutralPhysicalHit(123), 31);
20});
21
22test("bag max hit uses strength for a sword", () =>
23{
24 const display = bagMaxHitDisplay({
25 skillLevels: { [SkillId.strength]: 10 },
26 equipmentSlots: {
27 weapon: { itemId: SwordItemId.bronzeSword, quantity: 1 }
28 }
29 });
30 assert.equal(display.statLabel, "Strength");
31 assert.equal(display.text, "3");
32});
33
34test("bag max hit with staff shows mind spell range from known attack spells", () =>
35{
36 const display = bagMaxHitDisplay({
37 skillLevels: { [SkillId.mind]: 20, [SkillId.strength]: 20 },
38 equipmentSlots: {
39 weapon: { itemId: GemItemId.pineStaff, quantity: 1 }
40 },
41 knownSpellIds: [SpellId.manaBullet, SpellId.firebolt, SpellId.hellfire]
42 });
43 assert.equal(display.statLabel, "Mind");
44 assert.equal(display.text, "1 – 5");
45});
46
47test("spell max hit is shown only for damage spells", () =>
48{
49 assert.equal(isPlayerAttackDamageSpell(SpellId.firebolt), true);
50 assert.equal(isPlayerAttackDamageSpell(SpellId.light), false);
51 assert.equal(spellMaxHitDisplay({
52 spellId: SpellId.light,
53 skillLevels: { [SkillId.mind]: 50 }
54 }), null);
55 assert.equal(spellMaxHitDisplay({
56 spellId: SpellId.firebolt,
57 skillLevels: { [SkillId.mind]: 50 }
58 }), 13);
59});
60
61test("effective physical damage level includes gear strength bonus", () =>
62{
63 const level = effectivePhysicalDamageLevel({
64 skillLevels: { [SkillId.strength]: 10 },
65 equipmentSlots: {
66 weapon: { itemId: SwordItemId.bronzeSword, quantity: 1 }
67 }
68 });
69 assert.equal(level, 11);
70 assert.equal(maxNeutralPhysicalHit(level), 3);
71});