2021-12-06 15:07:34 +08:00
|
|
|
GemManager = {}
|
|
|
|
local this = GemManager
|
2021-12-06 14:24:24 +08:00
|
|
|
function this.Initialize()
|
2021-12-07 11:50:03 +08:00
|
|
|
this.myGemList = {}--我穿戴命石的id
|
|
|
|
this.allGemList = {}--背包中的命石id。不包括穿戴的
|
|
|
|
end
|
|
|
|
|
|
|
|
--获取服务器发来的数据信息
|
|
|
|
function this.UpdateGemsFromBag(_GemId,_num)
|
|
|
|
if not this.allGemList[_GemId] then
|
|
|
|
local data = {}
|
|
|
|
data.id = _GemId
|
|
|
|
data.num = 1
|
|
|
|
if _num then
|
|
|
|
data.num = _num
|
|
|
|
end
|
|
|
|
this.allGemList[_GemId] = data
|
|
|
|
else
|
|
|
|
this.allGemList[_GemId].num = this.allGemList[_GemId].num + 1
|
|
|
|
if _num then
|
|
|
|
this.allGemList[_GemId].num = _num
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function this.GetWearedGem(_GemList)
|
|
|
|
for k,v in pairs(_GemList) do
|
|
|
|
LogPink(string.format("命格:%s index:%s ID:%s",v.gridId,v.gridIndex,v.itemId))
|
|
|
|
if v and v.gridId then
|
|
|
|
if not this.myGemList[v.gridId] then
|
|
|
|
this.myGemList[v.gridId] = {}
|
|
|
|
end
|
|
|
|
if not this.myGemList[v.gridId][v.gridIndex] then
|
|
|
|
this.myGemList[v.gridId][v.gridIndex] = nil
|
|
|
|
end
|
|
|
|
if v.itemId and v.itemId > 0 then
|
|
|
|
this.myGemList[v.gridId][v.gridIndex] = v.itemId
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #this.myGemList == 0 then
|
|
|
|
LogError("没有命石数据,将使用测试数据")
|
|
|
|
this.myGemList = {--我穿戴命石的id
|
2021-12-06 18:37:12 +08:00
|
|
|
[1] = {45001,45002,45003},
|
|
|
|
[2] = {45004,45005,45006},
|
|
|
|
[3] = {45007,45008,45009},
|
|
|
|
[4] = {45010,45011,45013},
|
|
|
|
[5] = {45021,45022,45023},
|
|
|
|
[6] = {45031,45032,45033},
|
|
|
|
[7] = {45041,45042,45043},
|
|
|
|
[8] = {45051,45052,45053},
|
|
|
|
}
|
2021-12-07 11:50:03 +08:00
|
|
|
end
|
2021-12-06 14:24:24 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return this
|