BlueGit

timfa questward

Files

questward / server / tests / maxHit.test.js

maxHit.test.js

maxHit.test.js 2.4 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, "5 – 11");
45});
46
47test("spell max hit scales with spell tier", () =>
48{
49 assert.equal(spellMaxHitDisplay({
50 spellId: SpellId.manaBullet,
51 skillLevels: { [SkillId.mind]: 20 }
52 }), 5);
53 assert.equal(spellMaxHitDisplay({
54 spellId: SpellId.firebolt,
55 skillLevels: { [SkillId.mind]: 20 }
56 }), 7);
57 assert.equal(spellMaxHitDisplay({
58 spellId: SpellId.firebolt,
59 skillLevels: { [SkillId.mind]: 50 }
60 }), 15);
61});
62
63test("spell max hit is shown only for damage spells", () =>
64{
65 assert.equal(isPlayerAttackDamageSpell(SpellId.firebolt), true);
66 assert.equal(isPlayerAttackDamageSpell(SpellId.light), false);
67 assert.equal(spellMaxHitDisplay({
68 spellId: SpellId.light,
69 skillLevels: { [SkillId.mind]: 50 }
70 }), null);
71});
72
73test("effective physical damage level includes gear strength bonus", () =>
74{
75 const level = effectivePhysicalDamageLevel({
76 skillLevels: { [SkillId.strength]: 10 },
77 equipmentSlots: {
78 weapon: { itemId: SwordItemId.bronzeSword, quantity: 1 }
79 }
80 });
81 assert.equal(level, 11);
82 assert.equal(maxNeutralPhysicalHit(level), 3);
83});