ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -45,6 +45,8 @@
        self.playerName = ""
        self.playerJob = 0
        self.playerLV = 0
        self.face = 0
        self.facePic = 0
        self.maxHP = 0
        self.maxProDef = 0
        self.fightPower = 0
@@ -152,7 +154,7 @@
        billboardList = billboardList[:len(syncBillboardList)] # 直接用本服以后的排行数据实例clear后覆盖更新,不足的创建新实例
        orderDict = {} # 排行信息重新更新
        for i, syncData in enumerate(syncBillboardList):
            playerID, playerName, job, fightPower, realmLV, pkScore, danLV, billTime, order = syncData
            playerID, playerName, job, face, facePic, fightPower, realmLV, pkScore, danLV, billTime, order = syncData
            if i < len(billboardList):
                billboardData = billboardList[i]
                billboardData.clear()
@@ -164,6 +166,8 @@
            billboardData.PlayerID = playerID
            billboardData.PlayerName = playerName
            billboardData.Job = job
            billboardData.Face = face
            billboardData.FacePic = facePic
            billboardData.FightPower = fightPower
            billboardData.RealmLV = realmLV
            billboardData.PKScore = pkScore
@@ -226,7 +230,7 @@
            
        return pos
    
def UpdateCrossPKBillboard(zoneID, seasonID, winner, loser):
def UpdateCrossPKBillboard(zoneID, seasonID, winner, loser, syncClientServer=False):
    ## 更新跨服PK排行榜,跨服服务器结算调用,子服不调用
    
    curZoneSeasonID = GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)
@@ -295,6 +299,8 @@
        billboardData.PlayerID = playerID
        billboardData.PlayerName = pkPlayer.playerName
        billboardData.Job = pkPlayer.playerJob
        billboardData.Face = pkPlayer.face
        billboardData.FacePic = pkPlayer.facePic
        billboardData.FightPower = pkPlayer.fightPower
        billboardData.RealmLV = pkPlayer.realmLV
        billboardData.PKScore = pkPlayer.pkScore
@@ -310,13 +316,15 @@
    matchState = GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
    if not matchState and not PyGameData.g_crossPKRoomDict:
        GameWorld.Log("匹配已结束,且当前没有PK中的房间了!主动广播子服最新榜单! ")
        syncClientServer = True
    if syncClientServer:
        crossZoneName = GameWorld.GetCrossZoneName()
        zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
        if zoneIpyData:
            serverGroupIDList = zoneIpyData.GetServerGroupIDList()
            SyncPKSyncBillboardToClientServer(zoneID, seasonID, serverGroupIDList)
            
    return
    return True
#// C0 01 查看跨服竞技场赛季排行榜 #tagCGViewCrossPKBillboard
#
@@ -438,6 +446,9 @@
def ClientServerMsg_PKBillboard(serverGroupID, msgData):
    ## 收到子服请求查询PK排行榜信息
    if "GMSetCrossPK" in msgData:
        _GMSetCrossPK(serverGroupID, msgData)
        return
    zoneID = msgData["ZoneID"]
    seasonID = msgData["SeasonID"]
    exData = msgData.get("ExData", {}) # 原数据返回子服
@@ -463,13 +474,15 @@
        playerID = billboardData.PlayerID
        playerName = billboardData.PlayerName
        job = billboardData.Job
        face = billboardData.Face
        facePic = billboardData.FacePic
        fightPower = billboardData.FightPower
        realmLV = billboardData.RealmLV
        pkScore = billboardData.PKScore
        danLV = billboardData.DanLV
        billTime = billboardData.Time
        order = orderDict.get(playerID, 0)
        syncBillboardList.append([playerID, playerName, job, fightPower, realmLV, pkScore, danLV, billTime, order])
        syncBillboardList.append([playerID, playerName, job, face, facePic, fightPower, realmLV, pkScore, danLV, billTime, order])
        
    syncInfo = [zoneID, seasonID, syncBillboardList, exData, isFinalBillboardData]
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKSyncBillboard, syncInfo, serverGroupIDList)
@@ -516,6 +529,8 @@
        billboardInfoData.PlayerName = billboardData.PlayerName
        billboardInfoData.NameLen = len(billboardInfoData.PlayerName)
        billboardInfoData.Job = billboardData.Job
        billboardInfoData.Face = billboardData.Face
        billboardInfoData.FacePic = billboardData.FacePic
        billboardInfoData.FightPower = billboardData.FightPower
        billboardInfoData.RealmLV = billboardData.RealmLV
        billboardInfoData.PKScore = billboardData.PKScore
@@ -884,6 +899,8 @@
    playerID = playerInfoDict["playerID"] # 角色ID
    playerName = playerInfoDict["playerName"] # 玩家名
    job = playerInfoDict["playerJob"] # ְҵ
    face = playerInfoDict["face"]
    facePic = playerInfoDict["facePic"]
    playerLV = playerInfoDict["playerLV"] # ְҵ
    maxHP = playerInfoDict["maxHP"] # ְҵ
    maxProDef = playerInfoDict["maxProDef"] # 护盾
@@ -915,6 +932,8 @@
    pkPlayer.playerName = playerName
    pkPlayer.playerJob = job
    pkPlayer.playerLV = playerLV
    pkPlayer.face = face
    pkPlayer.facePic = facePic
    pkPlayer.maxHP = maxHP
    pkPlayer.maxProDef = maxProDef
    pkPlayer.pkScore = pkScore
@@ -1145,7 +1164,7 @@
            pkZoneID = roomPlayer.pkZoneID
            roomGroupIDList.append(roomPlayer.serverGroupID)
            readyMemberDict[roomPlayerID] = {"ServerGroupID":roomPlayer.serverGroupID, "Name":roomPlayer.playerName, "Number":num,
                                             "Job":roomPlayer.playerJob, "LV":roomPlayer.playerLV, "MaxHP":roomPlayer.maxHP, "MaxProDef":roomPlayer.maxProDef}
                                             "Job":roomPlayer.playerJob, "Face":roomPlayer.face, "FacePic":roomPlayer.facePic, "LV":roomPlayer.playerLV, "MaxHP":roomPlayer.maxHP, "MaxProDef":roomPlayer.maxProDef}
                    
        if not isAllReady:
            continue
@@ -1797,6 +1816,62 @@
    DR_CrossReamlPK("PKOverRobot", dataDict)
    return
def _GMSetCrossPK(serverGroupID, msgData):
    ## 收到子服GM同步的设置跨服PK数据
    if not GameWorld.IsCrossServer():
        GameWorld.ErrLog("GMSetCrossPK非跨服服务器不处理该跨服GM请求!")
        return
    zoneID = msgData["ZoneID"]
    seasonID = msgData["SeasonID"]
    playerInfoDict = msgData["PlayerInfo"]
    accID = playerInfoDict["accID"]
    playerID = playerInfoDict["playerID"]
    playerName = playerInfoDict["playerName"]
    playerJob = playerInfoDict["playerJob"]
    face = playerInfoDict.get("face", 0)
    facePic = playerInfoDict.get("facePic", 0)
    fightPower = playerInfoDict["fightPower"]
    realmLV = playerInfoDict["realmLV"]
    pkScore = playerInfoDict["pkScore"]
    danLV = playerInfoDict["danLV"]
    cWinCount = playerInfoDict["cWinCount"]
    ondayScore = playerInfoDict["ondayScore"]
    zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(zoneID, [])
    if playerID in zoneMatchPlayerList or playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict or playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
        GameWorld.ErrLog("GMSetCrossPK玩家正在匹配中,无法设置该GM请求数据! playerID=%s,accID=%s" % (playerID, accID))
        return
    pkPlayer = CrossPKPlayer()
    pkPlayer.accID = accID
    pkPlayer.playerID = playerID
    pkPlayer.playerName = playerName
    pkPlayer.playerJob = playerJob
    pkPlayer.face = face
    pkPlayer.facePic = facePic
    pkPlayer.pkScore = pkScore
    pkPlayer.danLV = danLV
    pkPlayer.fightPower = fightPower
    pkPlayer.realmLV = realmLV
    pkPlayer.cWinCount = cWinCount
    pkPlayer.ondayScore = ondayScore
    pkPlayer.serverGroupID = serverGroupID
    pkPlayer.pkZoneID = zoneID
    pkPlayer.seasonID = seasonID
    # 更新排行榜
    isOK = UpdateCrossPKBillboard(zoneID, seasonID, pkPlayer, None, True)
    GameWorld.Log("GMSetCrossPK设置跨服PK榜单玩家数据成功: isOK=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,accID=%s"
                  % (isOK, zoneID, seasonID, pkScore, danLV, cWinCount, accID), playerID)
    # 记录流向
    dataDict = {"zoneID":zoneID, "seasonID":seasonID, "pkPlayer":pkPlayer.GetDRInfo()}
    DR_CrossReamlPK("GMSet", dataDict)
    return
##================================== 以下是子服逻辑 ==========================================
def OnGameServerInitOK():
@@ -2007,6 +2082,8 @@
                    matchPlayer.NameLen = len(matchPlayer.PlayerName)
                    matchPlayer.Job = readyPlayerInfo["Job"]
                    matchPlayer.LV = readyPlayerInfo["LV"]
                    matchPlayer.Face = readyPlayerInfo["Face"]
                    matchPlayer.FacePic = readyPlayerInfo["FacePic"]
                    matchPlayer.MaxHP = readyPlayerInfo["MaxHP"] % ShareDefine.Def_PerPointValue
                    matchPlayer.MaxHPEx = readyPlayerInfo["MaxHP"] / ShareDefine.Def_PerPointValue
                    matchPlayer.MaxProDef = readyPlayerInfo["MaxProDef"]
@@ -2183,3 +2260,30 @@
    DataRecordPack.SendEventPack("CrossPK_%s" % eventName, drDataDict)
    return
def IsCrossRealmPKPlayer(playerID, checkPreSeason=False, checkAllSeason=False):
    ## 仅跨服服务器判断用
    # @param checkPreSeason: 检查上一赛季
    # @param checkAllSeason: 检查所有赛季
    # 默认取分区1的赛季作为当前赛季,所有分区赛季ID相同,且递增
    gameWorld = GameWorld.GetGameWorld()
    nowSeasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % 1)
    preSeasonID = nowSeasonID - 1
    crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
    crossZoneName = GameWorld.GetCrossZoneName()
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for index in range(ipyDataMgr.GetCrossRealmPKSeasonCount()):
        seasonIpyData = ipyDataMgr.GetCrossRealmPKSeasonByIndex(index)
        if crossZoneName != seasonIpyData.GetCrossZoneName():
            continue
        zoneID = seasonIpyData.GetZoneID()
        seasonID = seasonIpyData.GetSeasonID()
        if checkAllSeason or seasonID == nowSeasonID or (checkPreSeason and seasonID == preSeasonID):
            pass
        else:
            continue
        _, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID)
        if orderDict and playerID in orderDict:
            return True
    return False