Mercurial > wow > breuesk
comparison Lists.lua @ 27:611808dbc0c0
Untested impl for RemovePerson
author | John@Yosemite-PC |
---|---|
date | Sat, 10 Mar 2012 17:21:48 -0500 |
parents | 4c3140c7a1b4 |
children | eb3a3f69559e |
comparison
equal
deleted
inserted
replaced
26:4c3140c7a1b4 | 27:611808dbc0c0 |
---|---|
5 -- 3) working state - not saved because it can be so easily calculated | 5 -- 3) working state - not saved because it can be so easily calculated |
6 -- | 6 -- |
7 -- A separate user list is held - lists index into this | 7 -- A separate user list is held - lists index into this |
8 | 8 |
9 | 9 |
10 -- TODO: list trimming | 10 -- TODO: switch all action functions to use identifiers rather than names |
11 -- TODO: collaborative list trimming | |
11 -- TODO: collapse slists into delimited strings for space (premature optimization?) | 12 -- TODO: collapse slists into delimited strings for space (premature optimization?) |
12 -- TODO: organize working state data a little more carefully - hard to keep | 13 -- TODO: organize working state data a little more carefully - hard to keep |
13 -- track of all the arrays that are floating out there | 14 -- track of all the arrays that are floating out there |
14 -- TODO: (meta) remove player from all lists | 15 -- TODO: (meta) remove/nuke player from all lists |
15 -- TODO: remove person (trivial unless implementing a history viewer or | 16 -- TODO: remove person (trivial unless implementing a history viewer or |
16 -- something) | 17 -- something) |
17 | 18 |
18 -- holy crap long notes {{{ | 19 -- holy crap long notes {{{ |
19 -- notes on list storage: | 20 -- notes on list storage: |
227 bsk:DoDeleteList(change) | 228 bsk:DoDeleteList(change) |
228 elseif change.action == "AddToListEnd" then | 229 elseif change.action == "AddToListEnd" then |
229 bsk:DoAddPersonToListEnd(change) | 230 bsk:DoAddPersonToListEnd(change) |
230 elseif change.action == "AddToListRand" then | 231 elseif change.action == "AddToListRand" then |
231 bsk:DoAddPersonToListRandom(change) | 232 bsk:DoAddPersonToListRandom(change) |
233 elseif change.action == "RemovePerson" then | |
234 bsk:DoRemovePerson(change) | |
232 elseif change.action == "RemovePersonFromList" then | 235 elseif change.action == "RemovePersonFromList" then |
233 bsk:DoRemovePersonFromList(change) | 236 bsk:DoRemovePersonFromList(change) |
234 elseif change.action == "SuicidePerson" then | 237 elseif change.action == "SuicidePerson" then |
235 bsk:DoSuicidePerson(change) | 238 bsk:DoSuicidePerson(change) |
236 else | 239 else |
239 assert(false) | 242 assert(false) |
240 end | 243 end |
241 end | 244 end |
242 | 245 |
243 --}}} | 246 --}}} |
244 | 247 -- holy crap long winded {{{ |
245 -- timestamp logic: | 248 -- timestamp logic: |
246 -- use time() for comparisons - local clients use date() to make it pretty. only | 249 -- use time() for comparisons - local clients use date() to make it pretty. only |
247 -- dowisde - we can't have a server timestamp. Which kind of sucks, but it turns | 250 -- dowisde - we can't have a server timestamp. Which kind of sucks, but it turns |
248 -- out you can change timezones when you enter an instance server, so you really | 251 -- out you can change timezones when you enter an instance server, so you really |
249 -- never know what time it is. | 252 -- never know what time it is. |
268 -- otherwise ... causality has been violated. | 271 -- otherwise ... causality has been violated. |
269 -- Whenever an admin signon event happens, have the admins each perform a | 272 -- Whenever an admin signon event happens, have the admins each perform a |
270 -- timestamp check. Issue warnings for anyone with a clock that's more than | 273 -- timestamp check. Issue warnings for anyone with a clock that's more than |
271 -- X seconds out of sync with the others. Seriously, why isn't NTP a standard | 274 -- X seconds out of sync with the others. Seriously, why isn't NTP a standard |
272 -- setting on all operating systems ... | 275 -- setting on all operating systems ... |
276 --}}} | |
273 | 277 |
274 -- Action and DoAction defs {{{ | 278 -- Action and DoAction defs {{{ |
275 -- | 279 -- Action Discussion {{{ |
276 -- The actual actions for changes start here | 280 -- The actual actions for changes start here |
277 -- | 281 -- |
278 -- Each action occurs as a pair of functions. The bsk:Action() function is from | 282 -- Each action occurs as a pair of functions. The bsk:Action() function is from |
279 -- a list admin's point of view. Each will check for admin status, then create a | 283 -- a list admin's point of view. Each will check for admin status, then create a |
280 -- change bundle, call the handler for that change (ie the DoAction func), and | 284 -- change bundle, call the handler for that change (ie the DoAction func), and |
285 -- change packet. Each Do() function will accept *only* a change packet, and | 289 -- change packet. Each Do() function will accept *only* a change packet, and |
286 -- it's assumed that the change has been vetted elsewhere. These are very blunt | 290 -- it's assumed that the change has been vetted elsewhere. These are very blunt |
287 -- routines. | 291 -- routines. |
288 -- | 292 -- |
289 -- Note that "undo" has no special voodoo to it. It's basically a change that | 293 -- Note that "undo" has no special voodoo to it. It's basically a change that |
290 -- reverses the prior change on the stack. | 294 -- reverses the prior change on the stack.--}}} |
291 | |
292 function bsk:DoAddPerson(change)--{{{ | 295 function bsk:DoAddPerson(change)--{{{ |
293 assert(change) | 296 assert(change) |
294 assert(change.arg.id) | 297 assert(change.arg.id) |
295 local arg = change.arg | 298 local arg = change.arg |
296 -- require admin | 299 -- require admin |
405 if bsk:DoAddPersonToListRandom(change) then | 408 if bsk:DoAddPersonToListRandom(change) then |
406 bsk:CommitChange(change) | 409 bsk:CommitChange(change) |
407 end | 410 end |
408 end--}}} | 411 end--}}} |
409 function bsk:DoRemovePerson(change)--{{{ | 412 function bsk:DoRemovePerson(change)--{{{ |
410 | 413 local person = bsk.persons[change.arg.id] |
411 -- return true | 414 personName2id[person.main] = nil |
415 bsk.persons[change.arg.id] = nil | |
416 bsk.persons.time = change.time | |
417 return true | |
412 end--}}} | 418 end--}}} |
413 function bsk:RemovePerson(name)--{{{ | 419 function bsk:RemovePerson(name)--{{{ |
414 -- from both persons and lists | 420 local id = personName2id[name] |
421 if not id then | |
422 bsk:Print(sformat("%s is not in the persons list, please check your spelling", name)) | |
423 return false | |
424 end | |
425 local change = {action="RemovePerson",arg={id=id}} | |
426 bsk:StartChange(change) | |
427 if bsk:DoRemovePerson() then | |
428 bsk:CommitChange(change) | |
429 end | |
415 end--}}} | 430 end--}}} |
416 function bsk:DoSuicidePerson(change)--{{{ | 431 function bsk:DoSuicidePerson(change)--{{{ |
417 local list = bsk.lists[change.arg.listIndex] | 432 local list = bsk.lists[change.arg.listIndex] |
418 local affected = shallowCopy(change.arg.affect) | 433 local affected = shallowCopy(change.arg.affect) |
419 -- the goal here is to rotate the suicide list by 1 | 434 -- the goal here is to rotate the suicide list by 1 |