SHOW:
|
|
- or go back to the newest paste.
1 | local frame = CreateFrame("Frame") | |
2 | local timer = frame:CreateAnimationGroup() | |
3 | timer.animation = timer:CreateAnimation() | |
4 | timer.animation:SetDuration(1) | |
5 | timer.animation:SetOrder(1) | |
6 | timer.frame = frame | |
7 | ||
8 | timer.testMode = true | |
9 | ||
10 | local didAction, lastName, lastAction | |
11 | timer:SetScript("OnFinished", function(self) | |
12 | didAction = false | |
13 | for i = 1, GetNumGuildMembers() do | |
14 | local name, _, rankIndex, level, _, _, _, _, _, _, classFileName = GetGuildRosterInfo(i) | |
15 | -- Make it consistent with values for SetGuildMemberRank() for sanity's sake. | |
16 | rankIndex = rankIndex + 1 | |
17 | ||
18 | if rankIndex == 1 or rankIndex == 2 or rankIndex == 3 then -- Guild master, Officers, Intouchables | |
19 | return | |
20 | end | |
21 | ||
22 | if CanGuildPromote() then | |
23 | local targetRank | |
24 | if level >= 1 and level <= 79 and rankIndex ~= 7 then | |
25 | targetRank = 7 | |
26 | elseif level >= 80 and level <= 84 and rankIndex ~= 6 then | |
27 | targetRank = 6 | |
28 | elseif level >= 85 and level <= 89 and rankIndex ~= 5 then | |
29 | targetRank = 5 | |
30 | elseif level == 90 and rankIndex ~= 4 then | |
31 | targetRank = 4 | |
32 | end | |
33 | - | |
33 | + | if targetRank then |
34 | - | if self.testMode then |
34 | + | |
35 | - | print("PROMOTE", name, targetRank) |
35 | + | print("PROMOTE", name, targetRank) |
36 | - | else |
36 | + | |
37 | - | if lastAction == "PROMOTE" and lastName == name then |
37 | + | if lastAction == "PROMOTE" and lastName == name then |
38 | - | -- Avoid infinite loops if the action is failing: |
38 | + | |
39 | - | return print("Action failed:", lastAction, lastName, targetRank) |
39 | + | return print("Action failed:", lastAction, lastName, targetRank) |
40 | end | |
41 | - | didAction, lastAction, lastName = true, "PROMOTE", name |
41 | + | didAction, lastAction, lastName = true, "PROMOTE", name |
42 | - | SetGuildMemberRank(i, targetRank) |
42 | + | SetGuildMemberRank(i, targetRank) |
43 | end | |
44 | break | |
45 | end | |
46 | end | |
47 | ||
48 | if not ignoreList[name] and CanGuildRemove() then | |
49 | local year, month, day = GetGuildRosterLastOnline(i) | |
50 | -- (year > 0 or month > 0 or day > 21) | |
51 | if year and ( | |
52 | (rankIndex == 7 | |
53 | and (day >= 1 and level == 1) | |
54 | or (day >= 2 and level == 5 and classFileName == "DEATHKNIGHT") | |
55 | or (day >= 3 and ((level > 1 and level <= 5) or (level > 55 and level <= 55 and classFileName == "DEATHKNIGHT"))) | |
56 | or (day >= 14 and level > 5 and level <= 79) | |
57 | ) | |
58 | or (rankIndex == 6 and day >= 21) | |
59 | or ((rankIndex == 4 or rankIndex == 5) and day >= 28) | |
60 | ) then | |
61 | if self.testMode then | |
62 | print("REMOVE", name) | |
63 | else | |
64 | if lastAction == "REMOVE" and lastName == name then | |
65 | -- Avoid infinite loops if the action is failing: | |
66 | return print("Action failed:", lastAction, lastName) | |
67 | end | |
68 | didAction, lastAction, lastName = true, "REMOVE", name | |
69 | - | break |
69 | + | |
70 | end | |
71 | break | |
72 | end | |
73 | end | |
74 | end | |
75 | ||
76 | -- Start it again if we did something. | |
77 | if didAction then | |
78 | self:Play() | |
79 | end | |
80 | end) |