418 lines
13 KiB
Lua
418 lines
13 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.frame = GetQuantityImageByquality(quantity)
|
||
|
-- single.name = GetLanguageStrById(itemConfig[staticId].Name)
|
||
|
single.itemConfig = itemConfig[staticId]
|
||
|
single.levelPool = currJewel.LevelUpPool
|
||
|
single.refinePool = currJewel.Star
|
||
|
single.equipType = currJewel.Type
|
||
|
local quantity = currJewel.Level
|
||
|
single.quantity = single.itemConfig.Quantity
|
||
|
-- 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.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)
|
||
|
local lvConfig = nil
|
||
|
local nexLvConfig = nil
|
||
|
--获取当前等级属性加成
|
||
|
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 = {}
|
||
|
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
|
||
|
--没有下一等级数据为已升到最高级
|
||
|
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 = info[2]
|
||
|
else
|
||
|
local skillValue = {}
|
||
|
skillValue.currValue = info[2]
|
||
|
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.GetFaXiangLevelCost(pool,lv)
|
||
|
local levelConfig=ConfigManager.GetConfigDataByDoubleKey(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()
|
||
|
|
||
|
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)
|
||
|
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
|
||
|
--精炼的属性
|
||
|
if
|
||
|
configInfo.PoolID == curEuipTreaSureConfig.RankupPool and
|
||
|
configInfo.Level == rlv
|
||
|
then
|
||
|
for j = 1, #configInfo.Property do
|
||
|
if addAllProVal[configInfo.Property[j][1]] then
|
||
|
addAllProVal[configInfo.Property[j][1]] =
|
||
|
addAllProVal[configInfo.Property[j][1]] + configInfo.Property[j][2]
|
||
|
else
|
||
|
addAllProVal[configInfo.Property[j][1]] = configInfo.Property[j][2]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
local powerEndVal = HeroPowerManager.CalPower(addAllProVal)
|
||
|
return powerEndVal
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
return FaXiangManager
|