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