dezhou_client/lua_probject/base_project/Game/Data/Groups.lua

46 lines
742 B
Lua

local M = class("Groups")
function M:ctor()
self.groupList = {}
self.groupMap = {}
end
function M:add(group)
local _tem = self.groupMap[group.id]
if _tem then
for k, v in pairs(group) do
_tem[k] = v
end
else
self.groupMap[group.id] = group
self.groupList[#self.groupList + 1] = group
end
end
function M:del(id)
local _tem = self.groupMap[id]
if _tem then
local list = self.groupList
self.groupMap[id] = nil
for i=1,#list do
local group = list[i]
if group.id == id then
table.remove(list,i)
self.groupMap[id] = nil
break
end
end
end
end
function M:get(id)
local _tem = self.groupMap[id]
return _tem
end
function M:clear()
self.groupMap = {}
self.groupList = {}
end
return M