Mercurial > wow > breuesk
changeset 37:6362fe301d43
Storing class name in the persons so we can color them in later
Exposing some data lists, but this will likely be retracted later in favor of interface functions
author | John@Yosemite-PC |
---|---|
date | Tue, 13 Mar 2012 23:17:18 -0400 |
parents | cc25a1a51291 |
children | 7bfbff27a3d7 |
files | Lists.lua |
diffstat | 1 files changed, 29 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/Lists.lua Tue Mar 13 23:15:40 2012 -0400 +++ b/Lists.lua Tue Mar 13 23:17:18 2012 -0400 @@ -68,9 +68,9 @@ bsk.lists = {} bsk.persons = {} -local raidNameP = {} -- "name" is present in raid -local raidIdP = {} -- "id" is present in raid -local reserveIdP = {} -- "reserve id present" +bsk.raidNameP = {} -- "name" is present in raid +bsk.raidIdP = {} -- "id" is present in raid +bsk.reserveIdP = {} -- "reserve id present" local activeListKey = 1 -- temporary local personName2id = {} -- given "name" get that person's id @@ -84,9 +84,9 @@ bsk.db.profile.persons = {} bsk.db.profile.changes = {} bsk.db.profile.lists = {} - raidNameP = {} - raidIdP = {} - reserveIdP = {} + bsk.raidNameP = {} + bsk.raidIdP = {} + bsk.reserveIdP = {} personName2id = {} end function bsk:tcopy(to, from) @@ -130,6 +130,7 @@ function bsk:PrintTable(table, depth) depth = depth or "" if not table then return end + if #depth > 3*5 then self:Print(depth.."Recursion too deep - stopping"); return end for i,v in pairs(table) do if( type(v) == "string" ) then self:Print(depth .. i .. " - " .. v) @@ -140,6 +141,8 @@ self:PrintTable(v,depth.." ") elseif( type(v) == "boolean" ) then self:Print(depth .. i .. " - " .. tostring(v)) + elseif( type(v) == "function" ) then + self:Print(depth .. "function " .. i .. "()") else self:Print(depth .. i .. " - not sure how to print type: " .. type(v) ) end @@ -148,11 +151,11 @@ function bsk:PrintRaidAndReserve() bsk:Print("RaidNameP") - bsk:PrintTable(raidNameP) + bsk:PrintTable(bsk.raidNameP) bsk:Print("RaidIdP") - bsk:PrintTable(raidIdP) + bsk:PrintTable(bsk.raidIdP) bsk:Print("ReserveP") - bsk:PrintTable(reserveIdP) + bsk:PrintTable(bsk.reserveIdP) bsk:Print("personName2id") bsk:PrintTable(personName2id) end @@ -293,13 +296,12 @@ function bsk:DoAddPerson(change)--{{{ assert(change) assert(change.arg.id) - local arg = change.arg -- require admin local persons = bsk.persons - local name = arg.name - local id = arg.id + local name = change.arg.name + local id = change.arg.id assert(persons[id]==nil) - persons[id] = {main=name} + persons[id] = {main=name,class=change.arg.class} persons.time=change.time personName2id[name] = id return true @@ -312,6 +314,8 @@ self:Print(sformat("Could not add player %s - they must be in range or group",name)) return end + local _,englishClass = UnitClass(name) + --bsk:Print("Person " .. name .. " is class " .. englishClass) local id = string.sub(guid,6) -- skip at least 0x0580 ... id = id:gsub("^0*(.*)","%1") -- nom all leading zeroes remaining @@ -323,7 +327,7 @@ self:Print(sformat("%s is already in the persons list; disregarding", name)) return end - local change = {action="AddPerson",arg={name=name,id=id}} + local change = {action="AddPerson",arg={name=name,id=id,class=englishClass}} if bsk:DoAddPerson(change) then bsk:CreateChange(change) end @@ -565,7 +569,7 @@ for id,_ in pairs(bsk.persons) do t[id] = true end - for name,_ in pairs(raidNameP) do + for name,_ in pairs(bsk.raidNameP) do if personName2id[name] == nil then bsk:Print(sformat("Person %s is missing from the persons list - adding",name)) bsk:AddPerson(name) @@ -580,10 +584,10 @@ local list = bsk.lists[listIndex] local t = {} -- after loops, contains intersection of IDs present between raid and reserve - for i,v in pairs(raidIdP) do + for i,v in pairs(bsk.raidIdP) do if v then t[i] = true end end - for i,v in pairs(reserveIdP) do + for i,v in pairs(bsk.reserveIdP) do if v then t[i] = true end end @@ -616,12 +620,12 @@ -- reserves function bsk:AddReserve(name) - reserveIdP[personName2id[name]]=true + bsk.reserveIdP[personName2id[name]]=true -- TODO: communicate to others. don't store this in any way. end function bsk:RemoveReserve(name) - reserveIdP[personName2id[name]]=false + bsk.reserveIdP[personName2id[name]]=false -- TODO: communicate to others. don't store this in any way. end @@ -647,14 +651,14 @@ local inRaid = GetNumRaidMembers() local add = function(unitNameArg) local name = UnitName(unitNameArg) - raidNameP[name]=true + bsk.raidNameP[name]=true if personName2id[name] ~= nil then - raidIdP[personName2id[name]]=true + bsk.raidIdP[personName2id[name]]=true end end - wipe(raidNameP) - wipe(raidIdP) + wipe(bsk.raidNameP) + wipe(bsk.raidIdP) if inRaid > 0 then for i = 1, inRaid do add(rID[i]) @@ -669,7 +673,7 @@ -- You're alone add("player") end - --bsk:PrintTable(raidNameP) + --bsk:PrintTable(bsk.raidNameP) end -- undo rules! @@ -691,7 +695,7 @@ if list[i].id == id then pushing = true end - if pushing and (raidIdP[list[i].id] or reserveIdP[list[i].id]) then + if pushing and (bsk.raidIdP[list[i].id] or bsk.reserveIdP[list[i].id]) then tinsert(ret,list[i].id) end end