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