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