From 8fa22d40b64dd4e0ea374976453e6d1759bfc128 Mon Sep 17 00:00:00 2001 From: Paliak <91493239+Paliak@users.noreply.github.com> Date: Mon, 7 Oct 2024 06:33:26 +0200 Subject: [PATCH] FEAT(warnings): add name of source causing requirements warning to warning message --- src/Modules/Build.lua | 8 ++++---- src/Modules/CalcPerform.lua | 33 ++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index 09fe063e60..ecea912684 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -446,13 +446,13 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin { stat = "SoulCost", label = "Soul Cost", fmt = "d", color = colorCodes.RAGE, pool = "Soul", compPercent = true, lowerIsBetter = true, condFunc = function(v,o) return o.SoulHasCost end }, { }, { stat = "Str", label = "Strength", color = colorCodes.STRENGTH, fmt = "d" }, - { stat = "ReqStr", label = "Strength Required", color = colorCodes.STRENGTH, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Str end, warnFunc = function(v) return "You do not meet the Strength requirement" end }, + { stat = "ReqStr", label = "Strength Required", color = colorCodes.STRENGTH, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Str end, warnFunc = function(v,o) return "You do not meet the Strength requirement of " .. (o.ReqStrItem.source == "Item" and o.ReqStrItem.sourceItem.name or o.ReqStrItem.source == "Gem" and o.ReqStrItem.sourceGem.nameSpec) end }, { stat = "Dex", label = "Dexterity", color = colorCodes.DEXTERITY, fmt = "d" }, - { stat = "ReqDex", label = "Dexterity Required", color = colorCodes.DEXTERITY, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Dex end, warnFunc = function(v) return "You do not meet the Dexterity requirement" end }, + { stat = "ReqDex", label = "Dexterity Required", color = colorCodes.DEXTERITY, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Dex end, warnFunc = function(v,o) return "You do not meet the Dexterity requirement of " .. (o.ReqDexItem.source == "Item" and o.ReqDexItem.sourceItem.name or o.ReqDexItem.source == "Gem" and o.ReqDexItem.sourceGem.nameSpec) end }, { stat = "Int", label = "Intelligence", color = colorCodes.INTELLIGENCE, fmt = "d" }, - { stat = "ReqInt", label = "Intelligence Required", color = colorCodes.INTELLIGENCE, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Int end, warnFunc = function(v) return "You do not meet the Intelligence requirement" end }, + { stat = "ReqInt", label = "Intelligence Required", color = colorCodes.INTELLIGENCE, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Int end, warnFunc = function(v,o) return "You do not meet the Intelligence requirement of " .. (o.ReqIntItem.source == "Item" and o.ReqIntItem.sourceItem.name or o.ReqIntItem.source == "Gem" and o.ReqIntItem.sourceGem.nameSpec) end }, { stat = "Omni", label = "Omniscience", color = colorCodes.RARE, fmt = "d" }, - { stat = "ReqOmni", label = "Omniscience Required", color = colorCodes.RARE, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > (o.Omni or 0) end, warnFunc = function(v) return "You do not meet the Omniscience requirement" end }, + { stat = "ReqOmni", label = "Omniscience Required", color = colorCodes.RARE, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > (o.Omni or 0) end, warnFunc = function(v,o) return "You do not meet the Omniscience requirement of " .. (o.ReqOmniItem.source == "Item" and o.ReqOmniItem.sourceItem.name or o.ReqOmniItem.source == "Gem" and o.ReqOmniItem.sourceGem.nameSpec) end }, { }, { stat = "Devotion", label = "Devotion", color = colorCodes.RARE, fmt = "d" }, { }, diff --git a/src/Modules/CalcPerform.lua b/src/Modules/CalcPerform.lua index f659387e34..596c088611 100644 --- a/src/Modules/CalcPerform.lua +++ b/src/Modules/CalcPerform.lua @@ -1649,12 +1649,11 @@ function calcs.perform(env, skipEHP) -- Process attribute requirements do local reqMult = calcLib.mod(modDB, nil, "GlobalAttributeRequirements") - local attrTable = modDB:Flag(nil, "OmniscienceRequirements") and {"Omni","Str","Dex","Int"} or {"Str","Dex","Int"} + local omniRequirements = modDB:Flag(nil, "OmniscienceRequirements") and calcLib.mod(modDB, nil, "OmniAttributeRequirements") + local ignoreAttrReq = modDB:Flag(nil, "IgnoreAttributeRequirements") + local attrTable = omniRequirements and {"Omni","Str","Dex","Int"} or {"Str","Dex","Int"} for _, attr in ipairs(attrTable) do - local breakdownAttr = attr - if modDB:Flag(nil, "OmniscienceRequirements") then - breakdownAttr = "Omni" - end + local breakdownAttr = omniRequirements and "Omni" or attr if breakdown then breakdown["Req"..attr] = { rowList = { }, @@ -1665,16 +1664,19 @@ function calcs.perform(env, skipEHP) } } end - local out = 0 + local out = {val = 0, source = nil} for _, reqSource in ipairs(env.requirementsTable) do if reqSource[attr] and reqSource[attr] > 0 then local req = m_floor(reqSource[attr] * reqMult) - if modDB:Flag(nil, "OmniscienceRequirements") then - local omniReqMult = 1 / (calcLib.mod(modDB, nil, "OmniAttributeRequirements") - 1) + if omniRequirements then + local omniReqMult = 1 / (omniRequirements - 1) local attributereq = m_floor(reqSource[attr] * reqMult) req = m_floor(attributereq * omniReqMult) end - out = m_max(out, req) + if req > out.val then + out.val = req + out.source = reqSource + end if breakdown then local row = { req = req > output[breakdownAttr] and colorCodes.NEGATIVE..req or req, @@ -1694,15 +1696,16 @@ function calcs.perform(env, skipEHP) end end end - if modDB:Flag(nil, "IgnoreAttributeRequirements") then - out = 0 + if ignoreAttrReq then + out.val = 0 end output["Req"..attr.."String"] = 0 - if out > (output["Req"..breakdownAttr] or 0) then - output["Req"..breakdownAttr.."String"] = out - output["Req"..breakdownAttr] = out + if out.val > (output["Req"..breakdownAttr] or 0) then + output["Req"..breakdownAttr.."String"] = out.val + output["Req"..breakdownAttr] = out.val + output["Req"..breakdownAttr.."Item"] = out.source if breakdown then - output["Req"..breakdownAttr.."String"] = out > (output[breakdownAttr] or 0) and colorCodes.NEGATIVE..out or out + output["Req"..breakdownAttr.."String"] = out.val > (output[breakdownAttr] or 0) and colorCodes.NEGATIVE..(out.val) or out.val end end end