diff --git a/spec/System/TestConfigTab_spec.lua b/spec/System/TestConfigTab_spec.lua index ec5516facf..46b7e63baa 100644 --- a/spec/System/TestConfigTab_spec.lua +++ b/spec/System/TestConfigTab_spec.lua @@ -371,5 +371,31 @@ describe("TestConfig", function() assert.are.equals("test", newConfigSet.placeholder.testPlaceholder) end) end) + + describe("Leeching options", function() + local ConfigVisibility = LoadModule("Modules/ConfigVisibility") + local function isShown(var) + for _, varData in ipairs(LoadModule("Modules/ConfigOptions")) do + if varData.var == var then + return ConfigVisibility.isRelevantForBuild(varData, build) + end + end + end + + it("are hidden without a leech source", function() + assert.is_false(isShown("conditionLeeching")) + assert.is_false(isShown("conditionLeechingMana")) + end) + + it("are shown when the main skill leeches mana", function() + build.configTab.input.customMods = "1% of Physical Attack Damage Leeched as Mana" + build.configTab:BuildModList() + runCallback("OnFrame") + + assert.is_true(isShown("conditionLeeching")) + assert.is_true(isShown("conditionLeechingMana")) + assert.is_false(isShown("conditionLeechingLife")) + end) + end) end) end) diff --git a/src/Modules/Calcs.lua b/src/Modules/Calcs.lua index 9134e1080f..ff5948537a 100644 --- a/src/Modules/Calcs.lua +++ b/src/Modules/Calcs.lua @@ -607,6 +607,15 @@ function calcs.buildOutput(build, mode) end end end + -- Show the "Are you Leeching?" options when the main skill leeches, so mods that need the condition can be compared before they are equipped + for _, resource in ipairs({ "Life", "EnergyShield", "Mana" }) do + local leechRate = (output[resource.."LeechRate"] or 0) - (output[resource.."LeechInstantRate"] or 0) + if leechRate > 0 then + local mod = modLib.createMod(resource.."LeechRate", "BASE", leechRate, "Main skill leech") + addTo(env.conditionsUsed, "Leeching", mod) + addTo(env.conditionsUsed, "Leeching"..resource, mod) + end + end -- ConPrintf("=== Cond ===") -- ConPrintTable(env.conditionsUsed) -- ConPrintf("=== Mult ===")