-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
120 lines (89 loc) · 2.79 KB
/
Copy pathCore.lua
File metadata and controls
120 lines (89 loc) · 2.79 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
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
local AngryAssign = LibStub("AceAddon-3.0"):NewAddon("FACTSAssignments", "AceConsole-3.0", "AceEvent-3.0", "AceComm-3.0", "AceTimer-3.0")
local AceGUI = LibStub("AceGUI-3.0")
local libS = LibStub("AceSerializer-3.0")
local libC = LibStub("LibCompress")
local lwin = LibStub("LibWindow-1.1")
local libCE = libC:GetAddonEncodeTable()
local LSM = LibStub("LibSharedMedia-3.0")
local protocolVersion = 1
local comPrefix = "FACTSAss"..protocolVersion
-------------------------
-- Addon Communication --
-------------------------
function FACTSAssignments:ReceiveMessage(prefix, data, channel, sender)
if prefix ~= comPrefix then return end
local one = libCE:Decode(data) -- Decode the compressed data
local two, message = libC:Decompress(one) -- Decompress the decoded data
if not two then error("Error decompressing: " .. message); return end
local success, final = libS:Deserialize(two) -- Deserialize the decompressed data
if not success then error("Error deserializing " .. final); return end
self:ProcessMessage( sender, final )
end
function AngryAssign:SendMessage(data, channel, target)
local one = libS:Serialize(data)
local two = libC:CompressHuffman(one)
local final = libCE:Encode(two)
if not channel then
if IsInRaid() then
channel = "RAID"
elseif IsInGroup() then
channel = "PARTY"
end
end
if not channel then return end
-- Debug string
self:Print("Sending "..data[COMMAND].." over "..channel.." to "..tostring(target))
self:SendCommMessage(comPrefix, final, channel, target, "NORMAL")
return true
end
function AngryAssign:ProcessMessage(sender, data)
local cmd = data[COMMAND]
sender = EnsureUnitFullName(sender)
-- Debug string
self:Print("Received "..data[COMMAND].." from "..sender)
end
-------------------------------------------------------------------
---------Missing Methods that were implemented in MoP/WoD----------
-------------------------------------------------------------------
function IsInRaid()
if(GetNumRaidMembers() > 0) then
return true
end
return false;
end
function IsInGroup()
if(GetNumRaidMembers() == 0 and GetNumPartyMembers() > 0) then
return true
end
return false;
end
function GetNumGroupMembers()
if (IsInRaid()) then
return GetNumRaidMembers();
elseif (IsInGroup()) then
return GetNumPartyMembers() + 1;
end
end
function UnitIsGroupLeader(playerName)
if(IsInRaid()) then
local name, rank = GetRaidRosterInfo(UnitInRaid(playerName));
if(rank == 2) then
return true;
end
elseif (IsInGroup()) then
if((UnitName("player") == playername) and IsPartyLeader()) then
return true;
end
return true;
end
return false;
end
function UnitIsGroupAssistant(playerName)
if(IsInRaid()) then
local name, rank = GetRaidRosterInfo(UnitInRaid(playerName));
if(rank == 1) then
return true;
end
end
return false;
end