131 lines
6.0 KiB
Lua
131 lines
6.0 KiB
Lua
------------------------------------------------
|
||
--作者: 陈宇
|
||
--日期: 2019-07-19
|
||
--文件: XianPoData.lua
|
||
--模块: XianPoData
|
||
--描述: 仙魄数据类
|
||
------------------------------------------------
|
||
local XianPoData = {
|
||
Uid = 0, --仙魄的uid
|
||
Level = 0, --该仙魄的等级
|
||
Exp = 0, --该仙魄的经验
|
||
Location = 0, --该仙魄的位置
|
||
CfgId = 0, --该仙魄的配置表id
|
||
Name = "", --名字
|
||
Icon = 0, --图标
|
||
Quality = 0, --品质等级,(1蓝,2紫,3金,4红)
|
||
MaxLevel = 0, --最大等级
|
||
CanInlayLocationList = List:New(), --能够镶嵌的格子
|
||
BaseAttrDic = Dictionary:New(), --基础属性字典
|
||
BaseAddAttrDic = Dictionary:New(), --每级增加的属性字典
|
||
TotalAddAttrDic = Dictionary:New(), --该仙魄总的增加的属性
|
||
NextLvTotalAddAttrDic = Dictionary:New(), --该仙魄下一级总的增加的属性
|
||
GetConditionType = 35, --获取该仙魄所需条件的类型,functionVariable表中的类型
|
||
GetConditionValue = 0, --获取该仙魄所需条件的值
|
||
MutexIdList = List:New(), --和该仙魄互斥的仙魄id列表
|
||
BaseDecompositionExp = 0, --基础分解经验
|
||
Typ = 0, --仙魄类型
|
||
TypeName = "", --仙魄类型,1:属性仙魄,2:经验仙魄
|
||
Type2 = 0, --区分仙魄的类型,用户仙魄装备和替换时的互斥
|
||
SortId = 0, --排序ID
|
||
Star = 0,
|
||
}
|
||
|
||
function XianPoData:New()
|
||
local _m = Utils.DeepCopy(self)
|
||
return _m
|
||
end
|
||
|
||
function XianPoData:SetAllData(data)
|
||
self.Uid = data.uid
|
||
self.Level = data.level
|
||
self.Exp = data.exp
|
||
self.Location = data.location
|
||
self.CfgId = data.itemId
|
||
local _cfg = DataConfig.DataImmortalSoulAttribute[self.CfgId]
|
||
if _cfg then
|
||
self.Star = _cfg.Star
|
||
self.Name = _cfg.Name
|
||
self.Icon = _cfg.Icon
|
||
self.Quality = _cfg.Quality
|
||
if _cfg.LevelMax and _cfg.LevelMax ~= "" then
|
||
self.MaxLevel = _cfg.LevelMax
|
||
end
|
||
if _cfg.Grid ~= "" then
|
||
self.CanInlayLocationList = Utils.SplitNumber(_cfg.Grid, "_")
|
||
end
|
||
--计算基础属性
|
||
if _cfg.LevelMax and _cfg.LevelMax ~= "" then
|
||
local _baseAttrList = Utils.SplitStrByTableS(_cfg.DemandValue)
|
||
local _percentList = Utils.SplitStrByTableS(_cfg.DemandValuePercent)
|
||
if _percentList ~= nil then
|
||
for i = 1, #_percentList do
|
||
table.insert( _baseAttrList, _percentList[i] )
|
||
end
|
||
end
|
||
for i=1,#_baseAttrList do
|
||
if not self.BaseAttrDic:ContainsKey(_baseAttrList[i][1]) then
|
||
self.BaseAttrDic:Add(_baseAttrList[i][1], _baseAttrList[i][2])
|
||
end
|
||
if not self.TotalAddAttrDic:ContainsKey(_baseAttrList[i][1]) then
|
||
self.TotalAddAttrDic:Add(_baseAttrList[i][1], _baseAttrList[i][2])
|
||
end
|
||
end
|
||
--计算每级增加的属性和总属性
|
||
local _baseAddAttrList = Utils.SplitStrByTableS(_cfg.BasicAttributes)
|
||
local _baseAddAttrListPercent = Utils.SplitStrByTableS(_cfg.BasicAttributesPercent)
|
||
if _baseAddAttrListPercent ~= nil then
|
||
for i = 1, #_baseAddAttrListPercent do
|
||
table.insert( _baseAddAttrList, _baseAddAttrListPercent[i] )
|
||
end
|
||
end
|
||
for i=1,#_baseAddAttrList do
|
||
if not self.BaseAddAttrDic:ContainsKey(_baseAddAttrList[i][1]) then
|
||
self.BaseAddAttrDic:Add(_baseAddAttrList[i][1], _baseAddAttrList[i][2])
|
||
end
|
||
if self.TotalAddAttrDic:ContainsKey(_baseAddAttrList[i][1]) then
|
||
local _value = self.TotalAddAttrDic[_baseAddAttrList[i][1]]
|
||
--刚获得的仙魄,默认是1级
|
||
self.TotalAddAttrDic[_baseAddAttrList[i][1]] = _value + _baseAddAttrList[i][2] * (self.Level - 1)
|
||
end
|
||
end
|
||
--计算下一级增加的属性
|
||
self.TotalAddAttrDic:Foreach(
|
||
function(key, value)
|
||
if not self.NextLvTotalAddAttrDic:ContainsKey(key) then
|
||
self.NextLvTotalAddAttrDic:Add(key, value)
|
||
end
|
||
end
|
||
)
|
||
if self.Level < self.MaxLevel then
|
||
for i=1,#_baseAddAttrList do
|
||
if self.NextLvTotalAddAttrDic:ContainsKey(_baseAddAttrList[i][1]) then
|
||
local _value = self.NextLvTotalAddAttrDic[_baseAddAttrList[i][1]]
|
||
self.NextLvTotalAddAttrDic[_baseAddAttrList[i][1]] = _value + _baseAddAttrList[i][2]
|
||
end
|
||
end
|
||
end
|
||
end
|
||
if _cfg.ExchangeConditions ~= "" then
|
||
local _condition = Utils.SplitNumber(_cfg.ExchangeConditions, "_")
|
||
self.GetConditionType = _condition[1]
|
||
self.GetConditionValue = _condition[2]
|
||
end
|
||
if _cfg.ExclusiveID ~= "" then
|
||
self.MutexIdList = Utils.SplitNumber(_cfg.ExclusiveID, "_")
|
||
end
|
||
self.BaseDecompositionExp = _cfg.Exp
|
||
self.Typ = _cfg.Type
|
||
if _cfg.Type == 1 then
|
||
self.TypeName = DataConfig.DataMessageString.Get("PropertyXianPo")
|
||
elseif _cfg.Type == 2 then
|
||
self.TypeName = DataConfig.DataMessageString.Get("PropertyExp")
|
||
elseif _cfg.Type == 3 then
|
||
self.TypeName = DataConfig.DataMessageString.Get("PropertyXianPo")
|
||
end
|
||
self.Type2 = _cfg.ExclusiveID
|
||
end
|
||
end
|
||
|
||
return XianPoData
|