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