From 6b9d73e6043339a1706258b07955646b99f450f4 Mon Sep 17 00:00:00 2001 From: higurush Date: Sat, 5 Jun 2021 23:01:38 +0200 Subject: [PATCH] Fix Stat Filter Key Matching Fixed an issues where stat filter key was partially matching the filter key. Now it matches for the exact key defined in the filter tables. --- AtlasLoot/Core/Search.lua | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/AtlasLoot/Core/Search.lua b/AtlasLoot/Core/Search.lua index 48be708..0c07a2f 100644 --- a/AtlasLoot/Core/Search.lua +++ b/AtlasLoot/Core/Search.lua @@ -355,7 +355,7 @@ function AtlasLoot:Search(Text) local function HaveStat (textValue) for index, statItem in pairs(STATFILTERS) do - if string.find(textValue, index) then + if textValue == index then return STATFILTERS[index]; end end @@ -364,10 +364,13 @@ function AtlasLoot:Search(Text) local function IsItemStatMatch(searchTextItem, stats, operator) if stats then - local statFilterFound = HaveStat(searchTextItem); + local searchedStat = tonumber(string.match(searchTextItem, "%d+")); + local searchTerm = searchTextItem.gsub(searchTextItem, tostring(searchedStat), ""); + searchTerm = string.gsub(searchTerm, operator, ""); + + local statFilterFound = HaveStat(searchTerm); if statFilterFound then local statValue = tonumber(stats[statFilterFound]); - local searchedStat = tonumber(string.match(searchTextItem, "%d+")); if CompareNumbersByOperator(operator, statValue, searchedStat) then return true; end @@ -453,15 +456,15 @@ function AtlasLoot:Search(Text) local searchConditionsMet = true; local searchItems = SplitString(text, binaryOperator); - if searchItems and searchItems ~= nil then + if searchItems then for _, searchTextItem in ipairs(searchItems) do local localOperator = HaveOperator(searchTextItem); if not localOperator or not ( -- Stat Filter - (stats and IsItemStatMatch(searchTextItem, stats, localOperator)) + IsItemStatMatch(searchTextItem, stats, localOperator) -- Item Level Filter - or (IsItemLevelFilterMatch(searchTextItem, itemLvl, itemEquipLoc, localOperator)) + or IsItemLevelFilterMatch(searchTextItem, itemLvl, itemEquipLoc, localOperator) ) then searchConditionsMet = false; @@ -475,7 +478,7 @@ function AtlasLoot:Search(Text) end else -- Stat Filter - if (stats and IsItemStatMatch(text, stats, operator)) + if IsItemStatMatch(text, stats, operator) -- Item Level Filter or IsItemLevelFilterMatch(text, itemLvl, itemEquipLoc, operator) then