117 lines
3.2 KiB
Lua
117 lines
3.2 KiB
Lua
|
|
------------------------------------------------
|
|
--作者: 王圣
|
|
--日期: 2019-10-29
|
|
--文件: LingTiData.lua
|
|
--模块: LingTiData
|
|
--描述: 灵体数据
|
|
------------------------------------------------
|
|
--引用
|
|
local LingTiCel = require "Logic.LingTi.LingTiCel"
|
|
local LingTiData = {
|
|
--配置数据
|
|
Cfg = nil,
|
|
--是否激活
|
|
IsActive= false,
|
|
--默认品质
|
|
MinQuality = 6,
|
|
--装备格子数据
|
|
ListEquipCel = List:New(),
|
|
}
|
|
|
|
function LingTiData:New(cfg)
|
|
local _m = Utils.DeepCopy(self)
|
|
_m.Cfg = cfg
|
|
_m:InitEquipCelList()
|
|
return _m
|
|
end
|
|
|
|
--解析数据
|
|
function LingTiData:Parase(info)
|
|
if info == nil then
|
|
return
|
|
end
|
|
if info.equipList == nil then
|
|
return
|
|
end
|
|
for i = 1, #info.equipList do
|
|
self:SetCel(info.equipList[i])
|
|
end
|
|
self.IsActive = info.isActive
|
|
end
|
|
|
|
--初始化装备格子List
|
|
function LingTiData:InitEquipCelList()
|
|
--一共8个格子
|
|
for i = 1,8 do
|
|
local cel = LingTiCel:New()
|
|
self.ListEquipCel:Add(cel)
|
|
end
|
|
local array = Utils.SplitStr(self.Cfg.Equip,'_')
|
|
if array ~= nil then
|
|
local _qua = -1
|
|
for i = 1, #array do
|
|
local cfg = DataConfig.DataEquip[tonumber(array[i])]
|
|
if cfg ~= nil then
|
|
_qua = cfg.Quality
|
|
self.MinQuality = _qua
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--设置装备格子
|
|
function LingTiData:SetCel(equipId)
|
|
local _dic = Dictionary:New()
|
|
if equipId ~= 0 then
|
|
local equipCfg = DataConfig.DataEquip[equipId]
|
|
if equipCfg then
|
|
self.ListEquipCel[equipCfg.Part + 1].EquipId = equipId
|
|
self.ListEquipCel[equipCfg.Part + 1].StarNum = equipCfg.DiamondNumber
|
|
local list = Utils.SplitStr(equipCfg.Attribute1, ';')
|
|
if list ~= nil then
|
|
for j = 1,#list do
|
|
local array = Utils.SplitNumber(list[j],'_')
|
|
if _dic:ContainsKey(array[1]) then
|
|
_dic[array[1]] = _dic[array[1]] + array[2]
|
|
else
|
|
_dic:Add(array[1], array[2])
|
|
end
|
|
end
|
|
end
|
|
if equipCfg.Attribute2 then
|
|
list = Utils.SplitStr(equipCfg.Attribute2, ';')
|
|
if list ~= nil then
|
|
for j = 1,#list do
|
|
local array = Utils.SplitNumber(list[j],'_')
|
|
if _dic:ContainsKey(array[1]) then
|
|
_dic[array[1]] = _dic[array[1]] + array[2]
|
|
else
|
|
_dic:Add(array[1], array[2])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self.ListEquipCel[equipCfg.Part + 1].AttDic = _dic
|
|
end
|
|
end
|
|
end
|
|
|
|
function LingTiData:GetAllAtt()
|
|
local _dic = Dictionary:New()
|
|
for i = 1, #self.ListEquipCel do
|
|
if self.ListEquipCel[i].AttDic then
|
|
self.ListEquipCel[i].AttDic:Foreach(function(k, v)
|
|
if _dic:ContainsKey(k) then
|
|
_dic[k] = _dic[k] + v
|
|
else
|
|
_dic:Add(k, v)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
return _dic
|
|
end
|
|
|
|
return LingTiData |