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@18
|
10 -- ( ) limited communication - everyone trusts the loot master
|
John@70
|
11 -- (_) single user + admin gui (manual suicides)
|
John@0
|
12 -- ( ) single user + admin gui (master loot)
|
John@18
|
13 -- ( ) communication and list merging/trimming
|
John@0
|
14 -- ( ) admins
|
John@70
|
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@72
|
32 admin = admin or true
|
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@42
|
52 local HandlePassThrough = function(...) HandleCommand(...) end
|
John@42
|
53 bsk:RegisterChatCommand("bsk", HandlePassThrough)
|
John@68
|
54 bsk:OnInitializeSetStaticData()
|
John@70
|
55 InitializeComm()
|
John@73
|
56 InitializeLooting()
|
John@0
|
57 end
|
John@0
|
58
|
John@42
|
59 function OnEnable()
|
John@42
|
60 CreateWorkingStateFromChanges(db.profile.changes)
|
John@73
|
61 InitializeState()
|
John@66
|
62 --CreateGUI()
|
John@0
|
63 end
|
John@0
|
64
|
John@42
|
65 function HandleCommand(paramIn)
|
John@0
|
66 local param = { strsplit(" ", paramIn) }
|
John@8
|
67 local FixPersonName = function(p)
|
John@0
|
68 p = p:lower()
|
John@0
|
69 -- next two lines from sylvanaar
|
John@0
|
70 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
John@0
|
71 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
|
John@0
|
72 end
|
John@49
|
73 action,arg1,arg2,arg3 = bsk:GetArgs(paramIn,4)
|
John@0
|
74
|
John@49
|
75 if not action then
|
John@43
|
76 print("need args")
|
John@0
|
77 return
|
John@0
|
78 end
|
John@49
|
79 if action == "persons" then
|
John@42
|
80 PrintPersons()
|
John@49
|
81 elseif action == "changes" then
|
John@42
|
82 PrintChanges()
|
John@49
|
83 elseif action == "selfdestruct" then
|
John@49
|
84 SelfDestruct()
|
John@49
|
85 elseif action == "delete" or action == "remove" then
|
John@49
|
86 if not arg1 or not arg2 then
|
John@42
|
87 PrintTable(param)
|
John@21
|
88 return
|
John@21
|
89 end
|
John@49
|
90 if arg1 == "list" then
|
John@49
|
91 DeleteList(arg2)
|
John@49
|
92 elseif arg1 == "personfromlist" or "fromlist" then
|
John@49
|
93 if not arg3 then
|
John@42
|
94 PrintTable(param)
|
John@22
|
95 return
|
John@22
|
96 end
|
John@49
|
97 local person = FixPersonName(arg2)
|
John@49
|
98 RemovePersonFromList(person, arg3)
|
John@49
|
99 elseif arg1 == "person" then
|
John@49
|
100 local person = FixPersonName(arg2)
|
John@42
|
101 RemovePerson(person)
|
John@21
|
102 else
|
John@49
|
103 printf("Deleting anything of type %s is not supported",arg1)
|
John@21
|
104 end
|
John@49
|
105 elseif action == "nuke" then
|
John@49
|
106 if not arg1 then
|
John@42
|
107 PrintTable(param)
|
John@30
|
108 return
|
John@30
|
109 end
|
John@49
|
110 local person = FixPersonName(arg1)
|
John@42
|
111 NukePerson(person)
|
John@49
|
112 elseif action == "add" or action == "create" then
|
John@49
|
113 if not arg1 or not arg2 then
|
John@42
|
114 PrintTable(param)
|
John@0
|
115 return
|
John@0
|
116 end
|
John@49
|
117 if arg1 == "person" then
|
John@49
|
118 if arg2 == "all" or arg2 == "missing" then
|
John@49
|
119 PersonList:AddMissing()
|
John@1
|
120 else
|
John@49
|
121 local person = FixPersonName(arg2)
|
John@42
|
122 AddPerson(person)
|
John@1
|
123 end
|
John@49
|
124 elseif arg1 == "list" then
|
John@49
|
125 CreateList(arg2)
|
John@49
|
126 elseif arg1 == "tolist" then
|
John@49
|
127 if not arg3 then
|
John@42
|
128 PrintTable(param)
|
John@9
|
129 return
|
John@9
|
130 end
|
John@49
|
131 local person = FixPersonName(arg2)
|
John@49
|
132 AddPersonToListEnd(person,arg3)
|
John@49
|
133 elseif arg1 == "tolistrandom" then
|
John@49
|
134 if not arg3 then
|
John@42
|
135 PrintTable(param)
|
John@11
|
136 return
|
John@11
|
137 end
|
John@49
|
138 local person = FixPersonName(arg2)
|
John@49
|
139 AddPersonToListRandom(person,arg3)
|
John@0
|
140 end
|
John@49
|
141 elseif action == "populate" then
|
John@49
|
142 if not arg1 then
|
John@42
|
143 PrintTable(param)
|
John@3
|
144 return
|
John@3
|
145 end
|
John@3
|
146 -- list = p2
|
John@49
|
147 PopulateListRandom(arg1)
|
John@49
|
148 elseif action == "suicide" then
|
John@49
|
149 if not arg1 or not arg2 then
|
John@42
|
150 PrintTable(param)
|
John@0
|
151 return
|
John@0
|
152 end
|
John@49
|
153 local person = FixPersonName(arg1)
|
John@49
|
154 SuicidePerson(person,arg2)
|
John@49
|
155 elseif action == "lists" then
|
John@49
|
156 if not arg1 then
|
John@42
|
157 PrettyPrintLists()
|
John@14
|
158 return
|
John@14
|
159 else
|
John@49
|
160 PrettyPrintList(arg1)
|
John@14
|
161 end
|
John@49
|
162 elseif action == "reserve" then
|
John@49
|
163 if not arg1 then
|
John@49
|
164 PrintTable(param)
|
John@49
|
165 return
|
John@49
|
166 end
|
John@49
|
167 local person = FixPersonName(arg1)
|
John@49
|
168 ReservePerson(person)
|
John@49
|
169 elseif action == "trim" then
|
John@49
|
170 if not arg1 then
|
John@42
|
171 printtable(param)
|
John@0
|
172 return
|
John@0
|
173 end
|
John@49
|
174 TrimLists(arg1)
|
John@49
|
175 elseif action == "rename" then
|
John@49
|
176 if not arg1 or not arg2 then
|
John@49
|
177 PrintTable(param)
|
John@5
|
178 return
|
John@5
|
179 end
|
John@49
|
180 RenameList(arg1,arg2)
|
John@66
|
181 elseif action == "generate" then
|
John@66
|
182 if not arg1 then
|
John@66
|
183 PrintTable(param)
|
John@66
|
184 return
|
John@66
|
185 end
|
John@66
|
186 PersonList:AddMissing()
|
John@66
|
187 CreateList(arg1)
|
John@66
|
188 PopulateListRandom(arg1)
|
John@72
|
189 elseif action == "push" then
|
John@72
|
190 Comm:Push()
|
John@72
|
191 elseif action == "state" then
|
John@72
|
192 print(state)
|
John@38
|
193 else
|
John@42
|
194 CreateGUI()
|
John@0
|
195 end
|
John@0
|
196
|
John@42
|
197 --if frame == nil then
|
John@42
|
198 --CreateGUI()
|
John@42
|
199 --ShowGUI()
|
John@0
|
200 --else
|
John@42
|
201 --ShowGUI()
|
John@0
|
202 --end
|
John@0
|
203
|
John@0
|
204 end
|
John@0
|
205
|
John@42
|
206 defaults = {
|
John@0
|
207 profile = {
|
John@8
|
208 persons = {},
|
John@0
|
209 changes = {},
|
John@34
|
210 lists = {}
|
John@0
|
211 }
|
John@0
|
212 }
|
John@0
|
213
|
John@0
|
214
|