miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/EquipTreasureManager.lua

807 lines
28 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
EquipTreasureManager = {}
2020-07-06 19:11:15 +08:00
local this = EquipTreasureManager
local allTreasures = {}
2021-05-14 19:11:40 +08:00
local otherTreaures = {}
2020-07-06 19:11:15 +08:00
local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig)
2020-05-09 13:31:21 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2020-07-06 19:11:15 +08:00
local jewerLevelUpConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig)
2020-12-17 10:41:00 +08:00
local EquipTreasureData = require("Modules.RoleInfo.EquipTreasureData")
2020-05-09 13:31:21 +08:00
function this.Initialize()
this.TreasurePowerData = {}
2020-05-09 13:31:21 +08:00
end
--初始化所有宝器数据
function this.InitAllEquipTreasure(_equipData)
2020-07-06 19:11:15 +08:00
if _equipData == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
for i = 1, #_equipData do
2020-05-09 13:31:21 +08:00
this.InitSingleTreasureData(_equipData[i])
end
end
--初始化单个宝物的数据
2021-05-14 19:11:40 +08:00
function this.InitSingleTreasureData(_singleData,notAdd)
2020-07-06 19:11:15 +08:00
if _singleData == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-12-17 10:41:00 +08:00
local single = EquipTreasureData.new(_singleData)
2020-07-06 19:11:15 +08:00
local staticId = _singleData.equipId
local currJewel = jewelConfig[staticId]
2021-01-15 10:26:56 +08:00
single.equipType = currJewel.Location
2020-07-06 19:11:15 +08:00
single.id = staticId
single.idDyn = _singleData.id
single.lv = _singleData.exp
single.refineLv = _singleData.rebuildLevel
2022-09-06 10:16:57 +08:00
single.fourSpirit=_singleData.fourSpirit
2020-07-06 19:11:15 +08:00
single.maxLv = currJewel.Max[1]
single.maxRefineLv = currJewel.Max[2]
single.maxTreeLv = currJewel.GodHoodMaxlv
2023-11-30 20:17:27 +08:00
single.treeLv=0 --_singleData.treeLv <= single.maxTreeLv and _singleData.treeLv or single.maxTreeLv
2020-07-06 19:11:15 +08:00
single.upHeroDid = ""
2021-03-15 19:14:30 +08:00
single.fourTotal = MonsterCampManager.GetFourElementTotalWave()
2020-07-06 19:11:15 +08:00
local quantity = currJewel.Level
single.quantity = quantity
single.race = currJewel.Race
single.frame = GetQuantityImageByquality(quantity)
2021-01-26 17:08:39 +08:00
single.name = GetLanguageStrById(itemConfig[staticId].Name)
2020-07-06 19:11:15 +08:00
single.itemConfig = itemConfig[staticId]
single.levelPool = currJewel.LevelupPool
single.proIcon = GetProStrImageByProNum(currJewel.Race)
2021-03-15 19:14:30 +08:00
single.refinePool = currJewel.RankupPool
2020-12-15 17:27:16 +08:00
single.treePool = currJewel.GodHoodPool
2020-07-06 19:11:15 +08:00
single.equipType = currJewel.Location
if currJewel.Location == 1 then
2021-03-02 16:53:12 +08:00
single.type = Language[10552]
2020-05-09 13:31:21 +08:00
else
2021-03-02 16:53:12 +08:00
single.type = Language[10553]
2020-05-09 13:31:21 +08:00
end
2020-07-06 19:11:15 +08:00
single.icon = GetResourcePath(itemConfig[staticId].ResourceID)
single.strongConfig = this.GetCurrTreasureLvConfig(1, currJewel.LevelupPool, _singleData.exp)
single.refineConfig = this.GetCurrTreasureLvConfig(2, currJewel.RankupPool, _singleData.rebuildLevel)
2021-05-14 19:11:40 +08:00
if notAdd then
return single
else
allTreasures[_singleData.id] = single
end
2020-05-09 13:31:21 +08:00
end
2020-08-25 16:23:41 +08:00
2020-05-09 13:31:21 +08:00
--获取玩家可以穿戴的宝物
2020-07-06 19:11:15 +08:00
function this.GetTreasureDataByPos(_pos, _idDyn, PropertyName)
2020-05-09 13:31:21 +08:00
local equips = {}
for i, v in pairs(allTreasures) do
2020-07-06 19:11:15 +08:00
if v.equipType == _pos - 4 then
if (v.upHeroDid == "" or v.upHeroDid == 0) and v.race == PropertyName then
2020-12-15 17:27:16 +08:00
v.treeLv = 0
2020-07-06 19:11:15 +08:00
table.insert(equips, v)
2020-05-09 13:31:21 +08:00
end
end
end
return equips
end
2021-07-23 19:12:42 +08:00
--获取玩家穿戴的宝物
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
2021-07-23 19:12:42 +08:00
else
table.insert(equips, v)
end
end
return equips
end
2020-06-30 18:59:44 +08:00
function this.OpenTreasure(star)
2020-07-06 19:11:15 +08:00
local config = ConfigManager.GetConfigData(40)
local configs = string.split(config.Value, "|")
for i = 1, #configs do
if string.split(configs[i], "#")[1] == 1 then --玩家等级
return PlayerManager.level >= string.split(configs[i], "#")[2]
2020-07-01 10:54:39 +08:00
end
2020-07-06 19:11:15 +08:00
if string.split(configs[i], "#")[2] and string.split(configs[i], "#")[2] == 2 then --英雄星级
return star >= string.split(configs[i], "#")[2]
2020-07-01 10:54:39 +08:00
end
end
2020-06-30 18:59:44 +08:00
end
2020-05-09 13:31:21 +08:00
--获取当前宝物升级数据
2020-08-26 21:37:19 +08:00
function this.GetCurrTreasureLvConfig(_type, _id, _lv)
2020-05-09 13:31:21 +08:00
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
2020-07-06 19:11:15 +08:00
if configInfo.Type == _type and configInfo.PoolID == _id and configInfo.Level == _lv then
2020-05-09 13:31:21 +08:00
return configInfo
end
end
end
2020-06-30 18:59:44 +08:00
2020-05-09 13:31:21 +08:00
--获取当前等级的基础属性/精炼属性
2020-07-06 19:11:15 +08:00
function this.GetCurrLvAndNextLvPropertyValue(_type, _id, _lv)
local lvConfig = nil
local nexLvConfig = nil
2020-05-09 13:31:21 +08:00
--获取当前等级属性加成
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
2020-07-06 19:11:15 +08:00
if configInfo.Type == _type and configInfo.PoolID == _id and configInfo.Level == _lv then
lvConfig = configInfo
2020-05-09 13:31:21 +08:00
break
end
end
--获取下一等级属性加成
2020-07-06 19:11:15 +08:00
local nextLv = _lv + 1
2020-05-09 13:31:21 +08:00
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
2020-07-06 19:11:15 +08:00
if configInfo.Type == _type and configInfo.PoolID == _id and configInfo.Level == nextLv then
nexLvConfig = configInfo
2020-05-09 13:31:21 +08:00
break
end
end
2020-07-06 19:11:15 +08:00
local proList = {}
if lvConfig then
2020-05-09 13:31:21 +08:00
for i = 1, table.getn(lvConfig.Property) do
2020-07-06 19:11:15 +08:00
local info = lvConfig.Property[i]
2020-05-09 13:31:21 +08:00
if info then
2020-07-06 19:11:15 +08:00
local index = info[1]
local skillValue = {}
skillValue.currValue = info[2]
proList[index] = skillValue
2020-05-09 13:31:21 +08:00
end
end
end
2020-07-06 19:11:15 +08:00
--没有下一等级数据为已升到最高级
2020-05-09 13:31:21 +08:00
if nexLvConfig then
2020-07-06 19:11:15 +08:00
--最高级显示
2020-05-09 13:31:21 +08:00
for i = 1, table.getn(nexLvConfig.Property) do
2020-07-06 19:11:15 +08:00
local info = nexLvConfig.Property[i]
2020-05-09 13:31:21 +08:00
if info then
2020-07-06 19:11:15 +08:00
if proList[info[1]] then
proList[info[1]].nextValue = info[2]
2020-05-09 13:31:21 +08:00
else
2020-07-06 19:11:15 +08:00
local skillValue = {}
skillValue.currValue = info[2]
proList[info[1]] = skillValue
2020-05-09 13:31:21 +08:00
end
end
end
else
for i, v in pairs(proList) do
2020-07-06 19:11:15 +08:00
proList[i].nextValue = proList[i].currValue
2020-05-09 13:31:21 +08:00
end
end
return proList
end
2020-05-15 16:52:35 +08:00
--根据属性类型获取所有类型的表数据
function this.GetAllTabletTreasuresByRace(_index)
2020-07-06 19:11:15 +08:00
if jewelConfig == nil then
2020-05-15 16:52:35 +08:00
return
end
2020-07-06 19:11:15 +08:00
local list = {}
local index = 0
2020-05-15 16:52:35 +08:00
for _, configInfo in ConfigPairs(jewelConfig) do
2020-07-06 19:11:15 +08:00
local jewel = configInfo
2020-05-15 16:52:35 +08:00
if jewel then
-- 获取同类型的所有表中的数据 最低品质为2 不显示最低品质)
2023-01-13 10:46:41 +08:00
if jewel.Race == _index and jewel.Level > 3 then
2020-07-06 19:11:15 +08:00
index = index + 1
local treasure = {}
local Id = jewel.Id
treasure.Id = Id
local lv = jewel.Level
treasure.frame = GetQuantityImageByquality(lv)
2020-05-25 19:16:23 +08:00
--合成当前宝物需要的宝物id
2020-07-06 19:11:15 +08:00
treasure.lowId = Id - 1
treasure.lowFrame = GetQuantityImageByquality(lv - 1)
treasure.icon = GetResourcePath(itemConfig[Id].ResourceID)
treasure.quantity = lv
2021-01-26 17:08:39 +08:00
treasure.name = GetLanguageStrById(itemConfig[Id].Name)
2020-07-06 19:11:15 +08:00
treasure.race = lv
treasure.equipType = jewel.Location
treasure.quaUpCount = jewel.RankupCount
treasure.proIcon = GetProStrImageByProNum(jewel.Race)
treasure.costCoin = jewel.RankupResources
list[index] = treasure
2020-05-15 16:52:35 +08:00
end
end
end
2020-07-06 19:11:15 +08:00
if LengthOfTable(list) > 0 then
table.sort(
list,
function(a, b)
2020-07-14 15:54:18 +08:00
if a.race == b.race then
return a.Id < b.Id
end
2020-07-06 19:11:15 +08:00
return a.race < b.race
end
)
2020-05-15 16:52:35 +08:00
return list
end
end
--获取一键合成便利的所有宝物
function this.GetAllTabletTreasuresByRaceAndType(_index, _Location)
2020-07-06 19:11:15 +08:00
if jewelConfig == nil then
2020-05-15 16:52:35 +08:00
return
end
2020-07-06 19:11:15 +08:00
local list = {}
local index = 0
2020-05-15 16:52:35 +08:00
for _, configInfo in ConfigPairs(jewelConfig) do
2020-07-06 19:11:15 +08:00
local jewel = configInfo
2020-05-15 16:52:35 +08:00
if jewel then
-- 获取同类型的所有表中的数据 最低品质为2 不显示最低品质)
2020-07-06 19:11:15 +08:00
if
jewel.Race == _index and jewel.Level > 2 and
((_Location and jewel.Location == _Location) or not _Location)
then
index = index + 1
local treasure = {}
local Id = jewel.Id
treasure.Id = Id
local lv = jewel.Level
treasure.frame = GetQuantityImageByquality(lv)
treasure.lowFrame = GetQuantityImageByquality(lv - 1)
treasure.icon = GetResourcePath(itemConfig[Id].ResourceID)
treasure.quantity = lv
2021-01-26 17:08:39 +08:00
treasure.name = GetLanguageStrById(itemConfig[Id].Name)
2020-07-06 19:11:15 +08:00
treasure.race = lv
treasure.equipType = jewel.Location
treasure.quaUpCount = jewel.RankupCount
treasure.proIcon = GetProStrImageByProNum(jewel.Race)
treasure.costCoin = jewel.RankupResources
list[index] = treasure
2020-05-15 16:52:35 +08:00
end
end
end
2020-07-06 19:11:15 +08:00
if LengthOfTable(list) > 0 then
table.sort(
list,
function(a, b)
if a.race == b.race then
return a.Id < b.Id
else
return a.race < b.race
end
2020-07-06 19:11:15 +08:00
end
)
2020-05-15 16:52:35 +08:00
return list
end
end
--获取所有可以合成宝物的数据
function this.GeEquipTreasureDatas(_index)
local equips = {}
for i=1, 2 do
if not equips[i] then
equips[i] = {}
end
for j=2, 6 do
equips[i][j] = 0
end
end
for i, v in pairs(allTreasures) do
2022-09-07 14:08:01 +08:00
if v.upHeroDid == "" and v.lv == 0 and v.refineLv == 0 and v.treeLv == 0 and v.race == _index then
if not equips[v.equipType] then
equips[v.equipType] = {}
end
if not equips[v.equipType][v.quantity] then
equips[v.equipType][v.quantity] = 1
else
equips[v.equipType][v.quantity] = equips[v.equipType][v.quantity] + 1
end
end
end
return equips
end
2020-05-15 16:52:35 +08:00
--获取所有可以合成宝物的数据
function this.GetBagCompoundEquipDatasByequipSData(equipSData)
local equips = {}
for i, v in pairs(allTreasures) do
--获取没有穿戴,没有精炼/强化低一个品质表里低一个品质的id-1
2020-07-06 19:11:15 +08:00
if
v.equipType == equipSData.equipType and v.upHeroDid == "" and v.quantity == equipSData.quantity - 1 and
v.lv == 0 and
v.refineLv == 0 and
2022-09-07 14:08:01 +08:00
v.treeLv == 0 and
2020-07-06 19:11:15 +08:00
v.id == equipSData.Id - 1
then
table.insert(equips, v)
2020-05-15 16:52:35 +08:00
end
end
return equips
end
2020-05-15 16:52:35 +08:00
--获取可以合成宝物的数量根据宝物id
2020-07-06 19:11:15 +08:00
function this.GetCanCompoundTreasureNumByTreasureId(_id, _type)
2020-05-15 16:52:35 +08:00
local equips = {}
for i, v in pairs(allTreasures) do
--获取没有穿戴,没有精炼/强化低一个品质表里低一个品质的id-1
2022-09-07 14:08:01 +08:00
if v.equipType == _type and v.upHeroDid == "" and v.lv == 0 and v.refineLv == 0 and v.treeLv == 0 and v.id == _id then
2020-07-06 19:11:15 +08:00
table.insert(equips, v)
2020-05-15 16:52:35 +08:00
end
end
return LengthOfTable(equips)
end
--获取当前等级加成的属性
function this.GetCurLvPropertyValue(_type, _id, _lv, _isShow)
2020-07-06 19:11:15 +08:00
local lvConfig = nil
local isShow = _isShow == true
2020-05-09 13:31:21 +08:00
--获取当前等级属性加成
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
2020-07-06 19:11:15 +08:00
if configInfo.Type == _type and configInfo.PoolID == _id and configInfo.Level == _lv then
lvConfig = configInfo
2020-05-09 13:31:21 +08:00
break
end
end
2020-07-06 19:11:15 +08:00
local proList = {}
if lvConfig then
2020-05-09 13:31:21 +08:00
for i = 1, table.getn(lvConfig.Property) do
2020-07-06 19:11:15 +08:00
local info = lvConfig.Property[i]
2020-05-09 13:31:21 +08:00
if info then
2020-07-06 19:11:15 +08:00
local index = info[1]
local skillValue = {}
skillValue.currValue = info[2]
if isShow then
2020-07-06 19:11:15 +08:00
proList[index] = skillValue
else
if info[2] ~= 0 then
proList[index] = skillValue
end
2020-05-09 13:31:21 +08:00
end
end
end
end
2020-07-06 19:11:15 +08:00
return proList
2020-05-09 13:31:21 +08:00
end
--获取满足升级条件的宝物
2020-07-06 19:11:15 +08:00
function this.GetEnoughRefineTreasure(_id, _idDyn)
if allTreasures == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
local num = 0
local list = {}
2020-05-09 13:31:21 +08:00
for i, v in pairs(allTreasures) do
2020-07-06 19:11:15 +08:00
local isUpHero = false
if v.upHeroDid == "" or v.upHeroDid == nil then
isUpHero = false
2020-05-09 13:31:21 +08:00
else
2020-07-06 19:11:15 +08:00
isUpHero = true
2020-05-09 13:31:21 +08:00
end
2022-09-07 14:08:01 +08:00
if v.id == _id and v.idDyn ~= _idDyn and v.lv == 0 and v.refineLv == 0 and v.treeLv == 0 and isUpHero == false then
2020-07-06 19:11:15 +08:00
list[i] = v
num = num + 1
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 19:11:15 +08:00
return list, num
2020-05-09 13:31:21 +08:00
end
function this.RemoveTreasureByIdDyn(_idDyn)
2020-07-06 19:11:15 +08:00
if allTreasures == nil then
2020-05-09 13:31:21 +08:00
return
end
if allTreasures[_idDyn] then
2020-07-06 19:11:15 +08:00
allTreasures[_idDyn] = nil
2020-05-09 13:31:21 +08:00
end
end
--获取所有宝物 不算英雄身上穿的 通过稀有度
function this.GetAllTreasuresByQuantity(Quantity)
local curAllEquipTreasure = {}
for key, value in pairs(allTreasures) do
if (value.upHeroDid == "" or value.upHeroDid == "0") and value.itemConfig.Quantity == Quantity then
2020-07-06 19:11:15 +08:00
table.insert(curAllEquipTreasure, value)
elseif (value.upHeroDid == "" or value.upHeroDid == "0") and Quantity == 1 then --1 全部
2020-07-06 19:11:15 +08:00
table.insert(curAllEquipTreasure, value)
2020-05-09 13:31:21 +08:00
end
end
return curAllEquipTreasure
end
--获取所有宝物 不算英雄身上穿的 通过稀有度
2020-07-06 19:11:15 +08:00
function this.GetAllTreasuresByLocation(Location, PropertyName)
2020-05-09 13:31:21 +08:00
local curAllEquipTreasure = {}
2020-07-06 19:11:15 +08:00
for key, value in pairs(allTreasures) do
if
2021-07-24 19:36:34 +08:00
(value.upHeroDid == "" or value.upHeroDid == "0" ) and (Location == 0 or jewelConfig[value.id].Location == Location) and
2023-04-19 13:49:21 +08:00
(PropertyName==0 or jewelConfig[value.id].Race == PropertyName)
2020-07-06 19:11:15 +08:00
then
table.insert(curAllEquipTreasure, value)
2020-05-09 13:31:21 +08:00
end
end
return curAllEquipTreasure
end
--获取所有宝物 不算英雄身上穿的
2020-06-13 11:47:13 +08:00
function this.GetAllTreasures(PropertyName)
2020-05-09 13:31:21 +08:00
local curAllEquipTreasure = {}
for key, value in pairs(allTreasures) do
if value.upHeroDid == "" or value.upHeroDid == "0" then
2020-06-13 11:47:13 +08:00
if PropertyName then
if jewelConfig[value.id].Race == PropertyName or PropertyName == 0 then
2020-07-06 19:11:15 +08:00
table.insert(curAllEquipTreasure, value)
2020-06-13 11:47:13 +08:00
end
else
2020-07-06 19:11:15 +08:00
table.insert(curAllEquipTreasure, value)
2020-06-13 11:47:13 +08:00
end
2020-05-09 13:31:21 +08:00
end
end
2020-07-06 19:11:15 +08:00
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
2020-05-15 16:52:35 +08:00
else
return a.lv > b.lv
2020-05-15 16:52:35 +08:00
end
else
return a.quantity > b.quantity
2020-05-15 16:52:35 +08:00
end
end)
2020-05-15 16:52:35 +08:00
return curAllEquipTreasure
end
2020-05-09 13:31:21 +08:00
return curAllEquipTreasure
end
--改变宝物神应等级
function this.ChangeTreeLv()
for i, v in pairs(allTreasures) do
v.treeLv = v.TreeLv()
end
end
2022-09-07 10:14:05 +08:00
--改变宝物的等级或精炼等级或神应等级
2020-07-06 19:11:15 +08:00
function this.ChangeTreasureLv(_idDyn, _type)
if allTreasures == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
if allTreasures[_idDyn] == nil then
2020-05-09 13:31:21 +08:00
return
end
if allTreasures[_idDyn] then
2020-07-06 19:11:15 +08:00
if _type == 1 then
if allTreasures[_idDyn].lv == allTreasures[_idDyn].maxLv then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
local lv = allTreasures[_idDyn].lv + 1
allTreasures[_idDyn].lv = lv
allTreasures[_idDyn].strongConfig = this.GetCurrTreasureLvConfig(1, allTreasures[_idDyn].levelPool, lv)
2022-09-07 10:14:05 +08:00
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)
2020-07-06 19:11:15 +08:00
else
2022-09-07 11:40:13 +08:00
--改变神应等级
2022-09-07 10:14:05 +08:00
if allTreasures[_idDyn] then
allTreasures[_idDyn].treeLv=allTreasures[_idDyn].treeLv+1
2020-05-09 13:31:21 +08:00
end
end
end
end
--设置宝物的穿戴卸下 (第二个参数传nil为卸下)
2020-07-06 19:11:15 +08:00
function this.SetTreasureUpOrDown(_idDyn, _hero)
2020-05-09 13:31:21 +08:00
if allTreasures[_idDyn] then
2020-07-06 19:11:15 +08:00
allTreasures[_idDyn].upHeroDid = _hero
2022-09-06 10:16:57 +08:00
-- allTreasures[_idDyn].treeLv = SacredTreeManager.treeLevel <= allTreasures[_idDyn].maxTreeLv and
-- SacredTreeManager.treeLevel or allTreasures[_idDyn].maxTreeLv
2020-05-09 13:31:21 +08:00
end
end
--根据id删除宝物
function this.DeleteTreasureByIdDyn(_idDyn)
if allTreasures then
2020-07-06 19:11:15 +08:00
allTreasures[_idDyn] = nil
2020-05-09 13:31:21 +08:00
end
end
--设置装备穿戴的英雄
2020-07-06 19:11:15 +08:00
function this.SetEquipTreasureUpHeroDid(_equipTreasureDid, _heroDid)
2020-05-09 13:31:21 +08:00
if allTreasures[_equipTreasureDid] then
2020-07-06 19:11:15 +08:00
allTreasures[_equipTreasureDid].upHeroDid = _heroDid
2022-09-06 10:16:57 +08:00
-- allTreasures[_equipTreasureDid].treeLv = SacredTreeManager.treeLevel <= allTreasures[_equipTreasureDid].maxTreeLv and
-- SacredTreeManager.treeLevel or allTreasures[_equipTreasureDid].maxTreeLv
2020-05-09 13:31:21 +08:00
end
end
--设置装备穿戴的英雄
function this.GetSingleEquipTreasreData(_equipTreasureDid)
if allTreasures[_equipTreasureDid] then
return allTreasures[_equipTreasureDid]
else
return nil
end
end
--根据动态id获取宝物
function this.GetSingleTreasureByIdDyn(_idDyn)
2020-07-06 19:11:15 +08:00
if allTreasures == nil then
2020-05-09 13:31:21 +08:00
return
end
return allTreasures[_idDyn]
end
--根据动态id获取宝物
function this.GetTreasuresBydIds(ids)
local list = {}
if allTreasures then
for _, did in ipairs(ids) do
local treasure = allTreasures[did]
-- 没有数据尝试去大闹天宫获取
if not treasure then
treasure = ExpeditionManager.GetSingleTreasureByIdDyn(did)
end
if treasure then
table.insert(list, treasure)
end
end
end
return list
end
2020-05-09 13:31:21 +08:00
--计算战斗力
2020-12-15 17:27:16 +08:00
function this.CalculateWarForceBySid(sId, lv, rlv, tlv)
return this.CalculateWarForceBase(sId, lv, rlv, tlv)
2020-05-09 13:31:21 +08:00
end
--计算战斗力
2020-07-06 19:11:15 +08:00
function this.CalculateWarForce(Did)
-- Log("CalculateWarForce "..Did)
local power = 0
if this.IsTreasureDirty(Did) then
local curTreasure = allTreasures[Did]
if not curTreasure then
curTreasure = MonsterCampManager.GetSingleTreasureByIdDyn(Did)
end
if not curTreasure then
curTreasure = ExpeditionManager.GetSingleTreasureByIdDyn(Did)
end
if not curTreasure then
curTreasure = GoodFriendManager.GetSingleTreasureByIdDyn(Did)
end
if curTreasure then
power = this.CalculateWarForceBase(curTreasure.id, curTreasure.lv, curTreasure.refineLv, curTreasure.treeLv,curTreasure)
end
this.SetTreasurePower(Did, power)
this.SetTreasureDirty(Did, false)
else
if this.TreasurePowerData and this.TreasurePowerData[Did] then
power = this.TreasurePowerData[Did].power or 0
end
end
return power
end
-- 判断脏数据
function this.IsTreasureDirty(dId)
if not this.TreasurePowerData then
this.TreasurePowerData = {}
end
if not this.TreasurePowerData[dId] then
this.TreasurePowerData[dId] = {}
end
return this.TreasurePowerData[dId].isDirty ~= false
end
-- 设置脏数据
function this.SetTreasureDirty(dId, isDirty)
if not this.TreasurePowerData then
this.TreasurePowerData = {}
2021-08-30 18:09:06 +08:00
end
if not this.TreasurePowerData[dId] then
this.TreasurePowerData[dId] = {}
2021-08-30 18:09:06 +08:00
end
this.TreasurePowerData[dId].isDirty = isDirty ~= false
end
-- 设置脏数据
function this.SetAllTreasureDirty(isDirty)
if this.TreasurePowerData then
for did, data in pairs(this.TreasurePowerData) do
this.TreasurePowerData[did].isDirty = true
end
end
end
-- 设置宝物战斗力
function this.SetTreasurePower(dId, power)
if not this.TreasurePowerData then
this.TreasurePowerData = {}
2021-08-30 18:09:06 +08:00
end
if not this.TreasurePowerData[dId] then
this.TreasurePowerData[dId] = {}
2020-05-09 13:31:21 +08:00
end
this.TreasurePowerData[dId].power = power or 0
2020-05-09 13:31:21 +08:00
end
2021-08-31 18:07:34 +08:00
function this.CalculateWarForceBase(sId, lv, rlv, tlv,curTreasure)
-- LogGreen("sId:"..sId.." lv:"..lv.." rlv:"..rlv.." tlv:"..tlv)
2020-07-06 19:11:15 +08:00
local curEuipTreaSureConfig = ConfigManager.GetConfigData(ConfigName.JewelConfig, sId)
2020-05-09 13:31:21 +08:00
if curEuipTreaSureConfig then
local addAllProVal = {}
--主属性
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
--强化的属性
2020-07-06 19:11:15 +08:00
if
configInfo.PoolID == curEuipTreaSureConfig.LevelupPool and configInfo.Type == 1 and
configInfo.Level == lv
then
2020-05-09 13:31:21 +08:00
for j = 1, #configInfo.Property do
if addAllProVal[configInfo.Property[j][1]] then
2020-07-06 19:11:15 +08:00
addAllProVal[configInfo.Property[j][1]] =
addAllProVal[configInfo.Property[j][1]] + configInfo.Property[j][2]
2020-05-09 13:31:21 +08:00
else
addAllProVal[configInfo.Property[j][1]] = configInfo.Property[j][2]
end
end
end
--精炼的属性
2020-07-06 19:11:15 +08:00
if
configInfo.PoolID == curEuipTreaSureConfig.RankupPool and configInfo.Type == 2 and
configInfo.Level == rlv
then
2020-05-09 13:31:21 +08:00
for j = 1, #configInfo.Property do
if addAllProVal[configInfo.Property[j][1]] then
2020-07-06 19:11:15 +08:00
addAllProVal[configInfo.Property[j][1]] =
addAllProVal[configInfo.Property[j][1]] + configInfo.Property[j][2]
2020-05-09 13:31:21 +08:00
else
addAllProVal[configInfo.Property[j][1]] = configInfo.Property[j][2]
end
end
end
2024-01-03 15:24:49 +08:00
--注释神应属性 功能已屏蔽
--神应属性
2024-01-03 15:24:49 +08:00
-- if
-- configInfo.PoolID == curEuipTreaSureConfig.GodHoodPool and configInfo.Type == 3 and
-- configInfo.Level == tlv
-- then
-- for j = 1, SacredTreeManager.CulAttri(curTreasure) 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
2020-05-09 13:31:21 +08:00
end
local powerEndVal = HeroPowerManager.CalPower(addAllProVal)
return powerEndVal
2020-05-09 13:31:21 +08:00
end
end
--获取宝物升级消耗
2020-07-06 19:11:15 +08:00
function this.GetTreasureUpLvCostMatrial(_id, _lv)
local currJewel = jewelConfig[_id]
if currJewel == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
local lvConfig = nil
2020-05-09 13:31:21 +08:00
--获取当前等级属性加成
local lvList
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
2020-07-06 19:11:15 +08:00
if configInfo.Type == 2 and configInfo.PoolID == currJewel.RankupPool and configInfo.Level < _lv then
lvList[configInfo.Level] = configInfo
2020-05-09 13:31:21 +08:00
break
end
end
2020-07-06 19:11:15 +08:00
if lvList == nil then
2020-05-09 13:31:21 +08:00
return
end
2020-07-06 19:11:15 +08:00
local idList = {}
2020-05-09 13:31:21 +08:00
for i, v in pairs(lvList) do
2020-07-06 19:11:15 +08:00
local cost = v.JewelExpend
2020-05-09 13:31:21 +08:00
if cost then
for i = 1, cost do
for i = 1, cost[i][2] do
2020-07-06 19:11:15 +08:00
if cost[i][1] == 1 then
table.insert(idList, currJewel.Id)
2020-05-09 13:31:21 +08:00
else
2020-07-06 19:11:15 +08:00
table.insert(idList, cost[i][1])
2020-05-09 13:31:21 +08:00
end
end
end
end
end
2020-07-06 19:11:15 +08:00
return idList
2020-05-09 13:31:21 +08:00
end
2020-07-06 19:11:15 +08:00
--宝器分解返回item信息
local rewardGroup = ConfigManager.GetConfig(ConfigName.RewardGroup)
local ShowItemlist = {}
function this.GetEquipTreasureResolveItems(selectEquipTreasureData)
local allRewardData = {}
local specificValue = 1--tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,34).Value)/10000
ShowItemlist = {}
2020-07-17 14:15:42 +08:00
LogBlue(LengthOfTable(selectEquipTreasureData))
2020-07-06 19:11:15 +08:00
for i, v in pairs(selectEquipTreasureData) do
local curEquipTreasureData = allTreasures[i]
if not curEquipTreasureData then return end
2020-08-24 16:29:27 +08:00
--先把精炼的材料放进去 因为有宝器 放前边
2020-07-06 19:11:15 +08:00
if curEquipTreasureData.refineLv > 0 then
2020-07-16 10:49:01 +08:00
for i=0,curEquipTreasureData.refineLv-1 do
2020-07-17 14:15:42 +08:00
local refineJewelRankupConfig =ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",2,"Level",i,"PoolID",curEquipTreasureData.refinePool)
2020-07-16 10:49:01 +08:00
if refineJewelRankupConfig then
--精炼消耗的法宝
if refineJewelRankupConfig.JewelExpend then
for JewelExpendkey, JewelExpendvalue in ipairs(refineJewelRankupConfig.JewelExpend) do
if JewelExpendvalue[1] == 1 then
this.GetEquipTreasureResolveItems2(curEquipTreasureData.id, JewelExpendvalue[2])
elseif JewelExpendvalue[1] > 1 then
this.GetEquipTreasureResolveItems2(JewelExpendvalue[1], JewelExpendvalue[2])
end
2020-07-06 19:11:15 +08:00
end
end
--精炼消耗的材料
if refineJewelRankupConfig.UpExpend then
for UpExpendkey, UpExpendvalue in ipairs(refineJewelRankupConfig.UpExpend) do
this.GetEquipTreasureResolveItems2(UpExpendvalue[1], UpExpendvalue[2])
end
end
end
end
end
if curEquipTreasureData.lv > 0 then
2020-07-16 10:49:01 +08:00
for i=0,curEquipTreasureData.lv - 1 do
2022-09-07 10:14:05 +08:00
local lvJewelRankupConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",1,"Level",i,"PoolID",curEquipTreasureData.levelPool)
if lvJewelRankupConfig then
--强化消耗的材料
if lvJewelRankupConfig.UpExpend then
for UpExpendkey, UpExpendvalue in ipairs(lvJewelRankupConfig.UpExpend) do
this.GetEquipTreasureResolveItems2(UpExpendvalue[1], UpExpendvalue[2])
end
2020-07-06 19:11:15 +08:00
end
end
end
end
2022-09-07 10:14:05 +08:00
if curEquipTreasureData.treeLv > 0 then
local treeLvConfig= ConfigManager.GetConfig(ConfigName.GodHoodTreeLevel)
for i = 0, curEquipTreasureData.treeLv-1 do
local costConfig=treeLvConfig[i]
this.GetEquipTreasureResolveItems2(costConfig.LvupCost[1], costConfig.LvupCost[2])
end
2020-07-16 10:49:01 +08:00
end
2020-07-06 19:11:15 +08:00
--加自身分解消耗的东西
2020-10-12 15:54:05 +08:00
-- local rewardShowStr1 = {}
2022-09-07 10:25:38 +08:00
if curEquipTreasureData.refineLv <= 0 and curEquipTreasureData.lv <= 0 and curEquipTreasureData.treeLv <= 0 then
2020-10-12 15:54:05 +08:00
local resolveRewardStr = curEquipTreasureData.itemConfig.ResolveReward
if resolveRewardStr and rewardGroup[tonumber(resolveRewardStr)] then
local curRewardGroupData = rewardGroup[tonumber(resolveRewardStr)]
for key, curRewardGroupDatavalue in ipairs(curRewardGroupData.ShowItem) do
this.GetEquipTreasureResolveItems2(curRewardGroupDatavalue[1], curRewardGroupDatavalue[2])
end
2020-07-06 19:11:15 +08:00
end
2020-10-12 15:54:05 +08:00
else
this.GetEquipTreasureResolveItems2(curEquipTreasureData.id, 1)
2020-07-06 19:11:15 +08:00
end
end
local dropList = {}
for ShowItemlistkey, ShowItemlistvalue in pairs(ShowItemlist) do
local curReward = {}
curReward.id = ShowItemlistkey
curReward.num = math.floor(ShowItemlistvalue * specificValue)
curReward.itemConfig = itemConfig[ShowItemlistkey]
table.insert(dropList, curReward)
end
return dropList
end
function this.GetEquipTreasureResolveItems2(itemId, itemNum)
if ShowItemlist[itemId] then
ShowItemlist[itemId] = ShowItemlist[itemId] + itemNum
else
ShowItemlist[itemId] = itemNum
end
end
function this.GetTreasureData(did)
local data = EquipTreasureManager.GetSingleTreasureByIdDyn(did)
if not data then
data = MonsterCampManager.GetSingleTreasureByIdDyn(did)
end
if not data then
data = ExpeditionManager.GetSingleTreasureByIdDyn(did)
end
if not data then
data = GoodFriendManager.GetSingleTreasureByIdDyn(did)
end
return data
end
2020-07-10 19:13:29 +08:00
return EquipTreasureManager