ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -22,6 +22,7 @@
import ChPyNetSendPack
import PyGameDataStruct
import PlayerDBGSEvent
import PlayerViewCache
import CrossBillboard
import PyDataManager
import NetPackCommon
@@ -450,9 +451,10 @@
    playerID = playerInfoDict["playerID"] # 角色ID
    fightPower = playerInfoDict["fightPower"]
    requestType = playerInfoDict.get("requestType", 0)
    gmMatchIDList = playerInfoDict.get("gmMatchIDList", [])
    
    isRefresh = requestType == 1
    OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh)
    OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh, gmMatchIDList)
    return
def ClientServerMsg_PKOver(serverGroupID, playerInfoDict, tick):
@@ -512,9 +514,8 @@
    
    # 通知子服
    pkScore = updScore
    packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
    tagPackObj = packDataMgr.GetPlayerPackObj(tagPlayerID)
    tagPlayerName = tagPackObj.playerName if tagPackObj else ""
    tagCacheDict = PlayerViewCache.GetCachePropDataDict(PlayerViewCache.FindViewCache(tagPlayerID))
    tagPlayerName = tagCacheDict.get("Name", "")
    winnerID = playerID if isWinner else tagPlayerID
    timeStr = GameWorld.GetCurrentDataTimeStr()
    playerOverDict = {}
@@ -526,30 +527,27 @@
    OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, True)
    return
def OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh):
def OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh, gmMatchIDList=None):
    # 刷新匹配数据
    # @param isRefresh: 是否强制重新刷新
    
    if isRefresh or playerID not in PyGameData.g_crossPKMatchDict:
        # 执行匹配逻辑
        matchIDList = __DoPKMatch(zoneID, seasonID, playerID, fightPower)
        if matchIDList: # 有新结果才替换
            PyGameData.g_crossPKMatchDict[playerID] = matchIDList
    packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
        __DoPKMatch(zoneID, seasonID, playerID, fightPower, gmMatchIDList)
    matchIDList = PyGameData.g_crossPKMatchDict.get(playerID, [])
    matchInfoDict = {}
    for matchID in matchIDList:
        packObj = packDataMgr.GetPlayerPackObj(matchID)
        if not packObj:
        viewCache = PlayerViewCache.FindViewCache(matchID)
        if not viewCache:
            continue
        matchInfoDict[matchID] = packObj.GetBaseDict()
        matchInfoDict[matchID] = viewCache.getBuffer()
        
    dataMsg = {"playerID":playerID, "matchIDList":matchIDList, "matchInfoDict":matchInfoDict}
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, dataMsg, [serverGroupID])
    return
def __DoPKMatch(zoneID, seasonID, playerID, fightPower):
def __DoPKMatch(zoneID, seasonID, playerID, fightPower, gmMatchIDList=None):
    ## 执行匹配
    
    if not IsCrossRealmPKMatchState():
@@ -630,12 +628,22 @@
        matchIDList[-1] = robotID
        GameWorld.DebugLog("没有匹配到机器人,概率直接匹配到机器人: robotID=%s" % robotID, playerID)
        
    GameWorld.DebugLog("最终匹配结果: matchIDList=%s" % str(matchIDList), playerID)
    #GM指定匹配
    if gmMatchIDList:
        GameWorld.DebugLog("GM指定匹配目标玩家ID: gmMatchIDList=%s" % gmMatchIDList, playerID)
        for gmMatchID in gmMatchIDList:
            if matchIDList:
                matchIDList.pop(0)
            matchIDList.append(gmMatchID)
    GameWorld.DebugLog("最终匹配结果: matchIDList=%s" % str(matchIDList), playerID)
    if matchIDList: # 有新结果才替换
        PyGameData.g_crossPKMatchDict[playerID] = matchIDList
    return matchIDList
def __addRandMatchID(playerID, matchIndex, rankRange, randIDList, matchIDList, loopPlayerIDList, sign):
    ## 根据所有可循环玩家ID列表,添加对应匹配轮次可随机匹配的玩家
    packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
    pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
    indexStart = matchIndex * rankRange
    indexEnd = indexStart + rankRange - 1
    loopIDCount = len(loopPlayerIDList)
@@ -653,8 +661,8 @@
        if dataID in matchIDList:
            GameWorld.DebugLog("        不可添加已匹配过玩家: dataID=%s,randIDList=%s,matchIDList=%s" % (dataID, randIDList, matchIDList), playerID)
            continue
        if not packDataMgr.IsPlayerIn(dataID):
            GameWorld.DebugLog("        不匹配无打包数据玩家: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
        if not pyViewCacheMgr.IsPlayerIn(dataID):
            GameWorld.DebugLog("        不匹配无缓存数据玩家: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
            continue
        randIDList.append(dataID)
        GameWorld.DebugLog("        添加可以随机匹配玩家: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
@@ -666,10 +674,9 @@
    crossZoneName = GameWorld.GetCrossZoneName()
    zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
    if zoneIpyData:
        packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
        packDataMgr.Sort()
        serverIDList = zoneIpyData.GetServerGroupIDList()
        zonePackPlayerIDList = packDataMgr.GetPlayerIDListByServerIDInfo(zoneIpyData.GetServerGroupIDList())
        pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
        zonePackPlayerIDList = pyViewCacheMgr.GetPlayerIDListByServerIDInfo(serverIDList)
        GameWorld.DebugLog("    获得赛区活跃打包数据玩家: zoneID=%s,serverIDList=%s,%s,%s" 
                           % (zoneID, serverIDList, len(zonePackPlayerIDList), zonePackPlayerIDList), playerID)
        return zonePackPlayerIDList
@@ -824,22 +831,27 @@
    matchOKPack.MatchPlayer = []
    for matchID in matchIDList:
        matchPlayer = ChPyNetSendPack.tagGCCrossRealmPKMatchPlayer()
        if matchID not in matchInfoDict:
            matchPlayer.PlayerID = matchID
            matchOKPack.MatchPlayer.append(matchPlayer)
            continue
        matchInfo = matchInfoDict[matchID]
        matchPlayer.PlayerID = matchInfo["playerID"]
        matchPlayer.PlayerName = matchInfo["playerName"]
        matchPlayer.NameLen = len(matchPlayer.PlayerName)
        matchPlayer.Job = matchInfo["job"]
        matchPlayer.LV = matchInfo["lv"]
        matchPlayer.RealmLV = matchInfo["realmLV"]
        matchPlayer.Face = matchInfo["face"]
        matchPlayer.FacePic = matchInfo["facePic"]
        matchPlayer.FightPower = matchInfo["fightPower"] % ChConfig.Def_PerPointValue
        matchPlayer.FightPowerEx = matchInfo["fightPower"] / ChConfig.Def_PerPointValue
        matchPlayer.PlayerID = matchID
        matchOKPack.MatchPlayer.append(matchPlayer)
        if matchID not in matchInfoDict:
            continue
        cacheBuffer = matchInfoDict[matchID]
        curCache = PlayerViewCache.ReadCacheBufferToCacheObj(matchID, cacheBuffer)
        if not curCache:
            continue
        PlayerViewCache.Sync_PlayerCache(curPlayer, curCache)
        cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
        matchPlayer.PlayerID = matchID
        matchPlayer.PlayerName = cacheDict.get("Name", "")
        matchPlayer.NameLen = len(matchPlayer.PlayerName)
        matchPlayer.Job = cacheDict.get("Job", 1)
        matchPlayer.LV = cacheDict.get("LV", 1)
        matchPlayer.RealmLV = cacheDict.get("RealmLV", 0)
        matchPlayer.Face = cacheDict.get("Face", 0)
        matchPlayer.FacePic = cacheDict.get("FacePic", 0)
        matchPlayer.FightPower = cacheDict.get("FightPower", 0) % ChConfig.Def_PerPointValue
        matchPlayer.FightPowerEx = cacheDict.get("FightPower", 0) / ChConfig.Def_PerPointValue
        #matchOKPack.MatchPlayer.append(matchPlayer)
    matchOKPack.MatchPlayerCount = len(matchOKPack.MatchPlayer)
    NetPackCommon.SendFakePack(curPlayer, matchOKPack)
    return