| | |
| | | def GetGroupValue2(self): return self.__groupValue2
|
| | |
|
| | | def ClearData(self):
|
| | | GameWorld.Log("CrossBillboard ClearData billboardType=%s,groupValue1=%s,groupValue2=%s" |
| | | % (self.__billboardType, self.__groupValue1, self.__groupValue2))
|
| | | GameWorld.Log("CrossBillboard ClearData billboardType=%s,groupValue1=%s,groupValue2=%s,dataCount=%s" |
| | | % (self.__billboardType, self.__groupValue1, self.__groupValue2, len(self.__billboardList)))
|
| | | if GameWorld.IsCrossServer():
|
| | | self.SaveDRData()
|
| | | self.SaveDRData("Clear")
|
| | | self.__billboardList = [] # [tagDBCrossBillboard, ...]
|
| | | self.__idOrderDict = {} # {id:名次, ...}
|
| | |
|
| | |
| | | order = idOrderDict[findID]
|
| | | return order - 1
|
| | |
|
| | | def SaveDRData(self):
|
| | | def SaveDRData(self, eventName="", addDataDict={}):
|
| | | ## 记录流向数据
|
| | | eventTypeName = "CrossBillboard_%s" % (self.__billboardType)
|
| | | drDict = {"BillboardType":self.__billboardType, "GroupValue1":self.__groupValue1, "GroupValue2":self.__groupValue2, |
| | | "DataCount":len(self.__billboardList)}
|
| | | DataRecordPack.SendEventPack(eventTypeName, drDict)
|
| | | for billboardData in self.__billboardList:
|
| | | dataDict = {"BillboardType":billboardData.BillboardType, "GroupValue1":billboardData.GroupValue1, |
| | | "GroupValue2":billboardData.GroupValue2, "Type2":billboardData.Type2,
|
| | | "ID":billboardData.ID, "ID2":billboardData.ID2,
|
| | | |
| | | dataCount = len(self.__billboardList)
|
| | | if not dataCount:
|
| | | return
|
| | | |
| | | serverTime = GameWorld.GetServerTime()
|
| | | timeStr = "%02d%02d%02d%s" % (serverTime.hour, serverTime.minute, serverTime.second, str(serverTime.microsecond)[:3])
|
| | | eventTypeStr = "Billboard_%s_%s_%s_%s_%s" % (self.__billboardType, self.__groupValue1, self.__groupValue2, eventName, timeStr)
|
| | | |
| | | dataDict = {"BillboardType":self.__billboardType, "DataCount":dataCount, "addDataDict":addDataDict,
|
| | | "GroupValue1":self.__groupValue1, "GroupValue2":self.__groupValue2}
|
| | | DataRecordPack.SendEventPack(eventTypeStr, dataDict)
|
| | | |
| | | for index, billboardData in enumerate(self.__billboardList):
|
| | | rank = index + 1
|
| | | dataDict = {"Type2":billboardData.Type2, "Rank":rank,
|
| | | "ID":billboardData.ID, "ID2":billboardData.ID2, |
| | | "Name1":billboardData.Name1, "Name2":billboardData.Name2,
|
| | | "Value1":billboardData.Value1, "Value2":billboardData.Value2,
|
| | | "Value3":billboardData.Value3, "Value4":billboardData.Value4,
|
| | |
| | | "Value7":billboardData.Value7, "Value8":billboardData.Value8,
|
| | | "CmpValue":billboardData.CmpValue, "CmpValue2":billboardData.CmpValue2,
|
| | | "CmpValue3":billboardData.CmpValue3, "UserData":billboardData.UserData}
|
| | | DataRecordPack.SendEventPack(eventTypeName, dataDict)
|
| | | DataRecordPack.SendEventPack(eventTypeStr, dataDict)
|
| | | return
|
| | |
|
| | | def GetBillboardDataList(self): return self.__billboardList
|
| | |
| | | def CopyBillboardOnDay():
|
| | | billboardMgr = PyDataManager.GetCrossBillboardManager()
|
| | | for billboardType in ShareDefine.CrossBillboardTypeList:
|
| | | if billboardType in [ShareDefine.Def_CBT_BossTrialSubmitBak, ShareDefine.Def_CBT_BossTrialSubmitFamilyBak]:
|
| | | continue
|
| | | groupList = billboardMgr.GetBillboardGroupList(billboardType)
|
| | | for billboardType, groupValue1, groupValue2 in groupList:
|
| | | billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
|
| | | billboardObj.SaveDRData()
|
| | | billboardObj.SaveDRData("OnDay")
|
| | | return
|
| | |
|
| | | def CopyBillboard(fromBillboardType, toBillboardType):
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def CopyBillboardEx(fromBillboardType, toBillboardType, groupValue1, groupValue2=0):
|
| | | ## 将某个类型的榜单完全拷贝到其他榜单 - 一般用于备份、转移数据
|
| | | |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager()
|
| | | frbillboardObj = billboardMgr.GetCrossBillboard(fromBillboardType, groupValue1, groupValue2)
|
| | | toBillboardObj = billboardMgr.GetCrossBillboard(toBillboardType, groupValue1, groupValue2)
|
| | | toBillboardObj.ClearData()
|
| | | GameWorld.Log("CopyBillboardEx: fromBillboardType=%s,toBillboardType=%s,groupValue1=%s,groupValue2=%s" |
| | | % (fromBillboardType, 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.Value3 = frbillboardData.Value3
|
| | | tobillboardData.Value4 = frbillboardData.Value4
|
| | | tobillboardData.Value5 = frbillboardData.Value5
|
| | | tobillboardData.Value6 = frbillboardData.Value6
|
| | | tobillboardData.Value7 = frbillboardData.Value7
|
| | | tobillboardData.Value8 = frbillboardData.Value8
|
| | | tobillboardData.UserData = frbillboardData.UserData
|
| | | tobillboardData.DataLen = len(tobillboardData.UserData)
|
| | | tobillboardData.CmpValue = frbillboardData.CmpValue
|
| | | tobillboardData.CmpValue2 = frbillboardData.CmpValue2
|
| | | tobillboardData.CmpValue3 = frbillboardData.CmpValue3
|
| | | toBillboardObj.AddBillboardData(tobillboardData)
|
| | | |
| | | return
|
| | |
|
| | | #// C0 04 查看跨服排行榜 #tagCGViewCrossBillboard
|
| | | #
|
| | | #struct tagCGViewCrossBillboard
|
| | |
| | | # BYTE GroupValue2; // 分组值2,与分组值1组合归为同组榜单数据
|
| | | # DWORD StartIndex; //查看的起始名次索引, 默认0
|
| | | # BYTE WatchCnt; //查看条数,默认20,最大不超过100
|
| | | # BYTE IsWatchSelf; //是否查看自己名次前后,默认10条数据
|
| | | # DWORD WatchID; //查看指定ID名次前后,如玩家ID、家族ID等
|
| | | #};
|
| | | def OnViewCrossBillboard(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | |
| | | billboardType, groupValue1, groupValue2 = clientData.Type, clientData.GroupValue1, clientData.GroupValue2
|
| | | startIndex = clientData.StartIndex
|
| | | watchCnt = clientData.WatchCnt
|
| | | isWatchSelf = clientData.IsWatchSelf
|
| | | watchID = clientData.WatchID
|
| | |
|
| | | if billboardType not in ShareDefine.CrossBillboardTypeList:
|
| | | return
|
| | |
| | |
|
| | | # 请求查询跨服服务器
|
| | | dataMsg = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2,
|
| | | "QueryData":{"EventName":"View", "PlayerID":playerID, "StartIndex":startIndex, "WatchCnt":watchCnt, "IsWatchSelf":isWatchSelf}}
|
| | | "QueryData":{"EventName":"View", "PlayerID":playerID, "StartIndex":startIndex, "WatchCnt":watchCnt, "WatchID":watchID}}
|
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_QueryBillboard, dataMsg)
|
| | | return
|
| | |
|
| | |
| | |
|
| | | # 有查询数据时才同步榜单数据列表,否则只同步数据版本号
|
| | | if queryData:
|
| | | playerID = queryData.get("PlayerID", 0)
|
| | | #playerID = queryData.get("PlayerID", 0)
|
| | | startIndex = queryData.get("StartIndex", 0)
|
| | | watchCnt = queryData.get("WatchCnt", 0)
|
| | | isWatchSelf = queryData.get("IsWatchSelf", 0)
|
| | | watchID = queryData.get("WatchID", 0)
|
| | |
|
| | | count = billboardObj.GetCount()
|
| | | endIndex = 0
|
| | | # 查看自己前后名次
|
| | | if isWatchSelf:
|
| | | playerIndex = billboardObj.IndexOfByID(playerID)
|
| | | if watchID:
|
| | | playerIndex = billboardObj.IndexOfByID(watchID)
|
| | | if playerIndex != -1:
|
| | | # 前5后4,首尾补足10条记录
|
| | | endIndex = min(playerIndex + 5, count)
|
| | |
| | | return
|
| | |
|
| | | if eventName == "View":
|
| | | isWatchSelf = queryData.get("IsWatchSelf", 0)
|
| | | SyncCrossBillboardToPlayer(queryPlayer, billboardType, groupValue1, groupValue2, syncBillboardList, isWatchSelf)
|
| | | watchID = queryData.get("WatchID", 0)
|
| | | SyncCrossBillboardToPlayer(queryPlayer, billboardType, groupValue1, groupValue2, syncBillboardList, watchID)
|
| | | #else:
|
| | | # idOrderDict = billboardObj.GetIDOrderDict()
|
| | | # order = idOrderDict.get(queryPlayerID, 0)
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def SyncCrossBillboardToPlayer(curPlayer, billboardType, groupValue1, groupValue2, billboardList, isWatchSelf):
|
| | | def SyncCrossBillboardToPlayer(curPlayer, billboardType, groupValue1, groupValue2, billboardList, watchID):
|
| | | ## 同步给玩家跨服榜单
|
| | | billboardInfo = ChPyNetSendPack.tagGCCrossBillboardInfo()
|
| | | billboardInfo.Type = billboardType
|
| | | billboardInfo.GroupValue1 = groupValue1
|
| | | billboardInfo.GroupValue2 = groupValue2
|
| | | billboardInfo.IsWatchSelf = isWatchSelf
|
| | | billboardInfo.WatchID = watchID
|
| | | billboardInfo.CrossBillboardDataList = []
|
| | | for dataInfo in billboardList:
|
| | | index, ID, ID2, Name1, Name2, Type2, Value1, Value2, CmpValue, CmpValue2, CmpValue3, Value3, Value4, Value5, Value6, Value7, Value8, UserData = dataInfo
|