comparison Lists.lua @ 20:3fedb912c088

Rename a list
author John@Yosemite-PC
date Fri, 09 Mar 2012 23:18:20 -0500
parents cdca1f2ae605
children ffcea2f51663
comparison
equal deleted inserted replaced
19:cdca1f2ae605 20:3fedb912c088
11 -- TODO: list trimming 11 -- TODO: list trimming
12 -- TODO: collapse slists into delimited strings for space 12 -- TODO: collapse slists into delimited strings for space
13 -- 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
14 -- track of all the arrays that are floating out there 14 -- track of all the arrays that are floating out there
15 -- TODO: delete list 15 -- TODO: delete list
16 -- TODO: rename list
17 -- TODO: remove player from list 16 -- TODO: remove player from list
18 -- TODO: (meta) remove player from all lists 17 -- TODO: (meta) remove player from all lists
19 -- TODO: remove person (actually kinda tricky without casuality problems) 18 -- TODO: remove person (actually kinda tricky without casuality problems)
20 19
21 -- holy crap long notes {{{ 20 -- holy crap long notes {{{
220 end 219 end
221 220
222 function bsk:ProcessChange(change) 221 function bsk:ProcessChange(change)
223 if change.action == "AddPerson" then 222 if change.action == "AddPerson" then
224 bsk:DoAddPerson(change) 223 bsk:DoAddPerson(change)
224 elseif change.action == "RenameList" then
225 bsk:DoRenameList(change)
225 elseif change.action == "CreateList" then 226 elseif change.action == "CreateList" then
226 bsk:DoCreateList(change) 227 bsk:DoCreateList(change)
227 elseif change.action == "AddToListEnd" then 228 elseif change.action == "AddToListEnd" then
228 bsk:DoAddPersonToListEnd(change) 229 bsk:DoAddPersonToListEnd(change)
229 elseif change.action == "AddToListRand" then 230 elseif change.action == "AddToListRand" then
450 if bsk:DoSuicidePerson(change) then 451 if bsk:DoSuicidePerson(change) then
451 bsk:CommitChange(change) 452 bsk:CommitChange(change)
452 end 453 end
453 end 454 end
454 455
456 function bsk:DoRenameList(change)
457 bsk.lists[change.arg.listIndex].name = change.arg.name
458 bsk.lists[change.arg.listIndex].time = change.time
459 return true
460 end
461
462 function bsk:RenameList(listName,newListName)
463 -- require admin
464 local listIndex = bsk:GetListIndex(listName)
465 local change = {action="RenameList",arg={listIndex=listIndex,name=newListName}}
466 bsk:StartChange(change)
467 if bsk:DoRenameList(change) then
468 bsk:CommitChange(change)
469 end
470 end
471
472 --}}}
473 -- Higher order actions (ie calls other standard actions){{{
474
455 function bsk:TrimLists(time) 475 function bsk:TrimLists(time)
456 if not bsk:CheckListCausality() then 476 if not bsk:CheckListCausality() then
457 self:Print("Unable to trim changelist due to violated causality") 477 self:Print("Unable to trim changelist due to violated causality")
458 return false 478 return false
459 end 479 end
484 504
485 -- using the trimmed list and the new bases, recreate the working state 505 -- using the trimmed list and the new bases, recreate the working state
486 bsk:CreateWorkingStateFromChanges(bsk.db.profile.changes) 506 bsk:CreateWorkingStateFromChanges(bsk.db.profile.changes)
487 end 507 end
488 508
489 --}}}
490 -- Higher order actions (ie calls other standard actions){{{
491 function bsk:AddMissingPersons() 509 function bsk:AddMissingPersons()
492 bsk:PopulateRaidList() 510 bsk:PopulateRaidList()
493 local t = {} 511 local t = {}
494 for id,_ in pairs(bsk.persons) do 512 for id,_ in pairs(bsk.persons) do
495 t[id] = true 513 t[id] = true