From 2638c8b67d1dcac1c774f942ac144579c6f82ec1 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 11 九月 2018 21:41:11 +0800
Subject: [PATCH] 3479 【后端】【主干】【1.0.15】助战发送喊话时新增逻辑(自动加入匹配中的队伍);

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTeam.py |   72 ++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTeam.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTeam.py
index 0d135e1..817fd01 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerTeam.py
+++ b/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
 #

--
Gitblit v1.8.0