-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimeGroup.lua
121 lines (84 loc) · 2.46 KB
/
PrimeGroup.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
--[[
====================================================
LibPrime
Author: Ivan Leben
====================================================
--]]
PrimeGroup = {};
function PrimeGroup.GetMembers()
local members = {};
if (UnitInRaid( "player" )) then
--Walk the list of raid members
local numMembers = GetNumRaidMembers();
for m=1,numMembers do
--Add to name list
local name = GetRaidRosterInfo( m );
table.insert( members, name );
end
else
--Insert player's name
local player = UnitName( "player" );
table.insert( members, player );
--Walk the list of party members
local numMembers = GetNumPartyMembers();
for m=1,numMembers do
--Add to name list
local name = UnitName ( "party"..m );
table.insert( members, name );
end
end
return members;
end
function PrimeGroup.GetLeader()
if (UnitInRaid( "player" )) then
--Find the name of the raid leader
local numMembers = GetNumRaidMembers();
for m=1,numMembers do
local name, rank = GetRaidRosterInfo( m );
if (rank == 2) then return name end
end
--Report error if not found
AC:debug( "Failed finding raid leader!" );
return nil;
elseif (GetNumPartyMembers() > 0) then
--Find the name of the party leader
local leaderId = GetPartyLeaderIndex();
if (leaderId == 0) then return UnitName( "player" );
else return UnitName( "party"..leaderId );
end
else
--Return player name if not in group
return UnitName( "player" );
end
end
function PrimeGroup.GetLootMaster()
local method, partyMaster, raidMaster = GetLootMethod();
--Looting must be set to Master Looter
if (method ~= "master") then
return nil;
end
--Check if in raid
if (raidMaster ~= nil) then
return UnitName( "raid"..raidMaster );
end
--Check if in party
if (partyMaster ~= nil) then
return UnitName( "party"..partyMaster );
end
--Doesn't exist
return nil;
end
function PrimeGroup.GetClassColor( unitName )
local class, classFile = UnitClass( unitName );
if (classFile == nil) then
return { r=1, g=1, b=1, a=1 };
end
--if (classFile == nil) then return "|cffffffff" end;
local color = RAID_CLASS_COLORS[ classFile ];
if (color == nil) then
return { r=1, g=1, b=1, a=1 };
end
--if (color == nil) then return "|cffffffff" end;
return color;
--return string.format( "|cff%.2x%.2x%.2x", (color.r*255), (color.g*255), (color.b*255) );
end