Move some new weakauras to special foldr

This commit is contained in:
2024-03-07 12:24:39 +01:00
parent adc0218169
commit d163cf93eb
9 changed files with 0 additions and 1183 deletions

View File

@@ -1,8 +0,0 @@
-- CHAT_MSG_LOOT
function(allstates, e, msg)
if (msg:match("You receive loot")) then
aura_env.allstates = allstates
aura_env.drawIcon(msg)
return true
end
end

View File

@@ -1,34 +0,0 @@
local iconDisplayDuration = 3
aura_env.getItemInfo = function(msg)
local name = msg:match("h%[(.+)%]") or ""
local quantity = msg:match("x(%d+)") or 1
local icon = 134400
if WeakAurasSaved.Cyka.ItemCache[name] then
icon = WeakAurasSaved.Cyka.ItemCache[name].icon
end
local color = msg:match("cff(%w%w%w%w%w%w)") or "ffffff"
return name, icon, quantity, color
end
aura_env.drawIcon = function(msg)
local name, icon, quantity, color = aura_env.getItemInfo(msg)
local formattedName = "\124cff" .. color .. "[" .. name .. "]\124r x" .. quantity
aura_env.allstates[#aura_env.allstates + 1] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = icon,
name = formattedName,
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
end

View File

@@ -1,6 +0,0 @@
-- LOOT_READY
function(e)
C_Timer.After(0.1, function()
WeakAuras.ScanEvents("DO_AUTOLOOT")
end)
end

View File

@@ -1,6 +0,0 @@
-- DO_AUTOLOOT
function(e)
local lootInfo = GetLootInfo()
aura_env.FilterService.Run(lootInfo)
CloseLoot()
end

File diff suppressed because one or more lines are too long

View File

@@ -1,848 +0,0 @@
local debug = false
if not WeakAurasSaved then WeakAurasSaved = {} end
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
if not WeakAurasSaved.Cyka.ItemCache then WeakAurasSaved.Cyka.ItemCache = {} end
---@param slot number
---@return string, string|nil
local function getItemLink(slot)
if slot == nil then return "", string.format("Slot can not be nil") end
local link = GetLootSlotLink(slot)
if link == nil then return "", string.format("GetLootSlotLink returned nil for slot %d", slot) end
return link, nil
end
---@param slot number
---@return string, string|nil
local function getItemName(slot)
if slot == nil then return "", string.format("Slot can not be null") end
local name = select(2, GetLootSlotInfo(slot))
if name == nil then return "", string.format("GetLootSlotInfo returned nil for slot %d", slot) end
return name, nil
end
---@param slot number
---@return string, string|nil
local function getItemType(slot)
if slot == nil then return "", string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return "", err end
local itemType = select(6, GetItemInfo(itemLink))
if itemType == nil then return "", string.format("GetItemInfo returned nil for slot %d", slot) end
return itemType, nil
end
---@param slot number
---@return string, string|nil
local function getItemSubtype(slot)
if slot == nil then return "", string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return "", err end
local itemSubtype = select(7, GetItemInfo(itemLink))
if itemSubtype == nil then return "", string.format("GetItemInfo returned nil for slot %d", slot) end
return itemSubtype, nil
end
---@param slot number
---@return number, string|nil
local function getItemLevel(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 0, err end
local itemLevel = select(4, GetItemInfo(itemLink))
if itemLevel == nil then return 0, string.format("GetItemInfo returned nil for slot %d", slot) end
return itemLevel, nil
end
---The vendor price in copper, or 0 for items that cannot be sold
---@param slot number
---@return number, string|nil
local function getItemValue(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 0, err end
local value = select(11, GetItemInfo(itemLink))
if value == nil then return 0, string.format("GetItemInfo returned nil for slot %d", slot) end
return value, nil
end
---@param slot number
---@return number, string|nil
local function getItemSubclassId(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 0, err end
local subclassId = select(13, GetItemInfo(itemLink))
if subclassId == nil then return 0, string.format("GetItemInfo returned nil for slot %d", slot) end
return subclassId, nil
end
---@param slot number
---@return number, string|nil
local function getItemQuantity(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local quantity = select(3, GetLootSlotInfo(slot))
if quantity == nil then return 0, string.format("GetLootSlotInfo returned nil for slot %d", slot) end
return quantity, nil
end
---@param slot number
---@return Enum.ItemQuality, string|nil
local function getItemQuality(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 0, err end
local quality = select(3, GetItemInfo(itemLink))
if quality == nil then return 0, string.format("GetItemInfo returned nil for slot %d", slot) end
return quality, nil
end
---@param slot number
---@return string, string|nil
local function getItemEquipLocation(slot)
if slot == nil then return "", string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return "", err end
local equipLoc = select(9, GetItemInfo(itemLink))
if equipLoc == nil then return "", string.format("GetItemInfo returned nil for slot %d", slot) end
return equipLoc, nil
end
---@param slot number
---@return number, string|nil
local function getItemIcon(slot)
if slot == nil then return 134400, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 134400, err end
local icon = select(10, GetItemInfo(itemLink))
if icon == nil then return 134400, string.format("GetItemInfo returned nil for slot %d", slot) end
return icon, nil
end
---@param slot number
---@return number, string|nil
local function getBindType(slot)
if slot == nil then return 0, string.format("Slot can not be nil") end
local itemLink, err = getItemLink(slot)
if err then return 0, err end
local bindType = select(14, GetItemInfo(itemLink))
if bindType == nil then return 0, string.format("GetItemInfo returned nil for slot %d", slot) end
return bindType, nil
end
---@class Filter
---@field requires table<string, fun(slot: number): string|number|boolean> | nil
---@field filter fun(slot: number, provided: table<string, string|number|boolean>): boolean
Filter = {
---@param requires table<string, fun(slot: number): string|number|boolean> | nil
---@param filter fun(slot: number, provided: table<string, string|number|boolean>): boolean
---@return Filter
new = function(requires, filter)
local self = setmetatable({}, {
__index = Filter
})
self.requires = requires
self.filter = filter
return self
end,
---@param self Filter
---@param slot number
---@return boolean, string|nil
Run = function(self, slot)
---@type table<string, string|number|boolean>
local provided = {}
if self.requires then
for k, v in pairs(self.requires) do
local res, err = v(slot)
if err ~= nil then
if debug then print(err) end
return false, err
end
provided[k] = res
end
end
local res, err = self.filter(slot, provided)
if err ~= nil then
if debug then print(err) end
end
return res, nil
end
}
local goldFilter = Filter.new({ ["name"] = getItemName },
function(slot, provided)
---@cast provided { name: string }
if string.find(provided.name, "Gold") or
string.find(provided.name, "Silver") or
string.find(provided.name, "Copper") then
if debug then print(string.format("Gold filter pass for %s", provided.name)) end
return true
end
if debug then print(string.format("Gold filter fail for %s", provided.name)) end
return false
end)
local orderResourcesFilter = Filter.new({ ["name"] = getItemName },
function(slot, provided)
---@cast provided { name: string }
if string.find(provided.name, "Order Resources") then
if debug then print(string.format("Order resource filter pass for %s", provided.name)) end
return true
end
if debug then print(string.format("Order resource filter fail for %s", provided.name)) end
return false
end)
local mountFilter = Filter.new({ ["type"] = getItemType },
function(slot, provided)
---@cast provided { type: string }
if provided.type == "Mount" then
if debug then print(string.format("Mount filter pass for type %s", provided.type)) end
return true
end
if debug then print(string.format("Mount filter fail for type %s", provided.type)) end
return false
end)
local ilvlFilter = Filter.new({ ["ilvl"] = getItemLevel },
function(slot, provided)
---@cast provided { ilvl: number }
if provided.ilvl and provided.ilvl > 800 then
if debug then print(string.format("ilvl filter pass for ilvl %d", provided.ilvl)) end
return true
end
if debug then print(string.format("ilvl filter fail for ilvl %d", provided.ilvl)) end
return false
end)
local professionFilter = Filter.new({
["type"] = getItemType,
["subtype"] = getItemSubtype
},
function(slot, provided)
---@cast provided { type: string, subtype: string }
local enabled = {
["Herb"] = true,
["Leather"] = true,
["Cloth"] = true,
["Ore"] = false,
["Cooking"] = true,
["Inscription"] = true,
["Enchanting"] = true,
}
-- Maybe implement an expansion based filter
if provided.type == "Tradeskill" then
if enabled[provided.subtype] then
if debug then print(string.format("Profession filter pass for type %s", provided.type)) end
return true
end
end
if debug then print(string.format("Profession filter fail for type %s", provided.type)) end
return false
end)
local valueFilter = Filter.new({
["value"] = getItemValue,
["quantity"] = getItemQuality
},
function(slot, provided)
---@cast provided { value: number, quantity: number }
local valueThreshold = 35 * 100 * 100
local applyValueTostack = false
local value = provided.value
if applyValueTostack then value = value * provided.quantity end
if value > valueThreshold then
if debug then print(string.format("Value filter pass for value %d", value)) end
return true
end
if debug then print(string.format("Value filter fail for value %d", value)) end
return false
end)
local greyValueFilter = Filter.new({
["quality"] = getItemQuality,
["value"] = getItemValue,
["quantity"] = getItemQuantity
},
function(slot, provided)
---@cast provided { quality: number, value: number, quantity: number }
local valueThreshold = 4 * 100 * 100
local applyValueTostack = false
if provided.quality == 0 then
local value = provided.value
if applyValueTostack then value = value * provided.quantity end
if value > valueThreshold then
if debug then
print(string.format("Grey value filter pass for value %d of %s quality items", value,
provided.quality))
end
return true
end
end
if debug then
print(string.format("Grey value filter fail for value %d of %s quality items", provided.value,
provided.quality))
end
return false
end)
local questItemFilter = Filter.new({
["type"] = getItemType,
["subtype"] = getItemSubtype
},
function(slot, provided)
---@cast provided { type: string, subtype: string }
if provided.type == "Quest" and provided.subtype == "Quest" then
if debug then
print(string.format("Quest item filter pass for type %s and subtype", provided.type,
provided.subtype))
end
return true
end
if debug then
print(string.format("Quest item filter fail for type %s and subtype", provided.type,
provided.subtype))
end
return false
end)
local classGearFilter = Filter.new({
["ilvl"] = getItemLevel,
["quality"] = getItemQuality,
["type"] = getItemType,
["subtype"] = getItemSubtype,
["equiploc"] = getItemEquipLocation
},
function(slot, provided)
---@cast provided { ilvl: number, quality: number, type: string, subtype: string, equiploc: string }
local ilvlThreshold = 800
local qualityThreshold = 2
local isEquippable = aura_env.skills[select(3, UnitClass("player"))][provided.subtype] == 1
if isEquippable and provided.ilvl > ilvlThreshold and provided.quality > qualityThreshold then
if debug then
print(string.format("Class gear filter pass for ilvl %d and quality %d", provided.ilvl,
provided.quality))
end
return true
end
if debug then
print(string.format("Class gear filter fail for ilvl %d and quality %d", provided.ilvl,
provided.quality))
end
return false
end)
local arguniteFilter = Filter.new({ ["name"] = getItemName },
function(slot, provided)
---@cast provided { name: string }
if provided.name == "Veiled Argunite" then
if debug then
print(string.format("Argunite filter pass for %s", provided.name))
end
return true
end
if debug then print(string.format("Argunite 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
end)
local reicpeFilter = Filter.new({ ["name"] = getItemName },
function(slot, provided)
---@cast provided { name: string }
if string.find(provided.name, "Recipe") or string.find(provided.name, "Technique") then
if debug then print(string.format("Recipe filter pass for %s", provided.name)) end
return true
end
if debug then print(string.format("Recipe filter fail for %s", provided.name)) end
return false
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 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({
["ilvl"] = getItemLevel,
["type"] = getItemType,
["quality"] = getItemQuality,
["equiploc"] = getItemEquipLocation,
["bindtype"] = getBindType
},
function(slot, provided)
---@cast provided { ilvl: number, type: string, quality: number, equiploc: string, bindtype: number }
local ilvlThreshold = 800
local qualityThreshold = 1
local itemType = provided.type
local itemEquipLoc = provided.equiploc
if (itemType == "Armor"
or itemType == "Weapon"
or itemEquipLoc == "INVTYPE_FINGER"
or itemEquipLoc == "INVTYPE_TRINKET"
or itemEquipLoc == "INVTYPE_CLOAK"
or itemEquipLoc == "INVTYPE_NECK") then
local itemLevel = provided.ilvl
local itemQuality = provided.quality
local bindType = provided.bindtype
if itemLevel > ilvlThreshold and itemQuality > qualityThreshold and bindType == 1 then
if debug then print(string.format("BoE filter pass for ilvl %d and quality %d", itemLevel, itemQuality)) end
return true
end
end
if debug then print(string.format("BoE filter fail for ilvl %d and quality %d", provided.ilvl, provided.quality)) end
return false
end)
local artifactPowerFilter = Filter.new({
["type"] = getItemType,
["subtype"] = getItemSubtype,
["subclassid"] = getItemSubclassId,
["value"] = getItemValue
}, function(slot, provided)
---@cast provided { type: string, subtype: string, subclassid: number, value: number }
if provided.value == 0 and provided.type == "Consumable" and provided.subtype == "Other" and provided.subclassid == 8 then
if debug then
print(string.format("Artifact power filter pass for type %s and subtype %s and subclassid %d with value %d",
provided.type, provided.subtype, provided.subclassid, provided.value))
end
return true
end
if debug then
DevTools_Dump(provided)
print(string.format("Artifact power filter fail for type %s and subtype %s and subclassid %d with value %d",
provided.type, provided.subtype, provided.subclassid, provided.value))
end
return false
end)
-- local azeriteFilter = {
-- enabled = true,
-- ilvlThreshold = 800,
-- qualityThreshold = 2,
-- 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>
local filters = {
ancientManaFilter,
arguniteFilter,
artifactPowerFilter,
bloodhunerQuarryFilter,
bloodOfSargerasFilter,
boeFilter,
classGearFilter,
goldFilter,
greyValueFilter,
ilvlFilter,
mountFilter,
orderResourcesFilter,
professionFilter,
questItemFilter,
-- reicpeFilter,
valueFilter,
arguniteClusterFilter,
}
---@class FilterService
aura_env.FilterService = {
---@param lootInfo table<number>
Run = function(lootInfo)
---@type table<number>
local slotsToLoot = {}
for slot, item in pairs(lootInfo) do
if debug then
local itemname = getItemName(slot)
print(string.format("Checking slot %d for %s", slot, itemname))
end
for _, filter in pairs(filters) do
local res, err = filter:Run(slot)
if err then
if debug then print(err) end
end
if res then
slotsToLoot[#slotsToLoot + 1] = slot
break
end
end
end
aura_env.FilterService.doLoot(slotsToLoot)
end,
---@param slots table<number>
---@return nil
doLoot = function(slots)
for i = #slots, 1, -1 do
aura_env.FilterService.lootslot(slots[i])
end
end,
---@param slot number
---@return nil
lootslot = function(slot)
LootSlot(slot)
local itemIcon = getItemIcon(slot) or 134400
local itemName = getItemName(slot) or "Unknown"
itemName = itemName:gsub("\n", ", ")
local itemQuality = getItemQuality(slot) or 0
if not WeakAurasSaved.Cyka.ItemCache[itemName] then
WeakAurasSaved.Cyka.ItemCache[itemName] = {
icon = itemIcon,
quality = itemQuality,
}
end
end
}
aura_env.skills = {
--Warrior
[1] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 1,
["Shields"] = 1,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 1,
["Bows"] = 1,
["Guns"] = 1,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 1,
["Polearms"] = 1,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 1,
["Warglaives"] = 1,
["Staves"] = 1,
["Fist Weapons"] = 1,
["Daggers"] = 1,
["Crossbows"] = 1,
["Wands"] = 0,
},
--Paladin
[2] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 1,
["Shields"] = 1,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 1,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 1,
["Polearms"] = 1,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 1,
["Warglaives"] = 0,
["Staves"] = 0,
["Fist Weapons"] = 0,
["Daggers"] = 0,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Hunter
[3] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 0,
["Mail"] = 1,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 1,
["Bows"] = 1,
["Guns"] = 1,
["One-Handed Maces"] = 0,
["Two-Handed Maces"] = 0,
["Polearms"] = 1,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 1,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 1,
["Daggers"] = 1,
["Crossbows"] = 1,
["Wands"] = 0,
},
--Rogue
[4] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 1,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 0,
["Fist Weapons"] = 1,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Priest
[5] = {
--Armor Skills
["Cloth"] = 1,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 0,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 0,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 0,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 1,
},
--Death Knight
[6] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 1,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 1,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 1,
["Polearms"] = 1,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 1,
["Warglaives"] = 0,
["Staves"] = 0,
["Fist Weapons"] = 0,
["Daggers"] = 0,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Shaman
[7] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 0,
["Mail"] = 1,
["Plate"] = 0,
["Shields"] = 1,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 0,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 1,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Mage
[8] = {
--Armor Skills
["Cloth"] = 1,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 0,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 0,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 0,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 1,
},
--Warlock
[9] = {
--Armor Skills
["Cloth"] = 1,
["Leather"] = 0,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 0,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 0,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 0,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 1,
},
--Monk
[10] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 1,
["Mail"] = 0,
["Plate"] = 1,
["Shields"] = 1,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 0,
["Polearms"] = 1,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 1,
["Daggers"] = 0,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Druid
[11] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 1,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 0,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 1,
["Two-Handed Maces"] = 0,
["Polearms"] = 1,
["One-Handed Swords"] = 0,
["Two-Handed Swords"] = 0,
["Warglaives"] = 0,
["Staves"] = 1,
["Fist Weapons"] = 1,
["Daggers"] = 1,
["Crossbows"] = 0,
["Wands"] = 0,
},
--Demon Hunter
[12] = {
--Armor Skills
["Cloth"] = 0,
["Leather"] = 1,
["Mail"] = 0,
["Plate"] = 0,
["Shields"] = 0,
--Weapon Skills
["One-Handed Axes"] = 1,
["Two-Handed Axes"] = 0,
["Bows"] = 0,
["Guns"] = 0,
["One-Handed Maces"] = 0,
["Two-Handed Maces"] = 0,
["Polearms"] = 0,
["One-Handed Swords"] = 1,
["Two-Handed Swords"] = 0,
["Warglaives"] = 1,
["Staves"] = 0,
["Fist Weapons"] = 1,
["Daggers"] = 0,
["Crossbows"] = 0,
["Wands"] = 0,
},
}
aura_env.qualityColors = {
"\124cff9d9d9d", -- Poor
"\124cffffffff", -- Common
"\124cff1eff00", -- Uncommon
"\124cff0070dd", -- Rare
"\124cffa335ee", -- Epic
"\124cffff8000", -- Legendary
"\124cffe6cc80", -- Artifact
"\124cff00ccff", -- Heirloom
}

View File

@@ -1,15 +0,0 @@
-- MERCHANT_SHOW
function(allstates, e)
if (GetMerchantNumItems() > 0) then
aura_env.allstates = allstates
if CanMerchantRepair() == true then RepairAllItems() end
for container = 0, 4 do
for slot = 1, GetContainerNumSlots(container) do
aura_env.FilterService.Run(container, slot)
end
end
return true
end
end

File diff suppressed because one or more lines are too long

View File

@@ -1,264 +0,0 @@
local debug = false
local iconDisplayDuration = 3
---@param container number
---@param slot number
---@return string, string|nil
local function getItemLink(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local link = select(7, GetContainerItemInfo(container, slot))
if link == nil then return "", string.format("GetContainerItemInfo returned nil for link (arg 7)") end
return link
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemQuantity(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local quantity = select(2, GetContainerItemInfo(container, slot))
if quantity == nil then
return "",
string.format("GetContainerItemInfo returned nil for quantity (arg 2)")
end
return quantity
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemName(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local name = select(1, GetItemInfo(getItemLink(container, slot)))
if name == nil then return "", string.format("GetItemInfo returned nil for name (arg 1)") end
return name
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemType(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local type = select(6, GetItemInfo(getItemLink(container, slot)))
if type == nil then return "", string.format("GetItemInfo returned nil for type (arg 6)") end
return type
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemSubtype(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local subtype = select(7, GetItemInfo(getItemLink(container, slot)))
if subtype == nil then return "", string.format("GetItemInfo returned nil for subtype (arg 7)") end
return subtype
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemLevel(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local level = select(4, GetItemInfo(getItemLink(container, slot)))
if level == nil then return "", string.format("GetItemInfo returned nil for level (arg 4)") end
return level
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemValue(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local value = select(11, GetItemInfo(getItemLink(container, slot)))
if value == nil then return "", string.format("GetItemInfo returned nil for value (arg 11)") end
return value
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemQuality(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local quality = select(3, GetItemInfo(getItemLink(container, slot)))
if quality == nil then return "", string.format("GetItemInfo returned nil for quality (arg 3)") end
return quality
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemEquipLocation(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local equipLoc = select(9, GetItemInfo(getItemLink(container, slot)))
if equipLoc == nil then return "", string.format("GetItemInfo returned nil for equipLoc (arg 9)") end
return equipLoc
end
---@param container number
---@param slot number
---@return string, string|nil
local function getItemIcon(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local icon = select(10, GetItemInfo(getItemLink(container, slot)))
if icon == nil then return "", string.format("GetItemInfo returned nil for icon (arg 10)") end
return icon
end
---@param container number
---@param slot number
---@return string, string|nil
local function getBindType(container, slot)
if container == nil then return "", string.format("Container is nil") end
if slot == nil then return "", string.format("Slot is nil") end
local bindType = select(14, GetItemInfo(getItemLink(container, slot)))
if bindType == nil then return "", string.format("GetItemInfo returned nil for bindType (arg 14)") end
return bindType
end
---@class Filter
---@field requires table<string, fun(container:number, slot: number): string|number|boolean> | nil
---@field filter fun(container: number, slot: number, provided: table<string, string|number|boolean>): boolean
Filter = {
---@param requires table<string, fun(container:number, slot: number): string|number|boolean> | nil
---@param filter fun(container: number, slot: number, provided: table<string, string|number|boolean>): boolean
---@return Filter
new = function(requires, filter)
local self = setmetatable({}, {
__index = Filter
})
self.requires = requires
self.filter = filter
return self
end,
---@param self Filter
---@param container number
---@param slot number
---@return boolean, string|nil
Run = function(self, container, slot)
---@type table<string, string|number|boolean>
local provided = {}
if self.requires then
for k, v in pairs(self.requires) do
local res, err = v(container, slot)
if err then
if debug then print(err) end
return false, err
end
provided[k] = res
end
end
local res, err = self.filter(container, slot, provided)
if err then
if debug then print(err) end
end
return res, nil
end
}
local grayFilter = Filter.new({
["quality"] = getItemQuality
},
function(container, slot, provided)
if provided.quality == 0 then
return true
end
return false
end)
local gearFilter = Filter.new({
["ilvl"] = getItemLevel,
["bindType"] = getBindType,
["type"] = getItemType,
["equipLoc"] = getItemEquipLocation
},
function(container, slot, provided)
local ilvlThreshold = 850
local sellBoe = false
if provided.type == "Armor"
or provided.type == "Weapon"
or provided.equipLoc == "INVTYPE_FINGER"
or provided.equipLoc == "INVTYPE_TRINKET"
or provided.equipLoc == "INVTYPE_CLOAK"
or provided.equipLoc == "INVTYPE_NECK" then
if provided.ilvl < ilvlThreshold and (provided.bindType == 1 or sellBoe) then
return true
end
end
return false
end)
---@param container number
---@param slot number
---@return nil, string|nil
local function doSell(container, slot)
local itemIcon, err = getItemIcon(container, slot)
if err then return nil, string.format("Error getting item icon: %s", err) end
local itemName, err = getItemName(container, slot)
if err then return nil, string.format("Error getting item name: %s", err) end
local itemQuantity, err = getItemQuantity(container, slot)
if err then return nil, string.format("Error getting item quantity: %s", err) end
local itemQuality, err = getItemQuality(container, slot)
if err then return nil, string.format("Error getting item quality: %s", err) end
local nameWithColor = string.format("%s[%s]\124r", aura_env.qualityColors[itemQuality + 1], itemName)
local nameWithQuantity = string.format("%s x%s", nameWithColor, itemQuantity)
aura_env.allstates[#aura_env.allstates + 1] = {
show = true,
changed = true,
index = GetTime(),
resort = true,
icon = itemIcon,
name = nameWithQuantity,
amount = itemQuantity,
progressType = "timed",
expirationTime = GetTime() + iconDisplayDuration,
duration = iconDisplayDuration,
autoHide = true,
}
UseContainerItem(container, slot)
return nil, nil
end
---@type table<Filter>
local filters = {
grayFilter,
gearFilter
}
---@class FilterService
aura_env.FilterService = {
---@param container number
---@param slot number
---@return nil, nil
Run = function(container, slot)
local itemLink, err = getItemLink(container, slot)
if err then return nil, string.format("Err: slot empty (%d-%d) - %s", container, slot, err) end
for k, filter in pairs(filters) do
local res, err = filter:Run(container, slot)
if err then
if debug then print(err) end
else
if res then
doSell(container, slot)
return
end
end
end
end,
}
aura_env.qualityColors = {
"\124cff9d9d9d", -- Poor
"\124cffffffff", -- Common
"\124cff1eff00", -- Uncommon
"\124cff0070dd", -- Rare
"\124cffa335ee", -- Epic
"\124cffff8000", -- Legendary
"\124cffe6cc80", -- Artifact
"\124cff00ccff", -- Heirloom
}