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