Skip to content

Commit e33f3d2

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

3 files changed

Lines changed: 191 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: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,4 +1257,193 @@ 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", { flags = ModFlag.Spell }, "CritChance")
1275+
end
1276+
1277+
local function spellDamage()
1278+
return build.calcsTab.mainEnv.modDB:Sum("INC", { flags = ModFlag.Spell }, "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+
-- actually a ring so we don't have to allocate a socket
1369+
local realJewel = [[
1370+
Rarity: Rare
1371+
Pandemonium Desire
1372+
Ruby Ring
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+
assert.equal(0, spellCrit())
1404+
local item = new("Item", realJewel)
1405+
build.itemsTab:AddItem(item)
1406+
build.itemsTab:EquipItemInSet(item, build.itemsTab.activeItemSetId)
1407+
runCallback("OnFrame")
1408+
assert.equal(26, spellCrit())
1409+
assert.equal(8, spellDamage())
1410+
end)
1411+
1412+
it("does not apply scaling twice when saving and loading", function()
1413+
local item = new("Item", new("Item", realJewel):BuildRaw())
1414+
build.itemsTab:AddItem(item)
1415+
build.itemsTab:EquipItemInSet(item, build.itemsTab.activeItemSetId)
1416+
runCallback("OnFrame")
1417+
assert.equal(26, spellCrit())
1418+
assert.equal(8, spellDamage())
1419+
end)
1420+
1421+
it("The Unborn Lich scales its desecrated mods", function()
1422+
local raw
1423+
for _, itemStr in ipairs(data.uniques.staff) do
1424+
if itemStr:find("Unborn Lich") then
1425+
raw = itemStr
1426+
end
1427+
end
1428+
if not raw then
1429+
error("Couldn't find unborn lich")
1430+
end
1431+
build.itemsTab:CreateDisplayItemFromRaw(raw)
1432+
build.itemsTab:AddDisplayItem()
1433+
runCallback("OnFrame")
1434+
assert.are.equals(221, chaosDamageInc())
1435+
1436+
-- the tooltip advertises the same scaled value the calculation uses
1437+
local tooltip = new("Tooltip")
1438+
build.itemsTab:AddItemTooltip(tooltip, new("Item", raw))
1439+
local found = false
1440+
for _, section in ipairs(tooltip.lines) do
1441+
if section.text and section.text:find("221% increased Chaos Damage", 1, true) then
1442+
found = true
1443+
break
1444+
end
1445+
end
1446+
assert.is_true(found)
1447+
end)
1448+
end)
12601449
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)