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/Player/PlayerActBossTrial.py | 47 +++++++
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py | 91 +++++++++++++++
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py | 11 +
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboard.py | 8 +
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboardCross.py | 5
ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py | 2
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActXianXiaMJ.py | 36 ++++++
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActHorsePetTrain.py | 36 ++++++
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossActionControl.py | 11 +
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py | 40 +++++
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActGubao.py | 36 ++++++
11 files changed, 315 insertions(+), 8 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboard.py
index 8c6485e..00c1eb6 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboard.py
@@ -21,6 +21,7 @@
#导入
+import PlayerBillboard
import ShareDefine
import GMCommon
import GameWorld
@@ -55,6 +56,10 @@
GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_TypeNumErr)
return False
+ billboardMgr = PlayerBillboard.GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(billBoardType)
+ idOrderDict = billboardObj.GetIDOrderDict()
+
dataTotal = billBoard.GetCount()
fromIndex = startRank - 1
toIndex = fromIndex + queryCount
@@ -67,8 +72,9 @@
if not billBoardData:
continue
- rank = index + 1
+ rank = idOrderDict.get(billBoardData.GetID(), index + 1)
billBoardDict = {
+ "Index":index,
"Rank":rank,
"ID":billBoardData.GetID(),
"ID2":billBoardData.GetID2(),
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboardCross.py b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboardCross.py
index eae8484..72b72d8 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboardCross.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_QueryBillboardCross.py
@@ -62,6 +62,8 @@
if groupValue1 != None and groupValue2 != None:
billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
billboardObj.DoDelaySort()
+ idOrderDict = billboardObj.GetIDOrderDict()
+
dataTotal = billboardObj.GetCount()
fromIndex = startRank - 1
toIndex = fromIndex + queryCount
@@ -72,8 +74,9 @@
billboardData = billboardObj.At(i)
if not billboardData:
continue
- rank = i + 1
+ rank = idOrderDict.get(billboardData.ID, i + 1)
billboardDict = {
+ "Index":i,
"Rank":rank,
"ID":billboardData.ID,
"ID2":billboardData.ID2,
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossActionControl.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossActionControl.py
index 350e4b4..b04410a 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossActionControl.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossActionControl.py
@@ -649,6 +649,17 @@
% (actName, cfgID, groupName, zoneID, dbState, state, actIDChange, dbTemplateID))
actStateChangeList.append([actName, ipyData, dbState, state, cfgID, groupName, zoneID, actIDChange, dbTemplateID])
+ # 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if state:
+ if actName == ShareDefine.CrossActName_BossTrial:
+ PlayerActBossTrial.OnCrossActInStateRefresh(cfgID, zoneID, ipyData)
+ elif actName == ShareDefine.CrossActName_XianXiaMJ:
+ PlayerActXianXiaMJ.OnCrossActInStateRefresh(cfgID, zoneID, ipyData)
+ elif actName == ShareDefine.CrossActName_Gubao:
+ PlayerActGubao.OnCrossActInStateRefresh(cfgID, zoneID, ipyData)
+ elif actName == ShareDefine.CrossActName_HorsePetTrain:
+ PlayerActHorsePetTrain.OnCrossActInStateRefresh(cfgID, zoneID, ipyData)
+
# 仅活动有配置参与时间段的会触发
if actID and dbActID == actID and dbStateJoin != stateJoin:
GameWorld.Log(" 参与状态变更: dbStateJoin=%s,stateJoin=%s" % (dbStateJoin, stateJoin))
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
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
index 2f97f1f..876a37b 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
@@ -874,6 +874,17 @@
else:
GameWorld.Log(" dbActID不变: dbActID=%s,curActID=%s" % (dbActID, curActID))
+ # 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if state:
+ if actName == ShareDefine.OperationActionName_BossTrial:
+ PlayerActBossTrial.OnActInStateRefresh(actNum, ipyData, dayIndex)
+ elif actName == ShareDefine.OperationActionName_XianXiaMJ:
+ PlayerActXianXiaMJ.OnActInStateRefresh(actNum, ipyData)
+ elif actName == ShareDefine.OperationActionName_Gubao:
+ PlayerActGubao.OnActInStateRefresh(actNum, ipyData)
+ elif actName == ShareDefine.OperationActionName_HorsePetTrain:
+ PlayerActHorsePetTrain.OnActInStateRefresh(actNum, ipyData)
+
# 仅活动有配置参与时间段的会触发
if curActID and dbActID == curActID and preStateJoin != stateJoin:
GameWorld.Log(" 参与状态变更: preStateJoin=%s,stateJoin=%s" % (preStateJoin, stateJoin))
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActBossTrial.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActBossTrial.py
index 511c712..b90fac9 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActBossTrial.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActBossTrial.py
@@ -55,6 +55,26 @@
GameWorld.Log("=================================================================================")
return
+def OnActInStateRefresh(actNum, ipyData, dayIndex):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ cfgID = ipyData.GetCfgID()
+ templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex)
+ familyTemplateID = GameWorld.GetTemplateIDByList(ipyData.GetFamilyTemplateIDList(), dayIndex)
+
+ billboardMgr = PlayerBillboard.GetBillboardMgr()
+ if templateID:
+ orderRuleList = GetOrderRuleList(templateID)
+ billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmit)
+ billboardObj.SetOrderRuleList(orderRuleList)
+
+ if familyTemplateID:
+ orderRuleList = GetOrderRuleList(familyTemplateID)
+ billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmitFamily)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
def OnActJoinEnd(actNum, ipyData, dayIndex):
## 活动参与结束
__OnEndAward(actNum, ipyData, dayIndex)
@@ -500,6 +520,33 @@
GameWorld.Log("=================================================================================")
return
+def OnCrossActInStateRefresh(cfgID, zoneID, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ PersonalTemplateID = ipyData.GetPersonalTemplateID()
+ FamilyTemplateID = ipyData.GetFamilyTemplateID()
+ orderRuleList = GetOrderRuleList(PersonalTemplateID)
+ orderRuleListFamily = GetOrderRuleList(FamilyTemplateID)
+
+ groupValue1 = zoneID
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1)
+ billboardObj.SetOrderRuleList(orderRuleList)
+
+ billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1)
+ billboardObj.SetOrderRuleList(orderRuleListFamily)
+ return
+
+def GetOrderRuleList(templateID):
+ orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID)
+ if not orderIpyDataList:
+ return
+ orderRuleList = []
+ for ipyData in orderIpyDataList:
+ orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()])
+ return orderRuleList
+
def OnCrossActJoinEnd(cfgID, zoneID, ipyData):
## 跨服活动参与结束
__OnCrossEndAward(cfgID, zoneID, ipyData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActGubao.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActGubao.py
index 0c3030d..4055fcc 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActGubao.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActGubao.py
@@ -50,6 +50,20 @@
GameWorld.Log("=================================================================================")
return
+def OnActInStateRefresh(actNum, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ personalTemplateID = ipyData.GetPersonalTemplateID()
+ if not personalTemplateID:
+ return
+ orderRuleList = GetOrderRuleList(personalTemplateID)
+
+ billboardMgr = PlayerBillboard.GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_GubaoScore)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
def OnActJoinEnd(actNum, ipyData, dayIndex):
## 活动参与结束
__OnEndAward(actNum, ipyData, dayIndex)
@@ -263,6 +277,28 @@
GameWorld.Log("=================================================================================")
return
+def OnCrossActInStateRefresh(cfgID, zoneID, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ PersonalTemplateID = ipyData.GetPersonalTemplateID()
+ orderRuleList = GetOrderRuleList(PersonalTemplateID)
+
+ groupValue1 = zoneID
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_GubaoScore, groupValue1)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
+def GetOrderRuleList(templateID):
+ orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGubaoBillTemp", templateID)
+ if not orderIpyDataList:
+ return
+ orderRuleList = []
+ for ipyData in orderIpyDataList:
+ orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()])
+ return orderRuleList
+
def OnCrossActJoinEnd(cfgID, zoneID, ipyData):
## 跨服活动参与结束
__OnCrossEndAward(cfgID, zoneID, ipyData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActHorsePetTrain.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActHorsePetTrain.py
index c0234c2..8ae1bc2 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActHorsePetTrain.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActHorsePetTrain.py
@@ -49,6 +49,20 @@
GameWorld.Log("=================================================================================")
return
+def OnActInStateRefresh(actNum, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ personalTemplateID = ipyData.GetPersonalTemplateID()
+ if not personalTemplateID:
+ return
+ orderRuleList = GetOrderRuleList(personalTemplateID)
+
+ billboardMgr = PlayerBillboard.GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_HorsePetTrainScore)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
def OnActJoinEnd(actNum, ipyData, dayIndex):
## 活动参与结束
__OnEndAward(actNum, ipyData, dayIndex)
@@ -262,6 +276,28 @@
GameWorld.Log("=================================================================================")
return
+def OnCrossActInStateRefresh(cfgID, zoneID, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ PersonalTemplateID = ipyData.GetPersonalTemplateID()
+ orderRuleList = GetOrderRuleList(PersonalTemplateID)
+
+ groupValue1 = zoneID
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_HorsePetTrainScore, groupValue1)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
+def GetOrderRuleList(templateID):
+ orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", templateID)
+ if not orderIpyDataList:
+ return
+ orderRuleList = []
+ for ipyData in orderIpyDataList:
+ orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()])
+ return orderRuleList
+
def OnCrossActJoinEnd(cfgID, zoneID, ipyData):
## 跨服活动参与结束
__OnCrossEndAward(cfgID, zoneID, ipyData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActXianXiaMJ.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActXianXiaMJ.py
index e590a51..75ed919 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActXianXiaMJ.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerActXianXiaMJ.py
@@ -49,6 +49,20 @@
GameWorld.Log("=================================================================================")
return
+def OnActInStateRefresh(actNum, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ personalTemplateID = ipyData.GetPersonalTemplateID()
+ if not personalTemplateID:
+ return
+ orderRuleList = GetOrderRuleList(personalTemplateID)
+
+ billboardMgr = PlayerBillboard.GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_XianXiaMJScore)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
def OnActJoinEnd(actNum, ipyData, dayIndex):
## 活动参与结束
__OnEndAward(actNum, ipyData, dayIndex)
@@ -262,6 +276,28 @@
GameWorld.Log("=================================================================================")
return
+def OnCrossActInStateRefresh(cfgID, zoneID, ipyData):
+ ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等
+ if not ipyData:
+ return
+ PersonalTemplateID = ipyData.GetPersonalTemplateID()
+ orderRuleList = GetOrderRuleList(PersonalTemplateID)
+
+ groupValue1 = zoneID
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_XianXiaMJScore, groupValue1)
+ billboardObj.SetOrderRuleList(orderRuleList)
+ return
+
+def GetOrderRuleList(templateID):
+ orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJBillTemp", templateID)
+ if not orderIpyDataList:
+ return
+ orderRuleList = []
+ for ipyData in orderIpyDataList:
+ orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()])
+ return orderRuleList
+
def OnCrossActJoinEnd(cfgID, zoneID, ipyData):
## 跨服活动参与结束
__OnCrossEndAward(cfgID, zoneID, ipyData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
index ed52c4b..58dc777 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
@@ -40,6 +41,81 @@
Def_NeedCopyYesterday_Dict = {
#昨日榜(拷贝) #今日榜(源数据)
}
+
+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中
@@ -392,6 +468,11 @@
#if not __CheckWatchCD(curPlayer, packType, tick):
# return
+ 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
@@ -425,6 +506,10 @@
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.WatchID = watchID
@@ -439,7 +524,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()
@@ -711,6 +796,10 @@
if not cmpValueChange:
return True
+ billboardMgr = GetBillboardMgr()
+ billboardObj = billboardMgr.GetBillboardObj(billboardIndex)
+ billboardObj.OnBillboardChange()
+
if not autoSort:
#不自动排序
GameWorld.GetGameWorld().SetDict(Def_Key_BillboardNeedSort % billboardIndex, 1) # 设置需要下次查看需要先排序
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
index 7ec7d1c..10891b7 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
@@ -22,6 +22,8 @@
g_onlinePlayerMgr = None # 玩家在线管理
+g_billboardMgrMgr = None # 本服榜单管理
+
g_commMapLineInfo = {} # 地图线路真实地图虚拟线信息 {(dataMapID, lineID):(realMapID, copyMapID), ...}
g_commMapLineRouteDict = {} # 地图线路路由服务索引信息 {(dataMapID, lineID):routeServerIndex, ...}
g_commMapLinePlayerCountDict = {} # 常规地图分线人数 {dataMapID:{lineID:人数, ...}}
--
Gitblit v1.8.0