From 41c7b27b6ce4d57a1fc0f281d8323956599cceef Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 06 十二月 2023 10:13:15 +0800
Subject: [PATCH] 9811 【BT9】【后端】逐鹿万界(结算同步玩家信息改为字典)

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py |   46 +++++++++++++++++++++++++++-------------------
 1 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
index 088920e..530252d 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerBillboard.py
@@ -28,6 +28,7 @@
 import PlayerFamily
 import PyDataManager
 import PlayerViewCache
+import IpyGameDataPY
 
 import time
 import random
@@ -35,11 +36,6 @@
 Def_Key_BillboardSortTick = "BillboardSortTick_%s" # 排行榜是否排序tick,参数(排行榜类型)
 Def_Key_BillboardNeedSort = "BillboardNeedSort_%s" # 排行榜是否需要排序,参数(排行榜类型)
 
-#需要每天记录到oss的排行榜类型
-Def_NoteOssBillboardTypeList = [
-    ShareDefine.Def_BT_LV ,                  #个人等级日榜            
-    ShareDefine.Def_BT_FightPower,           #个人战斗力
-                                ]
 #需要每天拷贝昨日榜单的排行榜类型字典
 Def_NeedCopyYesterday_Dict = {
     #昨日榜(拷贝)                                    #今日榜(源数据)
@@ -47,6 +43,7 @@
 
 def NoteOssBillboardInfoByDay():
     ## 每天记录排行榜信息到oss中
+    Def_NoteOssBillboardTypeList = IpyGameDataPY.GetFuncEvalCfg("BillboardSet", 1)
     for billboardType in Def_NoteOssBillboardTypeList:
         DataRecordPack.DR_BillboardDataByDay(billboardType)
     return
@@ -486,8 +483,6 @@
     #GameWorld.DebugLog("更新排行榜:bType=%s,autoSort=%s,tick=%s,lastSortTick=%s,d=%s" % (bType, autoSort, tick, lastSortTick, tick - lastSortTick))
     
     UpdatePlayerBillboard(bID, bName, bName2, bType, bType2, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
-    gameWorld.SetDict(Def_Key_BillboardNeedSort % bType, 1)
-    #__UpdateBillboardSortState(gameWorld, bType, autoSort, isUpd)
     
     exInfo = billInfoDict["ExInfo"]
     # 以下为榜单附加特殊处理
@@ -509,20 +504,22 @@
         if job in ShareDefine.JobFightPowerBillboardDict:
             jobBType = ShareDefine.JobFightPowerBillboardDict[job]
             UpdatePlayerBillboard(bID, bName, bName2, jobBType, bType2, value1, value2, cmpValue, autoSort, cmpValue2)
-            gameWorld.SetDict(Def_Key_BillboardNeedSort % jobBType, 1)
-            #__UpdateBillboardSortState(gameWorld, jobBType, autoSort, isUpd)
             
     return
 
-def __UpdateBillboardSortState(gameWorld, bType, autoSort, isUpd):
-    key = Def_Key_BillboardNeedSort % bType
-    needSort = gameWorld.GetDictByKey(key)
-    if not autoSort and isUpd and not needSort:
-        gameWorld.SetDict(key, 1)
-    elif autoSort and needSort:
-        gameWorld.SetDict(key, 0)
-        
-    #GameWorld.DebugLog("__UpdateBillboardSortState:bType=%s,autoSort=%s,isUpd=%s,needSort=%s" % (bType, autoSort, isUpd, gameWorld.GetDictByKey(key)))
+def DelJobFightPowerBillboard(curPlayer, delJob):
+    ## 删除玩家对应职业战力榜  - 一般是玩家职业改变了,需要删除旧职业的职业战力榜单
+    if delJob not in ShareDefine.JobFightPowerBillboardDict:
+        return
+    jobBType = ShareDefine.JobFightPowerBillboardDict[delJob]
+    playerID = curPlayer.GetPlayerID()
+    billboardMgr = GameWorld.GetBillboard()
+    playerBillBoard = billboardMgr.FindBillboard(jobBType)
+    if not playerBillBoard:
+        return
+    if playerBillBoard.FindByID(playerID):
+        playerBillBoard.DeleteByID(playerID)
+        GameWorld.DebugLog("删除玩家职业战力榜单: delJob=%s,jobBType=%s" % (delJob, jobBType), playerID)
     return
 
 def GetBillboardOperateInfo(curPlayer):
@@ -568,7 +565,14 @@
         
     if bType in ShareDefine.BTValue1_OfficialRankList:
         value1 = playerRealmLV
-            
+        
+    tick = GameWorld.GetGameWorld().GetTick()
+    gameWorld = GameWorld.GetGameWorld()
+    lastSortTick = gameWorld.GetDictByKey(Def_Key_BillboardSortTick % bType)
+    autoSort = ((tick - lastSortTick) >= 60000 or autoSort) # 1分钟强制排序一次
+    if autoSort:
+        gameWorld.SetDict(Def_Key_BillboardSortTick % bType, tick)
+        
     UpdatePlayerBillboard(playerID, playerName, playerOpInfo, bType, playerJob, value1, value2, cmpValue, autoSort, cmpValue2, cmpValue3)
     return
 
@@ -624,6 +628,9 @@
         if opInfo != str(curPlayerOpInfo):
             playerBillBoardData.SetName2(str(curPlayerOpInfo))
             GameWorld.DebugLog("    更新operatInfo=%s" % curPlayerOpInfo, curPlayerID)
+        if playerBillBoardData.GetType2() != billboardType:
+            playerBillBoardData.SetType2(billboardType)
+            GameWorld.DebugLog("    更新Type2=%s" % billboardType, curPlayerID)
         return False
     
     # 没设置值默认为时间time,先上榜的排前面
@@ -654,6 +661,7 @@
                        % (billboardIndex, billboardType, value1, value2, cmpValue, cmpValue2, cmpValue3, isNewData), curPlayerID)
     if not autoSort:
         #不自动排序
+        GameWorld.GetGameWorld().SetDict(Def_Key_BillboardNeedSort % billboardIndex, 1) # 设置需要下次查看需要先排序
         return True
     
     #重新排序排行榜

--
Gitblit v1.8.0