Repository navigation
Expand file tree
/
Copy pathCore.lua
More file actions
85 lines (68 loc) · 3.18 KB
/
Copy pathCore.lua
File metadata and controls
85 lines (68 loc) · 3.18 KB
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
local _, dc = ...
dc.addonPrefix = "DCOribos"
dc.askMessage = "ASK"
DCovenant = {
["iconSize"] = 16,
}
DCovenantLog = true
local playerName = UnitName("player")
local realmName = ""
local frame = CreateFrame("FRAME", "DetailsCovenantFrame");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
local function init()
realmName = GetNormalizedRealmName()
frame:RegisterEvent("GROUP_ROSTER_UPDATE");
frame:RegisterEvent("CHAT_MSG_ADDON")
C_ChatInfo.RegisterAddonMessagePrefix(dc.addonPrefix)
dc.oribos:fillCovenants()
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end
---@diagnostic disable-next-line: unused-local
local function eventHandler(self, event, ...)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local _, subevent, _, sourceGUID, sourceName = CombatLogGetCurrentEventInfo()
if dc.oribos.emptyCovenants[sourceName] or dc.oribos.covenants[sourceName] then
if subevent == "SPELL_CAST_SUCCESS" and dc.utils:isValidGUID(sourceGUID) then
local _, englishClass = GetPlayerInfoByGUID(sourceGUID)
local classAbilityMap = dc.spellMaps.abilityMap[englishClass]
if classAbilityMap then
local spellID = select(12, CombatLogGetCurrentEventInfo())
local covenantIDByAbility = classAbilityMap[spellID]
local covenantIDByUtility = dc.spellMaps.utilityMap[spellID]
dc.oribos:logNewPlayer(covenantIDByAbility, sourceName, englishClass, spellID)
dc.oribos:addCovenantForPlayer(covenantIDByAbility, sourceName, englishClass)
dc.oribos:logNewPlayer(covenantIDByUtility, sourceName, englishClass, spellID)
dc.oribos:addCovenantForPlayer(covenantIDByUtility, sourceName, englishClass)
end
end
end
elseif event == "GROUP_ROSTER_UPDATE" then
dc.oribos:fillCovenants()
elseif event == "CHAT_MSG_ADDON" then
local prefix, messageText, _, sender = ...
if prefix == dc.addonPrefix then
if string.match(messageText, dc.askMessage) then
local _, askForName = dc.utils:splitMessage(messageText)
if string.match(askForName, playerName) then
dc.oribos:sendCovenantInfo(playerName)
end
elseif dc.oribos:hasPlayerWithEmptyCovenant() then
local senderName, senderRealm = dc.utils:splitName(sender)
if senderName ~= playerName then
local name, covenantID, playerClass = dc.utils:splitMessage(messageText)
if realmName ~= senderRealm then
name = name.."-"..senderRealm
end
dc.oribos:logNewPlayer(tonumber(covenantID), name, playerClass)
dc.oribos:addCovenantForPlayer(tonumber(covenantID), name, playerClass)
end
end
end
elseif event == "PLAYER_ENTERING_WORLD" then
init()
dc:replaceDetailsImplmentation()
dc:replaceSkadaImplmentation()
frame:UnregisterEvent("PLAYER_ENTERING_WORLD");
end
end
frame:SetScript("OnEvent", eventHandler);