From d25f856346bbcecf0e44e26d3e0d641ded2bc81e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 23 九月 2022 14:35:08 +0800
Subject: [PATCH] 9701 【后端】【越南】【BT7】【主干】跨服竞技64位排位赛(支持投注;GM命令支持不指定玩家ID时可全组重新随机匹配; 跨服服务器时间调整通知前端)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossChampionship.py |   81 ++++++++++++++++++++++++++--------------
 1 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossChampionship.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossChampionship.py
index 06ca95c..3e6f773 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossChampionship.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossChampionship.py
@@ -542,7 +542,7 @@
         if not offObj:
             continue
         offObj.challengeList.append(challengeDict)
-        GameWorld.Log("    zoneID=%s,officialID=%s,挑战记录=%s" % (zoneID, officialID, challengeDict))
+        #GameWorld.Log("    zoneID=%s,officialID=%s,挑战记录=%s" % (zoneID, officialID, challengeDict))
         
     return
 
@@ -591,7 +591,7 @@
         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)
         for guessType, playerGuessDict in pkZoneMgr.guessInfo.items():
             for guessPlayerID, guessObjList in playerGuessDict.items():
-                GameWorld.Log("    zoneID=%s,guessType=%s,guessPlayerID=%s,guessCount=%s" % (zoneID, guessType, guessPlayerID, len(guessObjList)))
+                #GameWorld.Log("    zoneID=%s,guessType=%s,guessPlayerID=%s,guessCount=%s" % (zoneID, guessType, guessPlayerID, len(guessObjList)))
                 for guessObj in guessObjList:
                     recData = guessRecDataList.AddRec()
                     recData.SetValue1(zoneID)
@@ -608,7 +608,7 @@
     challengeRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipOffChallenge)
     for zoneID in offZoneIDList:
         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)
-        GameWorld.Log("    zoneID=%s,officialInfoKey=%s" % (zoneID, offZoneMgr.officialInfo.keys()))
+        #GameWorld.Log("    zoneID=%s,officialInfoKey=%s" % (zoneID, offZoneMgr.officialInfo.keys()))
         for officialID in offZoneMgr.officialInfo.keys():
             offObj = offZoneMgr.GetOfficialObj(officialID)
             if not offObj:
@@ -624,8 +624,8 @@
             strValue3 = strValue3.replace(" ", "")
             recData.SetStrValue3(strValue3)
             
-            GameWorld.Log("        zoneID=%s,officialID=%s,playerID=%s,rank=%s,challengeCount=%s" 
-                          % (zoneID, officialID, offObj.playerID, offObj.rank, len(offObj.challengeList)))
+            #GameWorld.Log("        zoneID=%s,officialID=%s,playerID=%s,rank=%s,challengeCount=%s" 
+            #              % (zoneID, officialID, offObj.playerID, offObj.rank, len(offObj.challengeList)))
             for challengeDict in offObj.challengeList:
                 challRecData = challengeRecDataList.AddRec()
                 challRecData.SetValue1(value1)
@@ -757,6 +757,9 @@
         if playerID not in pkZoneMgr.syncGuessPlayerIDInfo:
             sendMsg = {"zoneID":playerZoneID, "playerID":playerID, "exDataType":"ChampionshipGuessQuery"}
             CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipGuess, sendMsg)
+        else:
+            Sync_ChampionshipGuessPriInfo(curPlayer)
+            Sync_ChampionshipGuessPubInfo(playerZoneID, curPlayer)
             
     return
 
@@ -826,7 +829,7 @@
     stateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)
     
     updState = 0
-    crossChampionshipID = 0
+    crossChampionshipID = dbCrossChampionshipID
     
     # 这里时间需精确到分钟,不然后面的比较会匹配不到
     curDateTime = GameWorld.GetServerTime()
@@ -1511,17 +1514,18 @@
     
     champMgr = GetChampionshipMgr()
     
-    syncKeyList = []
+    syncKeyInfo = {}
     for attrDict in guessList:
         zoneID = attrDict["zoneID"]
         guessType = attrDict["guessType"]
         guessPlayerID = attrDict["guessPlayerID"]
         tagPlayerID = attrDict["tagPlayerID"]
         
-        syncKey = [guessType, tagPlayerID]
-        if syncKey not in syncKeyList:
-            syncKeyList.append(syncKey)
-            
+        if guessType not in syncKeyInfo:
+            syncKeyInfo[guessType] = []
+        syncTagPlayerIDList = syncKeyInfo[guessType]
+        syncTagPlayerIDList.append(tagPlayerID)
+        
         # 竞猜列表仅针对玩家个人,所以不是请求方玩家或本服玩家则不处理个人信息,仅处理公共信息
         if playerID != guessPlayerID:
             continue
@@ -1563,17 +1567,17 @@
         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)
         pkZoneMgr.syncGuessPlayerIDInfo[playerID] = tick
         curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
-        if curPlayer == None or not curPlayer.GetInitOK():
+        if curPlayer == None:
             return
-        Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyList)
-        Sync_ChampionshipGuessPubInfo(zoneID, curPlayer, syncKeyList)
+        Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo)
+        Sync_ChampionshipGuessPubInfo(zoneID, curPlayer, syncKeyInfo)
         return
     
     if exDataType == "ChampionshipGuess":
         # 竞猜的如果有公共信息需要广播全服玩家,个人信息只同步该竞猜玩家
         zoneID = exData.get("zoneID", 0)
         if pubInfo != None:
-            Sync_ChampionshipGuessPubInfo(zoneID, None, syncKeyList)
+            Sync_ChampionshipGuessPubInfo(zoneID, None, syncKeyInfo)
         if not playerID:
             return
         if not PlayerControl.GetDBPlayerAccIDByID(playerID):
@@ -1582,7 +1586,7 @@
         msgInfo = [exDataType, exData]
         curPlayer = CrossRealmPlayer.MapServer_QueryCrossPlayerResult(playerID, "Championship", msgInfo, True)
         if curPlayer:
-            Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyList)
+            Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo)
         return
     
     return
@@ -2170,10 +2174,12 @@
     if not tagBatPlayer:
         GameWorld.ErrLog("该分区不存在该参赛玩家,无法排位竞猜! zoneID=%s,tagPlayerID=%s" % (zoneID, tagPlayerID), playerID)
         return
-        
+    
+    guessTagPlayerCountMax = guessType
     # 4强竞猜
     if guessType == 4:
-        if not guessRank:
+        if guessRank <= 0 or guessRank > guessTagPlayerCountMax:
+            GameWorld.ErrLog("竞猜名次错误! zoneID=%s,guessType=%s,guessRank=%s" % (zoneID, guessType, guessRank), playerID)
             return
         top8PlayerIDList = pkZoneMgr.GetTop8PlayerIDList()
         if tagPlayerID not in top8PlayerIDList:
@@ -2185,8 +2191,13 @@
     playerGuessList = pkZoneMgr.GetPlayerGuessList(playerID, guessType)
     for guess in playerGuessList:
         if guess.tagPlayerID == tagPlayerID:
+            if guessType == 4:
+                if guess.guessRank != guessRank:
+                    GameWorld.ErrLog("已经存在该竞猜,但是不能修改竞猜名次,无法竞猜! zoneID=%s,guessType=%s,tagPlayerID=%s, guessRank(%s) != guess.guessRank(%s)" 
+                         % (zoneID, guessType, tagPlayerID, guessRank, guess.guessRank), playerID)
+                    return
             guessObj = guess
-            GameWorld.Log("已经存在该竞猜,玩家进行加注!  guessInfo=%s" % guess.GetString())
+            GameWorld.Log("已经存在该竞猜,玩家进行加注!  guessInfo=%s" % guess.GetString(), playerID)
         else:
             if guessType == 4:
                 if guess.guessRank == guessRank:
@@ -2202,6 +2213,10 @@
     
     syncPub = False # 同步公共信息
     if not guessObj:
+        if len(playerGuessList) >= guessTagPlayerCountMax:
+            GameWorld.ErrLog("超出每个玩家最大竞猜人数,无法竞猜! zoneID=%s,guessType=%s,playerGuessListLen=%s >= guessTagPlayerCountMax=%s" 
+                             % (zoneID, guessType, len(playerGuessList), guessTagPlayerCountMax), playerID)
+            return
         guessObj = ChampionshipGuess()
         guessObj.zoneID = zoneID
         guessObj.guessType = guessType
@@ -2803,9 +2818,9 @@
             
     return
 
-def Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyList=None):
+def Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo=None):
     ## 同步排位分区竞猜个人信息
-    # @param syncKeyList: 指定同步的 [[guessType, tagPlayerID], ...]
+    # @param syncKeyInfo: 指定同步的 {guessType:[tagPlayerID, ...], ...}
     
     playerID = curPlayer.GetPlayerID()
     champMgr = GetChampionshipMgr()
@@ -2820,14 +2835,18 @@
     clientPack.GuessList = []
     
     for guessType, playerGuessDict in pkZoneMgr.guessInfo.items():
+        if syncKeyInfo and guessType not in syncKeyInfo:
+            continue
+        syncTagPlayerIDList = [] if not syncKeyInfo else syncKeyInfo.get(guessType, [])
+        
         priListPack = ChPyNetSendPack.tagGCChampionshipGuessPriList()
         priListPack.GuessType = guessType
         priListPack.GuessPlayerList = []
+        
         playerGuessList = playerGuessDict.get(playerID, [])
         for guess in playerGuessList:
             tagPlayerID = guess.tagPlayerID
-            syncKey = [guessType, tagPlayerID]
-            if syncKeyList and syncKey not in syncKeyList:
+            if syncTagPlayerIDList and tagPlayerID not in syncTagPlayerIDList:
                 continue
             priPlayerPack = ChPyNetSendPack.tagGCChampionshipGuessPlayerPri()
             priPlayerPack.PlayerID = tagPlayerID
@@ -2842,9 +2861,9 @@
     NetPackCommon.SendFakePack(curPlayer, clientPack)
     return
 
-def Sync_ChampionshipGuessPubInfo(zoneID, curPlayer=None, syncKeyList=None):
+def Sync_ChampionshipGuessPubInfo(zoneID, curPlayer=None, syncKeyInfo=None):
     ## 同步排位分区竞猜公共信息
-    # @param syncKeyList: 指定同步的 [[guessType, tagPlayerID], ...]
+    # @param syncKeyInfo: 指定同步的 {guessType:[tagPlayerID, ...], ...}
     
     champMgr = GetChampionshipMgr()
     if curPlayer:
@@ -2858,16 +2877,18 @@
     clientPack = ChPyNetSendPack.tagGCChampionshipGuessPubInfo()
     clientPack.ZoneID = zoneID
     clientPack.GuessList = []
-    clientPack.Count = len(clientPack.GuessList)
     
     for guessType, playerSupportCountDict in pkZoneMgr.supportCountInfo.items():
+        if syncKeyInfo and guessType not in syncKeyInfo:
+            continue
+        syncTagPlayerIDList = [] if not syncKeyInfo else syncKeyInfo.get(guessType, [])
+        
         pubListPack = ChPyNetSendPack.tagGCChampionshipGuessPubList()
         pubListPack.GuessType = guessType
         pubListPack.GuessPlayerList = []
         
         for tagPlayerID, supportCount in playerSupportCountDict.items():
-            syncKey = [guessType, tagPlayerID]
-            if syncKeyList and syncKey not in syncKeyList:
+            if syncTagPlayerIDList and tagPlayerID not in syncTagPlayerIDList:
                 continue
             pubPlayerPack = ChPyNetSendPack.tagGCChampionshipGuessPlayerPub()
             pubPlayerPack.PlayerID = tagPlayerID
@@ -2876,7 +2897,9 @@
         pubListPack.PlayerCount = len(pubListPack.GuessPlayerList)
         
         clientPack.GuessList.append(pubListPack)
-        
+                
+    clientPack.Count = len(clientPack.GuessList)
+    
     if curPlayer != None:
         NetPackCommon.SendFakePack(curPlayer, clientPack)
     else:

--
Gitblit v1.8.0