530 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			530 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			Lua
		
	
FormationManager = {}
 | 
						|
local this = FormationManager
 | 
						|
local ChallengeData = ConfigManager.GetConfig(ConfigName.ChallengeConfig)
 | 
						|
local specialConfig=ConfigManager.GetConfig(ConfigName.SpecialConfig)
 | 
						|
 | 
						|
this.AllFormationFunIds = {[1] = JumpType.Level,[601] = JumpType.BeastIncomingTide,[101] = JumpType.Arena,[201] = JumpType.Arena,
 | 
						|
                           [401] = JumpType.EndlessFight,[501] = JumpType.Guild,[502] = JumpType.Guild}
 | 
						|
function this.Initialize()
 | 
						|
    this.currentFormationIndex=0
 | 
						|
end
 | 
						|
 | 
						|
function this.MakeAEmptyTeam(teamId)
 | 
						|
    local oTeam = {}
 | 
						|
    Log("TeamId" .. teamId)
 | 
						|
    oTeam.teamId = teamId
 | 
						|
    if teamId < FormationTypeDef.FORMATION_ARENA_DEFEND then
 | 
						|
        oTeam.teamName = Language[10676]--Language[10677] .. tostring(teamId)
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_ARENA_DEFEND then
 | 
						|
        oTeam.teamName = Language[10678]-- 101
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_ARENA_ATTACK then
 | 
						|
        oTeam.teamName = Language[10679]-- 201
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_DREAMLAND then
 | 
						|
        oTeam.teamName = Language[10680]-- 301
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_ENDLESS_MAP then
 | 
						|
        oTeam.teamName = Language[10681]-- 401
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND then
 | 
						|
        oTeam.teamName = Language[10682]-- 501
 | 
						|
    elseif teamId == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then
 | 
						|
        oTeam.teamName = Language[10683]-- 502
 | 
						|
    elseif teamId == FormationTypeDef.MONSTER_CAMP_ATTACK then
 | 
						|
        oTeam.teamName = Language[10677]-- 601
 | 
						|
    elseif teamId == FormationTypeDef.BLOODY_BATTLE_ATTACK then
 | 
						|
        oTeam.teamName = Language[10684]-- 701
 | 
						|
    -- elseif teamId == FormationTypeDef.GUILD_BOSS then
 | 
						|
    --     oTeam.teamName = " 公会Boss"-- 901
 | 
						|
    elseif teamId == FormationTypeDef.EXPEDITION then
 | 
						|
        oTeam.teamName = Language[10685]-- 1001
 | 
						|
    elseif teamId == FormationTypeDef.ARENA_TOM_MATCH then
 | 
						|
        oTeam.teamName = Language[10678]-- 1301
 | 
						|
    end
 | 
						|
    oTeam.teamHeroInfos = {}
 | 
						|
    oTeam.teamPokemonInfos = {}
 | 
						|
    return oTeam
 | 
						|
end
 | 
						|
 | 
						|
-- 刷新编队信息
 | 
						|
function this.RefreshFormationData(func)
 | 
						|
    NetManager.TeamInfoRequest(func)
 | 
						|
end
 | 
						|
 | 
						|
--刷新编队数据
 | 
						|
function this.UpdateFormation(msg)
 | 
						|
    Log("#msg.TeamPosInfo : " .. #msg.TeamPosInfo)
 | 
						|
    this.formationList = {}
 | 
						|
    -- this.curFormationIndex = this.SetCurFormationIndex()
 | 
						|
    this.curFormationIndex = 1
 | 
						|
    for i, team in ipairs(msg.TeamPosInfo) do
 | 
						|
        local oTeam = this.MakeAEmptyTeam(team.teamId)
 | 
						|
 | 
						|
        for j = 1, #team.teamHeroInfos do
 | 
						|
            local teamHeroInfo = team.teamHeroInfos[j]
 | 
						|
            table.insert(oTeam.teamHeroInfos, teamHeroInfo)
 | 
						|
            HeroManager.SetHeroFormationList(teamHeroInfo.heroId,team.teamId,1)
 | 
						|
        end
 | 
						|
        oTeam.teamPokemonInfos = {}
 | 
						|
        -- for j = 1, #team.teamPokemonInfos do
 | 
						|
        --     local teamPokemonInfo = team.teamPokemonInfos[j]
 | 
						|
        --     table.insert(oTeam.teamPokemonInfos, teamPokemonInfo)
 | 
						|
        -- end
 | 
						|
        this.formationList[team.teamId] = oTeam
 | 
						|
 | 
						|
    end
 | 
						|
 | 
						|
    if #msg.TeamPosInfo == 0 then
 | 
						|
        for i = 1, 3 do
 | 
						|
            local curFormation = {}
 | 
						|
            curFormation.teamId = i
 | 
						|
            curFormation.teamName = Language[10676]--Language[10677] .. i
 | 
						|
            curFormation.teamHeroInfos = {}
 | 
						|
            curFormation.teamPokemonInfos = {}
 | 
						|
            this.formationList[i] = curFormation
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    -- 获取数据时检测一下公会战防守数据
 | 
						|
    this.CheckGuildFightDefendFormation()
 | 
						|
end
 | 
						|
 | 
						|
-- function this.SetCurFormationIndex()
 | 
						|
--     local curIndex = 1
 | 
						|
--     local curMapId = PlayerManager.curMapId
 | 
						|
--     local carbonType = 1
 | 
						|
--     if curMapId and curMapId > 0 then
 | 
						|
--         carbonType = ChallengeData[curMapId].Type
 | 
						|
--     end
 | 
						|
--     curIndex = carbonType == 4 and 401 or 1
 | 
						|
--     return curIndex
 | 
						|
-- end
 | 
						|
 | 
						|
function this.RefreshFormation(index, roleList, pokemonList,isDiffmonster)
 | 
						|
    local curFormation = this.formationList[index]
 | 
						|
    if not curFormation or #this.formationList == 0 then
 | 
						|
        return
 | 
						|
    end
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    local newTeamheroInfos = {}
 | 
						|
    for i = 1, #roleList do
 | 
						|
        newTeamheroInfos[roleList[i].heroId] = roleList[i]
 | 
						|
    end
 | 
						|
    local oldTeamheroInfos = {}
 | 
						|
    for i = 1, #curFormation.teamHeroInfos do
 | 
						|
        if curFormation.teamHeroInfos[i] then
 | 
						|
            oldTeamheroInfos[curFormation.teamHeroInfos[i].heroId] = curFormation.teamHeroInfos[i]
 | 
						|
            if not newTeamheroInfos[curFormation.teamHeroInfos[i].heroId] then
 | 
						|
                HeroManager.SetHeroFormationList(curFormation.teamHeroInfos[i].heroId,this.formationList[index].teamId,nil)
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    curFormation.teamHeroInfos = {}
 | 
						|
    LogPink("#roleList"..#roleList)
 | 
						|
    for i = 1, #roleList do
 | 
						|
        local teamInfo = {}
 | 
						|
        teamInfo.heroId = roleList[i].heroId--roleList[i]
 | 
						|
        teamInfo.position = roleList[i].position--i
 | 
						|
        table.insert(curFormation.teamHeroInfos, teamInfo)
 | 
						|
        if not oldTeamheroInfos[teamInfo.heroId] then
 | 
						|
            LogRed("roleList[i].heroId"..roleList[i].heroId.."    this.formationList[index].teamId"..this.formationList[index].teamId)
 | 
						|
            HeroManager.SetHeroFormationList(roleList[i].heroId,this.formationList[index].teamId,1)
 | 
						|
        end
 | 
						|
    end
 | 
						|
    curFormation.teamPokemonInfos = {}
 | 
						|
    for j = 1, #pokemonList do
 | 
						|
        --#curFormation.teamPokemonInfos
 | 
						|
        local teamPokemonInfo = {}
 | 
						|
        teamPokemonInfo.pokemonId = pokemonList[j].pokemonId
 | 
						|
        teamPokemonInfo.position = pokemonList[j].position
 | 
						|
        table.insert(curFormation.teamPokemonInfos, teamPokemonInfo)
 | 
						|
    end
 | 
						|
    NetManager.TeamInfoSaveRequest(curFormation, function()
 | 
						|
        Game.GlobalEvent:DispatchEvent(GameEvent.Formation.OnFormationChange,isDiffmonster)
 | 
						|
        LogGreen("发送保存编队请求 ,长度:"..#curFormation.teamHeroInfos)
 | 
						|
    end)
 | 
						|
 | 
						|
    this.CheckHeroIdExist()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
-- 获取所有正在编队的英雄id
 | 
						|
function this.GetAllFormationHeroId()
 | 
						|
    local list = {}
 | 
						|
    local index = 1
 | 
						|
    for i, team in pairs(this.formationList) do
 | 
						|
        for j = 1, #team.teamHeroInfos do
 | 
						|
            -- 加空判断避免不知名错误
 | 
						|
            if team and team.teamHeroInfos[j] then
 | 
						|
                list[team.teamHeroInfos[j].heroId] = index
 | 
						|
                index = index + 1
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return list
 | 
						|
end
 | 
						|
-- 获取主线所有正在编队的英雄id
 | 
						|
function this.GetAllMainFormationHeroId()
 | 
						|
    local list = {}
 | 
						|
    local index = 1
 | 
						|
    for i, team in pairs(this.formationList) do
 | 
						|
        if i == FormationTypeDef.FORMATION_NORMAL then
 | 
						|
            for j = 1, #team.teamHeroInfos do
 | 
						|
                -- 加空判断避免不知名错误
 | 
						|
                if team and team.teamHeroInfos[j] then
 | 
						|
                    list[team.teamHeroInfos[j].heroId] = index
 | 
						|
                    index = index + 1
 | 
						|
                end
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return list
 | 
						|
end
 | 
						|
--获取单个编队所有上阵英雄
 | 
						|
function this.GetWuJinFormationHeroIds(index)
 | 
						|
   local forMationData = this.GetFormationByID(index).teamHeroInfos
 | 
						|
    local index = 1
 | 
						|
    local list = {}
 | 
						|
    for j = 1, #forMationData do
 | 
						|
        list[forMationData[j].heroId] = index
 | 
						|
        index = index + 1
 | 
						|
    end
 | 
						|
    return list
 | 
						|
end
 | 
						|
-- 获取编队信息
 | 
						|
function this.GetFormationByID(teamId)
 | 
						|
    if not teamId then
 | 
						|
        return
 | 
						|
    end
 | 
						|
    if not this.formationList then return nil end
 | 
						|
    if not this.formationList[teamId] then
 | 
						|
        this.formationList[teamId] = this.MakeAEmptyTeam(teamId)
 | 
						|
    end
 | 
						|
 | 
						|
    --根据配置表 解锁功能时复制主线阵容 的配置
 | 
						|
    for i, v in ipairs(string.split(specialConfig[47].Value,"#")) do
 | 
						|
        local _v=tonumber(v)
 | 
						|
        if teamId==_v and #this.formationList[teamId].teamHeroInfos<=0 then
 | 
						|
            for n = 1, #this.formationList[1].teamHeroInfos do
 | 
						|
                table.insert(this.formationList[teamId].teamHeroInfos, this.formationList[1].teamHeroInfos[n])
 | 
						|
            end
 | 
						|
            -- 
 | 
						|
            FormationManager.RefreshFormation(teamId, this.formationList[teamId].teamHeroInfos, {})
 | 
						|
            return this.formationList[teamId]
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    return this.formationList[teamId]
 | 
						|
end
 | 
						|
 | 
						|
-- 获取编队总战斗力
 | 
						|
function this.GetFormationPower(formationId)
 | 
						|
    if not formationId then
 | 
						|
        return
 | 
						|
    end
 | 
						|
    --获取当前编队数据
 | 
						|
    if formationId == FormationTypeDef.EXPEDITION then
 | 
						|
        ExpeditionManager.ExpeditionRrefreshFormation()--刷新编队
 | 
						|
    end
 | 
						|
    local formationList = this.GetFormationByID(formationId)
 | 
						|
    --for i, v in pairs(allHeroTeamAddProVal) do
 | 
						|
    --    LogError("团队加成       "..i .."           " .. v)
 | 
						|
    --end
 | 
						|
    local power = 0
 | 
						|
    for i = 1, 6 do
 | 
						|
        if formationList.teamHeroInfos[i] then
 | 
						|
            local heroData = HeroManager.GetSingleHeroData(formationList.teamHeroInfos[i].heroId)
 | 
						|
            --1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
 | 
						|
            local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,formationList.teamHeroInfos[i].heroId)
 | 
						|
            local allEquipAddProVal = HeroManager.CalculateHeroAllProValList(1, heroData.dynamicId,false,nil,nil,true,allHeroTeamAddProVal)
 | 
						|
            power = power + allEquipAddProVal[HeroProType.WarPower]
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    
 | 
						|
    -- 主线编队战斗力
 | 
						|
    ThinkingAnalyticsManager.SetSuperProperties({
 | 
						|
        fighting_capacity = power,
 | 
						|
    })
 | 
						|
    return power
 | 
						|
end
 | 
						|
 | 
						|
--某个妖灵师战力发生变化检查是否在任何一个编队
 | 
						|
function this.CheckHeroIdExist(heroId)
 | 
						|
    if not heroId then
 | 
						|
        NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
 | 
						|
        return 
 | 
						|
    end
 | 
						|
 | 
						|
    -- for _, formationData in pairs(this.formationList) do
 | 
						|
        table.walk(this.formationList[FormationTypeDef.FORMATION_NORMAL].teamHeroInfos, function(teamInfo)
 | 
						|
            if heroId == teamInfo.heroId  then
 | 
						|
                NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
 | 
						|
            end
 | 
						|
        end)
 | 
						|
    -- end
 | 
						|
end
 | 
						|
 | 
						|
function this.UserPowerChanged()
 | 
						|
    
 | 
						|
    local maxPower, targetTeamId = 0
 | 
						|
    -- for _, teamInfo in pairs(this.formationList) do 
 | 
						|
        -- if #teamInfo.teamHeroInfos > 0 then
 | 
						|
            local curFormationWarPower = this.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)--teamInfo.teamId
 | 
						|
            if curFormationWarPower > maxPower then
 | 
						|
                maxPower = curFormationWarPower
 | 
						|
                -- targetTeamId = teamInfo.teamId
 | 
						|
            end
 | 
						|
        -- end
 | 
						|
    -- end
 | 
						|
    if maxPower > PlayerManager.maxForce then
 | 
						|
        Log("发送队伍战力改变 ~~~~~~~~~~~~~~          ")
 | 
						|
        NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)--targetTeamId
 | 
						|
        PlayerManager.maxForce = maxPower
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
-- 获取相应编队的血量数据
 | 
						|
function this.GetFormationHeroHp(formationIndex, dhId)
 | 
						|
    if formationIndex == FormationTypeDef.FORMATION_ENDLESS_MAP then
 | 
						|
        local data = EndLessMapManager.allHeroBlood[dhId]
 | 
						|
        if not data then return end
 | 
						|
        return data.percentHp
 | 
						|
    elseif formationIndex == FormationTypeDef.FORMATION_GUILD_FIGHT_ATTACK then
 | 
						|
        local dataList = GuildFightManager.GetMyHeroBloodData()
 | 
						|
        local data = dataList[dhId]
 | 
						|
        if not data then return end
 | 
						|
        return data
 | 
						|
    elseif formationIndex == FormationTypeDef.EXPEDITION then
 | 
						|
        local data = ExpeditionManager.heroInfo[dhId]
 | 
						|
        if not data then return end
 | 
						|
        return data.remainHp
 | 
						|
    end
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
-- 检测编队正确性
 | 
						|
function this.CheckFormationHp(formationIndex)
 | 
						|
    local formation = this.GetFormationByID(formationIndex)
 | 
						|
    local newFormation = {}
 | 
						|
    local newIndex = 1
 | 
						|
    for index = 1, #formation.teamHeroInfos do
 | 
						|
        local teamInfo = formation.teamHeroInfos[index]
 | 
						|
        local hp = this.GetFormationHeroHp(formationIndex, teamInfo.heroId)
 | 
						|
        if hp > 0 then
 | 
						|
            local singleData = {}
 | 
						|
            singleData.heroId = teamInfo.heroId
 | 
						|
            singleData.position = newIndex
 | 
						|
            newIndex = newIndex + 1
 | 
						|
            table.insert(newFormation, singleData)
 | 
						|
        end
 | 
						|
    end
 | 
						|
    this.RefreshFormation(formationIndex, newFormation, formation.teamPokemonInfos)
 | 
						|
end
 | 
						|
 | 
						|
-- 检测编队是否有上阵人数
 | 
						|
function this.CheckFormationValid(teamId)
 | 
						|
    local team = this.GetFormationByID(teamId)
 | 
						|
    local isValid = #team.teamHeroInfos > 0
 | 
						|
    return isValid
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
-- 检测公会战防守阶段玩家防守阵容正确性,防守阵容为空时将主线阵容复制到防守阵容
 | 
						|
function FormationManager.CheckGuildFightDefendFormation()
 | 
						|
    if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GUILD) then return end -- 公会未开启
 | 
						|
    if PlayerManager.familyId == 0 then return end  -- 没有公会
 | 
						|
    local isInFight = GuildFightManager.IsInGuildFight()
 | 
						|
    local curStage = GuildFightManager.GetCurFightStage()
 | 
						|
    if not isInFight or curStage == GUILD_FIGHT_STAGE.DEFEND then
 | 
						|
        if not this.CheckFormationValid(FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND) then
 | 
						|
            local formation = this.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
 | 
						|
            local newFormation = {}
 | 
						|
            for index = 1, #formation.teamHeroInfos do
 | 
						|
                local teamInfo = formation.teamHeroInfos[index]
 | 
						|
                local singleData = {}
 | 
						|
                singleData.heroId = teamInfo.heroId
 | 
						|
                singleData.position = index
 | 
						|
                table.insert(newFormation, singleData)
 | 
						|
            end
 | 
						|
            this.RefreshFormation(FormationTypeDef.FORMATION_GUILD_FIGHT_DEFEND, newFormation, formation.teamPokemonInfos)
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
--设置元素共鸣激活索引
 | 
						|
function this.GetElementIndex(curFormation)
 | 
						|
    local elementPropertyList = {}
 | 
						|
    local fireElementNum = 0
 | 
						|
    local windyElementNum = 0
 | 
						|
    local waterElementNum = 0
 | 
						|
    local groundElementNum = 0
 | 
						|
 | 
						|
    for _,go in pairs(curFormation) do--将所有元素信息存入列表
 | 
						|
        if go and go.heroId then
 | 
						|
            local temp = HeroManager.GetSingleHeroData(go.heroId)
 | 
						|
            if not temp then
 | 
						|
                LogGreen(go.heroId.."这个英雄不存在")
 | 
						|
            else
 | 
						|
            local heroPropertyType = temp.heroConfig.PropertyName
 | 
						|
            table.insert(elementPropertyList, heroPropertyType)
 | 
						|
            end
 | 
						|
        else
 | 
						|
            LogGreen(_.."这个编队的这个英雄不存在")
 | 
						|
        end
 | 
						|
    end
 | 
						|
    for i, v in pairs(elementPropertyList) do--遍历该列表拿筛选出各元素
 | 
						|
        if (v == 1) then
 | 
						|
            fireElementNum = fireElementNum + 1
 | 
						|
        elseif (v == 2) then
 | 
						|
            windyElementNum = windyElementNum + 1
 | 
						|
        elseif (v == 3) then
 | 
						|
            waterElementNum = waterElementNum + 1
 | 
						|
        elseif (v == 4) then
 | 
						|
            groundElementNum = groundElementNum + 1
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    local list = {}
 | 
						|
    list[1] = fireElementNum
 | 
						|
    list[2] = windyElementNum
 | 
						|
    list[3] = waterElementNum
 | 
						|
    list[4] = groundElementNum
 | 
						|
 | 
						|
    local indexChoose = 0
 | 
						|
    for i = 1, #list do
 | 
						|
        local v=list[i]
 | 
						|
        if v==4 then
 | 
						|
            indexChoose=4
 | 
						|
        end
 | 
						|
        if v==5 then
 | 
						|
            indexChoose=5
 | 
						|
        end
 | 
						|
        if v==6 then
 | 
						|
            indexChoose=6
 | 
						|
        end
 | 
						|
    end
 | 
						|
 | 
						|
    local count=0
 | 
						|
    for i = 1, #list do
 | 
						|
        local v=list[i]
 | 
						|
        if v==3 then
 | 
						|
            count=count+1
 | 
						|
        end
 | 
						|
    end
 | 
						|
    if count==1 then
 | 
						|
        indexChoose=2
 | 
						|
    elseif count==2 then
 | 
						|
        indexChoose=3
 | 
						|
    end
 | 
						|
 | 
						|
    local index=0
 | 
						|
    for i = 1, #list do
 | 
						|
        local v=list[i]
 | 
						|
        if v==2 then
 | 
						|
            index=index+1
 | 
						|
        end
 | 
						|
    end
 | 
						|
    if index==3 then
 | 
						|
        indexChoose=1
 | 
						|
    end
 | 
						|
 | 
						|
    return indexChoose
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
-- 获取所有正在编队的英雄id
 | 
						|
function this.AllFormationDeleCurHeroId(heroDid)
 | 
						|
    for i, team in pairs(this.formationList) do
 | 
						|
        local removeIndex
 | 
						|
        for j = 1, #team.teamHeroInfos do
 | 
						|
            if team.teamHeroInfos[j] and team.teamHeroInfos[j].heroId ==  heroDid then
 | 
						|
                removeIndex = j
 | 
						|
            end
 | 
						|
        end
 | 
						|
        if removeIndex then
 | 
						|
            table.remove( team.teamHeroInfos, removeIndex)
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
-- 归元时检测无尽 和 大闹天宫阵容是否需要下阵
 | 
						|
function this.ResolvDownBattleCurHeroId(heroDid)
 | 
						|
    for i, team in pairs(this.formationList) do
 | 
						|
        local removeIndex
 | 
						|
        if i == FormationTypeDef.EXPEDITION or i == FormationTypeDef.FORMATION_ENDLESS_MAP then
 | 
						|
            for j = 1, #team.teamHeroInfos do
 | 
						|
                if team.teamHeroInfos[j] and team.teamHeroInfos[j].heroId ==  heroDid then
 | 
						|
                    removeIndex = j
 | 
						|
                end
 | 
						|
            end
 | 
						|
            if removeIndex then
 | 
						|
                table.remove( team.teamHeroInfos, removeIndex)
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
end
 | 
						|
 | 
						|
-- 获取当前光环的加成数据 type 编队类型
 | 
						|
function this.GetCurFormationElementAdd(teamHeroInfos)
 | 
						|
    local data={}
 | 
						|
    local index= this.GetElementIndex(teamHeroInfos)
 | 
						|
    if index==0 then return data end
 | 
						|
    local config=ConfigManager.GetConfig(ConfigName.ElementalResonanceConfig)
 | 
						|
    for i = 1, #config[index].Content do
 | 
						|
        table.insert(data,config[index].Content[i][1],config[index].Content[i][2])
 | 
						|
    end
 | 
						|
    return data
 | 
						|
end
 | 
						|
 | 
						|
-- 获取当前光环的加成数据 type 编队类型
 | 
						|
function this.GetCurFormationElementAddByType(type,heroDid)
 | 
						|
    local data={}
 | 
						|
    local curFormation = this.GetFormationByID(type)
 | 
						|
    local isAdd = false
 | 
						|
    if not curFormation then return {} end
 | 
						|
    for i = 1, #curFormation.teamHeroInfos do
 | 
						|
        if curFormation.teamHeroInfos[i].heroId == heroDid then
 | 
						|
            isAdd = true
 | 
						|
        end
 | 
						|
    end
 | 
						|
    if isAdd then
 | 
						|
        local index= this.GetElementIndex(curFormation.teamHeroInfos)
 | 
						|
        if index==0 then return data end
 | 
						|
        local config=ConfigManager.GetConfig(ConfigName.ElementalResonanceConfig)
 | 
						|
        for i = 1, #config[index].Content do
 | 
						|
            table.insert(data,config[index].Content[i][1],config[index].Content[i][2])
 | 
						|
        end
 | 
						|
    end
 | 
						|
    return data
 | 
						|
end
 | 
						|
 | 
						|
--自动一键上阵没有前端显示
 | 
						|
function this.SetOneKeyGoWithoutUI(formationType,limitLevel)
 | 
						|
    local heros = HeroManager.GetAllHeroDatas(limitLevel)
 | 
						|
    --按战力从大到小排序
 | 
						|
    table.sort(heros,function(a,b)
 | 
						|
        if a.warPower == b.warPower then
 | 
						|
            return a.id>b.id
 | 
						|
        else
 | 
						|
            return a.warPower > b.warPower
 | 
						|
        end
 | 
						|
    end)
 | 
						|
    --修改 upHeroSidTable 静态id 存储  有则跳过
 | 
						|
    local upHeroSidTable = {}
 | 
						|
    local choosedList = {}
 | 
						|
    for i = 1, 6 do
 | 
						|
        if heros[i] then
 | 
						|
            local curSingleherodata = HeroManager.GetSingleHeroData(heros[i].dynamicId)
 | 
						|
            if not upHeroSidTable[curSingleherodata.id] then
 | 
						|
                upHeroSidTable[curSingleherodata.id] = curSingleherodata.id
 | 
						|
                table.insert(choosedList, {heroId = heros[i].dynamicId, position=i})
 | 
						|
            end
 | 
						|
        end
 | 
						|
    end
 | 
						|
    --保存编队
 | 
						|
    FormationManager.RefreshFormation(formationType, choosedList,FormationManager.formationList[formationType].teamPokemonInfos)
 | 
						|
end
 | 
						|
 | 
						|
return this |