hxp
2021-11-17 ffa8a645ed6a92a3c723bbf5c7f1eb4d5425c826
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
@@ -20,12 +20,17 @@
import GameWorld
import ChConfig
import ShareDefine
import PlayerControl
import ChPyNetSendPack
import PlayerDBGSEvent
import NetPackCommon
import DataRecordPack
import PlayerFamily
import PyDataManager
import PlayerViewCache
import time
import random
Def_Key_BillboardSortTick = "BillboardSortTick_%s" # 排行榜是否排序tick,参数(排行榜类型)
Def_Key_BillboardNeedSort = "BillboardNeedSort_%s" # 排行榜是否需要排序,参数(排行榜类型)
@@ -74,6 +79,30 @@
        
    return
def __CheckFightPowerBillboard():
    ## 由于战力修改为支持超过20E,所以需要处理下战力相关榜单,原 cmpValue 值移动到 cmpValue2
    eventKey = "FightPowerBillboardMoveValue"
    if PlayerDBGSEvent.GetDBGSTrig_ByKey(eventKey):
        return
    PlayerDBGSEvent.SetDBGSTrig_ByKey(eventKey, 1)
    GameWorld.Log("处理战力榜超过20E支持!")
    billboardList = [ShareDefine.Def_BT_FightPower] + ShareDefine.JobFightPowerBillboardDict.values()
    for billboardType in billboardList:
        billboard = GameWorld.GetBillboard().FindBillboard(billboardType)
        if not billboard:
            continue
        GameWorld.Log("    billboardType=%s,count=%s" % (billboardType, billboard.GetCount()))
        for index in xrange(billboard.GetCount()):
            billBoardData = billboard.At(index)
            if not billBoardData:
                continue
            billBoardData.SetCmpValue2(billBoardData.GetCmpValue())
            billBoardData.SetCmpValue(0)
    return
def SortServerBillboard():
    ##排序所有排行榜
    billboardMgr = GameWorld.GetBillboard()
@@ -82,7 +111,8 @@
        billBoard = billboardMgr.FindBillboard(index)
        #排序一次排行榜
        billBoard.Sort()
    __CheckFightPowerBillboard()
    return
def CopyBillboard(newBillboardIndex, oldBillboardIndex):
@@ -417,7 +447,7 @@
def MapServer_UpdateBillboard(billInfoDict, tick):
    '''地图更新排行榜, 通用
    {"Type":bType, "Type2":bType2, "ID":bID, "ID2":bID2, "Name1":bName, "Name2":bName2, "ExInfo":exInfo,
    "Value1":value1, "Value2":value2, "CmpValue":cmpValue, "CmpValue2":cmpValue2, "CmpValue3":cmpValue3}
    "Value1":value1, "Value2":value2, "CmpValue":cmpValue, "CmpValue2":cmpValue2, "CmpValue3":cmpValue3, "autoSort":autoSort}
    '''
    
    bType = billInfoDict["Type"]
@@ -450,7 +480,7 @@
    
    gameWorld = GameWorld.GetGameWorld()
    lastSortTick = gameWorld.GetDictByKey(Def_Key_BillboardSortTick % bType)
    autoSort = (tick - lastSortTick) >= 60000 # 1分钟强制排序一次
    autoSort = (tick - lastSortTick) >= 60000 or billInfoDict.get("autoSort") == True # 1分钟强制排序一次
    if autoSort:
        gameWorld.SetDict(Def_Key_BillboardSortTick % bType, tick)
    #GameWorld.DebugLog("更新排行榜:bType=%s,autoSort=%s,tick=%s,lastSortTick=%s,d=%s" % (bType, autoSort, tick, lastSortTick, tick - lastSortTick))
@@ -463,13 +493,13 @@
    # 以下为榜单附加特殊处理
    if bType == ShareDefine.Def_BT_FightPower:
        playerID = bID
        fightPowerTotal = cmpValue
        fightPowerTotal = cmpValue * ChConfig.Def_PerPointValue + cmpValue2
        familyID = exInfo[0]
        playerJob = bType2
        
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
        if curPlayer:
            curPlayer.SetFightPower(fightPowerTotal)
            PlayerControl.SetFightPower(curPlayer, fightPowerTotal)
            
        #更新战盟成员战力
        PlayerFamily.UpdFamilyMemberFightPower(familyID, playerID, fightPowerTotal)
@@ -478,7 +508,7 @@
        job = playerJob % 10
        if job in ShareDefine.JobFightPowerBillboardDict:
            jobBType = ShareDefine.JobFightPowerBillboardDict[job]
            UpdatePlayerBillboard(bID, bName, bName2, jobBType, bType2, value1, value2, cmpValue, autoSort)
            UpdatePlayerBillboard(bID, bName, bName2, jobBType, bType2, value1, value2, cmpValue, autoSort, cmpValue2)
            gameWorld.SetDict(Def_Key_BillboardNeedSort % jobBType, 1)
            #__UpdateBillboardSortState(gameWorld, jobBType, autoSort, isUpd)
            
@@ -495,6 +525,53 @@
    #GameWorld.DebugLog("__UpdateBillboardSortState:bType=%s,autoSort=%s,isUpd=%s,needSort=%s" % (bType, autoSort, isUpd, gameWorld.GetDictByKey(key)))
    return
def GetBillboardOperateInfo(curPlayer):
    # 排行榜中所保存的运营商相关信息
    platform = curPlayer.GetAccID()
    if platform in ["tencent"]:
        return curPlayer.GetOperateInfo()
    return platform
def UpdatePlayerBillboardEx(curPlayer, playerID, bType, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0, autoSort=False):
    ## 更新玩家排行榜
    # @param curPlayer: 可能为None
    playerOpInfo = ""
    playerJob = 0
    playerName = ""
    playerRealmLV = 0
    if curPlayer:
        playerID = curPlayer.GetID()
        playerJob = curPlayer.GetJob()
        playerName = curPlayer.GetName()
        playerRealmLV = curPlayer.GetOfficialRank()
        playerOpInfo = GetBillboardOperateInfo(curPlayer)
    else:
        socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID)
        if socialPlayer:
            playerJob = socialPlayer.playerInfo.Job
            playerName = socialPlayer.playerInfo.PlayerName
            playerRealmLV = socialPlayer.playerInfo.RealmLV
        else:
            curCache = PlayerViewCache.FindViewCache(playerID)
            if curCache:
                cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
                playerJob = cacheDict["Job"]
                playerName = cacheDict["Name"]
                playerRealmLV = cacheDict["RealmLV"]
    if not playerName and playerID < 10000:
        playerJob = random.choice([1, 2])
        playerName = "testName%s" % playerID
        playerRealmLV = random.randint(1, 10)
    if bType in ShareDefine.BTValue1_OfficialRankList:
        value1 = playerRealmLV
    UpdatePlayerBillboard(playerID, playerName, playerOpInfo, bType, playerJob, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
    return
#---------------------------------------------------------------------
#===============================================================================
#    void        SetType(int inputType);    //_I_KEY_INDEX_排行榜类型