-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOribos.lua
134 lines (108 loc) · 4.2 KB
/
Oribos.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
local _, dc = ...
dc.oribos = {}
local oribos = dc.oribos
oribos.emptyCovenants = {}
oribos.covenants = {}
local _, ownClass = UnitClass("player")
function oribos:getCovenantIcon(covenantID)
if covenantID > 0 and covenantID < 5 then
local covenantMap = {
[1] = "kyrian",
[2] = "venthyr",
[3] = "night_fae",
[4] = "necrolord",
}
return "|T".."Interface\\AddOns\\Details_Covenants\\resources\\"..covenantMap[covenantID]..".tga:"..DCovenant["iconSize"]..":"..DCovenant["iconSize"].."|t"
end
return ""
end
function oribos:fillCovenants()
local numGroupMembers = GetNumGroupMembers()
for groupindex = 1, numGroupMembers do
local name = GetRaidRosterInfo(groupindex)
if name and not oribos.covenants[name] and not oribos.emptyCovenants[name] then
oribos.emptyCovenants[name] = 0
oribos:askCovenantInfo(name)
end
end
end
function oribos:addCovenantForPlayer(covenantID, playerName, playerClass)
if covenantID then
local playerData = {}
playerData.covenantID = covenantID
playerData.class = playerClass
oribos.covenants[playerName] = playerData
oribos.emptyCovenants[playerName] = nil
end
end
function oribos:askCovenantInfo(playerName)
local message = dc.askMessage..":"..playerName
C_ChatInfo.SendAddonMessage(dc.addonPrefix, message, "RAID")
end
function oribos:sendCovenantInfo(playerName)
if playerName then
if playerName == UnitName("player") then
local message = playerName..":"..C_Covenants.GetActiveCovenantID()..":"..ownClass
C_ChatInfo.SendAddonMessage(dc.addonPrefix, message, "RAID")
elseif oribos.covenants[playerName] then
local message = playerName..":"..oribos.covenants[playerName].covenantID..":"..oribos.covenants[playerName].class
C_ChatInfo.SendAddonMessage(dc.addonPrefix, message, "RAID")
end
end
end
function oribos:hasPlayerWithEmptyCovenant()
return not dc.utils:isEmpty(oribos.emptyCovenants)
end
-- Loggers
function oribos:logNewPlayer(covenantID, playerName, playerClass, spellID)
if DCovenantLog and covenantID and playerName ~= UnitName("player") and (not oribos.covenants[playerName] or oribos.covenants[playerName].covenantID ~= covenantID) then
local coloredName = "|CFFe5a472Details_Covenants|r"
local _, _, _, classColor = GetClassColor(playerClass)
local byMessage = ""
if spellID then
local link = GetSpellLink(spellID)
byMessage = " (by spell: "..link..")"
end
print(coloredName.." covenant defined: "..oribos:getCovenantIcon(covenantID).." |C"..classColor..playerName.."|r"..byMessage)
end
end
function oribos:log()
print("|CFFe5a472Details_Covenants|r List of logged characters:")
for key, data in pairs(oribos.covenants) do
local _, _, _, classColor = GetClassColor(data.class)
print(oribos:getCovenantIcon(data.covenantID).." |C"..classColor..key.."|r")
end
end
function oribos:logParty()
local numGroupMembers = GetNumGroupMembers()
if numGroupMembers > 0 then
print("|CFFe5a472Details_Covenants|r Party covenants:")
for groupindex = 1, numGroupMembers do
local name = GetRaidRosterInfo(groupindex)
local playerData = oribos.covenants[name]
if name and playerData then
local _, _, _, classColor = GetClassColor(playerData.class)
print(oribos:getCovenantIcon(playerData.covenantID).." |C"..classColor..name.."|r")
end
end
else
print("|CFFe5a472Details_Covenants|r You are not currently in group.")
end
end
-- Public
_G.Oribos = {}
local publicOribos = _G.Oribos
function publicOribos:getCovenantIconForPlayer(playerName)
local covenantID = 0
if playerName == UnitName("player") then
covenantID = C_Covenants.GetActiveCovenantID()
else
local covenantData = oribos.covenants[playerName]
if covenantData and covenantData.covenantID then
covenantID = covenantData.covenantID
else
return ""
end
end
return oribos:getCovenantIcon(covenantID)
end