539 lines
17 KiB
Lua
539 lines
17 KiB
Lua
FaXiangManager = {}
|
|
local this = FaXiangManager
|
|
local allTreasures = {}
|
|
local otherTreaures = {}
|
|
local faXiangConfig = ConfigManager.GetConfig(ConfigName.FaxiangConfig)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local faxiangLevelConfig = ConfigManager.GetConfig(ConfigName.FaxiangLevelConfig)
|
|
local faxiangStarConfig = ConfigManager.GetConfig(ConfigName.FaxiangStarConfig)
|
|
function this.Initialize()
|
|
this.TreasurePowerData = {}
|
|
end
|
|
--初始化所有宝器数据
|
|
function this.InitAllEquipTreasure(_equipData)
|
|
if _equipData == nil then
|
|
return
|
|
end
|
|
for i = 1, #_equipData do
|
|
this.InitSingleTreasureData(_equipData[i])
|
|
end
|
|
end
|
|
--初始化单个宝物的数据
|
|
function this.InitSingleTreasureData(_singleData,notAdd)
|
|
if _singleData == nil then
|
|
return
|
|
end
|
|
local single = {}
|
|
local staticId = _singleData.equipId
|
|
LogError("starticid=="..staticId)
|
|
local currJewel = faXiangConfig[staticId]
|
|
single.equipType = currJewel.Location
|
|
single.id = staticId
|
|
single.idDyn = _singleData.id
|
|
single.lv = _singleData.exp
|
|
LogError("single.lv=="..single.lv)
|
|
single.refineLv = _singleData.rebuildLevel --星级
|
|
single.fourSpirit=_singleData.fourSpirit
|
|
single.maxLv = currJewel.LevelMax
|
|
single.maxRefineLv = currJewel.StarMax
|
|
single.upHeroDid = ""
|
|
-- single.race = currJewel.Race
|
|
single.itemConfig = itemConfig[staticId]
|
|
single.quantity = single.itemConfig.Quantity
|
|
single.name = GetLanguageStrById(itemConfig[staticId].Name)
|
|
single.frame = GetQuantityImageByquality(itemConfig[staticId].Quantity)
|
|
single.levelPool = currJewel.LevelUpPool
|
|
single.refinePool = currJewel.Star
|
|
single.equipType = currJewel.Type
|
|
local quantity = currJewel.Level
|
|
|
|
-- if currJewel.Location == 1 then
|
|
-- single.type = Language[10552]
|
|
-- else
|
|
-- single.type = Language[10553]
|
|
-- end
|
|
single.icon = GetResourcePath(itemConfig[staticId].ResourceID)
|
|
single.strongConfig = this.GetCurrTreasureLvConfig(currJewel.LevelUpPool, _singleData.exp)
|
|
-- single.refineConfig = this.GetCurrTreasureLvConfig(2, currJewel.Star, _singleData.rebuildLevel)
|
|
-- if notAdd then
|
|
-- return single
|
|
-- else
|
|
allTreasures[_singleData.id] = single
|
|
-- end
|
|
|
|
end
|
|
|
|
--获取玩家穿戴的宝物
|
|
function this.GetAllHeroEquipedTreasureData()
|
|
local equips = {}
|
|
for i, v in pairs(allTreasures) do
|
|
if (not v.upHeroDid or v.upHeroDid == "" or v.upHeroDid == 0 or v.upHeroDid == "0") then
|
|
else
|
|
table.insert(equips, v)
|
|
end
|
|
end
|
|
return equips
|
|
end
|
|
|
|
function this.GetFaXiangItemById(_id)
|
|
local equips={}
|
|
for i, v in pairs(allTreasures) do
|
|
if (v.upHeroDid == 0 or v.upHeroDid == "0") and v.id==_id then
|
|
table.insert(equips, v)
|
|
end
|
|
end
|
|
return equips,#equips
|
|
end
|
|
|
|
|
|
--设置装备穿戴的英雄
|
|
function this.SetEquipTreasureUpHeroDid(_equipTreasureDid, _heroDid)
|
|
if allTreasures[_equipTreasureDid] then
|
|
allTreasures[_equipTreasureDid].upHeroDid = _heroDid
|
|
end
|
|
end
|
|
|
|
function this.GetSingleEquipTreasreData(_equipTreasureDid)
|
|
if allTreasures[_equipTreasureDid] then
|
|
return allTreasures[_equipTreasureDid]
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
--改变宝物的等级或精炼等级或神应等级
|
|
function this.ChangeTreasureLv(_idDyn, _type)
|
|
if allTreasures == nil then
|
|
return
|
|
end
|
|
if allTreasures[_idDyn] == nil then
|
|
return
|
|
end
|
|
if allTreasures[_idDyn] then
|
|
if _type == 1 then
|
|
if allTreasures[_idDyn].lv == allTreasures[_idDyn].maxLv then
|
|
return
|
|
end
|
|
local lv = allTreasures[_idDyn].lv + 1
|
|
allTreasures[_idDyn].lv = lv
|
|
allTreasures[_idDyn].strongConfig = this.GetCurrTreasureLvConfig(1, allTreasures[_idDyn].levelPool, lv)
|
|
elseif _type == 2 then
|
|
if allTreasures[_idDyn].refineLv == allTreasures[_idDyn].maxRefineLv then
|
|
return
|
|
end
|
|
local refine = allTreasures[_idDyn].refineLv + 1
|
|
allTreasures[_idDyn].refineLv = refine
|
|
allTreasures[_idDyn].refineConfig =this.GetCurrTreasureLvConfig(2, allTreasures[_idDyn].refinePool, refine)
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取当前等级的基础属性/精炼属性
|
|
function this.GetCurrLvAndNextLvPropertyValue(_id, _lv,_data)
|
|
local lvConfig = nil
|
|
local nexLvConfig = nil
|
|
local Para=0
|
|
local starConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",_data.refinePool,"Level",_data.refineLv)
|
|
if starConfig then
|
|
LogError("starConfig.id=="..starConfig.Id)
|
|
Para=starConfig.StarPara/10000
|
|
end
|
|
|
|
--获取当前等级属性加成
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
if configInfo.PoolId == _id and configInfo.Level == _lv then
|
|
lvConfig = configInfo
|
|
break
|
|
end
|
|
end
|
|
--获取下一等级属性加成
|
|
local nextLv = _lv + 1
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
if configInfo.PoolId == _id and configInfo.Level == nextLv then
|
|
nexLvConfig = configInfo
|
|
break
|
|
end
|
|
end
|
|
local proList = {}
|
|
-- for key, value in pairs(addAllProVal) do
|
|
-- addEndAllProVal[key] = math.floor(value * (1 + Para))
|
|
-- end
|
|
if lvConfig then
|
|
for i = 1, table.getn(lvConfig.LevelPara) do
|
|
local info = lvConfig.LevelPara[i]
|
|
if info then
|
|
local index = info[1]
|
|
local skillValue = {}
|
|
skillValue.currValue = math.floor(info[2] * (1 + Para))
|
|
proList[index] = skillValue
|
|
end
|
|
end
|
|
|
|
end
|
|
--没有下一等级数据为已升到最高级
|
|
if nexLvConfig then
|
|
--最高级显示
|
|
for i = 1, table.getn(nexLvConfig.LevelPara) do
|
|
local info = nexLvConfig.LevelPara[i]
|
|
if info then
|
|
if proList[info[1]] then
|
|
proList[info[1]].nextValue = math.floor(info[2] * (1 + Para))
|
|
else
|
|
local skillValue = {}
|
|
skillValue.currValue = math.floor(info[2] * (1 + Para))
|
|
proList[info[1]] = skillValue
|
|
end
|
|
end
|
|
end
|
|
else
|
|
for i, v in pairs(proList) do
|
|
proList[i].nextValue = proList[i].currValue
|
|
end
|
|
end
|
|
return proList
|
|
end
|
|
|
|
--获取当前星级的基础属性/精炼属性
|
|
function this.GetCurrStarAndNextStarPropertyValue(_id, _lv,_data)
|
|
local lvConfig = nil
|
|
local nexLvConfig = nil
|
|
local Para=0
|
|
local nextPara=0
|
|
|
|
local starConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",_data.refinePool,"Level",_data.refineLv)
|
|
if starConfig then
|
|
LogError("starConfig.id=="..starConfig.Id)
|
|
Para=starConfig.StarPara/10000
|
|
end
|
|
|
|
if _data.refineLv==_data.maxRefineLv then
|
|
nextPara=Para
|
|
else
|
|
local nextStarConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",_data.refinePool,"Level",_data.refineLv+1)
|
|
nextPara=nextStarConfig.StarPara/10000
|
|
end
|
|
--获取当前等级属性加成
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
if configInfo.PoolId == _id and configInfo.Level == _lv then
|
|
lvConfig = configInfo
|
|
break
|
|
end
|
|
end
|
|
|
|
local proList = {}
|
|
if lvConfig then
|
|
for i = 1, table.getn(lvConfig.LevelPara) do
|
|
local info = lvConfig.LevelPara[i]
|
|
if info then
|
|
local index = info[1]
|
|
local skillValue = {}
|
|
skillValue.currValue = info[2]
|
|
proList[index] = skillValue
|
|
end
|
|
end
|
|
end
|
|
for key, value in pairs(proList) do
|
|
value.currValue=math.floor(value.currValue * (1 + Para))
|
|
value.nextValue=math.floor(value.currValue * (1 + nextPara))
|
|
end
|
|
|
|
return proList
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--获取法相升级消耗
|
|
function this.GetFaXiangLevelCost(_pool,_lv)
|
|
local levelConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.FaxiangLevelConfig,"PoolId",_pool,"Level",_lv)
|
|
if levelConfig then
|
|
local items={}
|
|
for i = 1,#levelConfig.PropList do
|
|
local id=levelConfig.PropList[i][1]
|
|
if itemConfig[id] then
|
|
local item={}
|
|
item.id=id
|
|
item.icon=GetResourcePath(itemConfig[id].ResourceID)
|
|
item.frame=GetQuantityImageByquality(itemConfig[id].Quantity)
|
|
item.haveNum=BagManager.GetItemCountById(id)
|
|
item.needNum=levelConfig.PropList[i][2]
|
|
item.isEnough=item.haveNum>=item.needNum
|
|
items[i]=item
|
|
end
|
|
end
|
|
|
|
local isEnough = true
|
|
for k,v in pairs(items) do
|
|
if not v.isEnough then
|
|
isEnough = false
|
|
break
|
|
end
|
|
end
|
|
return items,isEnough
|
|
end
|
|
end
|
|
|
|
--获取法相升级消耗
|
|
function this.GetFaXiangStarCost(_poolId,_star,_data)
|
|
local config=ConfigManager.GetConfigDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",_poolId,"Level",_star)
|
|
local items={}
|
|
if config and config.PropList then
|
|
for i = 1, #config.PropList do
|
|
local id=config.PropList[i]
|
|
local item={}
|
|
--同类型宝物
|
|
local type=id[1]
|
|
if type==0 then
|
|
item.id=_data.id
|
|
item.icon=_data.icon
|
|
item.frame=_data.frame
|
|
local equips,num=FaXiangManager.GetFaXiangItemById(_data.id)
|
|
if equips then
|
|
item.haveNum= num
|
|
else
|
|
item.haveNum=0
|
|
end
|
|
item.needNum=id[2]
|
|
if item.haveNum>=item.needNum then
|
|
item.isEnough=true
|
|
else
|
|
item.isEnough=false
|
|
end
|
|
items[#items+1]=item
|
|
else
|
|
item.id=type
|
|
local config=itemConfig[type]
|
|
if config then
|
|
item.icon=GetResourcePath(config.ResourceID)
|
|
item.frame=GetQuantityImageByquality(config.Quantity)
|
|
item.haveNum=BagManager.GetItemCountById(type)
|
|
item.needNum=id[2]
|
|
if item.haveNum>=item.needNum then
|
|
item.isEnough=true
|
|
else
|
|
item.isEnough=false
|
|
end
|
|
items[#items+1]=item
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local isEnough = true
|
|
for k,v in pairs(items) do
|
|
if not v.isEnough then
|
|
isEnough = false
|
|
break
|
|
end
|
|
end
|
|
return items,isEnough
|
|
end
|
|
|
|
function this.CalculateWarForceBase(sId, lv, rlv, curTreasure)
|
|
-- LogGreen("sId:"..sId.." lv:"..lv.." rlv:"..rlv.." tlv:"..tlv)
|
|
local curEuipTreaSureConfig = ConfigManager.GetConfigData(ConfigName.FaxiangConfig, sId)
|
|
if curEuipTreaSureConfig then
|
|
local addAllProVal = {}
|
|
--主属性
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
--强化的属性
|
|
if
|
|
configInfo.PoolId == curEuipTreaSureConfig.LevelUpPool and
|
|
configInfo.Level == lv
|
|
then
|
|
for j = 1, #configInfo.LevelPara do
|
|
if addAllProVal[configInfo.LevelPara[j][1]] then
|
|
addAllProVal[configInfo.LevelPara[j][1]] =
|
|
addAllProVal[configInfo.LevelPara[j][1]] + configInfo.LevelPara[j][2]
|
|
else
|
|
addAllProVal[configInfo.LevelPara[j][1]] = configInfo.LevelPara[j][2]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local starConfig=ConfigManager.TryGetAllConfigsDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",curEuipTreaSureConfig.Star,"Level",rlv)
|
|
local addEndAllProVal={}
|
|
if starConfig then
|
|
local StarPara=starConfig.StarPara/10000
|
|
for key, value in pairs(addAllProVal) do
|
|
addEndAllProVal[key] = math.floor(value * (1 + StarPara))
|
|
end
|
|
end
|
|
|
|
local powerEndVal = HeroPowerManager.CalPower(addEndAllProVal)
|
|
return powerEndVal
|
|
end
|
|
end
|
|
|
|
|
|
|
|
--获取消耗物品数据
|
|
function this.GetCostItems(_config)
|
|
|
|
if _config==nil then
|
|
return
|
|
end
|
|
local items={}
|
|
for i = 1,#_config.PropList do
|
|
local id=_config.PropList[i][1]
|
|
if itemConfig[id] then
|
|
local item={}
|
|
item.id=id
|
|
item.icon=GetResourcePath(itemConfig[id].ResourceID)
|
|
item.frame=GetQuantityImageByquality(itemConfig[id].Quantity)
|
|
item.haveNum=BagManager.GetItemCountById(id)
|
|
item.needNum=_config.PropList[i][2]
|
|
item.isEnough=item.haveNum>=item.needNum
|
|
items[i]=item
|
|
end
|
|
end
|
|
|
|
local isEnough = true
|
|
for k,v in pairs(items) do
|
|
if not v.isEnough then
|
|
isEnough = false
|
|
break
|
|
end
|
|
end
|
|
return items,isEnough
|
|
end
|
|
|
|
|
|
|
|
|
|
--根据动态id获取法相
|
|
function this.GetSingleTreasureByIdDyn(_idDyn)
|
|
if allTreasures == nil then
|
|
return
|
|
end
|
|
return allTreasures[_idDyn]
|
|
end
|
|
|
|
|
|
--获取当前等级加成的属性
|
|
function this.GetCurLvPropertyValue(_id, _lv, _isShow)
|
|
local lvConfig = nil
|
|
local isShow = _isShow == true
|
|
--获取当前等级属性加成
|
|
LogError("_id==".._id.." level==".._lv)
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
if configInfo.PoolId == _id and configInfo.Level == _lv then
|
|
|
|
lvConfig = configInfo
|
|
break
|
|
end
|
|
end
|
|
local proList = {}
|
|
if lvConfig then
|
|
for i = 1, table.getn(lvConfig.LevelPara) do
|
|
local info = lvConfig.LevelPara[i]
|
|
if info then
|
|
local index = info[1]
|
|
local skillValue = {}
|
|
skillValue.currValue = info[2]
|
|
if isShow then
|
|
proList[index] = skillValue
|
|
else
|
|
if info[2] ~= 0 then
|
|
proList[index] = skillValue
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return proList
|
|
end
|
|
|
|
|
|
--获取所有宝物 不算英雄身上穿的
|
|
function this.GetAllTreasures()
|
|
|
|
local curAllEquipTreasure = {}
|
|
for key, value in pairs(allTreasures) do
|
|
if value.upHeroDid == "" or value.upHeroDid == "0" then
|
|
table.insert(curAllEquipTreasure, value)
|
|
end
|
|
end
|
|
if LengthOfTable(curAllEquipTreasure) > 0 then
|
|
table.sort(curAllEquipTreasure,function(a, b)
|
|
if a.quantity == b.quantity then
|
|
if a.lv == b.lv then
|
|
return a.refineLv > b.refineLv
|
|
else
|
|
return a.lv > b.lv
|
|
end
|
|
else
|
|
return a.quantity > b.quantity
|
|
end
|
|
end)
|
|
return curAllEquipTreasure
|
|
end
|
|
|
|
return curAllEquipTreasure
|
|
end
|
|
|
|
|
|
--设置法相穿戴的英雄
|
|
function this.SetEquipTreasureUpHeroDid(_equipTreasureDid, _heroDid)
|
|
if allTreasures[_equipTreasureDid] then
|
|
allTreasures[_equipTreasureDid].upHeroDid = _heroDid
|
|
end
|
|
end
|
|
|
|
|
|
|
|
--获取当前宝物升级数据
|
|
function this.GetCurrTreasureLvConfig( _id, _lv)
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
if configInfo.PoolId == _id and configInfo.Level == _lv then
|
|
LogError("poolid==".._id .."_lv==================".._lv)
|
|
return configInfo
|
|
end
|
|
end
|
|
end
|
|
|
|
--计算战斗力
|
|
function this.CalculateWarForceBySid(sId, lv, rlv, tlv)
|
|
return this.CalculateWarForceBase(sId, lv, rlv, tlv)
|
|
end
|
|
|
|
function this.CalculateWarForceBase(sId, lv, rlv, tlv,curTreasure)
|
|
-- LogGreen("sId:"..sId.." lv:"..lv.." rlv:"..rlv.." tlv:"..tlv)
|
|
local curEuipTreaSureConfig = ConfigManager.GetConfigData(ConfigName.FaxiangConfig, sId)
|
|
local addEndAllProVal={}
|
|
if curEuipTreaSureConfig then
|
|
local addAllProVal = {}
|
|
--主属性
|
|
for _, configInfo in ConfigPairs(faxiangLevelConfig) do
|
|
--强化的属性
|
|
if configInfo.PoolID == curEuipTreaSureConfig.LevelUpPool and configInfo.Level == lv then
|
|
for j = 1, #configInfo.LevelPara do
|
|
if addAllProVal[configInfo.LevelPara[j][1]] then
|
|
addAllProVal[configInfo.LevelPara[j][1]] =
|
|
addAllProVal[configInfo.LevelPara[j][1]] + configInfo.LevelPara[j][2]
|
|
else
|
|
addAllProVal[configInfo.LevelPara[j][1]] = configInfo.LevelPara[j][2]
|
|
end
|
|
end
|
|
end
|
|
|
|
local starConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.FaxiangStarConfig,"PoolId",curEuipTreaSureConfig.Star,"Level",rlv)
|
|
|
|
if starConfig then
|
|
LogError("starConfig.id=="..starConfig.Id)
|
|
local Para=starConfig.StarPara/10000
|
|
for key, value in pairs(addAllProVal) do
|
|
addEndAllProVal[key] = math.floor(value * (1 + Para))
|
|
end
|
|
end
|
|
|
|
end
|
|
local powerEndVal = HeroPowerManager.CalPower(addEndAllProVal)
|
|
return powerEndVal
|
|
end
|
|
end
|
|
|
|
|
|
|
|
return FaXiangManager |