John@0
|
1 -- ideas: last attended data and/or remove people who haven't attended in X days
|
John@0
|
2 -- and/or just a "remove from all lists" option
|
John@0
|
3
|
John@0
|
4
|
John@0
|
5 -- order of implementation
|
John@31
|
6 -- (*) lists fully functional (/script interface)
|
John@31
|
7 -- (*) lists single-user functional via command line interface
|
John@27
|
8 -- (*) all actions should reference the player list rather than player names
|
John@27
|
9 -- (?) player entries should persist as long as any list or change references
|
John@18
|
10 -- (*) lists store number slots rather than flat indexing
|
John@18
|
11 -- ( ) limited communication - everyone trusts the loot master
|
John@0
|
12 -- ( ) single user + admin gui (manual suicides)
|
John@0
|
13 -- ( ) single user + admin gui (master loot)
|
John@18
|
14 -- ( ) communication and list merging/trimming
|
John@0
|
15 -- ( ) admins
|
John@0
|
16 -- ( ) players gui
|
John@0
|
17 -- ( ) crypto / protection against tampering
|
John@0
|
18 -- ( ) alt tracking
|
John@32
|
19 -- (_) reserves
|
John@32
|
20
|
John@32
|
21
|
John@0
|
22
|
John@0
|
23 -- important things to remember:
|
John@1
|
24 -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int
|
John@1
|
25 -- indexing
|
John@0
|
26 -- 2) a.x === a["x"]
|
John@0
|
27 -- 3) a["1"] =/= a[1]
|
John@5
|
28 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
|
John@5
|
29 -- 5) pairs() does not have a guaranteed iteration order
|
John@0
|
30
|
John@0
|
31 bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0")
|
John@0
|
32 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false)
|
John@0
|
33
|
John@0
|
34 local AceGUI = LibStub("AceGUI-3.0")
|
John@0
|
35
|
John@0
|
36 function bsk:OnInitialize()
|
John@0
|
37
|
John@0
|
38 self.db = LibStub("AceDB-3.0"):New("BskDB", self.defaults, "Default")
|
John@0
|
39
|
John@0
|
40 self.options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
|
John@0
|
41 LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", self.options)
|
John@0
|
42 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk")
|
John@0
|
43
|
John@0
|
44 self:RegisterChatCommand("bsk", "HandleCommand")
|
John@0
|
45 end
|
John@0
|
46
|
John@0
|
47 function bsk:OnEnable()
|
John@5
|
48 bsk:CreateWorkingStateFromChanges(self.db.profile.changes)
|
John@0
|
49 --self:HandleCommand()
|
John@0
|
50 end
|
John@0
|
51
|
John@0
|
52 function bsk:HandleCommand(paramIn)
|
John@0
|
53 local param = { strsplit(" ", paramIn) }
|
John@8
|
54 local FixPersonName = function(p)
|
John@0
|
55 p = p:lower()
|
John@0
|
56 -- next two lines from sylvanaar
|
John@0
|
57 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
|
John@0
|
58 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
|
John@0
|
59 end
|
John@0
|
60
|
John@0
|
61 if param[1] == nil or param[1] == "" then
|
John@0
|
62 bsk:Print("need args")
|
John@0
|
63 return
|
John@0
|
64 end
|
John@8
|
65 if param[1] == "persons" then
|
John@8
|
66 bsk:PrintPersons()
|
John@8
|
67 elseif param[1] == "changes" then
|
John@8
|
68 bsk:PrintChanges()
|
John@21
|
69 elseif param[1] == "delete" then
|
John@21
|
70 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@21
|
71 bsk:PrintTable(param)
|
John@21
|
72 return
|
John@21
|
73 end
|
John@21
|
74 if param[2] == "list" then
|
John@21
|
75 bsk:DeleteList(param[3])
|
John@22
|
76 elseif param[2] == "personfromlist" then
|
John@22
|
77 if param[4] == nil or param[4] == "" then
|
John@22
|
78 bsk:PrintTable(param)
|
John@22
|
79 return
|
John@22
|
80 end
|
John@22
|
81 local person = FixPersonName(param[3])
|
John@22
|
82 bsk:RemovePersonFromList(person, param[4])
|
John@28
|
83 elseif param[2] == "person" then
|
John@28
|
84 local person = FixPersonName(param[3])
|
John@28
|
85 bsk:RemovePerson(person)
|
John@21
|
86 else
|
John@21
|
87 bsk:Print(sformat("Deleting anything of type %s is not supported",param[2]))
|
John@21
|
88 end
|
John@30
|
89 elseif param[1] == "nuke" then
|
John@30
|
90 if param[2] == nil or param[2] == "" then
|
John@30
|
91 bsk:PrintTable(param)
|
John@30
|
92 return
|
John@30
|
93 end
|
John@30
|
94 local person = FixPersonName(param[2])
|
John@30
|
95 bsk:NukePerson(person)
|
John@0
|
96 elseif param[1] == "add" then
|
John@0
|
97 if param[2] == nil or param[2] == "" then
|
John@0
|
98 bsk:PrintTable(param)
|
John@0
|
99 return
|
John@0
|
100 end
|
John@0
|
101 if param[3] == nil or param[3] == "" then
|
John@0
|
102 bsk:PrintTable(param)
|
John@0
|
103 return
|
John@0
|
104 end
|
John@8
|
105 if param[2] == "person" then
|
John@1
|
106 if param[3] == "all" then
|
John@8
|
107 bsk:AddMissingPersons()
|
John@1
|
108 else
|
John@8
|
109 local person = FixPersonName(param[3])
|
John@8
|
110 bsk:AddPerson(person)
|
John@1
|
111 end
|
John@0
|
112 elseif param[2] == "list" then
|
John@0
|
113 bsk:CreateList(param[3])
|
John@11
|
114 elseif param[2] == "tolist" then
|
John@9
|
115 if param[4] == nil or param[4] == "" then
|
John@9
|
116 bsk:PrintTable(param)
|
John@9
|
117 return
|
John@9
|
118 end
|
John@9
|
119 local person = FixPersonName(param[3])
|
John@11
|
120 bsk:AddPersonToListEnd(person,param[4])
|
John@11
|
121 elseif param[2] == "tolistrandom" then
|
John@11
|
122 if param[4] == nil or param[4] == "" then
|
John@11
|
123 bsk:PrintTable(param)
|
John@11
|
124 return
|
John@11
|
125 end
|
John@11
|
126 local person = FixPersonName(param[3])
|
John@11
|
127 bsk:AddPersonToListRandom(person,param[4])
|
John@0
|
128 end
|
John@3
|
129 elseif param[1] == "populate" then
|
John@3
|
130 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@3
|
131 bsk:PrintTable(param)
|
John@3
|
132 return
|
John@3
|
133 end
|
John@3
|
134 -- list = p2
|
John@3
|
135 local index = bsk:GetListIndex(param[2])
|
John@3
|
136 if param[3] == "random" then
|
John@3
|
137 bsk:PopulateListRandom(index)
|
John@3
|
138 end
|
John@0
|
139 elseif param[1] == "suicide" then
|
John@0
|
140 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@0
|
141 bsk:PrintTable(param)
|
John@0
|
142 return
|
John@0
|
143 end
|
John@8
|
144 local person = FixPersonName(param[2])
|
John@8
|
145 bsk:SuicidePerson(person,param[3])
|
John@14
|
146 elseif param[1] == "lists" then
|
John@0
|
147 if param[2] == nil or param[2] == "" then
|
John@14
|
148 bsk:PrettyPrintLists()
|
John@14
|
149 return
|
John@14
|
150 else
|
John@14
|
151 local listIndex = bsk:GetListIndex(param[2])
|
John@14
|
152 bsk:PrettyPrintList(listIndex)
|
John@14
|
153 end
|
John@14
|
154 elseif param[1] == "reserve" then
|
John@14
|
155 if param[2] == nil or param[2] == "" then
|
John@14
|
156 bsk:printtable(param)
|
John@0
|
157 return
|
John@0
|
158 end
|
John@14
|
159 local person = FixPersonName(param[2])
|
John@14
|
160 bsk:AddReserve(person)
|
John@5
|
161 elseif param[1] == "trim" then
|
John@5
|
162 if param[2] == nil or param[2] == "" then
|
John@14
|
163 bsk:printtable(param)
|
John@5
|
164 return
|
John@5
|
165 end
|
John@5
|
166 bsk:TrimLists(param[2])
|
John@20
|
167 elseif param[1] == "rename" then
|
John@20
|
168 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
|
John@20
|
169 bsk:printtable(param)
|
John@20
|
170 return
|
John@20
|
171 end
|
John@20
|
172 bsk:RenameList(param[2],param[3])
|
John@17
|
173 elseif param[1] == "selfdestruct" then
|
John@17
|
174 bsk:SelfDestruct()
|
John@0
|
175 end
|
John@0
|
176
|
John@0
|
177 --if self.frame == nil then
|
John@0
|
178 --self:CreateGUI()
|
John@0
|
179 --self:ShowGUI()
|
John@0
|
180 --else
|
John@0
|
181 --self:ShowGUI()
|
John@0
|
182 --end
|
John@0
|
183
|
John@0
|
184 end
|
John@0
|
185
|
John@0
|
186 bsk.defaults = {
|
John@0
|
187 profile = {
|
John@8
|
188 persons = {},
|
John@0
|
189 changes = {},
|
John@0
|
190 listBase = {}
|
John@0
|
191 }
|
John@0
|
192 }
|
John@0
|
193
|
John@0
|
194
|