|  |  |  | 
|---|
|  |  |  | #邀请组队的时候,双方都有队伍不处理 | 
|---|
|  |  |  | if curPlayerTeam != None and tagPlayerTeam != None: | 
|---|
|  |  |  | #InviteEnterLost02  <n color="255,255,0">`o很抱歉,目标玩家已在他人队伍中,邀请入队失败!</n>  25  -   - | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "InviteEnterLost02") | 
|---|
|  |  |  | #PlayerControl.NotifyCode(curPlayer, "InviteEnterLost02") | 
|---|
|  |  |  | InvitePlayerJoinTeamReq(curPlayer, tagPlayer, curPlayerTeam, tick) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if tagPlayerTeam == None: | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.DebugLog("邀请组队, tagMapID=%s,tagMapEx=%s,tagPlayerID=%s" % (tagMapID, tagMapEx, tagPlayerID), curPlayerID) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | isTjg = PlayerControl.GetIsTJG(tagPlayer) | 
|---|
|  |  |  | if isTjg or not IsTeamInvateNeedCheck(tagPlayer): | 
|---|
|  |  |  | if (isTjg or not IsTeamInvateNeedCheck(tagPlayer)) and not tagPlayer.GetTeamID(): | 
|---|
|  |  |  | GameWorld.DebugLog("被邀请的玩家处于脱机状态或不需要审核的,直接入队! tagPlayerID=%s,isTjg=%s" | 
|---|
|  |  |  | % (tagPlayerID, isTjg), curPlayerID) | 
|---|
|  |  |  | DoPlayerJoinTeam(tagPlayer, curPlayer, curPlayerTeam, tick, curPlayer) | 
|---|
|  |  |  | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #双方的队伍 | 
|---|
|  |  |  | curPlayerTeam = curPlayer.GetTeam() | 
|---|
|  |  |  | #curPlayerTeam = curPlayer.GetTeam() | 
|---|
|  |  |  | tagPlayerTeam = tagPlayer.GetTeam() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if tagPlayerTeam == None: | 
|---|
|  |  |  | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "TeamNoExist") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if curPlayerTeam != None: | 
|---|
|  |  |  | #InviteEnterLost02  组队失败,双方都有队伍! | 
|---|
|  |  |  | PlayerControl.NotifyCode(curPlayer, "InviteEnterLost02") | 
|---|
|  |  |  | return | 
|---|
|  |  |  | #=============================================================================================== | 
|---|
|  |  |  | # if curPlayerTeam != None: | 
|---|
|  |  |  | #    #InviteEnterLost02  组队失败,双方都有队伍! | 
|---|
|  |  |  | #    PlayerControl.NotifyCode(curPlayer, "InviteEnterLost02") | 
|---|
|  |  |  | #    return | 
|---|
|  |  |  | #=============================================================================================== | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #组队类型 | 
|---|
|  |  |  | #teamType = sendPack.GetTeamType() | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #玩家本身有队伍时 | 
|---|
|  |  |  | if joinPlayer.GetTeam(): | 
|---|
|  |  |  | if notifyPlayer: | 
|---|
|  |  |  | # AcceptTeamLost 该玩家已有队伍 | 
|---|
|  |  |  | PlayerControl.NotifyCode(notifyPlayer, "AcceptTeamLost") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #=========================================================================================== | 
|---|
|  |  |  | # if notifyPlayer: | 
|---|
|  |  |  | #    # AcceptTeamLost 该玩家已有队伍 | 
|---|
|  |  |  | #    PlayerControl.NotifyCode(notifyPlayer, "AcceptTeamLost") | 
|---|
|  |  |  | # return | 
|---|
|  |  |  | #=========================================================================================== | 
|---|
|  |  |  | #先退队 | 
|---|
|  |  |  | DoPlayerLeaveTeam(joinPlayer, joinPlayer.GetTeam(), tick) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | teamID = tagTeam.GetTeamID() | 
|---|
|  |  |  | GameWorld.Log("%s(%d)加入队伍 %s(%d), teamID=%s!" % (joinPlayer.GetName(), joinPlayer.GetPlayerID(), | 
|---|
|  |  |  | teamPlayer.GetName(), teamPlayer.GetPlayerID(), teamID)) | 
|---|
|  |  |  | 
|---|
|  |  |  | playerMgr = GameWorld.GetPlayerManager() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | scenePlayerIDDict = GetScenePlayerIDDict() | 
|---|
|  |  |  | scenePlayerIDList = scenePlayerIDDict.get(mapID, []) | 
|---|
|  |  |  | scenePlayerIDList = copy.deepcopy(scenePlayerIDDict.get(mapID, [])) | 
|---|
|  |  |  | # 场景队伍数超过同步的个数才进行排序,否则直接同步给客户端,由客户端自行排序 | 
|---|
|  |  |  | if len(scenePlayerIDList) > Def_SyncPlayerCount: | 
|---|
|  |  |  | playerIDSortList = [] | 
|---|
|  |  |  | 
|---|
|  |  |  | player = playerMgr.FindPlayerByID(playerID) | 
|---|
|  |  |  | if not player: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if player.GetTeamID(): | 
|---|
|  |  |  | # 有队伍的不推荐 | 
|---|
|  |  |  | if PlayerControl.GetIsTJG(player): | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if not __CheckCanTeamComm(player): | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | #if player.GetTeamID(): | 
|---|
|  |  |  | #    # 有队伍的不推荐 | 
|---|
|  |  |  | #    continue | 
|---|
|  |  |  | playerLV = player.GetLV() | 
|---|
|  |  |  | playerIDSortList.append([abs(curPlayerLV - playerLV), -playerLV, playerID]) | 
|---|
|  |  |  | playerIDSortList.sort() # 等级差绝对值升序排, 绝对值相同的等级高的排前面 | 
|---|
|  |  |  | 
|---|
|  |  |  | player = playerMgr.FindPlayerByID(playerID) | 
|---|
|  |  |  | if not player: | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if player.GetTeamID(): | 
|---|
|  |  |  | # 有队伍的不推荐 | 
|---|
|  |  |  | if PlayerControl.GetIsTJG(player): | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | if not __CheckCanTeamComm(player): | 
|---|
|  |  |  | continue | 
|---|
|  |  |  | #if player.GetTeamID(): | 
|---|
|  |  |  | #    # 有队伍的不推荐 | 
|---|
|  |  |  | #    continue | 
|---|
|  |  |  | count += 1 | 
|---|
|  |  |  | nearbyPlayer = ChPyNetSendPack.tagGCRecommendNearbyPlayer() | 
|---|
|  |  |  | nearbyPlayer.PlayerID = playerID | 
|---|
|  |  |  | 
|---|
|  |  |  | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | packTagMapID = clientData.TagMapID | 
|---|
|  |  |  | # 发2时代表助战匹配 | 
|---|
|  |  |  | if packTagMapID == 2: | 
|---|
|  |  |  | __DoMatchHelpFightTeam(curPlayer, tick) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tagMapEx = clientData.TagMapEx | 
|---|
|  |  |  | tagMapID = packTagMapID | 
|---|
|  |  |  | curMapID = curPlayer.GetMapID() | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | # | 
|---|
|  |  |  | 
|---|
|  |  |  | curPlayer.MapServer_QueryPlayerResult(0, 0, "EnterFBTeamAsk", resultName, len(resultName)) | 
|---|
|  |  |  | # 多人队伍,队伍加入准备队列,通知队员准备 | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | DelTeamIDFromMatchingList(curTeam) # 进入准备阶段停止匹配 | 
|---|
|  |  |  | GameWorld.DebugLog("队伍验证通过,通知队员准备进入副本: memStateDict=%s" % memStateDict, playerID) | 
|---|
|  |  |  | PyGameData.g_prepareTeamDict[teamID] = [retAskMapID, retAskMapEx, memStateDict, tick] | 
|---|
|  |  |  | SyncTeamEnterFBPrepareInfo(curTeam, retAskMapID, retAskMapEx, memStateDict) | 
|---|