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@42
|
25 local bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0")
|
John@42
|
26 _G.bsk=bsk
|
John@42
|
27 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false)
|
John@42
|
28 setfenv(1,bsk)
|
John@42
|
29
|
John@34
|
30 local pkgrev = " @project-revision@ "
|
John@0
|
31
|
John@0
|
32 -- important things to remember:
|
John@1
|
33 -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int
|
John@1
|
34 -- indexing
|
John@0
|
35 -- 2) a.x === a["x"]
|
John@0
|
36 -- 3) a["1"] =/= a[1]
|
John@5
|
37 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
|
John@5
|
38 -- 5) pairs() does not have a guaranteed iteration order
|
John@0
|
39
|
John@0
|
40
|
John@0
|
41
|
John@42
|
42 function OnInitialize()
|
John@0
|
43
|
John@42
|
44 db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default")
|
John@42
|
45 bsk:Print("Totally libstubbed a db")
|
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@0
|
53 end
|
John@0
|
54
|
John@42
|
55 function OnEnable()
|
John@42
|
56 CreateWorkingStateFromChanges(db.profile.changes)
|
John@42
|
57 CreateGUI()
|
John@0
|
58 end
|
John@0
|
59
|
John@42
|
60 function HandleCommand(paramIn)
|
John@0
|
61 local param = { strsplit(" ", paramIn) }
|
John@8
|
62 local FixPersonName = function(p)
|
John@0
|
63 p = p:lower()
|
John@0
|
64 -- next two lines from sylvanaar
|
John@0
|
65 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
John@0
|
66 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
|
John@0
|
67 end
|
John@0
|
68
|
John@0
|
69 if param[1] == nil or param[1] == "" then
|
John@0
|
70 bsk:Print("need args")
|
John@0
|
71 return
|
John@0
|
72 end
|
John@8
|
73 if param[1] == "persons" then
|
John@42
|
74 PrintPersons()
|
John@8
|
75 elseif param[1] == "changes" then
|
John@42
|
76 PrintChanges()
|
John@21
|
77 elseif param[1] == "delete" then
|
John@21
|
78 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@42
|
79 PrintTable(param)
|
John@21
|
80 return
|
John@21
|
81 end
|
John@21
|
82 if param[2] == "list" then
|
John@42
|
83 DeleteList(param[3])
|
John@22
|
84 elseif param[2] == "personfromlist" then
|
John@22
|
85 if param[4] == nil or param[4] == "" then
|
John@42
|
86 PrintTable(param)
|
John@22
|
87 return
|
John@22
|
88 end
|
John@22
|
89 local person = FixPersonName(param[3])
|
John@42
|
90 RemovePersonFromList(person, param[4])
|
John@28
|
91 elseif param[2] == "person" then
|
John@28
|
92 local person = FixPersonName(param[3])
|
John@42
|
93 RemovePerson(person)
|
John@21
|
94 else
|
John@21
|
95 bsk:Print(sformat("Deleting anything of type %s is not supported",param[2]))
|
John@21
|
96 end
|
John@30
|
97 elseif param[1] == "nuke" then
|
John@30
|
98 if param[2] == nil or param[2] == "" then
|
John@42
|
99 PrintTable(param)
|
John@30
|
100 return
|
John@30
|
101 end
|
John@30
|
102 local person = FixPersonName(param[2])
|
John@42
|
103 NukePerson(person)
|
John@0
|
104 elseif param[1] == "add" then
|
John@0
|
105 if param[2] == nil or param[2] == "" then
|
John@42
|
106 PrintTable(param)
|
John@0
|
107 return
|
John@0
|
108 end
|
John@0
|
109 if param[3] == nil or param[3] == "" then
|
John@42
|
110 PrintTable(param)
|
John@0
|
111 return
|
John@0
|
112 end
|
John@8
|
113 if param[2] == "person" then
|
John@1
|
114 if param[3] == "all" then
|
John@42
|
115 AddMissingPersons()
|
John@1
|
116 else
|
John@8
|
117 local person = FixPersonName(param[3])
|
John@42
|
118 AddPerson(person)
|
John@1
|
119 end
|
John@0
|
120 elseif param[2] == "list" then
|
John@42
|
121 CreateList(param[3])
|
John@11
|
122 elseif param[2] == "tolist" then
|
John@9
|
123 if param[4] == nil or param[4] == "" then
|
John@42
|
124 PrintTable(param)
|
John@9
|
125 return
|
John@9
|
126 end
|
John@9
|
127 local person = FixPersonName(param[3])
|
John@42
|
128 AddPersonToListEnd(person,param[4])
|
John@11
|
129 elseif param[2] == "tolistrandom" then
|
John@11
|
130 if param[4] == nil or param[4] == "" then
|
John@42
|
131 PrintTable(param)
|
John@11
|
132 return
|
John@11
|
133 end
|
John@11
|
134 local person = FixPersonName(param[3])
|
John@42
|
135 AddPersonToListRandom(person,param[4])
|
John@0
|
136 end
|
John@3
|
137 elseif param[1] == "populate" then
|
John@3
|
138 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@42
|
139 PrintTable(param)
|
John@3
|
140 return
|
John@3
|
141 end
|
John@3
|
142 -- list = p2
|
John@42
|
143 local index = GetListIndex(param[2])
|
John@3
|
144 if param[3] == "random" then
|
John@42
|
145 PopulateListRandom(index)
|
John@3
|
146 end
|
John@0
|
147 elseif param[1] == "suicide" then
|
John@0
|
148 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@42
|
149 PrintTable(param)
|
John@0
|
150 return
|
John@0
|
151 end
|
John@8
|
152 local person = FixPersonName(param[2])
|
John@42
|
153 SuicidePerson(person,param[3])
|
John@14
|
154 elseif param[1] == "lists" then
|
John@0
|
155 if param[2] == nil or param[2] == "" then
|
John@42
|
156 PrettyPrintLists()
|
John@14
|
157 return
|
John@14
|
158 else
|
John@42
|
159 local listIndex = GetListIndex(param[2])
|
John@42
|
160 PrettyPrintList(listIndex)
|
John@14
|
161 end
|
John@14
|
162 elseif param[1] == "reserve" then
|
John@14
|
163 if param[2] == nil or param[2] == "" then
|
John@42
|
164 printtable(param)
|
John@0
|
165 return
|
John@0
|
166 end
|
John@14
|
167 local person = FixPersonName(param[2])
|
John@42
|
168 AddReserve(person)
|
John@5
|
169 elseif param[1] == "trim" then
|
John@5
|
170 if param[2] == nil or param[2] == "" then
|
John@42
|
171 printtable(param)
|
John@5
|
172 return
|
John@5
|
173 end
|
John@42
|
174 TrimLists(param[2])
|
John@20
|
175 elseif param[1] == "rename" then
|
John@20
|
176 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@42
|
177 printtable(param)
|
John@20
|
178 return
|
John@20
|
179 end
|
John@42
|
180 RenameList(param[2],param[3])
|
John@17
|
181 elseif param[1] == "selfdestruct" then
|
John@42
|
182 SelfDestruct()
|
John@38
|
183 else
|
John@42
|
184 CreateGUI()
|
John@0
|
185 end
|
John@0
|
186
|
John@42
|
187 --if frame == nil then
|
John@42
|
188 --CreateGUI()
|
John@42
|
189 --ShowGUI()
|
John@0
|
190 --else
|
John@42
|
191 --ShowGUI()
|
John@0
|
192 --end
|
John@0
|
193
|
John@0
|
194 end
|
John@0
|
195
|
John@42
|
196 defaults = {
|
John@0
|
197 profile = {
|
John@8
|
198 persons = {},
|
John@0
|
199 changes = {},
|
John@34
|
200 lists = {}
|
John@0
|
201 }
|
John@0
|
202 }
|
John@0
|
203
|
John@0
|
204
|