Rename IsStatsMatch for reusability
This commit is contained in:
+13
-11
@@ -206,15 +206,15 @@ function AtlasLoot:Search(Text)
|
|||||||
end
|
end
|
||||||
return nil;
|
return nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
local function IsStatsMatch(operator, statValue, searchedStat)
|
local function CompareNumbersByOperator (operator, baseValue, valueToCompare)
|
||||||
if searchedStat ~= nil and statValue ~= nil
|
if baseValue ~= nil and valueToCompare ~= nil
|
||||||
and ((operator == "<>") and (statValue ~= searchedStat)
|
and ((operator == "<>") and (baseValue ~= valueToCompare)
|
||||||
or (operator == "<=") and (statValue <= searchedStat)
|
or (operator == "<=") and (baseValue <= valueToCompare)
|
||||||
or (operator == ">=") and (statValue >= searchedStat)
|
or (operator == ">=") and (baseValue >= valueToCompare)
|
||||||
or (operator == "=") and (statValue == searchedStat)
|
or (operator == "=") and (baseValue == valueToCompare)
|
||||||
or (operator == "<") and (statValue < searchedStat)
|
or (operator == "<") and (baseValue < valueToCompare)
|
||||||
or (operator == ">") and (statValue > searchedStat))
|
or (operator == ">") and (baseValue > valueToCompare))
|
||||||
then
|
then
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
@@ -227,7 +227,7 @@ function AtlasLoot:Search(Text)
|
|||||||
if statFilterFound then
|
if statFilterFound then
|
||||||
local statValue = tonumber(stats[statFilterFound]);
|
local statValue = tonumber(stats[statFilterFound]);
|
||||||
local searchedStat = tonumber(string.match(searchTextItem, "%d+"));
|
local searchedStat = tonumber(string.match(searchTextItem, "%d+"));
|
||||||
if IsStatsMatch(operator, statValue, searchedStat) then
|
if CompareNumbersByOperator(operator, statValue, searchedStat) then
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -246,8 +246,10 @@ function AtlasLoot:Search(Text)
|
|||||||
local operator = HaveOperator(text);
|
local operator = HaveOperator(text);
|
||||||
if operator ~= nil then
|
if operator ~= nil then
|
||||||
|
|
||||||
|
local itemId = tostring(v[2]);
|
||||||
|
|
||||||
-- Stat Filter
|
-- Stat Filter
|
||||||
local stats = GetItemStats("item:"..tostring(v[2]));
|
local stats = GetItemStats("item:"..itemId);
|
||||||
if stats then
|
if stats then
|
||||||
-- Currently only supports "&"
|
-- Currently only supports "&"
|
||||||
local binaryOperator = HaveBinaryOperator(text);
|
local binaryOperator = HaveBinaryOperator(text);
|
||||||
|
|||||||
Reference in New Issue
Block a user