Skip to content

Commit 2c3b476

Browse files
committed
Add some tests and fix modlist not using scaled value
1 parent ff39c3a commit 2c3b476

3 files changed

Lines changed: 190 additions & 2 deletions

File tree

spec/System/TestItemMods_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("TetsItemMods", function()
1+
describe("TestItemMods", function()
22
before_each(function()
33
newBuild()
44
end)

spec/System/TestItemParse_spec.lua

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,4 +1257,192 @@ describe("TestAdvancedItemParse #item", function()
12571257
Note: ~b/o 2 chaos
12581258
]])
12591259
end)
1260+
describe("mod magnitude scaling", function()
1261+
before_each(function()
1262+
newBuild()
1263+
runCallback("onFrame")
1264+
end)
1265+
local function chaosDamageInc()
1266+
return build.calcsTab.mainEnv.modDB:Sum("INC", nil, "ChaosDamage")
1267+
end
1268+
1269+
local function chaosResist()
1270+
return build.calcsTab.mainEnv.modDB:Sum("BASE", nil, "ChaosResist")
1271+
end
1272+
1273+
local function spellCrit()
1274+
return build.calcsTab.mainEnv.modDB:Sum("INC", nil, "CritChance")
1275+
end
1276+
1277+
local function damage()
1278+
return build.calcsTab.mainEnv.modDB:Sum("INC", nil, "Damage")
1279+
end
1280+
1281+
it("scales matching desecrated mods by modifier magnitude", function()
1282+
-- 130% * 1.7 = 221
1283+
build.itemsTab:CreateDisplayItemFromRaw([[
1284+
Rarity: RARE
1285+
Test Subject
1286+
Ravenous Staff
1287+
LevelReq: 60
1288+
Implicits: 0
1289+
{desecrated}{range:0.5}(100-160)% increased Chaos Damage
1290+
{range:0.5}70% increased Desecrated Modifier magnitudes
1291+
]])
1292+
local item = build.itemsTab.displayItem
1293+
assert.is_true(item.advancedCopy)
1294+
build.itemsTab:AddDisplayItem()
1295+
runCallback("OnFrame")
1296+
assert.are.equals(221, chaosDamageInc())
1297+
end)
1298+
1299+
it("does not rescale old format (baked) copies", function()
1300+
-- magnitude already baked in, so no rescale
1301+
build.itemsTab:CreateDisplayItemFromRaw([[
1302+
Rarity: RARE
1303+
Baked Subject
1304+
Ravenous Staff
1305+
LevelReq: 60
1306+
Implicits: 0
1307+
130% increased Chaos Damage
1308+
70% increased Desecrated Modifier magnitudes
1309+
]])
1310+
local item = build.itemsTab.displayItem
1311+
assert.is_false(item.advancedCopy)
1312+
build.itemsTab:AddDisplayItem()
1313+
runCallback("OnFrame")
1314+
assert.are.equals(130, chaosDamageInc())
1315+
end)
1316+
1317+
it("only scales mods that share the magnitude mod's tags", function()
1318+
build.itemsTab:CreateDisplayItemFromRaw([[
1319+
Rarity: RARE
1320+
Test Subject
1321+
Sapphire Ring
1322+
LevelReq: 20
1323+
Implicits: 0
1324+
{tags:chaos,damage}{range:0.5}(100-160)% increased Chaos Damage
1325+
{tags:resistance}{range:0.5}+(20-40)% to Chaos Resistance
1326+
{range:0.5}100% increased resistance modifier magnitudes
1327+
]])
1328+
build.itemsTab:AddDisplayItem()
1329+
runCallback("OnFrame")
1330+
assert.are.equals(60, chaosResist())
1331+
assert.are.equals(130, chaosDamageInc())
1332+
end)
1333+
1334+
it("only scales the modifier type named by the magnitude mod", function()
1335+
build.itemsTab:CreateDisplayItemFromRaw([[
1336+
Rarity: RARE
1337+
Test Subject
1338+
Sapphire Ring
1339+
LevelReq: 20
1340+
Implicits: 1
1341+
{range:0.5}(100-160)% increased Chaos Damage
1342+
{range:0.5}+(20-40)% to Chaos Resistance
1343+
{range:0.5}100% increased explicit modifier magnitudes
1344+
]])
1345+
build.itemsTab:AddDisplayItem()
1346+
runCallback("OnFrame")
1347+
assert.are.equals(130, chaosDamageInc())
1348+
assert.are.equals(60, chaosResist())
1349+
end)
1350+
1351+
it("scales only prefixes for increased effect of prefixes", function()
1352+
build.itemsTab:CreateDisplayItemFromRaw([[
1353+
Rarity: RARE
1354+
Test Subject
1355+
Sapphire Ring
1356+
LevelReq: 20
1357+
Implicits: 0
1358+
{prefix}{range:0.5}(100-160)% increased Chaos Damage
1359+
{suffix}{range:0.5}+(20-40)% to Chaos Resistance
1360+
{range:0.5}50% increased effect of prefixes
1361+
]])
1362+
build.itemsTab:AddDisplayItem()
1363+
runCallback("OnFrame")
1364+
assert.are.equals(195, chaosDamageInc())
1365+
assert.are.equals(30, chaosResist())
1366+
end)
1367+
1368+
local realJewel = [[
1369+
Item Class: Jewels
1370+
Rarity: Rare
1371+
Pandemonium Desire
1372+
Sapphire
1373+
--------
1374+
Quality (Caster Modifiers): +20% (augmented)
1375+
--------
1376+
Item Level: 80
1377+
--------
1378+
{ Corruption Enhancement — Elemental, Cold, Resistance }
1379+
+7(5-10)% to Cold Resistance
1380+
{ Corruption Enhancement — Attribute }
1381+
+6(4-6) to Intelligence
1382+
--------
1383+
{ Fractured Crafted Prefix Modifier "" }
1384+
60(40-60)% increased Effect of Suffixes — Unscalable Value
1385+
{ Prefix Modifier "Mystic" (Tier: 1) — Damage, Caster — 20% Increased }
1386+
7(5-15)% increased Spell Damage
1387+
{ Suffix Modifier "of Unmaking" (Tier: 1) — Damage, Caster, Critical — 80% Increased }
1388+
20(10-20)% increased Critical Spell Damage Bonus
1389+
{ Desecrated Suffix Modifier "of Annihilating" (Tier: 1) — Caster, Critical — 80% Increased }
1390+
15(5-15)% increased Critical Hit Chance for Spells
1391+
{ Suffix Modifier "of Potency" (Tier: 1) — Damage, Critical — 60% Increased }
1392+
20(10-20)% increased Critical Damage Bonus
1393+
--------
1394+
Place into an allocated Jewel Socket on the Passive Skill Tree. Right click to remove from the Socket.
1395+
--------
1396+
Twice Corrupted
1397+
--------
1398+
Fractured Item
1399+
--------
1400+
Note: ~b/o 1 mirror
1401+
]]
1402+
it("scales only prefixes for increased effect of prefixes for advanced copy format", function()
1403+
build.itemsTab:CreateDisplayItemFromRaw(realJewel)
1404+
build.itemsTab:AddDisplayItem()
1405+
runCallback("OnFrame")
1406+
assert.equal(36, spellCrit())
1407+
assert.equal(8, damage())
1408+
end)
1409+
1410+
it("does not apply scaling twice when saving and loading", function()
1411+
local item = new("Item", new("Item", realJewel):BuildRaw())
1412+
build.itemsTab:SetDisplayItem(item)
1413+
build.itemsTab:AddDisplayItem()
1414+
runCallback("OnFrame")
1415+
assert.equal(36, spellCrit())
1416+
assert.equal(8, damage())
1417+
end)
1418+
1419+
it("The Unborn Lich scales its desecrated mods", function()
1420+
local raw
1421+
for _, itemStr in ipairs(data.uniques.staff) do
1422+
if itemStr:find("Unborn Lich") then
1423+
raw = itemStr
1424+
end
1425+
end
1426+
if not raw then
1427+
error("Couldn't find unborn lich")
1428+
end
1429+
build.itemsTab:CreateDisplayItemFromRaw(raw)
1430+
build.itemsTab:AddDisplayItem()
1431+
runCallback("OnFrame")
1432+
assert.are.equals(221, chaosDamageInc())
1433+
1434+
-- the tooltip advertises the same scaled value the calculation uses
1435+
local tooltip = new("Tooltip")
1436+
local raw = build.itemsTab.displayItem:BuildRaw()
1437+
build.itemsTab:AddItemTooltip(tooltip, new("Item", raw))
1438+
local found = false
1439+
for _, section in ipairs(tooltip.lines) do
1440+
if section.text and section.text:find("221% increased Chaos Damage", 1, true) then
1441+
found = true
1442+
break
1443+
end
1444+
end
1445+
assert.is_true(found)
1446+
end)
1447+
end)
12601448
end)

src/Classes/Item.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ local function getRangedModList(item, modLine)
6060
if not modLine.range or not modLine.line:find("%((%-?%d+%.?%d*)%-(%-?%d+%.?%d*)%)") then
6161
return
6262
end
63-
local line = itemLib.applyRange(modLine.line:gsub("\n", " "), modLine.range, getCatalystScalar(item.catalyst, modLine, item.catalystQuality), modLine.corruptedRange)
63+
local line = itemLib.applyRange(modLine.line:gsub("\n", " "), modLine.range, modLine.valueScalar, modLine.corruptedRange)
6464
local list, extra = modLib.parseMod(line)
6565
if itemLib.isZeroValueLine(line) then
6666
return { }

0 commit comments

Comments
 (0)