John@0
|
1 -- ideas: last attended data and/or remove people who haven't attended in X days
|
John@0
|
2
|
John@0
|
3 -- order of implementation
|
John@31
|
4 -- (*) lists fully functional (/script interface)
|
John@31
|
5 -- (*) lists single-user functional via command line interface
|
John@27
|
6 -- (*) all actions should reference the player list rather than player names
|
John@27
|
7 -- (?) player entries should persist as long as any list or change references
|
John@18
|
8 -- (*) lists store number slots rather than flat indexing
|
John@33
|
9 -- ( ) database and comm versioning
|
John@77
|
10 -- (_) limited communication - everyone trusts the loot master
|
John@70
|
11 -- (_) single user + admin gui (manual suicides)
|
John@77
|
12 -- (_) single user + admin gui (master loot)
|
John@84
|
13 -- (*) whisper UI
|
John@18
|
14 -- ( ) communication and list merging/trimming
|
John@0
|
15 -- ( ) admins
|
John@77
|
16 -- (*) players gui
|
John@35
|
17 -- ( ) undo
|
John@0
|
18 -- ( ) crypto / protection against tampering
|
John@0
|
19 -- ( ) alt tracking
|
John@70
|
20 -- (*) reserves
|
John@32
|
21
|
John@42
|
22 local _G=_G
|
John@42
|
23 local strsplit=strsplit
|
John@42
|
24 local string=string
|
John@42
|
25 local sformat=string.format
|
John@43
|
26 local bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0")
|
John@43
|
27 -- "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0"
|
John@42
|
28 _G.bsk=bsk
|
John@42
|
29 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false)
|
John@42
|
30 setfenv(1,bsk)
|
John@42
|
31
|
John@34
|
32 local pkgrev = " @project-revision@ "
|
John@0
|
33
|
John@0
|
34 -- important things to remember:
|
John@1
|
35 -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int
|
John@1
|
36 -- indexing
|
John@0
|
37 -- 2) a.x === a["x"]
|
John@0
|
38 -- 3) a["1"] =/= a[1]
|
John@5
|
39 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
|
John@5
|
40 -- 5) pairs() does not have a guaranteed iteration order
|
John@0
|
41
|
John@42
|
42 function OnInitialize()
|
John@0
|
43
|
John@69
|
44 debug = true
|
John@69
|
45
|
John@42
|
46 db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default")
|
John@0
|
47
|
John@42
|
48 options.args.profile = _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(db)
|
John@42
|
49 _G.LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", options)
|
John@42
|
50 --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk")
|
John@0
|
51
|
John@74
|
52 admin = db.profile.admin
|
John@74
|
53
|
John@42
|
54 local HandlePassThrough = function(...) HandleCommand(...) end
|
John@42
|
55 bsk:RegisterChatCommand("bsk", HandlePassThrough)
|
John@68
|
56 bsk:OnInitializeSetStaticData()
|
John@70
|
57 InitializeComm()
|
John@73
|
58 InitializeLooting()
|
John@0
|
59 end
|
John@0
|
60
|
John@42
|
61 function OnEnable()
|
John@42
|
62 CreateWorkingStateFromChanges(db.profile.changes)
|
John@73
|
63 InitializeState()
|
John@66
|
64 --CreateGUI()
|
John@0
|
65 end
|
John@0
|
66
|
John@42
|
67 function HandleCommand(paramIn)
|
John@0
|
68 local param = { strsplit(" ", paramIn) }
|
John@8
|
69 local FixPersonName = function(p)
|
John@0
|
70 p = p:lower()
|
John@0
|
71 -- next two lines from sylvanaar
|
John@0
|
72 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
John@0
|
73 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
|
John@0
|
74 end
|
John@49
|
75 action,arg1,arg2,arg3 = bsk:GetArgs(paramIn,4)
|
John@0
|
76
|
John@49
|
77 if not action then
|
John@43
|
78 print("need args")
|
John@0
|
79 return
|
John@0
|
80 end
|
John@49
|
81 if action == "persons" then
|
John@42
|
82 PrintPersons()
|
John@49
|
83 elseif action == "changes" then
|
John@42
|
84 PrintChanges()
|
John@49
|
85 elseif action == "selfdestruct" then
|
John@49
|
86 SelfDestruct()
|
John@49
|
87 elseif action == "delete" or action == "remove" then
|
John@49
|
88 if not arg1 or not arg2 then
|
John@42
|
89 PrintTable(param)
|
John@21
|
90 return
|
John@21
|
91 end
|
John@49
|
92 if arg1 == "list" then
|
John@49
|
93 DeleteList(arg2)
|
John@49
|
94 elseif arg1 == "personfromlist" or "fromlist" then
|
John@49
|
95 if not arg3 then
|
John@42
|
96 PrintTable(param)
|
John@22
|
97 return
|
John@22
|
98 end
|
John@49
|
99 local person = FixPersonName(arg2)
|
John@49
|
100 RemovePersonFromList(person, arg3)
|
John@49
|
101 elseif arg1 == "person" then
|
John@49
|
102 local person = FixPersonName(arg2)
|
John@42
|
103 RemovePerson(person)
|
John@21
|
104 else
|
John@49
|
105 printf("Deleting anything of type %s is not supported",arg1)
|
John@21
|
106 end
|
John@49
|
107 elseif action == "nuke" then
|
John@49
|
108 if not arg1 then
|
John@42
|
109 PrintTable(param)
|
John@30
|
110 return
|
John@30
|
111 end
|
John@49
|
112 local person = FixPersonName(arg1)
|
John@42
|
113 NukePerson(person)
|
John@49
|
114 elseif action == "add" or action == "create" then
|
John@49
|
115 if not arg1 or not arg2 then
|
John@42
|
116 PrintTable(param)
|
John@0
|
117 return
|
John@0
|
118 end
|
John@49
|
119 if arg1 == "person" then
|
John@49
|
120 if arg2 == "all" or arg2 == "missing" then
|
John@49
|
121 PersonList:AddMissing()
|
John@1
|
122 else
|
John@49
|
123 local person = FixPersonName(arg2)
|
John@42
|
124 AddPerson(person)
|
John@1
|
125 end
|
John@49
|
126 elseif arg1 == "list" then
|
John@49
|
127 CreateList(arg2)
|
John@49
|
128 elseif arg1 == "tolist" then
|
John@49
|
129 if not arg3 then
|
John@42
|
130 PrintTable(param)
|
John@9
|
131 return
|
John@9
|
132 end
|
John@49
|
133 local person = FixPersonName(arg2)
|
John@49
|
134 AddPersonToListEnd(person,arg3)
|
John@49
|
135 elseif arg1 == "tolistrandom" then
|
John@49
|
136 if not arg3 then
|
John@42
|
137 PrintTable(param)
|
John@11
|
138 return
|
John@11
|
139 end
|
John@49
|
140 local person = FixPersonName(arg2)
|
John@49
|
141 AddPersonToListRandom(person,arg3)
|
John@0
|
142 end
|
John@49
|
143 elseif action == "populate" then
|
John@49
|
144 if not arg1 then
|
John@42
|
145 PrintTable(param)
|
John@3
|
146 return
|
John@3
|
147 end
|
John@3
|
148 -- list = p2
|
John@49
|
149 PopulateListRandom(arg1)
|
John@49
|
150 elseif action == "suicide" then
|
John@49
|
151 if not arg1 or not arg2 then
|
John@42
|
152 PrintTable(param)
|
John@0
|
153 return
|
John@0
|
154 end
|
John@49
|
155 local person = FixPersonName(arg1)
|
John@49
|
156 SuicidePerson(person,arg2)
|
John@49
|
157 elseif action == "lists" then
|
John@49
|
158 if not arg1 then
|
John@42
|
159 PrettyPrintLists()
|
John@14
|
160 return
|
John@14
|
161 else
|
John@49
|
162 PrettyPrintList(arg1)
|
John@14
|
163 end
|
John@49
|
164 elseif action == "reserve" then
|
John@49
|
165 if not arg1 then
|
John@49
|
166 PrintTable(param)
|
John@49
|
167 return
|
John@49
|
168 end
|
John@49
|
169 local person = FixPersonName(arg1)
|
John@49
|
170 ReservePerson(person)
|
John@49
|
171 elseif action == "trim" then
|
John@49
|
172 if not arg1 then
|
John@42
|
173 printtable(param)
|
John@0
|
174 return
|
John@0
|
175 end
|
John@49
|
176 TrimLists(arg1)
|
John@49
|
177 elseif action == "rename" then
|
John@49
|
178 if not arg1 or not arg2 then
|
John@49
|
179 PrintTable(param)
|
John@5
|
180 return
|
John@5
|
181 end
|
John@49
|
182 RenameList(arg1,arg2)
|
John@66
|
183 elseif action == "generate" then
|
John@66
|
184 if not arg1 then
|
John@66
|
185 PrintTable(param)
|
John@66
|
186 return
|
John@66
|
187 end
|
John@66
|
188 PersonList:AddMissing()
|
John@66
|
189 CreateList(arg1)
|
John@66
|
190 PopulateListRandom(arg1)
|
John@77
|
191 elseif action == "liststatus" then
|
John@77
|
192 local lids = LootLists:GetAllIds()
|
John@77
|
193 for _,v in _G.pairs(lids) do
|
John@77
|
194 local lref = LootLists:Select(v)
|
John@77
|
195 printf("List %s, modified %s (%s)", lref:GetName(), _G.date("%m/%d/%y %H:%M:%S",lref:GetTime()), lref:GetTime())
|
John@77
|
196 end
|
John@72
|
197 elseif action == "push" then
|
John@72
|
198 Comm:Push()
|
John@72
|
199 elseif action == "state" then
|
John@72
|
200 print(state)
|
John@38
|
201 else
|
John@42
|
202 CreateGUI()
|
John@0
|
203 end
|
John@0
|
204
|
John@42
|
205 --if frame == nil then
|
John@42
|
206 --CreateGUI()
|
John@42
|
207 --ShowGUI()
|
John@0
|
208 --else
|
John@42
|
209 --ShowGUI()
|
John@0
|
210 --end
|
John@0
|
211
|
John@0
|
212 end
|
John@0
|
213
|
John@42
|
214 defaults = {
|
John@0
|
215 profile = {
|
John@8
|
216 persons = {},
|
John@0
|
217 changes = {},
|
John@34
|
218 lists = {}
|
John@0
|
219 }
|
John@0
|
220 }
|
John@0
|
221
|
John@0
|
222
|