vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Guild Event Manager by Kiki of European Cho'gall |
||
3 | Subscribers sorting - By stamp - By Kiki |
||
4 | ]] |
||
5 | |||
6 | |||
7 | if ( GetLocale() == "frFR" ) then |
||
8 | GEM_SORT_NAME = "Date"; |
||
9 | GEM_SORT_HELP = "Tri les joueurs en fonction de leur date d'inscription."; |
||
10 | elseif ( GetLocale() == "deDE" ) then |
||
11 | GEM_SORT_NAME = "Datum"; |
||
12 | GEM_SORT_HELP = "Sortiert Spieler unter Beachtung ihrer Anmeldezeit."; |
||
13 | else |
||
14 | GEM_SORT_NAME = "Date"; |
||
15 | GEM_SORT_HELP = "Sort players using their subscription time."; |
||
16 | end |
||
17 | --------------- Internal functions --------------- |
||
18 | |||
19 | local function _GEM_SORT_SortList(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 | return tab1.stamp < tab2.stamp; |
||
33 | end |
||
34 | |||
35 | local function _GEM_SORT_Sort(players,limits,max_count) |
||
36 | local list = {}; |
||
37 | local tits = {}; |
||
38 | local subs = {}; |
||
39 | |||
40 | -- Create list of all players |
||
41 | for name,tab in players do |
||
42 | if(tab.forcetit == nil) then tab.forcetit = 0; end; |
||
43 | table.insert(list,{name=name; stamp = tab.update_time; class = tab.class; forcetit = tab.forcetit }); |
||
44 | end |
||
45 | |||
46 | -- Sort it by stamp |
||
47 | table.sort(list,_GEM_SORT_SortList); |
||
48 | |||
49 | -- Fill tits and subs, using limits |
||
50 | for i,tab in list do |
||
51 | if(table.getn(tits) >= max_count or limits[tab.class].count >= limits[tab.class].max) -- Over the global or class limit ? |
||
52 | then |
||
53 | table.insert(subs,tab.name); |
||
54 | else |
||
55 | table.insert(tits,tab.name); |
||
56 | limits[tab.class].count = limits[tab.class].count + 1; |
||
57 | end |
||
58 | end |
||
59 | |||
60 | -- Return lists |
||
61 | return tits,subs; |
||
62 | end |
||
63 | |||
64 | |||
65 | --------------- Plugin structure --------------- |
||
66 | |||
67 | GEM_SORT_Stamp = { |
||
68 | --[[ |
||
69 | Name parameter. [MANDATORY] |
||
70 | Displayed name of the sorting plugin. |
||
71 | ]] |
||
72 | Name = GEM_SORT_NAME; |
||
73 | |||
74 | --[[ |
||
75 | SortType parameter. [MANDATORY] |
||
76 | Internal code for the sorting type (must be unique). |
||
77 | ]] |
||
78 | SortType = "Stamp"; |
||
79 | |||
80 | --[[ |
||
81 | Subscribers sorting function. [MANDATORY] |
||
82 | Sorts all passed players in two lists. |
||
83 | Params : |
||
84 | - players : Array indexed by Names (STRINGS) of {update_time(INT),guild(STRING),class(STRING),level(INT),forcetit(INT)} : READ ONLY |
||
85 | - 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 |
||
86 | - max_count : (INT) is the max titulars allowed for the event |
||
87 | Returns : |
||
88 | - Array of Names (STRING) : Titulars |
||
89 | - Array of Names (STRING) : Substitutes |
||
90 | ]] |
||
91 | Sort = function(players,limits,max_count) |
||
92 | return _GEM_SORT_Sort(players,limits,max_count); |
||
93 | end; |
||
94 | |||
95 | --[[ |
||
96 | Subscribers recover function. [MANDATORY] |
||
97 | Gives the plugin a chance to re-initialize its internal data (lost when leader crashed), based on the passed 'players' structure. |
||
98 | The "Sort" function will be called just after this call, so your data must be initialized. |
||
99 | Params : |
||
100 | - players : Array indexed by Names (STRINGS) of {update_time(INT),guild(STRING),class(STRING),level(INT)} : READ ONLY |
||
101 | WARNING : 'update_time' and 'guild' values are not accurate here, don't rely on them ! |
||
102 | - 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 |
||
103 | - max_count : (INT) is the max titulars allowed for the event |
||
104 | ]] |
||
105 | Recover = function(players,limits,max_count) |
||
106 | -- Nothing to do, no internal data |
||
107 | end; |
||
108 | |||
109 | --[[ |
||
110 | Configure function. [OPTIONAL] |
||
111 | Configures the plugin. |
||
112 | ]] |
||
113 | --Configure = function() |
||
114 | --end; |
||
115 | |||
116 | --[[ |
||
117 | Help parameter. [OPTIONAL] |
||
118 | Help string displayed when you mouse over the sort type. |
||
119 | ]] |
||
120 | Help = GEM_SORT_HELP; |
||
121 | |||
122 | --[[ |
||
123 | Default parameter. [MUST NOT BE SET] |
||
124 | Sets this plugin as the default one. Must only be set by the "Stamp" plugin. |
||
125 | ]] |
||
126 | Default = true; |
||
127 | }; |
||
128 | |||
129 | function GEM_SORT_OnLoad() |
||
130 | GEM_SUB_RegisterPlugin(GEM_SORT_Stamp); |
||
131 | end |
||
132 |