Refactor AutoLoot to use options instead of hardcoded values
This commit is contained in:
@@ -163,6 +163,7 @@ Filter = {
|
|||||||
local goldFilter = Filter.new({ ["name"] = getItemName },
|
local goldFilter = Filter.new({ ["name"] = getItemName },
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { name: string }
|
---@cast provided { name: string }
|
||||||
|
if not aura_env.config.goldFilter then return false end
|
||||||
if string.find(provided.name, "Gold") or
|
if string.find(provided.name, "Gold") or
|
||||||
string.find(provided.name, "Silver") or
|
string.find(provided.name, "Silver") or
|
||||||
string.find(provided.name, "Copper") then
|
string.find(provided.name, "Copper") then
|
||||||
@@ -175,6 +176,7 @@ local goldFilter = Filter.new({ ["name"] = getItemName },
|
|||||||
local orderResourcesFilter = Filter.new({ ["name"] = getItemName },
|
local orderResourcesFilter = Filter.new({ ["name"] = getItemName },
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { name: string }
|
---@cast provided { name: string }
|
||||||
|
if not aura_env.config.orderResourcesFilter then return false end
|
||||||
if string.find(provided.name, "Order Resources") then
|
if string.find(provided.name, "Order Resources") then
|
||||||
if debug then print(string.format("Order resource filter pass for %s", provided.name)) end
|
if debug then print(string.format("Order resource filter pass for %s", provided.name)) end
|
||||||
return true
|
return true
|
||||||
@@ -185,6 +187,7 @@ local orderResourcesFilter = Filter.new({ ["name"] = getItemName },
|
|||||||
local mountFilter = Filter.new({ ["type"] = getItemType },
|
local mountFilter = Filter.new({ ["type"] = getItemType },
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { type: string }
|
---@cast provided { type: string }
|
||||||
|
if not aura_env.config.mountFilter then return false end
|
||||||
if provided.type == "Mount" then
|
if provided.type == "Mount" then
|
||||||
if debug then print(string.format("Mount filter pass for type %s", provided.type)) end
|
if debug then print(string.format("Mount filter pass for type %s", provided.type)) end
|
||||||
return true
|
return true
|
||||||
@@ -195,7 +198,8 @@ local mountFilter = Filter.new({ ["type"] = getItemType },
|
|||||||
local ilvlFilter = Filter.new({ ["ilvl"] = getItemLevel },
|
local ilvlFilter = Filter.new({ ["ilvl"] = getItemLevel },
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { ilvl: number }
|
---@cast provided { ilvl: number }
|
||||||
if provided.ilvl and provided.ilvl > 800 then
|
if not aura_env.config.ilvlFilter then return false end
|
||||||
|
if provided.ilvl and provided.ilvl > aura_env.config.ilvlFilterThreshold then
|
||||||
if debug then print(string.format("ilvl filter pass for ilvl %d", provided.ilvl)) end
|
if debug then print(string.format("ilvl filter pass for ilvl %d", provided.ilvl)) end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -208,17 +212,18 @@ local professionFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { type: string, subtype: string }
|
---@cast provided { type: string, subtype: string }
|
||||||
|
if not aura_env.config.professionFilter then return false end
|
||||||
|
|
||||||
local enabled = {
|
local enabled = {
|
||||||
["Cloth"] = true,
|
["Cloth"] = aura_env.config.professionFilterProfessions[1],
|
||||||
["Cooking"] = true,
|
["Cooking"] = aura_env.config.professionFilterProfessions[2],
|
||||||
["Enchanting"] = true,
|
["Enchanting"] = aura_env.config.professionFilterProfessions[3],
|
||||||
["Herb"] = true,
|
["Herb"] = aura_env.config.professionFilterProfessions[4],
|
||||||
["Inscription"] = true,
|
["Inscription"] = aura_env.config.professionFilterProfessions[5],
|
||||||
["Jewelcrafting"] = true,
|
["Jewelcrafting"] = aura_env.config.professionFilterProfessions[6],
|
||||||
["Leather"] = true,
|
["Leather"] = aura_env.config.professionFilterProfessions[7],
|
||||||
["Metal & Stone"] = true,
|
["Metal & Stone"] = aura_env.config.professionFilterProfessions[8],
|
||||||
["Ore"] = true,
|
["Ore"] = aura_env.config.professionFilterProfessions[9],
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Maybe implement an expansion based filter
|
-- Maybe implement an expansion based filter
|
||||||
@@ -237,12 +242,12 @@ local valueFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { value: number, quantity: number }
|
---@cast provided { value: number, quantity: number }
|
||||||
|
if not aura_env.config.valueFilter then return false end
|
||||||
|
|
||||||
local valueThreshold = 35 * 100 * 100
|
local valueThreshold = aura_env.config.valueFilterThreshold
|
||||||
local applyValueTostack = false
|
|
||||||
|
|
||||||
local value = provided.value
|
local value = provided.value
|
||||||
if applyValueTostack then value = value * provided.quantity end
|
if aura_env.config.valueFilterApplyValueToStack then value = value * provided.quantity end
|
||||||
|
|
||||||
if value > valueThreshold then
|
if value > valueThreshold then
|
||||||
if debug then print(string.format("Value filter pass for value %d", value)) end
|
if debug then print(string.format("Value filter pass for value %d", value)) end
|
||||||
@@ -258,13 +263,13 @@ local greyValueFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { quality: number, value: number, quantity: number }
|
---@cast provided { quality: number, value: number, quantity: number }
|
||||||
|
if not aura_env.config.greyValueFilter then return false end
|
||||||
|
|
||||||
local valueThreshold = 0.1 * 100 * 100
|
local valueThreshold = aura_env.config.greyValueFilterThreshold
|
||||||
local applyValueTostack = false
|
|
||||||
|
|
||||||
if provided.quality == 0 then
|
if provided.quality == 0 then
|
||||||
local value = provided.value
|
local value = provided.value
|
||||||
if applyValueTostack then value = value * provided.quantity end
|
if aura_env.config.greyValueFilterApplyValueToStack then value = value * provided.quantity end
|
||||||
|
|
||||||
if value > valueThreshold then
|
if value > valueThreshold then
|
||||||
if debug then
|
if debug then
|
||||||
@@ -286,6 +291,8 @@ local questItemFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { type: string, subtype: string }
|
---@cast provided { type: string, subtype: string }
|
||||||
|
if not aura_env.config.questItemsFilter then return false end
|
||||||
|
|
||||||
if provided.type == "Quest" and provided.subtype == "Quest" then
|
if provided.type == "Quest" and provided.subtype == "Quest" then
|
||||||
if debug then
|
if debug then
|
||||||
print(string.format("Quest item filter pass for type %s and subtype", provided.type,
|
print(string.format("Quest item filter pass for type %s and subtype", provided.type,
|
||||||
@@ -308,9 +315,10 @@ local classGearFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { ilvl: number, quality: number, type: string, subtype: string, equiploc: string }
|
---@cast provided { ilvl: number, quality: number, type: string, subtype: string, equiploc: string }
|
||||||
|
if not aura_env.config.classGearFilter then return false end
|
||||||
|
|
||||||
local ilvlThreshold = 800
|
local ilvlThreshold = aura_env.config.classGearFilterIlvlThreshold
|
||||||
local qualityThreshold = 2
|
local qualityThreshold = aura_env.config.classGearFilterQualityThreshold
|
||||||
|
|
||||||
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][provided.subtype] == 1
|
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][provided.subtype] == 1
|
||||||
|
|
||||||
@@ -327,26 +335,27 @@ local classGearFilter = Filter.new({
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
local arguniteFilter = Filter.new({ ["name"] = getItemName },
|
local nameFilter = Filter.new({ ["name"] = getItemName },
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { name: string }
|
---@cast provided { name: string }
|
||||||
if provided.name == "Veiled Argunite" then
|
if not aura_env.config.nameFilter then return false end
|
||||||
if debug then
|
|
||||||
print(string.format("Argunite filter pass for %s", provided.name))
|
local names = string.split(",", aura_env.config.nameFilterNames or "")
|
||||||
|
if #names == 0 then return false end
|
||||||
|
for _, name in ipairs(names) do
|
||||||
|
name = string.trim(name)
|
||||||
|
|
||||||
|
if aura_env.config.nameFilterIgnoreCase then
|
||||||
|
name = string.lower(name)
|
||||||
|
provided.name = string.lower(provided.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
if provided.name == name then
|
||||||
|
if debug then print(string.format("Name filter pass for %s", provided.name)) end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
if debug then print(string.format("Argunite filter fail for %s", provided.name)) end
|
if debug then print(string.format("Name filter fail for %s", provided.name)) end
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local ancientManaFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if string.find(provided.name, "Ancient Mana") then
|
|
||||||
if debug then print(string.format("Ancient Mana filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Ancient Mana filter fail for %s", provided.name)) end
|
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
local reicpeFilter = Filter.new({ ["name"] = getItemName },
|
local reicpeFilter = Filter.new({ ["name"] = getItemName },
|
||||||
@@ -359,66 +368,6 @@ local reicpeFilter = Filter.new({ ["name"] = getItemName },
|
|||||||
if debug then print(string.format("Recipe filter fail for %s", provided.name)) end
|
if debug then print(string.format("Recipe filter fail for %s", provided.name)) end
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
local bloodOfSargerasFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Blood of Sargeras" then
|
|
||||||
if debug then print(string.format("Blood of Sargeras filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Blood of Sargeras filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local primalSpiritFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Primal Spirit" then
|
|
||||||
if debug then print(string.format("Primal Spirit filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Primal Spirit filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local apexisCrystalFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Apexis Crystal" then
|
|
||||||
if debug then print(string.format("Apexis Crystal filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Apexis Crystal filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local nethershardFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Nethershard" then
|
|
||||||
if debug then print(string.format("Nethershard filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Nethershard filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local bloodhunerQuarryFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Bloodhunter's Quarry" then
|
|
||||||
if debug then print(string.format("Bloodhunter's Quarry filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Bloodhunter's Quarry filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local arguniteClusterFilter = Filter.new({ ["name"] = getItemName },
|
|
||||||
function(slot, provided)
|
|
||||||
---@cast provided { name: string }
|
|
||||||
if provided.name == "Argunite Cluster" then
|
|
||||||
if debug then print(string.format("Argunite Cluster filter pass for %s", provided.name)) end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if debug then print(string.format("Argunite Cluster filter fail for %s", provided.name)) end
|
|
||||||
return false
|
|
||||||
end)
|
|
||||||
local boeFilter = Filter.new({
|
local boeFilter = Filter.new({
|
||||||
["ilvl"] = getItemLevel,
|
["ilvl"] = getItemLevel,
|
||||||
["type"] = getItemType,
|
["type"] = getItemType,
|
||||||
@@ -428,9 +377,10 @@ local boeFilter = Filter.new({
|
|||||||
},
|
},
|
||||||
function(slot, provided)
|
function(slot, provided)
|
||||||
---@cast provided { ilvl: number, type: string, quality: number, equiploc: string, bindtype: number }
|
---@cast provided { ilvl: number, type: string, quality: number, equiploc: string, bindtype: number }
|
||||||
|
aura_env.config.boeFilter = true
|
||||||
|
|
||||||
local ilvlThreshold = 800
|
local ilvlThreshold = aura_env.config.boeFilterIlvlThreshold
|
||||||
local qualityThreshold = 1
|
local qualityThreshold = aura_env.config.boeFilterQualityThreshold
|
||||||
|
|
||||||
local itemType = provided.type
|
local itemType = provided.type
|
||||||
local itemEquipLoc = provided.equiploc
|
local itemEquipLoc = provided.equiploc
|
||||||
@@ -459,6 +409,7 @@ local artifactPowerFilter = Filter.new({
|
|||||||
["value"] = getItemValue
|
["value"] = getItemValue
|
||||||
}, function(slot, provided)
|
}, function(slot, provided)
|
||||||
---@cast provided { type: string, subtype: string, subclassid: number, value: number }
|
---@cast provided { type: string, subtype: string, subclassid: number, value: number }
|
||||||
|
if not aura_env.config.artifactPowerFilter then return false end
|
||||||
if provided.value == 0 and provided.type == "Consumable" and provided.subtype == "Other" and provided.subclassid == 8 then
|
if provided.value == 0 and provided.type == "Consumable" and provided.subtype == "Other" and provided.subclassid == 8 then
|
||||||
if debug then
|
if debug then
|
||||||
print(string.format("Artifact power filter pass for type %s and subtype %s and subclassid %d with value %d",
|
print(string.format("Artifact power filter pass for type %s and subtype %s and subclassid %d with value %d",
|
||||||
@@ -473,32 +424,16 @@ local artifactPowerFilter = Filter.new({
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end)
|
end)
|
||||||
|
local everythingFilter = Filter.new({ ["name"] = getItemName },
|
||||||
-- local azeriteFilter = {
|
function(slot, provided)
|
||||||
-- enabled = true,
|
---@cast provided { name: string }
|
||||||
-- ilvlThreshold = 800,
|
return aura_env.config.everythingFilter
|
||||||
-- qualityThreshold = 2,
|
end)
|
||||||
-- filter = function(self, slot)
|
|
||||||
-- if self.enabled the
|
|
||||||
-- local itemType = getItemType(slot)
|
|
||||||
-- local itemSubtype = getItemSubtype(slot)
|
|
||||||
-- local itemQuality = getItemQuality(slot)
|
|
||||||
-- if itemType and itemSubtype and itemQuality and itemType == "Consumable" and itemSubtype == "Other" and itemQuality > 1 the
|
|
||||||
-- return true
|
|
||||||
-- en
|
|
||||||
-- tostring(itemType) .. " " .. tostring(itemSubtype) .. " " .. tostring(itemQuality))
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- }
|
|
||||||
|
|
||||||
|
|
||||||
---@type table<Filter>
|
---@type table<Filter>
|
||||||
local filters = {
|
local filters = {
|
||||||
ancientManaFilter,
|
everythingFilter,
|
||||||
arguniteFilter,
|
|
||||||
artifactPowerFilter,
|
artifactPowerFilter,
|
||||||
bloodhunerQuarryFilter,
|
|
||||||
bloodOfSargerasFilter,
|
|
||||||
boeFilter,
|
boeFilter,
|
||||||
classGearFilter,
|
classGearFilter,
|
||||||
goldFilter,
|
goldFilter,
|
||||||
@@ -510,10 +445,7 @@ local filters = {
|
|||||||
questItemFilter,
|
questItemFilter,
|
||||||
-- reicpeFilter,
|
-- reicpeFilter,
|
||||||
valueFilter,
|
valueFilter,
|
||||||
arguniteClusterFilter,
|
nameFilter,
|
||||||
primalSpiritFilter,
|
|
||||||
apexisCrystalFilter,
|
|
||||||
nethershardFilter,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
---@class FilterService
|
---@class FilterService
|
||||||
@@ -527,7 +459,7 @@ aura_env.FilterService = {
|
|||||||
local itemname = getItemName(slot)
|
local itemname = getItemName(slot)
|
||||||
print(string.format("Checking slot %d for %s", slot, itemname))
|
print(string.format("Checking slot %d for %s", slot, itemname))
|
||||||
end
|
end
|
||||||
for _, filter in pairs(filters) do
|
for _, filter in ipairs(filters) do
|
||||||
local res, err = filter:Run(slot)
|
local res, err = filter:Run(slot)
|
||||||
if err then
|
if err then
|
||||||
if debug then print(err) end
|
if debug then print(err) end
|
||||||
|
1
FreshShit/AutoLoot/export
Normal file
1
FreshShit/AutoLoot/export
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user