Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions spec/System/TestLeech_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
describe("TestLeech", function()
before_each(function()
newBuild()
build.configTab.input.enemyLevel = 1
end)

local function setMods(mods)
build.configTab.input.customMods = mods
build.configTab:BuildModList()
runCallback("OnFrame")
return build.calcsTab.mainOutput
end

local hitMods = "Your hits can't be Evaded\nAdds 10 to 100 Physical Damage\nLeeches 10% of Physical Damage as Life\n"
local baseMods = hitMods .. "Never deal Critical Hits\n"

it("leeches a portion of hit damage over one second", function()
local output = setMods(baseMods)
assert.True(output.LifeLeechPerHit > 0)
assert.are.near(0.1 * output.MainHand.PhysicalHitAverage, output.LifeLeechPerHit, 1e-9)
assert.are.equals(1, output.LifeLeechDuration)
end)

it("only recovers from the strongest instance at a time", function()
local output = setMods(baseMods)
local hitRate = output.LifeLeechInstances / output.LifeLeechDuration
assert.True(output.LifeLeechInstances > 1)
assert.True(output.LifeLeechRate < output.LifeLeechPerHit * hitRate)
-- the active instance rolls towards the top of the damage range
assert.True(output.LifeLeechInstanceAmount > output.LifeLeechPerHit)
assert.are.equals(output.LifeLeechInstanceAmount, output.LifeLeechRate)
end)

it("averages leech when instances do not overlap", function()
local output = setMods(baseMods .. "75% reduced Attack Speed")
local hitRate = output.LifeLeechInstances / output.LifeLeechDuration
assert.True(output.LifeLeechInstances < 1)
assert.are.near(output.LifeLeechPerHit * hitRate, output.LifeLeechRate, 1e-9)
end)

it("has no leech rate cap", function()
local output = setMods(baseMods .. "Leeches 1000% of Physical Damage as Life")
assert.True(output.LifeLeechRate > output.Life * 0.2)
end)

it("increases the amount leeched with amount modifiers", function()
local base = setMods(baseMods).LifeLeechPerHit
assert.are.near(base * 1.5, setMods(baseMods .. "50% increased amount of Life Leeched").LifeLeechPerHit, 1e-9)
assert.are.near(base * 1.5, setMods(baseMods .. "50% more amount of Life Leeched").LifeLeechPerHit, 1e-9)
end)

it("slows leech without reducing the amount leeched", function()
local base = setMods(baseMods).LifeLeechPerHit
local output = setMods(baseMods .. "Leech Life 50% slower")
assert.are.near(base, output.LifeLeechPerHit, 1e-9)
assert.are.near(2, output.LifeLeechDuration, 1e-9)
output = setMods(baseMods .. "Leech Life 67% less quickly")
assert.are.near(1 / 0.33, output.LifeLeechDuration, 1e-9)
end)

it("treats hits above 40000 damage as 40000 damage", function()
local output = setMods(baseMods .. "Adds 100000 to 100000 Physical Damage")
assert.True(output.MainHand.PhysicalHitAverage > 40000)
assert.are.near(4000, output.LifeLeechPerHit, 1e-6)
end)

it("shortens the duration with instant leech", function()
local base = setMods(baseMods).LifeLeechPerHit
local output = setMods(baseMods .. "25% of Leech is Instant")
assert.are.near(base, output.LifeLeechPerHit, 1e-9)
assert.are.near(base * 0.25, output.LifeLeechInstant, 1e-9)
assert.are.near(0.75, output.LifeLeechDuration, 1e-9)
end)

it("is reduced by enemy leech resistance", function()
local base = setMods(baseMods).LifeLeechPerHit
build.configTab.input.enemyLevel = 83
local output = setMods(baseMods)
assert.are.near(base * (1 - data.monsterLeechResistanceTable[83] / 10000), output.LifeLeechPerHit, 1e-9)
assert.True(output.LifeLeechPerHit < base)
end)

it("favours critical hits when instances overlap", function()
local output = setMods(hitMods .. "+30% to Critical Hit Chance")
local critChance = output.CritChance
assert.True(critChance > 0 and critChance < 100)
assert.True(output.LifeLeechInstances > 1)
assert.True(output.LifeLeechCritActive > critChance)
end)
end)
1 change: 1 addition & 0 deletions src/Data/Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data.monsterAllyDamageTable = { 3.1099998950958, 4.4200000762939, 5.820000171661
data.monsterArmourTable = { 3, 6, 8, 10, 13, 16, 19, 22, 26, 30, 34, 39, 43, 49, 54, 60, 67, 73, 81, 89, 97, 106, 116, 126, 137, 149, 161, 174, 189, 204, 220, 237, 255, 274, 295, 317, 340, 364, 391, 418, 448, 479, 512, 547, 585, 624, 666, 711, 758, 808, 861, 917, 976, 1039, 1105, 1176, 1250, 1329, 1412, 1500, 1594, 1692, 1796, 1906, 2023, 2146, 2276, 2413, 2558, 2712, 2874, 3044, 3225, 3416, 3617, 3829, 4053, 4290, 4540, 4803, 5081, 5375, 5684, 6011, 6355, 6718, 7101, 7505, 7930, 8379, 8852, 9351, 9877, 10431, 11015, 11630, 12279, 12962, 13682, 14441, }
data.monsterAilmentThresholdTable = { 15, 20, 24, 28, 34, 39, 46, 52, 60, 70, 81, 95, 110, 126, 144, 171, 193, 218, 245, 275, 306, 340, 376, 413, 455, 497, 543, 590, 641, 695, 752, 812, 874, 950, 1033, 1123, 1220, 1326, 1442, 1568, 1705, 1854, 2015, 2192, 2384, 2564, 2757, 2966, 3188, 3426, 3681, 3955, 4247, 4560, 4895, 5254, 5638, 6049, 6489, 6959, 7462, 8001, 8576, 9193, 9649, 10228, 10841, 11492, 12181, 18272, 19369, 20531, 21763, 23068, 34602, 36679, 38879, 41212, 43685, 65527, 68415, 71303, 74191, 77079, 79967, 82855, 85743, 88631, 91519, 94407, 97295, 100183, 103071, 105959, 108847, 111735, 114623, 117511, 120399, 123287, }
data.monsterPoiseThresholdTable = { 30, 40, 48, 57, 67, 79, 93, 106, 122, 142, 165, 192, 220, 254, 290, 344, 390, 437, 488, 542, 599, 659, 724, 791, 862, 937, 1015, 1097, 1183, 1273, 1367, 1464, 1567, 1660, 1758, 1864, 1976, 2093, 2219, 2352, 2494, 2644, 2804, 2971, 3150, 3369, 3598, 3846, 4109, 4387, 4685, 5002, 5338, 5697, 6078, 6485, 6915, 7377, 7866, 8386, 8940, 9528, 10153, 10819, 26703, 28651, 30662, 32890, 35192, 53405, 57263, 61392, 65810, 70537, 106973, 114630, 122820, 131580, 140949, 213635, 225270, 236905, 248540, 260175, 271810, 283445, 295080, 306715, 318350, 329985, 341620, 353255, 364890, 376525, 388160, 399795, 411430, 423065, 434700, 446335, }
data.monsterLeechResistanceTable = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 638, 987, 1416, 1835, 2246, 2634, 3013, 3384, 3742, 4077, 4405, 4717, 5022, 5307, 5453, 5601, 5749, 5892, 6038, 6178, 6314, 6453, 6586, 6718, 6848, 6973, 7097, 7218, 7336, 7453, 7565, 7674, 7781, 7884, 8003, 8119, 8227, 8332, 8432, 8528, 8619, 8706, 8789, 8867, 8942, 9013, 9080, 9144, 9204, 9262, 9316, 9367, 9415, 9460, 9502, 9542, 9579, 9613, 9645, 9675, 9703, 9729, 9752, 9775, 9795, 9814, 9831, 9847, 9861, }

-- From MinionGemLevelScaling.dat
data.minionLevelTable = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, }
Expand Down
Loading
Loading