Skip to content

Commit fbcbaf7

Browse files
committed
fix: address PR #62 review — remove Ward double-count, hoist escapeGGGString, add non-authoritative test
1 parent 910b34e commit fbcbaf7

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,4 +728,4 @@ describe("TestAdvancedItemParse #item", function()
728728
item:BuildModList()
729729
assert.are.equals(83, item.armourData.Ward)
730730
end)
731-
end)
731+
end)

spec/System/TestWard_spec.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,28 @@ describe("TestWard", function()
203203

204204
assert.are.equals(10, build.calcsTab.calcsOutput.WardCoverOnMinionDeath)
205205
end)
206+
207+
it("Non-authoritative Ward path: plain Ward mods scale correctly (no property line)", function()
208+
-- Test that when Ward comes only from customMods (no property line),
209+
-- the non-authoritative path in Item.lua applies INC and quality correctly.
210+
-- Use a Runeforged item without a Runic Ward property line:
211+
-- wardBase comes from mods, wardInc from mods, quality from item.
212+
local item = new("Item", [[
213+
Rarity: Rare
214+
Mock Runeforged Coat
215+
Runeforged Serpentscale Coat
216+
--------
217+
Quality: 20
218+
--------
219+
+65 to maximum Ward
220+
30% increased Ward
221+
]])
222+
item:BuildModList()
223+
-- Non-authoritative: no "Runic Ward" property line → armourData.Ward was nil on entry
224+
-- wardBase = calcLocal(Ward,BASE,0) + base.armour.Ward = 65 + 0 = 65
225+
-- wardInc = calcLocal(Ward,INC,0) = 30
226+
-- quality = 20
227+
-- Expected: round(65 * (1 + 30/100) * (1 + 20/100)) = round(65 * 1.3 * 1.2) = round(101.4) = 101
228+
assert.are.equals(101, item.armourData.Ward)
229+
end)
206230
end)

src/Classes/ImportTab.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,26 +1114,26 @@ function ImportTabClass:ImportItem(itemData, slotName)
11141114
end
11151115
if itemData.properties then
11161116
for _, property in pairs(itemData.properties) do
1117-
if escapeGGGString(property.name) == "Quality" then
1117+
local escapedPropertyName = escapeGGGString(property.name)
1118+
if escapedPropertyName == "Quality" then
11181119
item.quality = tonumber(property.values[1][1]:match("%d+"))
11191120
elseif property.name == "Radius" then
11201121
item.jewelRadiusLabel = property.values[1][1]
11211122
elseif property.name == "Limited to" then
11221123
item.limit = tonumber(property.values[1][1])
1123-
elseif escapeGGGString(property.name) == "Evasion Rating" then
1124+
elseif escapedPropertyName == "Evasion Rating" then
11241125
if item.baseName == "Two-Toned Boots (Armour/Energy Shield)" then
11251126
-- Another hack for Two-Toned Boots
11261127
item.baseName = "Two-Toned Boots (Armour/Evasion)"
11271128
item.base = self.build.data.itemBases[item.baseName]
11281129
end
1129-
elseif escapeGGGString(property.name) == "Energy Shield" then
1130+
elseif escapedPropertyName == "Energy Shield" then
11301131
if item.baseName == "Two-Toned Boots (Armour/Evasion)" then
11311132
-- Yet another hack for Two-Toned Boots
11321133
item.baseName = "Two-Toned Boots (Evasion/Energy Shield)"
11331134
item.base = self.build.data.itemBases[item.baseName]
11341135
end
11351136
end
1136-
local escapedPropertyName = escapeGGGString(property.name)
11371137
if escapedPropertyName == "Energy Shield" or escapedPropertyName == "Ward" or escapedPropertyName == "Runic Ward" or escapedPropertyName == "Armour" or escapedPropertyName == "Evasion Rating" then
11381138
item.armourData = item.armourData or { }
11391139
local armourKey = escapedPropertyName:gsub(" Rating", ""):gsub(" ", "")

src/Classes/Item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ function ItemClass:BuildModListForSlotNum(baseList, slotNum)
17931793
if wardIsAuthoritative then
17941794
calcLocal(modList, "Ward", "BASE", 0) -- consume flat rune ward mods (discard result)
17951795
calcLocal(modList, "Ward", "INC", 0) -- consume INC rune ward mods (discard result)
1796-
wardBase = armourData.Ward + (self.base.armour.Ward or 0)
1796+
wardBase = armourData.Ward -- property line is the final game value; base Ward is already baked in
17971797
else
17981798
wardBase = calcLocal(modList, "Ward", "BASE", 0) + (self.base.armour.Ward or 0)
17991799
end

0 commit comments

Comments
 (0)