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