2020-07-06 19:11:15 +08:00
|
|
|
|
EquipTreasureManager = {}
|
|
|
|
|
local this = EquipTreasureManager
|
|
|
|
|
local allTreasures = {}
|
|
|
|
|
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-05-09 13:31:21 +08:00
|
|
|
|
function this.Initialize()
|
|
|
|
|
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
|
|
|
|
|
--初始化单个宝物的数据
|
|
|
|
|
function this.InitSingleTreasureData(_singleData)
|
2020-07-06 19:11:15 +08:00
|
|
|
|
if _singleData == nil then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-07-06 19:11:15 +08:00
|
|
|
|
local single = {}
|
|
|
|
|
local staticId = _singleData.equipId
|
|
|
|
|
local currJewel = jewelConfig[staticId]
|
|
|
|
|
single.id = staticId
|
|
|
|
|
single.idDyn = _singleData.id
|
|
|
|
|
single.lv = _singleData.exp
|
|
|
|
|
single.refineLv = _singleData.rebuildLevel
|
|
|
|
|
single.maxLv = currJewel.Max[1]
|
|
|
|
|
single.maxRefineLv = currJewel.Max[2]
|
|
|
|
|
single.upHeroDid = ""
|
|
|
|
|
local quantity = currJewel.Level
|
|
|
|
|
single.quantity = quantity
|
|
|
|
|
single.race = currJewel.Race
|
|
|
|
|
single.frame = GetQuantityImageByquality(quantity)
|
|
|
|
|
single.name = itemConfig[staticId].Name
|
|
|
|
|
single.itemConfig = itemConfig[staticId]
|
|
|
|
|
single.levelPool = currJewel.LevelupPool
|
|
|
|
|
single.proIcon = GetProStrImageByProNum(currJewel.Race)
|
|
|
|
|
single.refinePool = currJewel.RankupPool
|
|
|
|
|
single.equipType = currJewel.Location
|
|
|
|
|
if currJewel.Location == 1 then
|
|
|
|
|
single.type = Language[10505]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-06 19:11:15 +08:00
|
|
|
|
single.type = Language[10506]
|
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)
|
|
|
|
|
allTreasures[_singleData.id] = single
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
--获取玩家可以穿戴的宝物
|
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 == _idDyn) and v.race == PropertyName then
|
|
|
|
|
table.insert(equips, v)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
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-07-06 19:11:15 +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 不显示最低品质)
|
2020-07-06 19:11:15 +08:00
|
|
|
|
if jewel.Race == _index and jewel.Level > 2 then
|
|
|
|
|
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
|
|
|
|
|
treasure.name = itemConfig[Id].Name
|
|
|
|
|
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
|
|
|
|
|
treasure.name = itemConfig[Id].Name
|
|
|
|
|
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)
|
|
|
|
|
return a.race < b.race
|
|
|
|
|
end
|
|
|
|
|
)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
return list
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取所有可以合成宝物的数据
|
|
|
|
|
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
|
|
|
|
|
v.id == equipSData.Id - 1
|
|
|
|
|
then
|
|
|
|
|
table.insert(equips, v)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return equips
|
|
|
|
|
end
|
|
|
|
|
--获取可以合成宝物的数量根据宝物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)
|
2020-07-06 19:11:15 +08:00
|
|
|
|
if v.equipType == _type and v.upHeroDid == "" and v.lv == 0 and v.refineLv == 0 and v.id == _id then
|
|
|
|
|
table.insert(equips, v)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return LengthOfTable(equips)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取当前等级加成的属性
|
2020-07-06 19:11:15 +08:00
|
|
|
|
function this.GetCurLvPropertyValue(_type, _id, _lv)
|
|
|
|
|
local lvConfig = 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 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 info[2] ~= 0 then
|
|
|
|
|
proList[index] = skillValue
|
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
|
|
|
|
|
|
2020-07-06 19:11:15 +08:00
|
|
|
|
if v.id == _id and v.idDyn ~= _idDyn and v.lv == 0 and v.refineLv == 0 and isUpHero == false then
|
|
|
|
|
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
|
2020-07-13 15:00:07 +08:00
|
|
|
|
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)
|
2020-07-13 15:00:07 +08:00
|
|
|
|
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
|
2020-07-13 15:00:07 +08:00
|
|
|
|
(value.upHeroDid == "" or value.upHeroDid == "0" ) and jewelConfig[value.id].Location == Location and
|
2020-07-06 19:11:15 +08:00
|
|
|
|
jewelConfig[value.id].Race == PropertyName
|
|
|
|
|
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)
|
|
|
|
|
if PropertyName then
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local curAllEquipTreasure = {}
|
|
|
|
|
for key, value in pairs(allTreasures) do
|
2020-07-13 15:00:07 +08:00
|
|
|
|
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 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
|
|
|
|
|
else
|
|
|
|
|
return a.lv > b.lv
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
else
|
2020-07-06 19:11:15 +08:00
|
|
|
|
return a.quantity > b.quantity
|
2020-05-15 16:52:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-06 19:11:15 +08:00
|
|
|
|
)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
return curAllEquipTreasure
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return curAllEquipTreasure
|
|
|
|
|
end
|
|
|
|
|
--改变宝物的等级或精炼等级
|
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)
|
|
|
|
|
else
|
|
|
|
|
if _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-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
|
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
|
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
|
|
|
|
|
|
|
|
|
|
--计算战斗力
|
2020-07-06 19:11:15 +08:00
|
|
|
|
function this.CalculateWarForceBySid(sId, lv, rlv)
|
|
|
|
|
return this.CalculateWarForceBase(sId, lv, rlv)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--计算战斗力
|
2020-07-06 19:11:15 +08:00
|
|
|
|
function this.CalculateWarForce(Did)
|
|
|
|
|
local curTreasure = allTreasures[Did]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if curTreasure then
|
2020-07-06 19:11:15 +08:00
|
|
|
|
return this.CalculateWarForceBase(curTreasure.id, curTreasure.lv, curTreasure.refineLv)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-07-06 19:11:15 +08:00
|
|
|
|
function this.CalculateWarForceBase(sId, lv, rlv)
|
|
|
|
|
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
|
|
|
|
|
end
|
2020-07-06 19:11:15 +08:00
|
|
|
|
local heroPropertyScore = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.PropertyConfig)) do
|
2020-07-06 19:11:15 +08:00
|
|
|
|
heroPropertyScore[i] = v.Score
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-07-06 19:11:15 +08:00
|
|
|
|
local powerEndVal = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i, v in pairs(addAllProVal) do
|
|
|
|
|
if v > 0 then
|
2020-07-06 19:11:15 +08:00
|
|
|
|
local curProConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, i)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if curProConfigData then
|
|
|
|
|
if curProConfigData.Style == 1 then
|
2020-07-06 19:11:15 +08:00
|
|
|
|
powerEndVal = powerEndVal + v * heroPropertyScore[i]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2020-07-06 19:11:15 +08:00
|
|
|
|
powerEndVal = powerEndVal + v / 100 * heroPropertyScore[i]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return math.floor(powerEndVal)
|
|
|
|
|
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 = {}
|
|
|
|
|
--先把回溯英雄放进去
|
|
|
|
|
for i, v in pairs(selectEquipTreasureData) do
|
|
|
|
|
local curEquipTreasureData = allTreasures[i]
|
|
|
|
|
if not curEquipTreasureData then return end
|
|
|
|
|
--先把精炼的材料放进去 因为有宝器 放前边
|
|
|
|
|
if curEquipTreasureData.refineLv > 0 then
|
|
|
|
|
local refineJewelRankupConfig =ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.JewelRankupConfig,"Type",2,"Level",curEquipTreasureData.refineLv)
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
local lvJewelRankupConfig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.JewelRankupConfig,"Type",2,"Level", curEquipTreasureData.lv)
|
|
|
|
|
if lvJewelRankupConfig then
|
|
|
|
|
--强化消耗的材料
|
|
|
|
|
if lvJewelRankupConfig.UpExpend then
|
|
|
|
|
for UpExpendkey, UpExpendvalue in ipairs(lvJewelRankupConfig.UpExpend) do
|
|
|
|
|
this.GetEquipTreasureResolveItems2(UpExpendvalue[1], UpExpendvalue[2])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--加自身分解消耗的东西
|
|
|
|
|
local rewardShowStr1 = {}
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
2020-07-10 19:13:29 +08:00
|
|
|
|
return EquipTreasureManager
|