| | |
| | | # @date 2018-03-06
|
| | | # @version 1.0
|
| | | #
|
| | | # 详细描述: 排行榜
|
| | | # 详细描述: 排行榜,本服、跨服通用
|
| | | #
|
| | | #-------------------------------------------------------------------------------
|
| | | #"""Version = 2018-03-06 11:00"""
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import ShareDefine
|
| | | import GameWorld
|
| | | import ChConfig
|
| | | import GameWorld
|
| | | import ShareDefine
|
| | | import PlayerControl
|
| | | import OpenServerCampaign
|
| | | import CrossRealmPlayer
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | | import GameFuncComm
|
| | | import EventReport
|
| | | import DBDataMgr
|
| | |
|
| | | import time
|
| | |
|
| | | def OnDay():
|
| | | |
| | | drBillboardTypeList = []
|
| | | if GameWorld.IsCrossServer():
|
| | | drBillboardTypeList = ShareDefine.CrossBillboardTypeList
|
| | | else:
|
| | | drBillboardTypeList = IpyGameDataPY.GetFuncEvalCfg("BillboardSet", 1)
|
| | | |
| | | billboardMgr = DBDataMgr.GetBillboardMgr()
|
| | | for billboardType in drBillboardTypeList:
|
| | | if billboardType in [ShareDefine.Def_CBT_BossTrialSubmitBak, ShareDefine.Def_CBT_BossTrialSubmitFamilyBak, ShareDefine.Def_CBT_CrossRealmPK]:
|
| | | continue
|
| | | groupList = billboardMgr.GetBillboardGroupList(billboardType)
|
| | | for billboardType, groupValue1, groupValue2 in groupList:
|
| | | billboardObj = billboardMgr.GetBillboard(billboardType, groupValue1, groupValue2)
|
| | | billboardObj.SaveDRData("OnDay")
|
| | | |
| | | return
|
| | |
|
| | | def DoBillboardOpen(curPlayer):
|
| | | ## 排行榜开启时需要处理的
|
| | |
| | | OpenServerCampaign.DoBillboardOpen(curPlayer) # 同步开服活动榜单
|
| | | return
|
| | |
|
| | | def BillboardOnLogin(curPlayer):
|
| | | # 上线默认同步排行榜
|
| | | UpdatePlayerBillboardOnLeaveServer(curPlayer) #排行榜已实时更新,故上线不再同步
|
| | | return
|
| | |
|
| | | def GetBillboardOperateInfo(curPlayer):
|
| | | # 排行榜中所保存的运营商相关信息
|
| | | platform = curPlayer.GetAccID()
|
| | | if platform in ["tencent"]:
|
| | | return curPlayer.GetOperateInfo()
|
| | | return platform
|
| | |
|
| | | def GetBillboardJob(curPlayer): return curPlayer.GetJob()
|
| | |
| | | if GameWorld.IsCrossServer():
|
| | | # 跨服服务器不用更新本服榜
|
| | | return
|
| | | #UpdateTotalRechargeBillboard(curPlayer)
|
| | |
|
| | | UpdatePlayerLVBillboard(curPlayer) # 等级榜
|
| | | UpdatePlayerFPTotalBillboard(curPlayer, True) # 战斗力榜
|
| | |
| | | if isAll:
|
| | | UpdateRuneTowerBillboard(curPlayer)
|
| | |
|
| | | #UpdateTJGBillboard(curPlayer, minuteExp) 脱机效率可不更新
|
| | | |
| | | EventReport.WriteEvent_FightPower(curPlayer)
|
| | | return
|
| | |
|
| | | def __CanPlayerBillboardComm(curPlayer):
|
| | | ## 玩家可否上榜通用检查
|
| | | if not GameWorld.IsNormalPlayer(curPlayer):
|
| | | return False
|
| | | if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Billboard):
|
| | | GameWorld.DebugLog("排行榜未开启,无法上榜!curLV=%s" % (curPlayer.GetLV()), curPlayer.GetPlayerID())
|
| | | return False
|
| | | |
| | | return True
|
| | |
|
| | | def UpdatePlayerBillboard(curPlayer, bType, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0, exInfo=[], autoSort=False, **kwargs):
|
| | | ## 更新玩家排行榜
|
| | | |
| | | #if not cmpValue and not cmpValue2 and not cmpValue3:
|
| | | # return
|
| | | |
| | | if not __CanPlayerBillboardComm(curPlayer):
|
| | | return
|
| | | |
| | | playerJob = GetBillboardJob(curPlayer)
|
| | | playerID = curPlayer.GetID()
|
| | | playerName = curPlayer.GetName()
|
| | | playerOpInfo = GetBillboardOperateInfo(curPlayer)
|
| | | kwargs["value3"] = curPlayer.GetFace()
|
| | | kwargs["value4"] = curPlayer.GetFacePic()
|
| | | if bType in ShareDefine.BTValue1_OfficialRankList:
|
| | | value1 = curPlayer.GetOfficialRank()
|
| | | GameServer_UpdateBillboard(bType, playerJob, playerID, playerName, playerOpInfo,
|
| | | value1, value2, cmpValue, cmpValue2, cmpValue3, 0, exInfo, autoSort, **kwargs)
|
| | | return
|
| | |
|
| | | def GameServer_UpdateBillboard(bType, bType2, bID, bName, bName2, value1, value2, cmpValue, cmpValue2=0, cmpValue3=0, bID2=0, exInfo=[], autoSort=False, **kwargs):
|
| | | bData = {"Type":bType, "Type2":bType2, "ID":bID, "ID2":bID2, "Name1":bName, "Name2":bName2, "ExInfo":exInfo, |
| | | "Value1":value1, "Value2":value2, "CmpValue":cmpValue, "CmpValue2":cmpValue2, "CmpValue3":cmpValue3, "autoSort":autoSort}
|
| | | if "value3" in kwargs:
|
| | | bData["Value3"] = kwargs["value3"]
|
| | | if "value4" in kwargs:
|
| | | bData["Value4"] = kwargs["value4"]
|
| | | if "value5" in kwargs:
|
| | | bData["Value5"] = kwargs["value5"]
|
| | | if "value6" in kwargs:
|
| | | bData["Value6"] = kwargs["value6"]
|
| | | if "value7" in kwargs:
|
| | | bData["Value7"] = kwargs["value7"]
|
| | | if "value8" in kwargs:
|
| | | bData["Value8"] = kwargs["value8"]
|
| | | if "userData" in kwargs:
|
| | | bData["UserData"] = kwargs["userData"]
|
| | | sendMsg = "%s" % (bData) |
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "UpdateBillboard", sendMsg, len(sendMsg))
|
| | | GameWorld.DebugLog("同步GameServer排行榜:bType=%s,cmpValue=%s,cmpValue2=%s %s" % (bType, cmpValue, cmpValue2, sendMsg), bID)
|
| | | return
|
| | |
|
| | | def UpdatePlayerCrossBillboard(curPlayer, bType, groupValue1, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0, |
| | | groupValue2=0, **kwargs):
|
| | | ## 更新玩家跨服排行榜
|
| | | |
| | | #if not cmpValue and not cmpValue2 and not cmpValue3:
|
| | | # return
|
| | | |
| | | #if not __CanPlayerBillboardComm(curPlayer):
|
| | | # return
|
| | | |
| | | playerJob = GetBillboardJob(curPlayer)
|
| | | playerID = curPlayer.GetID()
|
| | | playerName = CrossRealmPlayer.GetCrossPlayerName(curPlayer)
|
| | | playerOpInfo = GetBillboardOperateInfo(curPlayer)
|
| | | kwargs["value3"] = curPlayer.GetFace()
|
| | | kwargs["value4"] = curPlayer.GetFacePic()
|
| | | if bType in ShareDefine.BTValue1_OfficialRankList:
|
| | | value1 = curPlayer.GetOfficialRank()
|
| | | id2 = 0
|
| | | GameServer_UpdateCrossBillboard(bType, groupValue1, playerID, playerName, playerOpInfo, playerJob, value1, value2, |
| | | cmpValue, cmpValue2, cmpValue3, groupValue2, id2, **kwargs)
|
| | | return
|
| | |
|
| | | def GameServer_UpdateCrossBillboard(bType, groupValue1, dataID, name1, name2, type2, value1, value2, cmpValue, |
| | | cmpValue2=0, cmpValue3=0, groupValue2=0, id2=0, **kwargs):
|
| | | bData = {"Type":bType, "GroupValue1":groupValue1, "Type2":type2, "ID":dataID, "ID2":id2, "Name1":name1, "Name2":name2, |
| | | "Value1":value1, "Value2":value2, "CmpValue":cmpValue, "CmpValue2":cmpValue2, "CmpValue3":cmpValue3, "GroupValue2":groupValue2}
|
| | | if "value3" in kwargs:
|
| | | bData["Value3"] = kwargs["value3"]
|
| | | if "value4" in kwargs:
|
| | | bData["Value4"] = kwargs["value4"]
|
| | | if "value5" in kwargs:
|
| | | bData["Value5"] = kwargs["value5"]
|
| | | if "value6" in kwargs:
|
| | | bData["Value6"] = kwargs["value6"]
|
| | | if "value7" in kwargs:
|
| | | bData["Value7"] = kwargs["value7"]
|
| | | if "value8" in kwargs:
|
| | | bData["Value8"] = kwargs["value8"]
|
| | | if "userData" in kwargs:
|
| | | bData["UserData"] = kwargs["userData"]
|
| | | sendMsg = "%s" % (bData) |
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "UpdateCrossBillboard", sendMsg, len(sendMsg))
|
| | | GameWorld.DebugLog("同步GameServer跨服排行榜:bType=%s,groupValue1=%s,groupValue2=%s,cmpValue=%s, %s" |
| | | % (bType, groupValue1, groupValue2, cmpValue, sendMsg), dataID)
|
| | | return
|
| | |
|
| | | def UpdatePlayerFPTotalBillboard(curPlayer, isForceUpdate=False, isCheckRule=True):
|
| | |
| | | ChConfig.Def_PDictType_FightPower)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FightPower_TotalEx, fightPowerEx,
|
| | | ChConfig.Def_PDictType_FightPower)
|
| | | familyID = curPlayer.GetFamilyID()
|
| | | |
| | | GameWorld.DebugLog("更新总战斗力:playerFightPower=%s" % (playerFightPower), curPlayer.GetPlayerID())
|
| | |
|
| | | UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FightPower, fightPowerEx, fightPower, exInfo=[familyID])
|
| | | #EventReport.WriteEvent_FightPower(curPlayer)
|
| | | UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FightPower, fightPowerEx, fightPower)
|
| | | |
| | | # if bType == ShareDefine.Def_BT_FightPower:
|
| | | # playerID = bID
|
| | | # fightPowerTotal = cmpValue * ChConfig.Def_PerPointValue + cmpValue2
|
| | | # familyID = exInfo[0]
|
| | | # playerJob = bType2
|
| | | # |
| | | # curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | # if curPlayer:
|
| | | # PlayerControl.SetFightPower(curPlayer, fightPowerTotal)
|
| | | # |
| | | # #更新战盟成员战力
|
| | | # PlayerFamily.UpdFamilyMemberFightPower(familyID, playerID, fightPowerTotal)
|
| | | # |
| | | # #职业战力榜
|
| | | # job = playerJob % 10
|
| | | # if job in ShareDefine.JobFightPowerBillboardDict:
|
| | | # jobBType = ShareDefine.JobFightPowerBillboardDict[job]
|
| | | # UpdatePlayerBillboard(bID, bName, bName2, jobBType, bType2, value1, value2, cmpValue, autoSort, cmpValue2, **kwargs)
|
| | | return
|
| | |
|
| | | def __CheckFightPowerCanUpdate(curPlayer, key, fightPower, isForceUpdate=False, isCheckRule=True, key2=None):
|
| | |
| | | UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_TrialTower, passLV)
|
| | | return
|
| | |
|
| | |
|
| | | def UpdateTJGBillboard(curPlayer, minuteExp):
|
| | | ##脱机效率榜
|
| | | if not minuteExp:
|
| | | return
|
| | | expPoint = minuteExp / ChConfig.Def_PerPointValue
|
| | | exp = minuteExp % ChConfig.Def_PerPointValue
|
| | | UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_OffLineEfficient, expPoint, exp)
|
| | | return
|
| | |
|
| | | def UpdateRealmBillboard(curPlayer):
|
| | | ##境界榜
|
| | | if not curPlayer.GetOfficialRank():
|
| | |
| | | UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_Realm, curPlayer.GetOfficialRank())
|
| | | return
|
| | |
|
| | | def __CanPlayerBillboardComm(curPlayer):
|
| | | ## 玩家可否上榜通用检查
|
| | | if not GameWorld.IsNormalPlayer(curPlayer):
|
| | | return False
|
| | | if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Billboard):
|
| | | GameWorld.DebugLog("排行榜未开启,无法上榜!curLV=%s" % (curPlayer.GetLV()), curPlayer.GetPlayerID())
|
| | | return False
|
| | |
|
| | | ###################################### 以下代码暂时没用,修改时再整合 ################################################
|
| | | return True
|
| | |
|
| | | ##玩家登录排行处理
|
| | | # @param curPlayer 玩家实例
|
| | | # @return |
| | | def BillboardOnLogin(curPlayer):
|
| | | # 上线默认同步排行榜
|
| | | UpdatePlayerBillboardOnLeaveServer(curPlayer) #排行榜已实时更新,故上线不再同步
|
| | | return
|
| | | def UpdatePlayerBillboard(curPlayer, bType, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0, autoSort=False, **kwargs):
|
| | | ## 更新玩家排行榜
|
| | |
|
| | | ## 更新当前镖车信息
|
| | | # @param playerID: 玩家ID
|
| | | # @param playerName: 玩家名字
|
| | | # @param playerOpInfo: 玩家平台信息
|
| | | # @param playerLV: 玩家等级
|
| | | # @param truckLV: 镖车等级
|
| | | # @param truckMapID: 镖车所在地图ID
|
| | | # @return: |
| | | def UpdateBillboardPlayerTruck(playerID, playerName, playerOpInfo, playerLV, truckLV, truckMapID):
|
| | | |
| | | #当truckMapID为0时表示在排行在删除该镖车的记录
|
| | | |
| | | #[玩家ID, 玩家名字, 玩家等级, 镖车等级, 镖车位置]
|
| | | cmdList = [playerID, playerName, playerOpInfo, playerLV, truckLV, truckMapID]
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "UpdateBillboardPlayerTruck",
|
| | | '%s' % (cmdList), len(str(cmdList)))
|
| | | return
|
| | | |
| | | ##更新玩家充值排行榜
|
| | | # @param curPlayer 玩家实例
|
| | | # @return 任务实例
|
| | | # @remarks |
| | | def UpdateTotalRechargeBillboard(curPlayer):
|
| | | # if GameWorld.IsGM(curPlayer):
|
| | | # #GM不上榜
|
| | | #if not cmpValue and not cmpValue2 and not cmpValue3:
|
| | | # return
|
| | | totalChangeCoinPoint = curPlayer.GetChangeCoinPointTotal()
|
| | |
|
| | | #排行榜需要数据[玩家ID, 玩家名字, 玩家职业, 玩家等级]
|
| | | if not __CanPlayerBillboardComm(curPlayer):
|
| | | return
|
| | | |
| | | playerJob = GetBillboardJob(curPlayer)
|
| | | playerID = curPlayer.GetID()
|
| | | playerName = curPlayer.GetName()
|
| | | playerOpInfo = curPlayer.GetOperateInfo()
|
| | | playerJob = curPlayer.GetJob()
|
| | | playerLV = curPlayer.GetLV()
|
| | | playerOpInfo = GetBillboardOperateInfo(curPlayer)
|
| | | kwargs["value3"] = curPlayer.GetFace()
|
| | | kwargs["value4"] = curPlayer.GetFacePic()
|
| | | if bType in ShareDefine.BTValue1_OfficialRankList:
|
| | | value1 = curPlayer.GetOfficialRank()
|
| | |
|
| | | sendMsg = '%s' % ([playerID, playerName, playerOpInfo, playerJob, playerLV, totalChangeCoinPoint]) |
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'UpdateTotalRechargeBillboard', \
|
| | | sendMsg, len(sendMsg))
|
| | | groupValue1 = 0
|
| | | UpdateBillboard(bType, groupValue1, playerID, playerName, playerOpInfo, playerJob, value1, value2, |
| | | cmpValue, cmpValue2, cmpValue3, autoSort=autoSort, **kwargs)
|
| | | return
|
| | |
|
| | | def UpdateBillboard(billboardType, groupValue1, dataID, name1, name2, type2, value1, value2, cmpValue,
|
| | | cmpValue2=0, cmpValue3=0, groupValue2=0, id2=0, autoSort=True, **kwargs):
|
| | | ''' 更新跨服排行榜
|
| | | @param billboardType: 排行榜索引类型,同个榜单类型可以有多个分组榜单数据,独立排序
|
| | | @param groupValue1: 榜单分组1
|
| | | @param dataID: 榜单唯一数据ID,如玩家ID等
|
| | | @param name1: 显示名称1,不影响排序
|
| | | @param name2: 显示名称2,不影响排序
|
| | | @param type2: 榜单数据类型2,自定义,一般为职业等二级分类,不影响排序
|
| | | @param value1: 显示值1,不影响排序
|
| | | @param value2: 显示值2,不影响排序
|
| | | @param cmpValue: 比较值1
|
| | | @param cmpValue2: 比较值2
|
| | | @param cmpValue3: 比较值3,没设定的话默认为时间戳比较值
|
| | | @param groupValue1: 榜单分组2
|
| | | @param id2: 扩展数据ID2
|
| | | @param autoSort: 是否排序,默认True
|
| | | @return: 是否上榜更新榜单
|
| | | '''
|
| | | if GameWorld.IsCrossServer():
|
| | | if billboardType not in ShareDefine.CrossBillboardTypeList:
|
| | | return
|
| | | else:
|
| | | if billboardType not in ShareDefine.BillboardTypeList:
|
| | | return
|
| | | |
| | | if not dataID:
|
| | | return
|
| | | |
| | | billboardMgr = DBDataMgr.GetBillboardMgr()
|
| | | billboardObj = billboardMgr.GetBillboard(billboardType, groupValue1, groupValue2)
|
| | | billboardData = billboardObj.FindByID(dataID)
|
| | | isNewData = False
|
| | | if not billboardData:
|
| | | isNewData = True
|
| | | if billboardObj.IsFull():
|
| | | # 与最后一名对比
|
| | | lastBillBoardData = __CmpLastBillboardData(cmpValue, cmpValue2, cmpValue3, billboardObj)
|
| | | if not lastBillBoardData:
|
| | | GameWorld.DebugLog(" 榜单值不超过最后一名,不上榜! ")
|
| | | return
|
| | | billboardData = lastBillBoardData
|
| | | billboardData.Clear()
|
| | | else:
|
| | | billboardData = billboardObj.AddNewBillboardData()
|
| | | if not billboardData:
|
| | | return
|
| | | |
| | | cmpValueChange = isNewData or billboardData.GetCmpValue() != cmpValue or billboardData.GetCmpValue2() != cmpValue2 \
|
| | | or (cmpValue3 and billboardData.GetCmpValue3() != cmpValue3)
|
| | | |
| | | # 没设置值默认为时间time,先上榜的排前面
|
| | | if cmpValue3 == 0:
|
| | | # 时间权值仅在比较值变更的情况下才更新, 防止其他附属值更新时导致比较值相同的玩家名次间会变动的问题
|
| | | if cmpValueChange:
|
| | | calcTime = GameWorld.ChangeTimeStrToNum("2090-01-01 00:00:00")
|
| | | cmpValue3 = max(0, calcTime - int(time.time())) # 比较值3如果没指定值则默认存当前更新的time
|
| | | else:
|
| | | cmpValue3 = billboardData.GetCmpValue3()
|
| | | |
| | | # 更新所有值
|
| | | billboardData.SetType(billboardType)
|
| | | billboardData.SetGroupValue1(groupValue1)
|
| | | billboardData.SetGroupValue2(groupValue2)
|
| | | billboardData.SetID(dataID)
|
| | | billboardData.SetID2(id2)
|
| | | billboardData.SetName1(name1)
|
| | | billboardData.SetName2(name2)
|
| | | billboardData.SetType2(type2)
|
| | | billboardData.SetValue1(value1)
|
| | | billboardData.SetValue2(value2)
|
| | | billboardData.SetValue3(kwargs.get("value3", 0))
|
| | | billboardData.SetValue4(kwargs.get("value4", 0))
|
| | | billboardData.SetValue5(kwargs.get("value5", 0))
|
| | | billboardData.SetValue6(kwargs.get("value6", 0))
|
| | | billboardData.SetValue7(kwargs.get("value7", 0))
|
| | | billboardData.SetValue8(kwargs.get("value8", 0))
|
| | | billboardData.SetUserData(kwargs.get("userData", ""))
|
| | | billboardData.SetCmpValue(cmpValue)
|
| | | billboardData.SetCmpValue2(cmpValue2)
|
| | | billboardData.SetCmpValue3(cmpValue3)
|
| | | |
| | | GameWorld.DebugLog("更新跨服排行榜值: billboardType=%s,groupValue1=%s,groupValue2=%s,dataID=%s,isNewData=%s,cmpValueChange=%s,type2=%s,value1=%s,value2=%s,cmpValue=%s,cmpValue2=%s,cmpValue3=%s,%s" |
| | | % (billboardType, groupValue1, groupValue2, dataID, isNewData, cmpValueChange,
|
| | | type2, value1, value2, cmpValue, cmpValue2, cmpValue3, kwargs), dataID)
|
| | | if not autoSort:
|
| | | if isNewData or cmpValueChange:
|
| | | billboardObj.SetSortDelay()
|
| | | else:
|
| | | billboardObj.SortData()
|
| | | |
| | | return True
|
| | |
|
| | | def __CmpLastBillboardData(cmpValue, cmpValue2, cmpValue3, billboardObj):
|
| | | ## 比较是否超过最后一名
|
| | | # @return: 超过则返回最后一名数据实例,否则返回None
|
| | | if not billboardObj.GetCount():
|
| | | return
|
| | | lastBillBoardData = billboardObj.At(billboardObj.GetCount() - 1)
|
| | | if cmpValue < lastBillBoardData.GetCmpValue():
|
| | | #无法上榜
|
| | | return
|
| | | elif cmpValue == lastBillBoardData.GetCmpValue(): |
| | | if cmpValue2 < lastBillBoardData.GetCmpValue2():
|
| | | return
|
| | | elif cmpValue2 == lastBillBoardData.GetCmpValue2():
|
| | | if cmpValue3 <= lastBillBoardData.GetCmpValue3():
|
| | | return
|
| | | return lastBillBoardData
|
| | |
|
| | | def UpdatePlayerCrossBillboard(curPlayer, bType, groupValue1, cmpValue, cmpValue2=0, cmpValue3=0, value1=0, value2=0,
|
| | | groupValue2=0, **kwargs):
|
| | | ## 在本服直接更新玩家跨服排行榜,发送到跨服,之后扩展
|
| | | return
|
| | |
|
| | | #// A1 30 查看榜单 #tagCMViewBillboard
|
| | | #
|
| | | #struct tagCMViewBillboard
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE Type; //榜单类型
|
| | | # DWORD GroupValue1; //分组值1
|
| | | # DWORD GroupValue2; //分组值2,与分组值1组合归为同组榜单数据
|
| | | # WORD StartIndex; //查看的起始名次索引, 默认0
|
| | | # BYTE ViewCnt; //查看条数,默认20,单次最大不超过100
|
| | | # DWORD ViewID; //附带查看指定ID所在名次前后数据,如玩家ID、家族ID等
|
| | | #};
|
| | | def OnViewBillboard(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | billboardType, groupValue1, groupValue2 = clientData.Type, clientData.GroupValue1, clientData.GroupValue2
|
| | | startIndex = clientData.StartIndex
|
| | | viewCnt = clientData.ViewCnt
|
| | | viewID = clientData.ViewID
|
| | | |
| | | if billboardType in ShareDefine.CrossBillboardTypeList:
|
| | | # 跨服榜单直接查跨服服务器,待扩展
|
| | | return
|
| | | |
| | | clientPack = GetPack_ViewBillboardRet(billboardType, groupValue1, groupValue2, startIndex, viewCnt, viewID)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def GetPack_ViewBillboardRet(bbType, groupValue1, groupValue2, startIndex=0, viewCnt=20, viewID=0):
|
| | | ## 获取查看榜单返回信息封包,本服跨服通用
|
| | | |
| | | billboardMgr = DBDataMgr.GetBillboardMgr()
|
| | | billboardObj = billboardMgr.GetBillboard(bbType, groupValue1, groupValue2)
|
| | | billboardObj.SortDelayDo()
|
| | | idOrderDict = billboardObj.GetIDOrderDict()
|
| | | count = billboardObj.GetCount()
|
| | | |
| | | maxIndex = count - 1
|
| | | startIndex = max(min(startIndex, maxIndex), 0)
|
| | | viewCnt = 20 if not viewCnt else min(viewCnt, 100) # 默认20,最多100
|
| | | endIndex = min(startIndex + viewCnt - 1, maxIndex)
|
| | | viewRange = [] if not count else range(startIndex, endIndex + 1)
|
| | | |
| | | viewIDRange = []
|
| | | # 查看viewID前后名次
|
| | | if viewID:
|
| | | viewBFCnt = 3 # 查看ViewID返回前后数据条数,一般设置为奇数
|
| | | viewIDIndex = billboardObj.IndexOfByID(viewID)
|
| | | if viewIDIndex != -1:
|
| | | # 前x后x
|
| | | viewIDStartIndex = max(0, viewIDIndex - viewBFCnt / 2)
|
| | | viewIDEndIndex = min(viewIDIndex + viewBFCnt / 2, maxIndex)
|
| | | viewIDRange = range(viewIDStartIndex, viewIDEndIndex + 1)
|
| | | |
| | | clientPack = ChPyNetSendPack.tagMCViewBillboardRet()
|
| | | clientPack.Type = bbType
|
| | | clientPack.GroupValue1 = groupValue1
|
| | | clientPack.GroupValue2 = groupValue2
|
| | | clientPack.DataTotal = count
|
| | | clientPack.PageDataList = []
|
| | | for index in viewRange:
|
| | | billboardData = billboardObj.At(index)
|
| | | viewData = ChPyNetSendPack.tagMCViewBillboardData()
|
| | | viewData.Index = index
|
| | | viewData.Rank = idOrderDict.get(billboardData.GetID(), 0)
|
| | | viewData.ID = billboardData.GetID()
|
| | | viewData.ID2 = billboardData.GetID2()
|
| | | viewData.Name1 = billboardData.GetName1()
|
| | | viewData.Name2 = billboardData.GetName2()
|
| | | viewData.Type2 = billboardData.GetType2()
|
| | | viewData.Value1 = billboardData.GetValue1()
|
| | | viewData.Value2 = billboardData.GetValue2()
|
| | | viewData.Value3 = billboardData.GetValue3()
|
| | | viewData.Value4 = billboardData.GetValue4()
|
| | | viewData.Value5 = billboardData.GetValue5()
|
| | | viewData.Value6 = billboardData.GetValue6()
|
| | | viewData.Value7 = billboardData.GetValue7()
|
| | | viewData.Value8 = billboardData.GetValue8()
|
| | | viewData.CmpValue = billboardData.GetCmpValue()
|
| | | viewData.CmpValue2 = billboardData.GetCmpValue2()
|
| | | viewData.CmpValue3 = billboardData.GetCmpValue3()
|
| | | viewData.UserData = billboardData.GetUserData()
|
| | | viewData.DataLen = len(viewData.UserData)
|
| | | clientPack.PageDataList.append(viewData)
|
| | | clientPack.PageDataCnt = len(clientPack.PageDataList)
|
| | |
|
| | | clientPack.ViewID = viewID
|
| | | clientPack.ViewIDDataList = []
|
| | | for index in viewIDRange:
|
| | | billboardData = billboardObj.At(index)
|
| | | viewData = ChPyNetSendPack.tagMCViewBillboardData()
|
| | | viewData.Index = index
|
| | | viewData.Rank = idOrderDict.get(billboardData.GetID(), 0)
|
| | | viewData.ID = billboardData.GetID()
|
| | | viewData.ID2 = billboardData.GetID2()
|
| | | viewData.Name1 = billboardData.GetName1()
|
| | | viewData.Name2 = billboardData.GetName2()
|
| | | viewData.Type2 = billboardData.GetType2()
|
| | | viewData.Value1 = billboardData.GetValue1()
|
| | | viewData.Value2 = billboardData.GetValue2()
|
| | | viewData.Value3 = billboardData.GetValue3()
|
| | | viewData.Value4 = billboardData.GetValue4()
|
| | | viewData.Value5 = billboardData.GetValue5()
|
| | | viewData.Value6 = billboardData.GetValue6()
|
| | | viewData.Value7 = billboardData.GetValue7()
|
| | | viewData.Value8 = billboardData.GetValue8()
|
| | | viewData.CmpValue = billboardData.GetCmpValue()
|
| | | viewData.CmpValue2 = billboardData.GetCmpValue2()
|
| | | viewData.CmpValue3 = billboardData.GetCmpValue3()
|
| | | viewData.UserData = billboardData.GetUserData()
|
| | | viewData.DataLen = len(viewData.UserData)
|
| | | clientPack.ViewIDDataList.append(viewData)
|
| | | clientPack.ViewIDDataCnt = len(clientPack.ViewIDDataList)
|
| | | return clientPack
|