From a2ee319b264ed45d01c66b2fb9c0d36f9682bfd4 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 26 二月 2025 14:22:40 +0800
Subject: [PATCH] 10408 【BT】【GM】【英语】【越南】【砍树】红装分解(支持根据品质额外再给奖励)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py | 236 +++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 198 insertions(+), 38 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
index c28f355..e68a555 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
@@ -29,6 +29,7 @@
import PyDataManager
import PlayerViewCache
import IpyGameDataPY
+import PyGameData
import time
import random
@@ -41,11 +42,88 @@
#昨日榜(拷贝) #今日榜(源数据)
}
+class BillboardObj(object):
+ ''' 榜单额外数据管理
+ '''
+
+ def __init__(self, billboardType):
+ self.__billboardType = billboardType
+ self.__idOrderDict = {} # {id:名次, ...}
+ self.__orderRuleList = None
+ return
+
+ def OnBillboardChange(self):
+ ## 榜单数据变更
+ self.__idOrderDict = {}
+ return
+
+ def GetIDOrderDict(self):
+ ## 获取ID对应名次字典,本服榜仅处理有特殊排名规则的
+ # @return: {ID:名次, ...} 名次从1开始,如果返回空字典,则使用默认名次逻辑,即 index + 1
+ if not self.__orderRuleList:
+ return {}
+
+ if not self.__idOrderDict:
+ billBoard = GameWorld.GetBillboard().FindBillboard(self.__billboardType)
+ if not billBoard:
+ return {}
+ billboardDataCount = billBoard.GetCount()
+ rankPre = 0
+ billboardIndex = 0
+ for rank, needCmpValue in self.__orderRuleList:
+ orderCountTotal = rank - rankPre # 奖励名次数量
+ rankPre = rank
+ for index in xrange(billboardIndex, billboardDataCount):
+ if orderCountTotal <= 0:
+ break
+ billboardData = billBoard.At(index)
+ if billboardData.GetCmpValue() < needCmpValue:
+ break
+ orderReal = rank - orderCountTotal + 1
+ self.__idOrderDict[billboardData.GetID()] = orderReal
+ orderCountTotal -= 1
+ billboardIndex += 1
+ return self.__idOrderDict
+
+ def SetOrderRuleList(self, orderRuleList):
+ ## 排名所需值规则列表
+ # @param orderRuleList: 排名所需值规则列表 [[order, needCmpValue], ...]
+ self.__orderRuleList = orderRuleList
+ self.__idOrderDict = {} # 设置后需重置,可能配置规则变化了导致实际排名可能变化
+ GameWorld.Log("设置排名所需值规则列表: billboardType=%s, %s" % (self.__billboardType, orderRuleList))
+ return
+
+class BillboardMgr(object):
+ ''' 榜单额外管理
+ '''
+
+ def __init__(self):
+ self.__billboardDict = {} # {榜单类型:Billboard, ...}
+ return
+
+ def GetBillboardObj(self, billboardType):
+ if billboardType in self.__billboardDict:
+ billboard = self.__billboardDict[billboardType]
+ else:
+ billboard = BillboardObj(billboardType)
+ self.__billboardDict[billboardType] = billboard
+ return billboard
+
+def GetBillboardMgr():
+ if PyGameData.g_billboardMgrMgr:
+ billMgr = PyGameData.g_billboardMgrMgr
+ else:
+ billMgr = BillboardMgr()
+ PyGameData.g_billboardMgrMgr = billMgr
+ return billMgr
+
def NoteOssBillboardInfoByDay():
## 每天记录排行榜信息到oss中
+ if GameWorld.IsCrossServer():
+ return
Def_NoteOssBillboardTypeList = IpyGameDataPY.GetFuncEvalCfg("BillboardSet", 1)
for billboardType in Def_NoteOssBillboardTypeList:
- DataRecordPack.DR_BillboardDataByDay(billboardType)
+ DataRecordPack.DR_BillboardData(billboardType, "OnDay")
return
def CopyBillboardOnDay():
@@ -76,27 +154,40 @@
return
-def __CheckFightPowerBillboard():
- ## 由于战力修改为支持超过20E,所以需要处理下战力相关榜单,原 cmpValue 值移动到 cmpValue2
-
- eventKey = "FightPowerBillboardMoveValue"
- if PlayerDBGSEvent.GetDBGSTrig_ByKey(eventKey):
+def FixBillboardBigCmpValue():
+ ## 修正部分榜单大比较值,支持超20亿,主要为了模块战力等支持超20亿
+ if PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_FixBillboardBigCmpValue):
+ GameWorld.Log("修正部分榜单大比较值支持超20亿已经处理过")
return
- PlayerDBGSEvent.SetDBGSTrig_ByKey(eventKey, 1)
- GameWorld.Log("处理战力榜超过20E支持!")
+ PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_FixBillboardBigCmpValue, 1)
+ fixBillTypeList = [ShareDefine.Def_BT_FightPower_Horse]
+ fixBillTypeList += ShareDefine.Def_Campaign_Billboard_Dict.values()
+ GameWorld.Log("修正部分榜单大比较值支持超20亿: %s" % fixBillTypeList)
- billboardList = [ShareDefine.Def_BT_FightPower] + ShareDefine.JobFightPowerBillboardDict.values()
- for billboardType in billboardList:
- billboard = GameWorld.GetBillboard().FindBillboard(billboardType)
- if not billboard:
+ billboardMgr = GameWorld.GetBillboard()
+ for billboardType in fixBillTypeList:
+ billBoard = billboardMgr.FindBillboard(billboardType)
+ dataCount = billBoard.GetCount()
+ if not dataCount:
continue
- GameWorld.Log(" billboardType=%s,count=%s" % (billboardType, billboard.GetCount()))
- for index in xrange(billboard.GetCount()):
- billBoardData = billboard.At(index)
- if not billBoardData:
+ DataRecordPack.DR_BillboardData(billboardType, "FixBillboardBigCmpValue")
+ GameWorld.Log("修正榜单大比较值: billboardType=%s" % billboardType)
+ for index in range(dataCount):
+ boardData = billBoard.At(index)
+ if not boardData:
continue
- billBoardData.SetCmpValue2(billBoardData.GetCmpValue())
- billBoardData.SetCmpValue(0)
+ dataID = boardData.GetID()
+ cmpValue = boardData.GetCmpValue()
+ cmpValue2 = boardData.GetCmpValue2()
+ if cmpValue2:
+ GameWorld.Log(" index=%s,dataID=%s, keep CmpValue=%s,CmpValue2=%s" % (index, dataID, cmpValue, cmpValue2))
+ continue
+ boardData.SetCmpValue(0)
+ boardData.SetCmpValue2(cmpValue)
+
+ cmpValue = boardData.GetCmpValue()
+ cmpValue2 = boardData.GetCmpValue2()
+ GameWorld.Log(" index=%s,dataID=%s, Update CmpValue=%s,CmpValue2=%s" % (index, dataID, cmpValue, cmpValue2))
return
@@ -109,7 +200,6 @@
#排序一次排行榜
billBoard.Sort()
- __CheckFightPowerBillboard()
return
def CopyBillboard(newBillboardIndex, oldBillboardIndex):
@@ -375,7 +465,7 @@
# BYTE Type; //类型 TBillboardType
# DWORD StartIndex; //查看的起始名次索引, 默认0
# BYTE WatchCnt; //查看条数,默认20,最大不超过100
-# BYTE IsWatchSelf; //是否查看自己名次前后,默认10条数据
+# DWORD WatchID; //查看指定ID名次前后,如玩家ID、家族ID等
#};
def Client_PYWatchBillboard(index, clientData, tick):
@@ -386,14 +476,19 @@
packType = clientData.Type
startIndex = clientData.StartIndex
watchCnt = clientData.WatchCnt
- isWatchSelf = clientData.IsWatchSelf
- if not __CheckWatchCD(curPlayer, packType, tick):
- return
+ watchID = clientData.WatchID
+ #if not __CheckWatchCD(curPlayer, packType, tick):
+ # return
- Sync_BillboardEx(curPlayer, packType, isWatchSelf, startIndex, watchCnt)
+ if GameWorld.GetGameWorld().GetDictByKey(Def_Key_BillboardNeedSort % packType):
+ GameWorld.GetGameWorld().SetDict(Def_Key_BillboardNeedSort % packType, 0)
+ #GameWorld.DebugLog("玩家查看排行榜,强制排序!packType=%s" % (packType))
+ SortBillboardByIndex(packType)
+
+ Sync_BillboardEx(curPlayer, packType, watchID, startIndex, watchCnt)
return
-def Sync_BillboardEx(curPlayer, bbType, isWatchSelf=False, startIndex=0, watchCnt=20):
+def Sync_BillboardEx(curPlayer, bbType, watchID=0, startIndex=0, watchCnt=20):
if bbType < 0 or bbType >= ShareDefine.Def_BT_Max:
return
@@ -402,12 +497,12 @@
GameWorld.ErrLog("找不到排行榜数据!bbType=%s" % (bbType))
return
- playerID = curPlayer.GetPlayerID()
+ #playerID = curPlayer.GetPlayerID()
count = billBoard.GetCount()
endIndex = 0
# 查看自己前后名次
- if isWatchSelf:
- playerIndex = billBoard.IndexOfByID(playerID)
+ if watchID:
+ playerIndex = billBoard.IndexOfByID(watchID)
if playerIndex != -1:
# 前5后4,首尾补足10条记录
endIndex = min(playerIndex + 5, count)
@@ -423,9 +518,13 @@
watchCnt = 20 if not watchCnt else min(watchCnt, 100) # 默认20,最多100
endIndex = min(startIndex + watchCnt, count)
+ billboardMgr = GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(bbType)
+ idOrderDict = billboardObj.GetIDOrderDict()
+
billBoardData = ChPyNetSendPack.tagPYBillboardData()
billBoardData.Clear()
- billBoardData.IsWatchSelf = isWatchSelf
+ billBoardData.WatchID = watchID
billBoardData.Type = bbType
billBoardData.Billboard = []
for index in xrange(startIndex, endIndex):
@@ -437,7 +536,7 @@
bbInfo = ChPyNetSendPack.tagPYBillboardInfo()
bbInfo.Clear()
- bbInfo.OrderIndex = index
+ bbInfo.OrderIndex = idOrderDict.get(bbData.GetID(), index + 1) - 1
bbInfo.ID = bbData.GetID()
bbInfo.ID2 = bbData.GetID2()
bbInfo.Name1 = bbData.GetName1()
@@ -587,6 +686,8 @@
playerJob = 0
playerName = ""
playerRealmLV = 0
+ face = 0
+ facePic = 0
if curPlayer:
playerID = curPlayer.GetID()
@@ -594,12 +695,16 @@
playerName = curPlayer.GetName()
playerRealmLV = curPlayer.GetOfficialRank()
playerOpInfo = GetBillboardOperateInfo(curPlayer)
+ face = curPlayer.GetFace()
+ facePic = curPlayer.GetFacePic()
else:
socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID)
if socialPlayer:
playerJob = socialPlayer.playerInfo.Job
playerName = socialPlayer.playerInfo.PlayerName
playerRealmLV = socialPlayer.playerInfo.RealmLV
+ face = socialPlayer.playerInfo.Face
+ facePic = socialPlayer.playerInfo.FacePic
else:
curCache = PlayerViewCache.FindViewCache(playerID)
if curCache:
@@ -607,6 +712,8 @@
playerJob = cacheDict["Job"]
playerName = cacheDict["Name"]
playerRealmLV = cacheDict["RealmLV"]
+ face = cacheDict.get("Face", 0)
+ facePic = cacheDict.get("FacePic", 0)
if not playerName and playerID < 10000:
playerJob = random.choice([1, 2])
@@ -623,7 +730,7 @@
if autoSort:
gameWorld.SetDict(Def_Key_BillboardSortTick % bType, tick)
- UpdatePlayerBillboard(playerID, playerName, playerOpInfo, bType, playerJob, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
+ UpdatePlayerBillboard(playerID, playerName, playerOpInfo, bType, playerJob, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3, value3=face, value4=facePic)
return
#---------------------------------------------------------------------
@@ -668,15 +775,19 @@
return False
isNewData = playerBillBoardData.GetID2() == 0 # 是否是新增的数据
- cmpValueChange = False
- if isNewData or playerBillBoardData.GetCmpValue() != cmpValue or playerBillBoardData.GetCmpValue2() != cmpValue2 \
- or playerBillBoardData.GetCmpValue3() != cmpValue3:
- cmpValueChange = True
- if cmpValue3 == 0:
+ cmpValueChange = isNewData or playerBillBoardData.GetCmpValue() != cmpValue or playerBillBoardData.GetCmpValue2() != cmpValue2 \
+ or (cmpValue3 and playerBillBoardData.GetCmpValue3() != cmpValue3)
+ if cmpValue3 == 0:
+ if cmpValueChange:
# 时间权值仅在比较值变更的情况下才更新, 防止其他附属值更新时导致比较值相同的玩家名次间会变动的问题
calcTime = GameWorld.ChangeTimeStrToNum("2080-01-01 00:00:00")
cmpValue3 = max(0, calcTime - int(time.time())) # 比较值3如果没指定值则默认存当前更新的time
+ else:
+ cmpValue3 = playerBillBoardData.GetCmpValue3()
+ GameWorld.DebugLog("更新排行榜值 index=%s,type2=%s,value1=%s,value2=%s,cmpValue=%s,cmpValue2==%s,cmpValue3==%s,isNewData=%s,cmpValueChange=%s,%s"
+ % (billboardIndex, type2, value1, value2, cmpValue, cmpValue2, cmpValue3, isNewData, cmpValueChange, kwargs), curPlayerID)
+
#设置排行榜数据
playerBillBoardData.SetType(billboardIndex)
#附属类型
@@ -702,10 +813,12 @@
if cmpValue3 > 0:
playerBillBoardData.SetCmpValue3(cmpValue3)
- GameWorld.DebugLog("更新排行榜值 index=%s,type2=%s,value1=%s,value2=%s,cmpValue=%s,cmpValue2==%s,cmpValue3==%s,isNewData=%s,%s"
- % (billboardIndex, type2, value1, value2, cmpValue, cmpValue2, cmpValue3, isNewData, kwargs), curPlayerID)
if not cmpValueChange:
return True
+
+ billboardMgr = GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(billboardIndex)
+ billboardObj.OnBillboardChange()
if not autoSort:
#不自动排序
@@ -874,3 +987,50 @@
return
+def UpdateBillboardFace(curPlayer):
+ ## 更新排行榜中的玩家头像
+
+ curPlayerID = curPlayer.GetID()
+ curFace = curPlayer.GetFace()
+
+ billboardMgr = GameWorld.GetBillboard()
+ for billboardIndex in ShareDefine.BillboardTypeList:
+ if billboardIndex in ShareDefine.FamilyBillboardList:
+ continue
+ billBoard = billboardMgr.FindBillboard(billboardIndex)
+ if not billBoard:
+ #找不到这类型排行榜
+ continue
+
+ playerBillBoardData = billBoard.FindByID(curPlayerID)
+ if not playerBillBoardData:
+ #该玩家没有在排行榜上
+ continue
+
+ playerBillBoardData.SetValue3(curFace)
+
+ return
+
+def UpdateBillboardFacePic(curPlayer):
+ ## 更新排行榜中的玩家头像
+
+ curPlayerID = curPlayer.GetID()
+ curFacePic = curPlayer.GetFacePic()
+
+ billboardMgr = GameWorld.GetBillboard()
+ for billboardIndex in ShareDefine.BillboardTypeList:
+ if billboardIndex in ShareDefine.FamilyBillboardList:
+ continue
+ billBoard = billboardMgr.FindBillboard(billboardIndex)
+ if not billBoard:
+ #找不到这类型排行榜
+ continue
+
+ playerBillBoardData = billBoard.FindByID(curPlayerID)
+ if not playerBillBoardData:
+ #该玩家没有在排行榜上
+ continue
+
+ playerBillBoardData.SetValue4(curFacePic)
+
+ return
--
Gitblit v1.8.0