From 6c9e5f47e1d65e9f66b84fa995305ca96891914c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 30 八月 2024 18:32:57 +0800
Subject: [PATCH] 10256 【越南】【砍树】排行榜名次加入积分限制(优化本服榜单、跨服榜单查询返回的OrderIndex为实际名次-1; boss历练、仙匣秘境、古宝养成、骑宠养成相关活动榜单支持根据具体名次规则更新实际排名;)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
index 2f8cfed..0679a0c 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
@@ -115,6 +115,7 @@
         self.__clientServerDataVer = 0 # 子服榜单数据版本
         self.__billboardList = [] # [tagDBCrossBillboard, ...] 
         self.__idOrderDict = {} # {id:名次, ...}
+        self.__orderRuleList = None
         self.__sortDelay = False # 是否需要延迟排序
         return
     
@@ -223,9 +224,36 @@
         ## 获取ID对应名次字典
         # @return: {ID:名次, ...}  名次从1开始
         if not self.__idOrderDict:
-            for order, billboardData in enumerate(self.__billboardList, 1):
-                self.__idOrderDict[billboardData.ID] = order
+            if self.__orderRuleList:
+                billboardDataCount = self.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 = self.At(index)
+                        if billboardData.CmpValue < needCmpValue:
+                            break
+                        orderReal = rank - orderCountTotal + 1
+                        self.__idOrderDict[billboardData.ID] = orderReal
+                        orderCountTotal -= 1
+                        billboardIndex += 1
+            else:
+                for order, billboardData in enumerate(self.__billboardList, 1):
+                    self.__idOrderDict[billboardData.ID] = order
         return self.__idOrderDict
+    
+    def SetOrderRuleList(self, orderRuleList):
+        ## 排名所需值规则列表
+        # @param orderRuleList: 排名所需值规则列表 [[order, needCmpValue], ...]
+        self.__orderRuleList = orderRuleList
+        self.__idOrderDict = {} # 设置后需重置,可能配置规则变化了导致实际排名可能变化
+        GameWorld.Log("设置排名所需值规则列表: billboardType=%s,groupValue1=%s,groupValue2=%s, %s" 
+                      % (self.__billboardType, self.__groupValue1, self.__groupValue2, orderRuleList))
+        return
     
     def GetCount(self): return len(self.__billboardList)
     def GetMaxCount(self): return self.__maxCount
@@ -449,6 +477,7 @@
     billboardMgr = PyDataManager.GetCrossBillboardManager()
     billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
     billboardObj.DoDelaySort()
+    idOrderDict = billboardObj.GetIDOrderDict()
     crossServerDataVer = billboardObj.GetCrossServerDataVer()
     msgData = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2,
                "QueryData":queryData, "CrossServerDataVer":crossServerDataVer}
@@ -505,7 +534,8 @@
             CmpValue = billboardData.CmpValue
             CmpValue2 = billboardData.CmpValue2
             CmpValue3 = billboardData.CmpValue3
-            syncBillboardList.append([index, ID, ID2, Name1, Name2, Type2, Value1, Value2, CmpValue, CmpValue2, CmpValue3, Value3, Value4, Value5, Value6, Value7, Value8, UserData])
+            orderIndex = idOrderDict.get(ID, index + 1) - 1
+            syncBillboardList.append([orderIndex, ID, ID2, Name1, Name2, Type2, Value1, Value2, CmpValue, CmpValue2, CmpValue3, Value3, Value4, Value5, Value6, Value7, Value8, UserData])
         msgData["BillboardDataList"] = syncBillboardList
         
     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_SyncBillboard, msgData, serverGroupIDList)
@@ -559,9 +589,9 @@
     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
+        orderIndex, ID, ID2, Name1, Name2, Type2, Value1, Value2, CmpValue, CmpValue2, CmpValue3, Value3, Value4, Value5, Value6, Value7, Value8, UserData = dataInfo
         billboardInfoData = ChPyNetSendPack.tagGCCrossBillboardData()
-        billboardInfoData.OrderIndex = index
+        billboardInfoData.OrderIndex = orderIndex
         billboardInfoData.ID = ID
         billboardInfoData.ID2 = ID2
         billboardInfoData.Name1 = Name1

--
Gitblit v1.8.0