Show live max hit in bag panel and spell list.
Compute neutral max hit from worn weapon stat, skill levels, and gear bonuses; staff users see a mind spell range from known attack spells.
@@ -105,7 +105,10 @@
105
105
</div>
106
106
107
107
<aside id="bag-panel" hidden>
108
<h2>Bag</h2>
108
<div class="bag-header">
109
<h2>Bag</h2>
110
<p id="bag-max-hit" class="bag-max-hit hint" hidden></p>
111
</div>
109
112
<p id="bag-coins" hidden>0 coins</p>
110
113
<div id="equip-grid" class="item-grid equip"></div>
111
114
<div id="bag-grid" class="item-grid"></div>
@@ -105,7 +105,10 @@105
</div>105
</div>106
106
107
<aside id="bag-panel" hidden>107
<aside id="bag-panel" hidden>108
<h2>Bag</h2>108
<div class="bag-header">109
<h2>Bag</h2>110
<p id="bag-max-hit" class="bag-max-hit hint" hidden></p>111
</div>109
<p id="bag-coins" hidden>0 coins</p>112
<p id="bag-coins" hidden>0 coins</p>110
<div id="equip-grid" class="item-grid equip"></div>113
<div id="equip-grid" class="item-grid equip"></div>111
<div id="bag-grid" class="item-grid"></div>114
<div id="bag-grid" class="item-grid"></div>@@ -13,6 +13,7 @@ import
13
13
import { formatLetterSignature } from "/shared/courier/systemLetters.js";
14
14
import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";
15
15
import { spellDefinition } from "/shared/definitions/spells.js";
16
import { bagMaxHitDisplay } from "/shared/combat/maxHit.js";
16
17
import { applyItemIcon } from "../render/potionIcon.js";
17
18
import { mountLayerPreview } from "./characterPreview.js";
18
19
@@ -35,12 +36,17 @@ export function initInventory ({
35
36
getLocalName,
36
37
tipArrows = null,
37
38
getSoftClaims = null,
38
knowsSpell = null
39
knowsSpell = null,
40
getSkillLevels = null,
41
getSettings = null,
42
getKnownSpellIds = null,
43
onBagChanged = null
39
44
})
40
45
{
41
46
const bagPanel = document.getElementById("bag-panel");
42
47
const bagGrid = document.getElementById("bag-grid");
43
48
const equipGrid = document.getElementById("equip-grid");
49
const bagMaxHitEl = document.getElementById("bag-max-hit");
44
50
const hint = document.getElementById("bag-hint");
45
51
const bankPanel = document.getElementById("bank-panel");
46
52
const vaultGrid = document.getElementById("vault-grid");
@@ -191,6 +197,22 @@ export function initInventory ({
191
197
return slots;
192
198
}
193
199
200
function refreshMaxHit ()
201
{
202
if (!bagMaxHitEl)
203
{ return; }
204
const display = bagMaxHitDisplay({
205
skillLevels: getSkillLevels?.() ?? {},
206
equipmentSlots: bag.equipment?.slots ?? {},
207
settings: getSettings?.() ?? null,
208
knownSpellIds: getKnownSpellIds?.() ?? []
209
});
210
const statSuffix = display.statLabel ? ` (${display.statLabel})` : "";
211
bagMaxHitEl.textContent = `Max hit: ${display.text}${statSuffix}`;
212
bagMaxHitEl.title = display.title ?? "";
213
bagMaxHitEl.hidden = false;
214
}
215
194
216
function render ()
195
217
{
196
218
bagGrid.innerHTML = "";
@@ -327,6 +349,7 @@ export function initInventory ({
327
349
});
328
350
equipGrid.append(button);
329
351
}
352
refreshMaxHit();
330
353
}
331
354
332
355
function showItemMenu (x, y, slotIndex, slot)
@@ -1008,6 +1031,7 @@ export function initInventory ({
1008
1031
{
1009
1032
render();
1010
1033
},
1034
refreshMaxHit,
1011
1035
isBlocking ()
1012
1036
{
1013
1037
if (!sendPanel.hidden || !letterPanel.hidden || !sendTargetPanel.hidden
@@ -1060,6 +1084,7 @@ export function initInventory ({
1060
1084
{
1061
1085
bag = { ...bag, ...message };
1062
1086
render();
1087
onBagChanged?.();
1063
1088
if (bankOpen)
1064
1089
{
1065
1090
renderBank();
@@ -13,6 +13,7 @@ import13
import { formatLetterSignature } from "/shared/courier/systemLetters.js";13
import { formatLetterSignature } from "/shared/courier/systemLetters.js";14
import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";14
import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";15
import { spellDefinition } from "/shared/definitions/spells.js";15
import { spellDefinition } from "/shared/definitions/spells.js";16
import { bagMaxHitDisplay } from "/shared/combat/maxHit.js";16
import { applyItemIcon } from "../render/potionIcon.js";17
import { applyItemIcon } from "../render/potionIcon.js";17
import { mountLayerPreview } from "./characterPreview.js";18
import { mountLayerPreview } from "./characterPreview.js";18
19
@@ -35,12 +36,17 @@ export function initInventory ({35
getLocalName,36
getLocalName,36
tipArrows = null,37
tipArrows = null,37
getSoftClaims = null,38
getSoftClaims = null,38
knowsSpell = null39
knowsSpell = null,40
getSkillLevels = null,41
getSettings = null,42
getKnownSpellIds = null,43
onBagChanged = null39
})44
})40
{45
{41
const bagPanel = document.getElementById("bag-panel");46
const bagPanel = document.getElementById("bag-panel");42
const bagGrid = document.getElementById("bag-grid");47
const bagGrid = document.getElementById("bag-grid");43
const equipGrid = document.getElementById("equip-grid");48
const equipGrid = document.getElementById("equip-grid");49
const bagMaxHitEl = document.getElementById("bag-max-hit");44
const hint = document.getElementById("bag-hint");50
const hint = document.getElementById("bag-hint");45
const bankPanel = document.getElementById("bank-panel");51
const bankPanel = document.getElementById("bank-panel");46
const vaultGrid = document.getElementById("vault-grid");52
const vaultGrid = document.getElementById("vault-grid");@@ -191,6 +197,22 @@ export function initInventory ({191
return slots;197
return slots;192
}198
}193
199
200
function refreshMaxHit ()201
{202
if (!bagMaxHitEl)203
{ return; }204
const display = bagMaxHitDisplay({205
skillLevels: getSkillLevels?.() ?? {},206
equipmentSlots: bag.equipment?.slots ?? {},207
settings: getSettings?.() ?? null,208
knownSpellIds: getKnownSpellIds?.() ?? []209
});210
const statSuffix = display.statLabel ? ` (${display.statLabel})` : "";211
bagMaxHitEl.textContent = `Max hit: ${display.text}${statSuffix}`;212
bagMaxHitEl.title = display.title ?? "";213
bagMaxHitEl.hidden = false;214
}215
194
function render ()216
function render ()195
{217
{196
bagGrid.innerHTML = "";218
bagGrid.innerHTML = "";@@ -327,6 +349,7 @@ export function initInventory ({327
});349
});328
equipGrid.append(button);350
equipGrid.append(button);329
}351
}352
refreshMaxHit();330
}353
}331
354
332
function showItemMenu (x, y, slotIndex, slot)355
function showItemMenu (x, y, slotIndex, slot)@@ -1008,6 +1031,7 @@ export function initInventory ({1008
{1031
{1009
render();1032
render();1010
},1033
},1034
refreshMaxHit,1011
isBlocking ()1035
isBlocking ()1012
{1036
{1013
if (!sendPanel.hidden || !letterPanel.hidden || !sendTargetPanel.hidden1037
if (!sendPanel.hidden || !letterPanel.hidden || !sendTargetPanel.hidden@@ -1060,6 +1084,7 @@ export function initInventory ({1060
{1084
{1061
bag = { ...bag, ...message };1085
bag = { ...bag, ...message };1062
render();1086
render();1087
onBagChanged?.();1063
if (bankOpen)1088
if (bankOpen)1064
{1089
{1065
renderBank();1090
renderBank();@@ -1668,6 +1668,22 @@ async function main ()
1668
1668
knowsSpell (spellId)
1669
1669
{
1670
1670
return !!spells?.knowsSpell?.(spellId);
1671
},
1672
getSkillLevels ()
1673
{
1674
return skills?.getSkillLevels?.() ?? {};
1675
},
1676
getSettings ()
1677
{
1678
return view?.settings ?? null;
1679
},
1680
getKnownSpellIds ()
1681
{
1682
return spells?.getKnownSpellIds?.() ?? [];
1683
},
1684
onBagChanged ()
1685
{
1686
spells?.refreshMaxHitDisplay?.();
1671
1687
}
1672
1688
});
1673
1689
skills = initSkills({
@@ -1686,6 +1702,18 @@ async function main ()
1686
1702
getSkillLevel (skillId)
1687
1703
{
1688
1704
return skills?.skillLevel?.(skillId) ?? 1;
1705
},
1706
getSkillLevels ()
1707
{
1708
return skills?.getSkillLevels?.() ?? {};
1709
},
1710
getEquipmentSlots ()
1711
{
1712
return inventory?.getEquipment?.() ?? {};
1713
},
1714
getSettings ()
1715
{
1716
return view?.settings ?? null;
1689
1717
}
1690
1718
});
1691
1719
crafting = initCrafting({
@@ -1906,12 +1934,15 @@ async function main ()
1906
1934
break;
1907
1935
case MessageType.skills:
1908
1936
skills?.render(message.skills, message.combatLevel);
1937
inventory?.refreshMaxHit?.();
1938
spells?.refreshMaxHitDisplay?.();
1909
1939
crafting?.refresh();
1910
1940
spells?.refreshCastGates?.();
1911
1941
break;
1912
1942
case MessageType.spells:
1913
1943
case MessageType.spellsUpdated:
1914
1944
spells?.render(message);
1945
inventory?.refreshMaxHit?.();
1915
1946
break;
1916
1947
case MessageType.spellArmed:
1917
1948
spells?.handleSpellArmed(message);
@@ -1668,6 +1668,22 @@ async function main ()1668
knowsSpell (spellId)1668
knowsSpell (spellId)1669
{1669
{1670
return !!spells?.knowsSpell?.(spellId);1670
return !!spells?.knowsSpell?.(spellId);1671
},1672
getSkillLevels ()1673
{1674
return skills?.getSkillLevels?.() ?? {};1675
},1676
getSettings ()1677
{1678
return view?.settings ?? null;1679
},1680
getKnownSpellIds ()1681
{1682
return spells?.getKnownSpellIds?.() ?? [];1683
},1684
onBagChanged ()1685
{1686
spells?.refreshMaxHitDisplay?.();1671
}1687
}1672
});1688
});1673
skills = initSkills({1689
skills = initSkills({@@ -1686,6 +1702,18 @@ async function main ()1686
getSkillLevel (skillId)1702
getSkillLevel (skillId)1687
{1703
{1688
return skills?.skillLevel?.(skillId) ?? 1;1704
return skills?.skillLevel?.(skillId) ?? 1;1705
},1706
getSkillLevels ()1707
{1708
return skills?.getSkillLevels?.() ?? {};1709
},1710
getEquipmentSlots ()1711
{1712
return inventory?.getEquipment?.() ?? {};1713
},1714
getSettings ()1715
{1716
return view?.settings ?? null;1689
}1717
}1690
});1718
});1691
crafting = initCrafting({1719
crafting = initCrafting({@@ -1906,12 +1934,15 @@ async function main ()1906
break;1934
break;1907
case MessageType.skills:1935
case MessageType.skills:1908
skills?.render(message.skills, message.combatLevel);1936
skills?.render(message.skills, message.combatLevel);1937
inventory?.refreshMaxHit?.();1938
spells?.refreshMaxHitDisplay?.();1909
crafting?.refresh();1939
crafting?.refresh();1910
spells?.refreshCastGates?.();1940
spells?.refreshCastGates?.();1911
break;1941
break;1912
case MessageType.spells:1942
case MessageType.spells:1913
case MessageType.spellsUpdated:1943
case MessageType.spellsUpdated:1914
spells?.render(message);1944
spells?.render(message);1945
inventory?.refreshMaxHit?.();1915
break;1946
break;1916
case MessageType.spellArmed:1947
case MessageType.spellArmed:1917
spells?.handleSpellArmed(message);1948
spells?.handleSpellArmed(message);@@ -174,6 +174,13 @@ export function initSkills ({ getEquipmentSlots, getSettings } = {})
174
174
{
175
175
return current.find((entry) => entry.skillId === skillId)?.level ?? 1;
176
176
},
177
getSkillLevels ()
178
{
179
const out = {};
180
for (const skill of current)
181
{ out[skill.skillId] = skill.level | 0 || 1; }
182
return out;
183
},
177
184
hide ()
178
185
{
179
186
panel.hidden = true;
@@ -174,6 +174,13 @@ export function initSkills ({ getEquipmentSlots, getSettings } = {})174
{174
{175
return current.find((entry) => entry.skillId === skillId)?.level ?? 1;175
return current.find((entry) => entry.skillId === skillId)?.level ?? 1;176
},176
},177
getSkillLevels ()178
{179
const out = {};180
for (const skill of current)181
{ out[skill.skillId] = skill.level | 0 || 1; }182
return out;183
},177
hide ()184
hide ()178
{185
{179
panel.hidden = true;186
panel.hidden = true;@@ -3,8 +3,16 @@
3
3
*/
4
4
import { spellDefinition, spellMindPowerFromTier, spellMinMagicLevel } from "/shared/definitions/spells.js";
5
5
import { SkillId } from "/shared/definitions/skills.js";
6
import { spellMaxHitDisplay } from "/shared/combat/maxHit.js";
6
7
7
export function initSpells ({ socket, MessageType, getSkillLevel } = {})
8
export function initSpells ({
9
socket,
10
MessageType,
11
getSkillLevel,
12
getSkillLevels = null,
13
getEquipmentSlots = null,
14
getSettings = null
15
} = {})
8
16
{
9
17
const panel = document.getElementById("spells-panel");
10
18
const list = document.getElementById("spells-list");
@@ -53,6 +61,12 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})
53
61
renderBar();
54
62
}
55
63
64
function refreshMaxHitDisplay ()
65
{
66
if (!panel.hidden)
67
{ renderList(); }
68
}
69
56
70
function disarmLocal ()
57
71
{
58
72
if (!armedSpellId)
@@ -116,6 +130,22 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})
116
130
desc.className = "spell-desc hint";
117
131
desc.textContent = spell.description ?? "";
118
132
133
const maxHit = spellMaxHitDisplay({
134
spellId: spell.spellId,
135
skillLevels: getSkillLevels?.() ?? {},
136
equipmentSlots: getEquipmentSlots?.() ?? {},
137
settings: getSettings?.() ?? null
138
});
139
const maxHitEl = maxHit != null
140
? (() =>
141
{
142
const line = document.createElement("div");
143
line.className = "spell-max-hit hint";
144
line.textContent = `Max hit: ${maxHit}`;
145
return line;
146
})()
147
: null;
148
119
149
const actions = document.createElement("div");
120
150
actions.className = "spell-actions";
121
151
@@ -146,7 +176,10 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})
146
176
});
147
177
148
178
actions.append(favorite, arm);
149
body.append(title, desc, actions);
179
body.append(title, desc);
180
if (maxHitEl)
181
{ body.append(maxHitEl); }
182
body.append(actions);
150
183
row.append(icon, body);
151
184
return row;
152
185
}
@@ -253,6 +286,11 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})
253
286
{
254
287
return spells.some((spell) => spell.spellId === spellId);
255
288
},
289
getKnownSpellIds ()
290
{
291
return spells.map((spell) => spell.spellId);
292
},
293
refreshMaxHitDisplay,
256
294
handleSpellDisarmed ()
257
295
{
258
296
disarmLocal();
@@ -3,8 +3,16 @@3
*/3
*/4
import { spellDefinition, spellMindPowerFromTier, spellMinMagicLevel } from "/shared/definitions/spells.js";4
import { spellDefinition, spellMindPowerFromTier, spellMinMagicLevel } from "/shared/definitions/spells.js";5
import { SkillId } from "/shared/definitions/skills.js";5
import { SkillId } from "/shared/definitions/skills.js";6
import { spellMaxHitDisplay } from "/shared/combat/maxHit.js";6
7
7
export function initSpells ({ socket, MessageType, getSkillLevel } = {})8
export function initSpells ({9
socket,10
MessageType,11
getSkillLevel,12
getSkillLevels = null,13
getEquipmentSlots = null,14
getSettings = null15
} = {})8
{16
{9
const panel = document.getElementById("spells-panel");17
const panel = document.getElementById("spells-panel");10
const list = document.getElementById("spells-list");18
const list = document.getElementById("spells-list");@@ -53,6 +61,12 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})53
renderBar();61
renderBar();54
}62
}55
63
64
function refreshMaxHitDisplay ()65
{66
if (!panel.hidden)67
{ renderList(); }68
}69
56
function disarmLocal ()70
function disarmLocal ()57
{71
{58
if (!armedSpellId)72
if (!armedSpellId)@@ -116,6 +130,22 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})116
desc.className = "spell-desc hint";130
desc.className = "spell-desc hint";117
desc.textContent = spell.description ?? "";131
desc.textContent = spell.description ?? "";118
132
133
const maxHit = spellMaxHitDisplay({134
spellId: spell.spellId,135
skillLevels: getSkillLevels?.() ?? {},136
equipmentSlots: getEquipmentSlots?.() ?? {},137
settings: getSettings?.() ?? null138
});139
const maxHitEl = maxHit != null140
? (() =>141
{142
const line = document.createElement("div");143
line.className = "spell-max-hit hint";144
line.textContent = `Max hit: ${maxHit}`;145
return line;146
})()147
: null;148
119
const actions = document.createElement("div");149
const actions = document.createElement("div");120
actions.className = "spell-actions";150
actions.className = "spell-actions";121
151
@@ -146,7 +176,10 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})146
});176
});147
177
148
actions.append(favorite, arm);178
actions.append(favorite, arm);149
body.append(title, desc, actions);179
body.append(title, desc);180
if (maxHitEl)181
{ body.append(maxHitEl); }182
body.append(actions);150
row.append(icon, body);183
row.append(icon, body);151
return row;184
return row;152
}185
}@@ -253,6 +286,11 @@ export function initSpells ({ socket, MessageType, getSkillLevel } = {})253
{286
{254
return spells.some((spell) => spell.spellId === spellId);287
return spells.some((spell) => spell.spellId === spellId);255
},288
},289
getKnownSpellIds ()290
{291
return spells.map((spell) => spell.spellId);292
},293
refreshMaxHitDisplay,256
handleSpellDisarmed ()294
handleSpellDisarmed ()257
{295
{258
disarmLocal();296
disarmLocal();@@ -861,6 +861,11 @@ button.friend-account-name:hover {
861
861
line-height: 1.35;
862
862
}
863
863
864
.spell-max-hit {
865
margin: 0.15rem 0 0.35rem;
866
font-size: 0.82rem;
867
}
868
864
869
.spell-actions {
865
870
display: flex;
866
871
gap: 0.4rem;
@@ -945,6 +950,25 @@ button.friend-account-name:hover {
945
950
padding: 0.75rem;
946
951
}
947
952
953
.bag-header {
954
display: flex;
955
align-items: baseline;
956
justify-content: space-between;
957
gap: 0.75rem;
958
flex-wrap: wrap;
959
margin-bottom: 0.35rem;
960
}
961
962
.bag-header h2 {
963
margin: 0;
964
}
965
966
.bag-max-hit {
967
margin: 0;
968
font-size: 0.85rem;
969
white-space: nowrap;
970
}
971
948
972
#bank-panel {
949
973
left: auto;
950
974
right: 0.75rem;
@@ -861,6 +861,11 @@ button.friend-account-name:hover {861
line-height: 1.35;861
line-height: 1.35;862
}862
}863
863
864
.spell-max-hit {865
margin: 0.15rem 0 0.35rem;866
font-size: 0.82rem;867
}868
864
.spell-actions {869
.spell-actions {865
display: flex;870
display: flex;866
gap: 0.4rem;871
gap: 0.4rem;@@ -945,6 +950,25 @@ button.friend-account-name:hover {945
padding: 0.75rem;950
padding: 0.75rem;946
}951
}947
952
953
.bag-header {954
display: flex;955
align-items: baseline;956
justify-content: space-between;957
gap: 0.75rem;958
flex-wrap: wrap;959
margin-bottom: 0.35rem;960
}961
962
.bag-header h2 {963
margin: 0;964
}965
966
.bag-max-hit {967
margin: 0;968
font-size: 0.85rem;969
white-space: nowrap;970
}971
948
#bank-panel {972
#bank-panel {949
left: auto;973
left: auto;950
right: 0.75rem;974
right: 0.75rem;@@ -0,0 +1,71 @@
1
import test from "node:test";
2
import assert from "node:assert/strict";
3
import { SkillId } from "../../shared/definitions/skills.js";
4
import { SwordItemId } from "../../shared/definitions/swordItems.js";
5
import { GemItemId } from "../../shared/definitions/gemItems.js";
6
import { SpellId } from "../../shared/definitions/spells.js";
7
import
8
{
9
bagMaxHitDisplay,
10
effectivePhysicalDamageLevel,
11
isPlayerAttackDamageSpell,
12
maxNeutralPhysicalHit,
13
spellMaxHitDisplay
14
} from "../../shared/combat/maxHit.js";
15
16
test("physical max hit uses quarter-tier damage roll cap", () =>
17
{
18
assert.equal(maxNeutralPhysicalHit(99), 25);
19
assert.equal(maxNeutralPhysicalHit(123), 31);
20
});
21
22
test("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
34
test("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
47
test("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
61
test("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
});
@@ -0,0 +1,71 @@1
import test from "node:test";2
import assert from "node:assert/strict";3
import { SkillId } from "../../shared/definitions/skills.js";4
import { SwordItemId } from "../../shared/definitions/swordItems.js";5
import { GemItemId } from "../../shared/definitions/gemItems.js";6
import { SpellId } from "../../shared/definitions/spells.js";7
import8
{9
bagMaxHitDisplay,10
effectivePhysicalDamageLevel,11
isPlayerAttackDamageSpell,12
maxNeutralPhysicalHit,13
spellMaxHitDisplay14
} from "../../shared/combat/maxHit.js";15
16
test("physical max hit uses quarter-tier damage roll cap", () =>17
{18
assert.equal(maxNeutralPhysicalHit(99), 25);19
assert.equal(maxNeutralPhysicalHit(123), 31);20
});21
22
test("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
34
test("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
47
test("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
61
test("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
});