From b7159ca5db25404f507a27a43a970a0ca5fdf5bf Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 27 五月 2024 11:07:48 +0800
Subject: [PATCH] 9689 【越南】世界等级修改

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
index 696ac71..ec66a34 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
@@ -73,7 +73,9 @@
     initOpenServerTime = GameWorld.ChangeTimeNumToDatetime(initOpenServerTime, ChConfig.TYPE_Time_Format)
     openServerSecond = max(0, GameWorld.GetPastSeconds(str(initOpenServerTime)) + diffSecond)
     maxCnt = IpyGameDataPY.IPY_Data().GetWorldLVCount()
-    for i in xrange(max(0, beforeLv-1), maxCnt):
+    GameWorld.Log("计算世界等级: diffSecond=%s,initOpenServerTime=%s,openServerSecond=%s,maxCnt=%s" 
+                  % (diffSecond, initOpenServerTime, openServerSecond, maxCnt))
+    for i in xrange(maxCnt):
         curIpyData = IpyGameDataPY.IPY_Data().GetWorldLVByIndex(i)
         if i == maxCnt - 1:
             worldLV = curIpyData.GetWorldLV()
@@ -81,13 +83,37 @@
             nextIpyData = IpyGameDataPY.IPY_Data().GetWorldLVByIndex(i+1)
             if curIpyData.GetOpenServerSecond() <= openServerSecond < nextIpyData.GetOpenServerSecond():
                 worldLV = curIpyData.GetWorldLV()
+                GameWorld.Log("    i=%s,worldLV=%s" % (i, worldLV))
                 break
             if openServerSecond < curIpyData.GetOpenServerSecond():
                 #防止时间往回调的情况,导致世界等级异常
                 worldLV = beforeLv
+                GameWorld.Log("    i=%s,worldLV=%s,beforeLv=%s" % (i, worldLV, beforeLv))
                 break
     
-    return worldLV
+    playerAvgLV = 0
+    billBoard = GameWorld.GetBillboard().FindBillboard(ShareDefine.Def_BT_LV)
+    needPlayerCount = IpyGameDataPY.GetFuncCfg("WorldAverageLv", 1)
+    if billBoard and needPlayerCount:
+        totalLV = 0
+        playerCount = 0
+        for index in xrange(billBoard.GetCount()):
+            boardData = billBoard.At(index)
+            if not boardData:
+                continue
+            playerCount += 1
+            totalLV += boardData.GetCmpValue()
+            if playerCount >= needPlayerCount:
+                break
+        if totalLV > 0 and playerCount > 0:
+            playerAvgLV = int(totalLV / float(playerCount))
+            GameWorld.Log("    playerAvgLV=%s" % playerAvgLV)
+            
+    worldAvgLV = int(eval(IpyGameDataPY.GetFuncCompileCfg("WorldAverageLv", 2)))
+    if worldAvgLV < worldLV:
+        worldAvgLV = worldLV
+    GameWorld.Log("    worldAvgLV=%s" % worldAvgLV)
+    return worldAvgLV
 
 def GetWorldLVListByTime(startTime, day=1):
     ##根据时间计算多个世界等级

--
Gitblit v1.8.0