xdh
2018-09-14 01e033a79a5ce63e298015d0783560a77ccffea9
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTeam.py
@@ -2028,6 +2028,11 @@
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    
    packTagMapID = clientData.TagMapID
    # 发2时代表助战匹配
    if packTagMapID == 2:
        __DoMatchHelpFightTeam(curPlayer, tick)
        return
    tagMapEx = clientData.TagMapEx
    tagMapID = packTagMapID
    curMapID = curPlayer.GetMapID()
@@ -2240,6 +2245,73 @@
        PlayerControl.NotifyCode(curPlayer, "TeamMatchingSucceed")
    return
def __DoMatchHelpFightTeam(curPlayer, tick):
    ''' 一次性匹配需要助战的队伍,满足队伍条件自动加入匹配队伍
            按以下优先级加入:
        大境界渡劫    > 所有宗门试炼  > 所有娲皇遗迹  > 混乱妖域
        自己有队伍时发送助战喊话不执行此逻辑
    '''
    curTeam = curPlayer.GetTeam()
    if curTeam:
        return
    matchingTeamDict = PyGameData.g_matchingTeamDict
    GameWorld.DebugLog("__DoMatchHelpFightTeam matchingTeamDict=%s" % (matchingTeamDict), curPlayer.GetPlayerID())
    if not matchingTeamDict:
        return
    playerLV = curPlayer.GetLV()
    matchMapIDList = [ChConfig.Def_FBMapID_DuJie, ChConfig.Def_FBMapID_MunekadoTrial, ChConfig.Def_FBMapID_QueenRelics, ChConfig.Def_FBMapID_ChaosDemon]
    teamMgr = GameWorld.GetTeamManager()
    for matchMapID in matchMapIDList:
        matchTeamInfoList = []
        for key, teamIDList in matchingTeamDict.items():
            tagMapID, tagMapEx = key
            if tagMapID != matchMapID:
                continue
            for teamID in teamIDList:
                team = teamMgr.FindTeam(teamID)
                if not team:
                    continue
                reqMinLV = team.GetReqMinLV()
                reqMaxLV = team.GetReqMaxLV()
                if not (reqMinLV <= playerLV <= reqMaxLV):
                    continue
                onLineCount = CheckTeamOnLineCount(team)
                # 优先级: 人数多的 > 线路简单的 > 队伍人数多的 ...
                matchTeamInfoList.append([onLineCount, 999999 - tagMapEx, team.GetTeamPlayerCount(), teamID, team])
        if not matchTeamInfoList:
            GameWorld.DebugLog("    没有满足助战等级条件匹配中的队伍: matchMapID=%s" % (matchMapID))
            continue
        matchTeamInfoList.sort(reverse=True) # 倒序排
        GameWorld.DebugLog("    匹配队伍顺序: matchMapID=%s,%s" % (matchMapID, matchTeamInfoList))
        joinTeamID = 0
        for teamInfo in matchTeamInfoList:
            team = teamInfo[-1]
            if not team:
                continue
            leader = GetTeamLeader(team)
            if not leader:
                continue
            if DoPlayerJoinTeam(curPlayer, leader, team, tick, isAutoMatchJoin=False):
                joinTeamID  = team.GetTeamID()
                break
        GameWorld.DebugLog("        joinTeamID=%s" % joinTeamID)
        if joinTeamID:
            break
    return
#// B9 08 取消匹配队伍或玩家 #tagCGCancelMatchTeam
#