miduo_client/Assets/ManagedResources/~Lua/Modules/HelpFight/HelpFightManager.lua

123 lines
3.8 KiB
Lua

HelpFightManager = {}
local this = HelpFightManager
local assConfig=ConfigManager.GetConfig(ConfigName.AssistanceConfig)
function this.Initialize()
this.upHeroList={}
this.HelpFightList={}
end
function this.InitData(msg)
this.HelpFightList={}
this.upHeroList={}
for i = 1, #msg.boxs do
local data=msg.boxs[i]
this.HelpFightList[i]=data
LogError("helpfight id========================="..data.id)
table.insert(this.upHeroList,data.heroId)
end
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.HelpFight)
end
function this.AddOrRemoveHero(_pos,_type,_id)
if _type==1 then
this.HelpFightList[_pos].heroId=_id
table.insert(this.upHeroList,_id)
elseif _type==2 then
this.HelpFightList[_pos].heroId=""
table.removebyvalue(this.upHeroList,_id)
end
end
function this.CheckRedPoint()
for i = 1, #this.HelpFightList do
local isCan=this.CheckRedPointByPosition(i)
if isCan then
return isCan
end
end
return false
end
function this.CheckRedPointByPosition(_pos)
if this.HelpFightList[_pos] then
--还没有开启
if this.HelpFightList[_pos].state==0 then
return false
end
--没有英雄看有没有能上的 有就看有没有能替换的
local list=HeroManager.GetHeroDatasByNaturalAndProfession(assConfig[_pos].Quality,assConfig[_pos].ProfessionLimit)
if this.HelpFightList[_pos].heroId=="" or this.HelpFightList[_pos].heroId==nil then
if assConfig[_pos] then
if list and #list>0 then
return true
else
return false
end
end
else
local heroData=HeroManager.GetSingleHeroData(this.HelpFightList[_pos].heroId)
if heroData and list and #list>0 then
for k, v in pairs(list) do
if v.star>heroData.star then
return true
end
end
end
end
end
return false
end
--获取所有的加成属性
function this.GetAllAddPro()
local allAddPro={}
local addNum=0
for k, v in pairs(this.HelpFightList) do
if v.heroId~="" and v.heroId~=nil then
local heroData=HeroManager.GetSingleHeroData(v.heroId)
if heroData then
LogError("heroData.heroConfig.Natural==="..heroData.heroConfig.Natural)
LogError("heroData.star==="..heroData.star)
local config=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.AssistanceProperty,"Quality",heroData.heroConfig.Natural,"Star",heroData.star)
if config then
for i = 1, #config.Property do
local key=config.Property[i][1]
local value=config.Property[i][2]
if allAddPro[key] then
allAddPro[key]=allAddPro[key]+value
else
allAddPro[key]=value
end
end
addNum=addNum+assConfig[k].PropertyUp
end
end
end
end
if addNum>0 then
-- LogError("addNum=================================="..addNum)
-- for k, v in pairs(allAddPro) do
-- LogError("k==========前============"..k.." v============"..v)
-- end
for k, v in pairs(allAddPro) do
allAddPro[k]= math.floor(v*(1+addNum/10000)+0.5)
--LogError("v==============================="..v)
end
end
for k, v in pairs(allAddPro) do
LogError("k==================="..k.." v============"..v)
end
return allAddPro,addNum
end
return this