vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Contributed by Nerolabs Shadowsong Server US |
||
3 | November 10th, 2005 |
||
4 | ]] |
||
5 | |||
6 | if ( GetLocale() == "frFR" ) then |
||
7 | GEM_SORT_MEMBERSHIP_NAME = "RangGuilde"; |
||
8 | GEM_SORT_MEMBERSHIP_HELP = "Tri les joueurs en fonction de leur rang de guilde."; |
||
9 | elseif ( GetLocale() == "deDE" ) then |
||
10 | GEM_SORT_MEMBERSHIP_NAME = "Gildenrang"; |
||
11 | GEM_SORT_MEMBERSHIP_HELP = "Sortiert Spieler unter Beachtung ihres Gildenranges."; |
||
12 | else |
||
13 | GEM_SORT_MEMBERSHIP_NAME = "Membership"; |
||
14 | GEM_SORT_MEMBERSHIP_HELP = "Sort players using their membership level."; |
||
15 | end |
||
16 | |||
17 | --------------- Internal functions --------------- |
||
18 | |||
19 | local function _GEM_SORT_SortByMembershipList(tab1,tab2) |
||
20 | if(tab1.forcetit == 1) |
||
21 | then |
||
22 | if(tab2.forcetit == 0) |
||
23 | then |
||
24 | return true; |
||
25 | end |
||
26 | else |
||
27 | if(tab2.forcetit == 1) |
||
28 | then |
||
29 | return false; |
||
30 | end |
||
31 | end |
||
32 | |||
33 | if (tab1.rankindex == nil or tab2.rankindex == nil) then |
||
34 | -- message ("Sorted by time"); |
||
35 | return tab1.stamp < tab2.stamp; |
||
36 | end |
||
37 | |||
38 | if (tab1.rankindex == tab2.rankindex) then |
||
39 | -- message ("Equal Memberships " .. tab1.name .. tab1.rankindex .. " " .. tab2.name .. tab2.rankindex); |
||
40 | return tab1.stamp < tab2.stamp; |
||
41 | else |
||
42 | -- message ("Non -Equal Memberships " .. tab1.name .. tonumber(tab1.rankindex) .. " " .. tab2.name .. tonumber(tab2.rankindex)); |
||
43 | return (tonumber(tab1.rankindex) < tonumber(tab2.rankindex)); |
||
44 | end |
||
45 | |||
46 | end |
||
47 | |||
48 | local function _GEM_SORT_Membership(players,limits,max_count) |
||
49 | local list = {}; |
||
50 | local tits = {}; |
||
51 | local subs = {}; |
||
52 | local channelName = GEM_DefaultSendChannel; |
||
53 | local gplayers = GEM_Players[GEM_Realm][channelName]; |
||
54 | local leader_guildname = GetGuildInfo("player") ; |
||
55 | |||
56 | -- Create list of all players |
||
57 | for name,tab in players do |
||
58 | if (gplayers[name] ~= nil and gplayers[name].grank_name ~= nil and gplayers[name].grank_idx ~= nil and gplayers[name].grank_idx >= 0) then |
||
59 | grank_name = gplayers[name].grank_name; |
||
60 | grank_idx = gplayers[name].grank_idx; |
||
61 | |||
62 | -- SPECIAL LOGIC FOR OZ NZ GUILD ONLY, CAN BE REMOVED FOR OTHER GUILDS |
||
63 | -- THIS ESTABLISHES PARTNER GUILD MEMBERS EQUAL TO RANK 4 IN OZ NZ |
||
64 | -- AND RANK 6 FOR NON-MEMBERS OF THE GUILD |
||
65 | if (leader_guildname == "OZ NZ") then |
||
66 | if (gplayers[name].guild == "Gnome Liberation Front") then |
||
67 | grank_idx = 4; |
||
68 | elseif (gplayers[name].guild ~= "OZ NZ") then |
||
69 | grank_idx = 6; |
||
70 | end |
||
71 | end |
||
72 | -- END SPECIAL LOGIC |
||
73 | |||
74 | else |
||
75 | grank_name = "Unknown"; |
||
76 | grank_idx = 666; |
||
77 | end |
||
78 | |||
79 | -- message("Inserting " .. name .. grank_name .. grank_idx); |
||
80 | |||
81 | if(tab.forcetit == nil) then tab.forcetit = 0; end; |
||
82 | table.insert(list,{name=name; stamp = tab.update_time; class = tab.class; forcetit = tab.forcetit; rankindex = grank_idx; rankname = grank_name; }); |
||
83 | end |
||
84 | |||
85 | -- Sort it by membership |
||
86 | table.sort(list,_GEM_SORT_SortByMembershipList); |
||
87 | |||
88 | -- Fill tits and subs, using limits |
||
89 | for i,tab in list do |
||
90 | if(table.getn(tits) >= max_count or limits[tab.class].count >= limits[tab.class].max) -- Over the global or class limit ? |
||
91 | then |
||
92 | table.insert(subs,tab.name); |
||
93 | else |
||
94 | table.insert(tits,tab.name); |
||
95 | limits[tab.class].count = limits[tab.class].count + 1; |
||
96 | end |
||
97 | end |
||
98 | |||
99 | -- Return lists |
||
100 | return tits,subs; |
||
101 | end |
||
102 | |||
103 | |||
104 | |||
105 | |||
106 | --------------- Plugin structure --------------- |
||
107 | |||
108 | GEM_SORT_Membership = { |
||
109 | --[[ |
||
110 | Name parameter. [MANDATORY] |
||
111 | Displayed name of the sorting plugin. |
||
112 | ]] |
||
113 | Name = GEM_SORT_MEMBERSHIP_NAME; |
||
114 | |||
115 | --[[ |
||
116 | SortType parameter. [MANDATORY] |
||
117 | Internal code for the sorting type (must be unique). |
||
118 | ]] |
||
119 | SortType = "Membership"; |
||
120 | |||
121 | --[[ |
||
122 | Subscribers sorting function. [MANDATORY] |
||
123 | Sorts all passed players in two lists. |
||
124 | Params : |
||
125 | - players : Array indexed by Names (STRINGS) of {update_time(INT),guild(STRING),class(STRING),level(INT)} : READ ONLY |
||
126 | - limits : Array indexed by Classes (STRINGS) of {min(INT),max(INT),count(INT)} : 'min'/'max' is the min/max allowed for this class, 'count' is the current count in the class (always 0) : READ/WRITE |
||
127 | - max_count : (INT) is the max titulars allowed for the event |
||
128 | Returns : |
||
129 | - Array of Names (STRING) : Titulars |
||
130 | - Array of Names (STRING) : Substitutes |
||
131 | ]] |
||
132 | Sort = function(players,limits,max_count) |
||
133 | return _GEM_SORT_Membership(players,limits,max_count); |
||
134 | end; |
||
135 | |||
136 | --[[ |
||
137 | Subscribers recover function. [MANDATORY] |
||
138 | Gives the plugin a chance to re-initialize its internal data (lost when leader crashed), based on the passed 'players' structure. |
||
139 | The "Sort" function will be called just after this call, so your data must be initialized. |
||
140 | Params : |
||
141 | - players : Array indexed by Names (STRINGS) of {update_time(INT),guild(STRING),class(STRING),level(INT)} : READ ONLY |
||
142 | WARNING : 'update_time' and 'guild' values are not accurate here, don't rely on them ! |
||
143 | - limits : Array indexed by Classes (STRINGS) of {min(INT),max(INT),count(INT)} : 'min'/'max' is the min/max allowed for this class, 'count' is the current count in the class (always 0) : READ/WRITE |
||
144 | - max_count : (INT) is the max titulars allowed for the event |
||
145 | ]] |
||
146 | Recover = function(players,limits,max_count) |
||
147 | -- Nothing to do, no internal data |
||
148 | end; |
||
149 | |||
150 | --[[ |
||
151 | Configure function. [OPTIONAL] |
||
152 | Configures the plugin. |
||
153 | ]] |
||
154 | --Configure = function() |
||
155 | --end; |
||
156 | |||
157 | --[[ |
||
158 | Help parameter. [OPTIONAL] |
||
159 | Help string displayed when you mouse over the sort type. |
||
160 | ]] |
||
161 | Help = GEM_SORT_MEMBERSHIP_HELP; |
||
162 | |||
163 | --[[ |
||
164 | Default parameter. [MUST NOT BE SET] |
||
165 | Sets this plugin as the default one. Must only be set by the "Stamp" plugin. |
||
166 | ]] |
||
167 | Default = false; |
||
168 | }; |
||
169 | |||
170 | function GEM_SORT_Membership_OnLoad() |
||
171 | GEM_SUB_RegisterPlugin(GEM_SORT_Membership); |
||
172 | end |
||
173 |