Mercurial > wow > breuesk
changeset 12:a6bc3f2d3207
Many corrections to support ID based lists
author | John@Yosemite-PC |
---|---|
date | Wed, 07 Mar 2012 23:01:33 -0500 |
parents | 99c279ab0b75 |
children | e62cbf3a0c07 |
files | Lists.lua |
diffstat | 1 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Lists.lua Wed Mar 07 23:00:59 2012 -0500 +++ b/Lists.lua Wed Mar 07 23:01:33 2012 -0500 @@ -9,6 +9,8 @@ -- TODO: rename player -- TODO: list trimming +-- TODO: lists allow double-add +-- TODO: collapse slists into delimited strings for space -- notes on list storage: -- Using names as keys as I do now is atrocious. @@ -89,7 +91,7 @@ local list = bsk.lists[listIndex] bsk:Print("List: " .. list.name .. " (" .. list.time .. ")") for i = 1,#list do - bsk:Print(" " .. i .. " - " .. bsk.persons[list[i]].main) + bsk:Print(" " .. i .. " - " .. bsk.persons[list[i].id].main) end end function bsk:PrettyPrintLists() @@ -342,7 +344,7 @@ local entry = {index=change.arg.roll, id=change.arg.id} tinsert(list,entry) - table.sort(list,function(a,b) return a.roll < b.roll end) + table.sort(list,function(a,b) return a.index < b.index end) list.time = change.time return true @@ -353,6 +355,7 @@ local listIndex = bsk:GetListIndex(list) if bsk.lists[listIndex].closedRandom then self:Print("Cannot add person to list by random roll because an add-to-end operation has already occurred") + return false end local id = personsReverse[name] local roll = math.random() @@ -400,8 +403,9 @@ -- require admin bsk:PopulateRaidList() local listIndex = bsk:GetListIndex(list) - local slist=bsk:GetSuicideList(name,bsk.lists[listIndex]) - local change = {action="SuicidePerson",arg={names=names,list=slist,listIndex=listIndex}} + local id = personsReverse[name] + local slist=bsk:GetSuicideList(id,bsk.lists[listIndex]) + local change = {action="SuicidePerson",arg={list=slist,listIndex=listIndex}} bsk:PrintTable(change) bsk:StartChange(change) if bsk:DoSuicidePerson(change) then @@ -479,12 +483,12 @@ -- reserves function bsk:AddReserve(name) - reserveList[name]=true + reserveList[personsReverse[name]]=true -- TODO: communicate to others. don't store this in any way. end function bsk:RemoveReserve(name) - reserveList[name]=false + reserveList[personsReverse[name]]=false -- TODO: communicate to others. don't store this in any way. end @@ -512,17 +516,17 @@ wipe(raidList) if inRaid > 0 then for i = 1, inRaid do - raidList[UnitName(rID[i])]=true + raidList[personsReverse[UnitName(rID[i])]]=true end elseif inParty > 0 then for i = 1, inParty do - raidList[UnitName(pID[i])]=true + raidList[personsReverse[UnitName(pID[i])]]=true end -- Now add yourself as the last party member - raidList[UnitName("player")]=true + raidList[personsReverse[UnitName("player")]]=true else -- You're alone - raidList[UnitName("player")]=true + raidList[personsReverse[UnitName("player")]]=true end end @@ -535,20 +539,23 @@ -- prevent proper undo, such as add/delete player or add/delete list -function bsk:GetSuicideList(name,list) +function bsk:GetSuicideList(id,list) --self:Print("Calculating changeset for "..name.." from list -") --self:PrintTable(list) local t = {} local ret = {} local pushing = false for i = 1, #list do - if list[i] == name then + if list[i].id == id then pushing = true end - if pushing and (raidList[list[i]] or reserveList[list[i]]) then + if pushing and (raidList[list[i].id] or reserveList[list[i].id]) then tinsert(ret,list[i].id) end end + bsk:Print("GSL") + bsk:PrintTable(ret) + bsk:Print("GSL") return ret end