2021-10-18 10:36:32 +08:00
|
|
|
|
GodSoulManager = {}
|
|
|
|
|
local this = GodSoulManager
|
2021-10-20 18:02:09 +08:00
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
local heroRankupGroup = ConfigManager.GetConfig(ConfigName.HeroRankupGroup)
|
|
|
|
|
local passiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
this.heroDatas = {}
|
2021-10-20 18:02:09 +08:00
|
|
|
|
this.GodSoulTableData = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
function this.Initialize()
|
2021-10-22 15:47:59 +08:00
|
|
|
|
this.InitializeTableData()
|
|
|
|
|
this.heroDatas = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.InitializeTableData()
|
2021-10-20 18:02:09 +08:00
|
|
|
|
for k,v in ConfigPairs(heroConfig) do
|
|
|
|
|
if not this.GodSoulTableData[v.Id] then
|
|
|
|
|
this.GodSoulTableData[v.Id] = {}
|
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
if not v.Soul then
|
|
|
|
|
else
|
|
|
|
|
for i = 1,#v.Soul do
|
|
|
|
|
if not this.GodSoulTableData[v.Id][v.Soul[i][1]] then
|
|
|
|
|
this.GodSoulTableData[v.Id][v.Soul[i][1]] = {}
|
|
|
|
|
for j = 1,#v.SoulSkill do
|
|
|
|
|
if v.Soul[i][1] == v.SoulSkill[j][1] then
|
|
|
|
|
this.GodSoulTableData[v.Id][v.Soul[i][1]].skill = GetSkillConfigDesc(passiveSkillConfig[v.SoulSkill[j][2]])
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
local data = {}
|
|
|
|
|
data.index = v.Soul[i][2]
|
|
|
|
|
data.num = v.Soul[i][4]
|
|
|
|
|
local config = heroRankupGroup[v.Soul[i][3]]
|
|
|
|
|
if config.Issame == 1 then
|
|
|
|
|
data.id = v.Id
|
2021-10-27 12:50:15 +08:00
|
|
|
|
data.property = 0
|
|
|
|
|
data.profession = 0
|
2021-10-22 15:47:59 +08:00
|
|
|
|
elseif config.IsId > 0 then
|
|
|
|
|
data.id = config.IsId
|
2021-10-27 12:50:15 +08:00
|
|
|
|
data.property = 0
|
|
|
|
|
data.profession = 0
|
2021-10-20 18:02:09 +08:00
|
|
|
|
else
|
2021-10-22 15:47:59 +08:00
|
|
|
|
data.id = 0
|
|
|
|
|
if config.IsSameClan == 1 then
|
|
|
|
|
data.property = v.PropertyName
|
|
|
|
|
else
|
|
|
|
|
data.property = 0
|
|
|
|
|
end
|
|
|
|
|
if config.IsSameJob == 1 then
|
|
|
|
|
data.profession = v.Profession
|
|
|
|
|
else
|
|
|
|
|
data.profession = 0
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
data.star = config.StarLimit
|
|
|
|
|
table.insert(this.GodSoulTableData[v.Id][v.Soul[i][1]],data)
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.BindHeroDatas(heroData)
|
|
|
|
|
if not this.heroDatas[heroData.id] then
|
|
|
|
|
this.heroDatas[heroData.id] = {}
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[heroData.id].BindHeroDatas then
|
2021-10-26 16:00:31 +08:00
|
|
|
|
this.heroDatas[heroData.id].BindHeroDatas = {}
|
2021-10-18 10:36:32 +08:00
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
for k,v in ipairs(heroData.godSoulList) do
|
2021-10-18 10:36:32 +08:00
|
|
|
|
if not this.heroDatas[heroData.id].BindHeroDatas[v.level] then
|
|
|
|
|
this.heroDatas[heroData.id].BindHeroDatas[v.level] = {}
|
|
|
|
|
end
|
|
|
|
|
for n,m in ipairs(v.heros) do
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if this.CheckExistBindHeroDataByDid(heroData.id,m) and this.CheckExistBindHeroDataByDid(heroData.id,m) > 0 then
|
2021-10-18 10:36:32 +08:00
|
|
|
|
else
|
|
|
|
|
table.insert(this.heroDatas[heroData.id].BindHeroDatas[v.level],m)
|
|
|
|
|
this.BingToHeroData(heroData.id,v.level,m)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
HeroPropManager.SetDirtyByType(heroData.id,Hero_Prop_Type.GodSoul)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.GetGodSoulLv(curId)
|
|
|
|
|
local level = 0
|
|
|
|
|
if not this.heroDatas[curId] then
|
|
|
|
|
return level
|
|
|
|
|
end
|
|
|
|
|
local existLevel = {}
|
|
|
|
|
local unExistLevel = {}
|
|
|
|
|
for k,v in pairs(this.heroDatas[curId].BindHeroDatas) do
|
|
|
|
|
if #v > 0 and level < k then
|
|
|
|
|
level = k
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return level
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.BingToHeroData(targetId,tarGetLv,Id)
|
|
|
|
|
if not this.heroDatas[Id] then
|
|
|
|
|
this.heroDatas[Id] = {}
|
|
|
|
|
end
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if not this.heroDatas[Id].BindToHeroDatas then
|
2021-10-18 10:36:32 +08:00
|
|
|
|
this.heroDatas[Id].BindToHeroDatas = {} --被绑定了哪些神将
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[Id].BindToHeroDatas[targetId] then
|
|
|
|
|
this.heroDatas[Id].BindToHeroDatas[targetId] = {}
|
|
|
|
|
end
|
|
|
|
|
this.heroDatas[Id].BindToHeroDatas[targetId] = tarGetLv
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测curId 是否绑定了bindId
|
|
|
|
|
function this.CheckExistBindHeroDataByDid(curId,bindId)
|
|
|
|
|
local level = 0
|
|
|
|
|
if not this.heroDatas[curId] then
|
|
|
|
|
return level
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[curId].BindHeroDatas then
|
|
|
|
|
return level
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(this.heroDatas[curId].BindHeroDatas) do
|
|
|
|
|
for n,m in ipairs(v) do
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if m == bindId then
|
2021-10-18 10:36:32 +08:00
|
|
|
|
return k
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return level
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--检测 curId 是否被 bindId 绑定
|
|
|
|
|
function this.CheckExistBindToHeroDataByDid(curId,bindId)
|
|
|
|
|
if not this.heroDatas[curId] then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[curId].BindHeroDatas then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[curId].BindToHeroDatas[bindId] or this.heroDatas[curId].BindToHeroDatas[bindId] == 0 then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
return this.heroDatas[curId].BindToHeroDatas[bindId]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--解除curId,curlv绑定的
|
2021-10-26 16:00:31 +08:00
|
|
|
|
function this.UnBindHeroDatas(curId,curlv,isOnly)
|
2021-10-18 10:36:32 +08:00
|
|
|
|
if not this.heroDatas[curId] then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[curId].BindHeroDatas then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(this.heroDatas[curId].BindHeroDatas) do
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if (k >= curlv and not isOnly) or (isOnly and k == curlv) then
|
2021-10-18 10:36:32 +08:00
|
|
|
|
for n,m in ipairs(v) do
|
|
|
|
|
this.UnBindToHeroDatas(m,curId)
|
|
|
|
|
end
|
|
|
|
|
this.heroDatas[curId].BindHeroDatas[k] = {}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
HeroPropManager.SetDirtyByType(curId,Hero_Prop_Type.GodSoul)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--解除bindId被绑定的curId
|
|
|
|
|
function this.UnBindToHeroDatas(bindId,curId)
|
|
|
|
|
if not this.heroDatas[bindId] then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[bindId].BindToHeroDatas then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[bindId].BindToHeroDatas[curId] or this.heroDatas[bindId].BindToHeroDatas[curId] == 0 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
this.heroDatas[bindId].BindToHeroDatas[curId] = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--删除一个神将
|
|
|
|
|
function this.DeleteHeroId(heroId)
|
|
|
|
|
if not this.heroDatas[heroId] then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
this.UnBindHeroDatas(heroId,1)
|
|
|
|
|
if not this.heroDatas[heroId].BindToHeroDatas then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(this.heroDatas[heroId].BindToHeroDatas) do
|
|
|
|
|
if v > 0 then
|
|
|
|
|
this.UnBindHeroDatas(k,v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
this.heroDatas[heroId] = {}
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-22 15:47:59 +08:00
|
|
|
|
--获取id,lv级绑定的神将
|
|
|
|
|
function this.GetBindHeroDatasByLevel(id,lv)
|
|
|
|
|
local data = {}
|
|
|
|
|
if not this.heroDatas[id] then
|
|
|
|
|
return data
|
|
|
|
|
end
|
|
|
|
|
if not this.heroDatas[id].BindHeroDatas then
|
|
|
|
|
return data
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(this.heroDatas[id].BindHeroDatas) do
|
|
|
|
|
if k == lv then
|
|
|
|
|
return v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return data
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取激活神魂所需的神将条件
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function this.GetGodSoulDataByLv(id,lv)
|
|
|
|
|
if lv == 0 then
|
2021-10-22 15:47:59 +08:00
|
|
|
|
return this.GodSoulTableData[id] or {}
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
if this.GodSoulTableData[id] and this.GodSoulTableData[id][lv] and #this.GodSoulTableData[id][lv] > 0 then
|
|
|
|
|
return this.GodSoulTableData[id][lv]
|
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
return {}
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-10-22 15:47:59 +08:00
|
|
|
|
--检测红点
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function this.CheckRedPointGodSoul(curHeroData)
|
2021-10-27 17:04:33 +08:00
|
|
|
|
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.shenhun)
|
|
|
|
|
or curHeroData.heroConfig.IsSoulOpen == 0 or curHeroData.star < 11 then
|
|
|
|
|
return false
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
local lv = this.GetGodSoulLv(curHeroData.dynamicId)
|
2021-10-27 17:04:33 +08:00
|
|
|
|
local isShow = this.CheckCanUpGodSoul(curHeroData,lv + 1) or false
|
|
|
|
|
return isShow
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-10-22 15:47:59 +08:00
|
|
|
|
--筛选符合条件的所有神将
|
2021-10-20 18:02:09 +08:00
|
|
|
|
function this.GetGodSoulData(curHeroData,lv)
|
|
|
|
|
local datas = HeroManager.GetAllHeroList()
|
|
|
|
|
local godData = this.GetGodSoulDataByLv(curHeroData.heroConfig.Id,lv)
|
|
|
|
|
local haveDatas = {}
|
|
|
|
|
if godData then
|
2021-10-22 15:47:59 +08:00
|
|
|
|
for k,v in pairs(datas) do
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if v.star >= 10 and curHeroData.dynamicId ~= v.dynamicId then
|
|
|
|
|
local index = -1 --无法使用
|
|
|
|
|
for j = 1,#godData do
|
|
|
|
|
local isChoosed = this.CheckExistBindHeroDataByDid(curHeroData.dynamicId,v.dynamicId)
|
|
|
|
|
--LogGreen("isChoosed:"..isChoosed.." lv:"..lv.." v.heroConfig.Id:"..v.heroConfig.Id.." index:"..index)
|
|
|
|
|
if godData[j].id > 0 and v.heroConfig.Id == godData[j].id then
|
|
|
|
|
if isChoosed and isChoosed == lv then
|
|
|
|
|
index = 666
|
|
|
|
|
elseif v.star >= godData[j].star then
|
|
|
|
|
index = 665
|
|
|
|
|
else
|
|
|
|
|
index = 664
|
|
|
|
|
end
|
|
|
|
|
break
|
|
|
|
|
elseif isChoosed > 0 and isChoosed ~= lv then
|
|
|
|
|
--LogYellow("isChoosed:"..isChoosed.." lv:"..lv.." v.heroConfig.Id:"..v.heroConfig.Id.." index:"..index)
|
|
|
|
|
index = 0
|
|
|
|
|
break
|
|
|
|
|
elseif (v.star >= godData[j].star) then
|
|
|
|
|
if (godData[j].property > 0 and v.property == godData[j].property)
|
|
|
|
|
or (godData[j].profession > 0 and v.profession == godData[j].profession)
|
|
|
|
|
or (godData[j].property == 0 and godData[j].profession == 0) then
|
|
|
|
|
if index == -1 then
|
|
|
|
|
index = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if (godData[j].property > 0 and v.property == godData[j].property) then
|
|
|
|
|
index = index + 1
|
|
|
|
|
elseif (godData[j].profession > 0 and v.profession == godData[j].profession) then
|
|
|
|
|
index = index + 1
|
|
|
|
|
elseif godData[j].property == 0 and godData[j].profession == 0 then
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--LogGreen("index:"..index.." v.heroConfig.Id:"..v.heroConfig.Id)
|
|
|
|
|
table.insert(haveDatas,{state = index,herodata = v})
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-26 16:00:31 +08:00
|
|
|
|
table.sort(haveDatas,function(a,b)
|
|
|
|
|
if a.state == b.state then
|
|
|
|
|
if a.herodata.star == b.herodata.star then
|
|
|
|
|
return a.herodata.star > b.herodata.star
|
|
|
|
|
end
|
|
|
|
|
return a.herodata.heroConfig.Sort < b.herodata.heroConfig.Sort
|
|
|
|
|
end
|
|
|
|
|
return a.state > b.state
|
|
|
|
|
end)
|
|
|
|
|
-- for k,v in ipairs(haveDatas) do
|
|
|
|
|
-- LogGreen("v.state:"..v.state.." v.heroConfig.Id:"..v.herodata.heroConfig.Id)
|
|
|
|
|
-- end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
return haveDatas
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-22 15:47:59 +08:00
|
|
|
|
--检测所选择神将是否满足激活神魂
|
|
|
|
|
function this.CheckCanUpGodSoul(curHeroData,lv,datas)
|
|
|
|
|
local godDatas = HeroManager.GetAllHeroList()
|
|
|
|
|
if datas then
|
|
|
|
|
godDatas = {}
|
|
|
|
|
for i = 1,#datas do
|
|
|
|
|
local tempData = HeroManager.GetSingleHeroData(datas[i])
|
|
|
|
|
table.insert(godDatas,tempData)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
local godData = this.GetGodSoulDataByLv(curHeroData.heroConfig.Id,lv)
|
2021-10-27 12:50:15 +08:00
|
|
|
|
local enoughData = {} --每个条件满足的数量
|
|
|
|
|
local enoughDatas = {} --每个条件是否满足
|
2021-10-20 18:02:09 +08:00
|
|
|
|
for j = 1,#godData do
|
|
|
|
|
if not enoughData[j] then
|
|
|
|
|
enoughData[j] = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-27 12:50:15 +08:00
|
|
|
|
for j = 1,#godData do
|
|
|
|
|
if not enoughDatas[j] then
|
|
|
|
|
enoughDatas[j] = false
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
local s = function()
|
|
|
|
|
local isAll = true
|
2021-10-27 12:50:15 +08:00
|
|
|
|
enoughDatas = {}
|
2021-10-20 18:02:09 +08:00
|
|
|
|
for i = 1,#enoughData do
|
2021-10-22 15:47:59 +08:00
|
|
|
|
if enoughData[i] < godData[i].num then
|
2021-10-20 18:02:09 +08:00
|
|
|
|
isAll = false
|
2021-10-27 12:50:15 +08:00
|
|
|
|
enoughDatas[i] = false
|
|
|
|
|
else
|
|
|
|
|
enoughDatas[i] = true
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-27 12:50:15 +08:00
|
|
|
|
return isAll,enoughData,enoughDatas
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
if godData then
|
2021-10-27 17:04:33 +08:00
|
|
|
|
for k,v in pairs(godDatas) do
|
2021-10-27 12:50:15 +08:00
|
|
|
|
local isChoosed = this.CheckExistBindHeroDataByDid(curHeroData.dynamicId,v.dynamicId)
|
2021-10-27 17:04:33 +08:00
|
|
|
|
if isChoosed and isChoosed ~= lv and isChoosed > 0 then
|
2021-10-22 15:47:59 +08:00
|
|
|
|
else
|
|
|
|
|
for j = 1,#godData do
|
2021-10-27 12:50:15 +08:00
|
|
|
|
if v.star >= godData[j].star then
|
|
|
|
|
if godData[j].id > 0 and v.heroConfig.Id == godData[j].id then
|
|
|
|
|
enoughData[j] = enoughData[j] + 1
|
|
|
|
|
elseif godData[j].property > 0 and v.property == godData[j].property then
|
|
|
|
|
enoughData[j] = enoughData[j] + 1
|
|
|
|
|
elseif godData[j].profession > 0 and v.profession == godData[j].profession then
|
|
|
|
|
enoughData[j] = enoughData[j] + 1
|
|
|
|
|
elseif godData[j].property == 0 and godData[j].profession == 0 and godData[j].id == 0 then
|
|
|
|
|
enoughData[j] = enoughData[j] + 1
|
|
|
|
|
end
|
|
|
|
|
local isAll,enoughData,enoughDatas = s()
|
|
|
|
|
if isAll then
|
|
|
|
|
return isAll,enoughData,enoughDatas
|
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
2021-10-27 12:50:15 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
|
|
|
|
return s()
|
|
|
|
|
end
|
2021-10-27 12:50:15 +08:00
|
|
|
|
return false,enoughData,enoughDatas
|
2021-10-20 18:02:09 +08:00
|
|
|
|
end
|
2021-10-18 10:36:32 +08:00
|
|
|
|
|
2021-10-26 16:00:31 +08:00
|
|
|
|
function this.GetHeroGodSoulDatas(dynamicId,id,_lv)
|
|
|
|
|
local lv = _lv or 0
|
|
|
|
|
if HeroManager.GetHongMengData(dynamicId) then
|
|
|
|
|
lv = this.GetGodSoulLv(dynamicId) or 0
|
|
|
|
|
end
|
|
|
|
|
local data = {}
|
|
|
|
|
for j = 1,#heroConfig[id].SoulSkill do
|
|
|
|
|
if heroConfig[id].SoulSkill[j][1] <= lv then
|
|
|
|
|
table.insert(data,heroConfig[id].SoulSkill[j][2])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return data
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-18 10:36:32 +08:00
|
|
|
|
return this
|