hxp
2024-06-03 242e5a77aac262b16b20bd2ab52adb3233fe2475
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
@@ -61,6 +61,13 @@
            self.__billboardDict[key] = billboardObj
        return billboardObj
    
    def RemoveBillboard(self, billboardType):
        ## 移除某个类型的榜单所有数据
        for key in self.__billboardDict.keys():
            if key[0] == billboardType:
                self.__billboardDict.pop(key)
        return
    # 保存数据 存数据库和realtimebackup
    def GetSaveData(self):
        savaData = ""
@@ -118,6 +125,8 @@
    def ClearData(self):
        GameWorld.Log("CrossBillboard ClearData billboardType=%s,groupValue1=%s,groupValue2=%s" 
                      % (self.__billboardType, self.__groupValue1, self.__groupValue2))
        if GameWorld.IsCrossServer():
            self.SaveDRData()
        self.__billboardList = [] # [tagDBCrossBillboard, ...] 
        self.__idOrderDict = {} # {id:名次, ...}
        
@@ -240,6 +249,46 @@
            
        return
def CopyBillboardOnDay():
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    for billboardType in ShareDefine.CrossBillboardTypeList:
        groupList = billboardMgr.GetBillboardGroupList(billboardType)
        for billboardType, groupValue1, groupValue2 in groupList:
            billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
            billboardObj.SaveDRData()
    return
def CopyBillboard(fromBillboardType, toBillboardType):
    ## 将某个类型的榜单完全拷贝到其他榜单 - 一般用于备份、转移数据
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardMgr.RemoveBillboard(toBillboardType) # 默认清空目标榜单
    groupList = billboardMgr.GetBillboardGroupList(fromBillboardType)
    for billboardType, groupValue1, groupValue2 in groupList:
        frbillboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
        toBillboardObj = billboardMgr.GetCrossBillboard(toBillboardType, groupValue1, groupValue2)
        GameWorld.Log("CopyCrossBillboard: billboardType=%s,toBillboardType=%s,groupValue1=%s,groupValue2=%s"
                      % (billboardType, toBillboardType, groupValue1, groupValue2))
        for frbillboardData in frbillboardObj.GetBillboardDataList():
            tobillboardData = PyGameDataStruct.tagDBCrossBillboard()
            tobillboardData.GroupValue1 = groupValue1
            tobillboardData.GroupValue2 = groupValue2
            tobillboardData.BillboardType = toBillboardType
            tobillboardData.ID = frbillboardData.ID
            tobillboardData.ID2 = frbillboardData.ID2
            tobillboardData.Name1 = frbillboardData.Name1
            tobillboardData.Name2 = frbillboardData.Name2
            tobillboardData.Type2 = frbillboardData.Type2
            tobillboardData.Value1 = frbillboardData.Value1
            tobillboardData.Value2 = frbillboardData.Value2
            tobillboardData.CmpValue = frbillboardData.CmpValue
            tobillboardData.CmpValue2 = frbillboardData.CmpValue2
            tobillboardData.CmpValue3 = frbillboardData.CmpValue3
            toBillboardObj.AddBillboardData(tobillboardData)
    return
#// C0 04 查看跨服排行榜 #tagCGViewCrossBillboard
#
#struct    tagCGViewCrossBillboard
@@ -282,10 +331,14 @@
    SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, [serverGroupID], queryData)
    return
def SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, serverGroupIDList=[], queryData={}):
def SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, serverGroupIDList=None, queryData=None):
    ## 同步跨服榜单到子服
    if not GameWorld.IsCrossServer():
        return
    if serverGroupIDList == None:
        serverGroupIDList = []
    if queryData == None:
        queryData = {}
    billboardMgr = PyDataManager.GetCrossBillboardManager()
    billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
    crossServerDataVer = billboardObj.GetCrossServerDataVer()
@@ -455,7 +508,7 @@
    return
def UpdCrossBillboard(billboardType, groupValue1, dataID, name1, name2, type2, value1, value2, cmpValue,
                      cmpValue2=0, cmpValue3=0, groupValue2=0, id2=0, autoSort=True):
                      cmpValue2=0, cmpValue3=0, groupValue2=0, id2=0, autoSort=True, noSortAndSync=False):
    ''' 更新跨服排行榜
    @param billboardType: 排行榜索引类型,同个榜单类型可以有多个分组榜单数据,独立排序
    @param groupValue1: 榜单分组1
@@ -471,6 +524,7 @@
    @param groupValue1: 榜单分组2
    @param id2: 扩展数据ID2
    @param autoSort: 是否排序,默认True
    @param noSortAndSync: 不排序及同步子服,默认False; 一般用于批量更新数据时设置为True,减少排序及同步频率,但是一定要在设置完数据或最后一条数据后手动调用一次排序SortData
    @return: 是否上榜更新榜单
    '''
    if not GameWorld.IsCrossServer():
@@ -514,8 +568,8 @@
    billboardData.BillboardType = billboardType
    billboardData.ID = dataID
    billboardData.ID2 = id2
    billboardData.Name1 = "" if name1 > 33 else name1
    billboardData.Name2 = "" if name2 > 33 else name2
    billboardData.Name1 = "" if len(name1) > 33 else name1
    billboardData.Name2 = "" if len(name2) > 33 else name2
    billboardData.Type2 = type2
    billboardData.Value1 = value1
    billboardData.Value2 = value2
@@ -527,6 +581,8 @@
                       % (billboardType, groupValue1, groupValue2, dataID, isNewData, cmpValueChange,
                          type2, value1, value2, cmpValue, cmpValue2, cmpValue3), dataID)
    
    if noSortAndSync:
        return True
    if autoSort and cmpValueChange:
        billboardObj.SortData()
    else: