-
Notifications
You must be signed in to change notification settings - Fork 3
/
TargetSelectionFilter.lua
54 lines (48 loc) · 1.21 KB
/
TargetSelectionFilter.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---@class AddonNamespace
local addon = select(2, ...)
local TargetSelectionFilter = {}
addon.TargetSelectionFilter = TargetSelectionFilter
---@alias TargetSelectionFilter fun(unit: string): boolean
---@param filters (TargetSelectionFilter)[]
---@return TargetSelectionFilter
function TargetSelectionFilter.Any(filters)
return function(unit)
if #filters == 0 then return true end
for _, filter in ipairs(filters) do
if filter(unit) then
return true
end
end
return false
end
end
---@param filters (TargetSelectionFilter)[]
---@return TargetSelectionFilter
function TargetSelectionFilter.All(filters)
return function(unit)
for _, filter in ipairs(filters) do
if not filter(unit) then
return false
end
end
return true
end
end
---@param targetRole "TANK"|"HEALER"|"DAMAGER"
---@return TargetSelectionFilter
function TargetSelectionFilter.Role(targetRole)
return function(unit)
local role = UnitGroupRolesAssigned(unit)
if role ~= "NONE" then
return targetRole == role
end
return false
end
end
---@return TargetSelectionFilter
function TargetSelectionFilter.MainTank()
return function(unit)
local isMainTank = GetPartyAssignment("MAINTANK", unit, true)
return isMainTank
end
end