Add stylua toml

This commit is contained in:
2025-05-04 14:27:32 +02:00
parent 21b6ecccd0
commit cbe7741954
6 changed files with 191 additions and 546 deletions

View File

@@ -19,29 +19,17 @@ local skills = {}
---@field value number
local NumberValue = {
---@param other number
Gt = function(self, other)
return self.value > other
end,
Gt = function(self, other) return self.value > other end,
---@param other number
Lt = function(self, other)
return self.value < other
end,
Lt = function(self, other) return self.value < other end,
---@param other number
Eq = function(self, other)
return self.value == other
end,
Eq = function(self, other) return self.value == other end,
---@param other number
Ne = function(self, other)
return self.value ~= other
end,
Ne = function(self, other) return self.value ~= other end,
---@param other number
Ge = function(self, other)
return self.value >= other
end,
Ge = function(self, other) return self.value >= other end,
---@param other number
Le = function(self, other)
return self.value <= other
end,
Le = function(self, other) return self.value <= other end,
}
local function NewNumberValue(value)
local ret = { value = value }
@@ -59,37 +47,21 @@ end
---@field value string
local StringValue = {
---@param other string
Gt = function(self, other)
return self.value > other
end,
Gt = function(self, other) return self.value > other end,
---@param other string
Lt = function(self, other)
return self.value < other
end,
Lt = function(self, other) return self.value < other end,
---@param other string
Eq = function(self, other)
return self.value == other
end,
Eq = function(self, other) return self.value == other end,
---@param other string
Ne = function(self, other)
return self.value ~= other
end,
Ne = function(self, other) return self.value ~= other end,
---@param other string
Ge = function(self, other)
return self.value >= other
end,
Ge = function(self, other) return self.value >= other end,
---@param other string
Le = function(self, other)
return self.value <= other
end,
Le = function(self, other) return self.value <= other end,
---@param other string
Matches = function(self, other)
return string.match(self.value, other)
end,
Matches = function(self, other) return string.match(self.value, other) end,
---@param other string
Contains = function(self, other)
return string.find(self.value, other)
end,
Contains = function(self, other) return string.find(self.value, other) end,
}
local function NewStringValue(value)
local ret = { value = value }
@@ -126,13 +98,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Link(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local link = GetLootSlotLink(slot)
if link == nil then
return ret, "link is nil"
end
if link == nil then return ret, "link is nil" end
ret.value = link
return ret, nil
end
@@ -141,13 +109,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Name(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local name = select(2, GetLootSlotInfo(slot))
if name == nil then
return ret, "name is nil"
end
if name == nil then return ret, "name is nil" end
ret.value = name
return ret, nil
end
@@ -156,13 +120,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Type(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local type = select(6, GetItemInfo(Link(slot).value))
if type == nil then
return ret, "type is nil"
end
if type == nil then return ret, "type is nil" end
ret.value = type
return ret, nil
end
@@ -171,13 +131,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function SubType(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local subType = select(7, GetItemInfo(Link(slot).value))
if subType == nil then
return ret, "subType is nil"
end
if subType == nil then return ret, "subType is nil" end
ret.value = subType
return ret, nil
end
@@ -186,13 +142,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function ItemLevel(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local itemLevel = select(4, GetItemInfo(Link(slot).value))
if itemLevel == nil then
return ret, "itemLevel is nil"
end
if itemLevel == nil then return ret, "itemLevel is nil" end
ret.value = itemLevel
return ret, nil
end
@@ -201,13 +153,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Value(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local itemValue = select(11, GetItemInfo(Link(slot).value))
if itemValue == nil then
return ret, "itemValue is nil"
end
if itemValue == nil then return ret, "itemValue is nil" end
ret.value = itemValue
return ret, nil
end
@@ -216,13 +164,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function SubclassId(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local subclassId = select(13, GetItemInfo(Link(slot).value))
if subclassId == nil then
return ret, "subclassId is nil"
end
if subclassId == nil then return ret, "subclassId is nil" end
ret.value = subclassId
return ret, nil
end
@@ -231,13 +175,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Quantity(slot)
local ret = NewNumberValue(1)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local quantity = select(3, GetLootSlotInfo(slot))
if quantity == nil then
return ret, "quantity is nil"
end
if quantity == nil then return ret, "quantity is nil" end
ret.value = quantity
return ret, nil
end
@@ -246,13 +186,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function EquipLocation(slot)
local ret = NewNumberValue(0)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local equipLocation = select(9, GetItemInfo(Link(slot).value))
if equipLocation == nil then
return ret, "equipLocation is nil"
end
if equipLocation == nil then return ret, "equipLocation is nil" end
ret.value = equipLocation
return ret, nil
end
@@ -261,13 +197,9 @@ function shared.Autoloot.Init()
---@return StringValue, string?
local function Icon(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local icon = select(10, GetItemInfo(Link(slot).value))
if icon == nil then
return ret, "icon is nil"
end
if icon == nil then return ret, "icon is nil" end
ret.value = icon
return ret, nil
end
@@ -276,13 +208,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function BindType(slot)
local ret = NewStringValue("")
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local bindType = select(14, GetItemInfo(Link(slot).value))
if bindType == nil then
return ret, "bindType is nil"
end
if bindType == nil then return ret, "bindType is nil" end
ret.value = bindType
return ret, nil
end
@@ -291,13 +219,9 @@ function shared.Autoloot.Init()
---@return NumberValue, string?
local function Quality(slot)
local ret = NewNumberValue(-1)
if slot == nil then
return ret, "slot is nil"
end
if slot == nil then return ret, "slot is nil" end
local quality = select(4, GetLootSlotInfo(slot))
if quality == nil then
return ret, "quality is nil"
end
if quality == nil then return ret, "quality is nil" end
ret.value = quality
return ret, nil
end
@@ -311,9 +235,7 @@ function shared.Autoloot.Init()
---@class GoldFilter : Filter
local GoldFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.gold.enabled then
return false
end
if not shared.config.autoloot.filter.gold.enabled then return false end
local name = Name(slot)
return name:Contains("Gold") or name:Contains("Silver") or name:Contains("Copper")
end,
@@ -321,40 +243,30 @@ function shared.Autoloot.Init()
---@class OrderResourceFilter : Filter
local OrderResourceFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.orderResource.enabled then
return false
end
if not shared.config.autoloot.filter.orderResource.enabled then return false end
return Name(slot):Contains("Order Resources")
end,
}
---@class MountFilter : Filter
local MountFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.mount.enabled then
return false
end
if not shared.config.autoloot.filter.mount.enabled then return false end
return Type(slot):Eq("Mount")
end,
}
---@class IlvlFilter : Filter
local IlvlFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.ilvl.enabled then
return false
end
if not shared.config.autoloot.filter.ilvl.enabled then return false end
return ItemLevel(slot):Ge(shared.config.autoloot.filter.ilvl.value)
end,
}
---@class ProfessionFilter : Filter
local ProfessionFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.profession.enabled then
return false
end
if not shared.config.autoloot.filter.profession.enabled then return false end
local type = Type(slot)
if not type:Eq("Tradeskill") then
return false
end
if not type:Eq("Tradeskill") then return false end
local subtype = SubType(slot)
local professions = { strsplit(",", shared.config.autoloot.filter.profession.professions) }
return shared.TableContains(professions, subtype) or false
@@ -363,69 +275,49 @@ function shared.Autoloot.Init()
---@class ValueFilter : Filter
local ValueFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.value.enabled then
return false
end
if not shared.config.autoloot.filter.value.enabled then return false end
local value = Value(slot)
if shared.config.autoloot.filter.value.byStack then
value = value * Quantity(slot).value
end
if shared.config.autoloot.filter.value.byStack then value = value * Quantity(slot).value end
return value:Ge(shared.config.autoloot.filter.value.value)
end,
}
---@class GreyValueFilter : Filter
local GreyValueFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.greyvalue.enabled then
return false
end
if not shared.config.autoloot.filter.greyvalue.enabled then return false end
local quality = Quality(slot)
if not quality:Eq(0) then
return false
end
if not quality:Eq(0) then return false end
local value = Value(slot)
if shared.config.autoloot.filter.greyvalue.byStack then
value = value * Quantity(slot).value
end
if shared.config.autoloot.filter.greyvalue.byStack then value = value * Quantity(slot).value end
return value:Ge(shared.config.autoloot.filter.greyvalue.value)
end,
}
---@class QuestItemFilter : Filter
local QuestItemFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.questItem.enabled then
return false
end
if not shared.config.autoloot.filter.questItem.enabled then return false end
return Type(slot):Eq("Quest") and SubType(slot):Eq("Quest")
end,
}
---@class ClassGearFilter : Filter
local ClassGearFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.classGear.enabled then
return false
end
if not shared.config.autoloot.filter.classGear.enabled then return false end
local ilvlThreshold = shared.config.autoloot.filter.classGear.ilvlThreshold
local qualityThreshold = shared.config.autoloot.filter.classGear.qualityThreshold
local isEquippable = skills[select(3, UnitClass("player"))][SubType(slot).value] or false
if not isEquippable then
return false
end
if not isEquippable then return false end
return ItemLevel(slot):Ge(ilvlThreshold) and Quality(slot):Ge(qualityThreshold)
end,
}
---@class NameFilter : Filter
local NameFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.name.enabled then
return false
end
if not shared.config.autoloot.filter.name.enabled then return false end
local whitelist = { strsplit(",", shared.config.autoloot.filter.name.whitelist) }
for _, name in ipairs(whitelist) do
if not shared.config.autoloot.filter.name.caseSensitive then
name = name:lower()
end
if not shared.config.autoloot.filter.name.caseSensitive then name = name:lower() end
if shared.config.autoloot.filter.name.exact then
return Name(slot):Eq(name)
else
@@ -440,9 +332,7 @@ function shared.Autoloot.Init()
types = { "Armor", "Weapon" },
equipLocs = { "INVTYPE_FINGER", "INVTYPE_TRINKET", "INVTYPE_CLOAK", "INVTYPE_NECK" },
Matches = function(self, slot)
if not shared.config.autoloot.filter.boe.enabled then
return false
end
if not shared.config.autoloot.filter.boe.enabled then return false end
local ilvlThreshold = shared.config.autoloot.filter.boe.ilvlThreshold
local qualityThreshold = shared.config.autoloot.filter.boe.qualityThreshold
@@ -457,9 +347,7 @@ function shared.Autoloot.Init()
---@class APFilter : Filter
local APFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.ap.enabled then
return false
end
if not shared.config.autoloot.filter.ap.enabled then return false end
return Value(slot):Eq(0)
and Type(slot):Eq("Consumable")
and SubType(slot):Eq("Other")
@@ -469,9 +357,7 @@ function shared.Autoloot.Init()
---@class EverythingFilter : Filter
local EverythingFilter = {
Matches = function(self, slot)
if not shared.config.autoloot.filter.everything.enabled then
return false
end
if not shared.config.autoloot.filter.everything.enabled then return false end
return true
end,
}