| | |
| | |
|
| | | import copy
|
| | | import time
|
| | | import random
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | TeamFBAskType_Match = 0 # 组队副本进入询问类型 - 匹配
|
| | |
| | | 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
|
| | | #
|
| | |
| | | return
|
| | |
|
| | | # 覆盖添加
|
| | | PyGameData.g_teamFBEnterAskDict[teamID] = [askVer, askType, askMapID, askMapEx, askPlayerRetDict]
|
| | | PyGameData.g_teamFBEnterAskDict[teamID] = [askVer, askType, askMapID, askMapEx, askPlayerRetDict, tick]
|
| | |
|
| | | sendCMD = str([teamID, askVer, askType, askMapID, askMapEx])
|
| | | for memPlayerID, mapInfo in askPlayerMapDict.items():
|
| | |
| | | if retTeamID not in PyGameData.g_teamFBEnterAskDict:
|
| | | GameWorld.DebugLog(" 该队伍的请求信息记录已不存在,不处理!retTeamID=%s" % retTeamID, playerID)
|
| | | return
|
| | | askVer, askType, askMapID, askMapEx, askPlayerRetDict = PyGameData.g_teamFBEnterAskDict[retTeamID]
|
| | | askVer, askType, askMapID, askMapEx, askPlayerRetDict = PyGameData.g_teamFBEnterAskDict[retTeamID][:5]
|
| | | if askVer != retAskVer or askType != retAskType or askMapID != retAskMapID or askMapEx != retAskMapEx:
|
| | | GameWorld.DebugLog(" 非本队伍请求版本,不处理!askVer=%s, askType=%s, askMapID=%s, askMapEx=%s"
|
| | | % (askVer, askType, askMapID, askMapEx), playerID)
|
| | |
| | | '''准备队伍异常处理
|
| | | 后端延长15秒,防范前端异常情况导致卡队伍准备界面,超时时强制取消准备队伍
|
| | | '''
|
| | | if PyGameData.g_teamFBEnterAskDict:
|
| | | for teamID, askInfo in PyGameData.g_teamFBEnterAskDict.items():
|
| | | if askInfo:
|
| | | askVer, askType, askMapID, askMapEx, askPlayerRetDict, askTick = askInfo
|
| | | # 询问的做个10s预防,超时的话移除
|
| | | if tick - askTick <= 10000:
|
| | | continue
|
| | | PyGameData.g_teamFBEnterAskDict.pop(teamID)
|
| | | GameWorld.ErrLog("队伍进入副本询问超时,强制移除询问状态! teamID=%s,askVer=%s,askType=%s,askMapID=%s,askMapEx=%s,askPlayerRetDict=%s,askTick=%s,tick=%s" |
| | | % (teamID, askVer, askType, askMapID, askMapEx, askPlayerRetDict, askTick, tick))
|
| | | |
| | | if not PyGameData.g_prepareTeamDict:
|
| | | return
|
| | |
|
| | |
| | | SyncTeamEnterFBPrepareInfo(curTeam, askMapID, askMapEx, memStateDict, True)
|
| | | return
|
| | |
|
| | | #// B9 0A 按条件邀请玩家加入队伍 #tagCGInvitePlayerJoinTeamByLV
|
| | | #
|
| | | #struct tagCGInvitePlayerJoinTeamByLV
|
| | | #{
|
| | | # tagHead Head;
|
| | | # WORD LVLimit; // 目标玩家大于等于此等级
|
| | | # BYTE InviteCnt; // 邀请玩家个数
|
| | | #};
|
| | | def OnInvitePlayerJoinTeamByLV(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | lvlimit = clientData.LVLimit
|
| | | inviteCnt = clientData.InviteCnt
|
| | | |
| | | curPlayerTeam = curPlayer.GetTeam()
|
| | | if not curPlayerTeam:
|
| | | return
|
| | | curInviteCnt = 0 #当前邀请数量
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | | playerCount = playerManager.GetActivePlayerCount()
|
| | | if playerCount < 2:
|
| | | return
|
| | | indexList = range(playerCount)
|
| | | random.shuffle(indexList)
|
| | | for i in indexList:
|
| | | tagPlayer = playerManager.GetActivePlayerAt(i)
|
| | | if tagPlayer == None or not tagPlayer.GetInitOK():
|
| | | continue
|
| | | if PlayerControl.GetIsTJG(tagPlayer):
|
| | | continue
|
| | | if tagPlayer.GetPlayerID() == curPlayer.GetPlayerID():
|
| | | continue
|
| | | if tagPlayer.GetLV() < lvlimit:
|
| | | continue
|
| | | if tagPlayer.GetTeam():
|
| | | continue
|
| | | if InvitePlayerJoinTeamReq(curPlayer, tagPlayer, curPlayerTeam, tick):
|
| | | curInviteCnt +=1
|
| | | if curInviteCnt >= inviteCnt:
|
| | | break
|
| | | |
| | | return |