From a49287c1591671d95952114f04db742c1507de13 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 20 八月 2024 15:01:53 +0800
Subject: [PATCH] 10223 10238 10241 【越南】【砍树】【主干】【港台】仙匣秘境、骑宠养成、古宝养成增加可配置是否关联跨服活动;

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

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
index d7ebfa8..ec66a34 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldAverageLv.py
@@ -23,6 +23,8 @@
 import PlayerDBGSEvent
 import ChConfig
 import IpyGameDataPY
+
+import datetime
 #------------------------------------------------------------------------------
 
         
@@ -71,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()
@@ -79,11 +83,65 @@
             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):
+    ##根据时间计算多个世界等级
+    initOpenServerTime = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_InitOpenServerTime)
+    if initOpenServerTime <= 0:
+        return []
+    worldlvList = []
+    diffSecond = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_WorldLVExtraTime) #额外时间参数
+    initOpenServerTime = GameWorld.ChangeTimeNumToDatetime(initOpenServerTime, ChConfig.TYPE_Time_Format)
+    if startTime < initOpenServerTime:
+        return []
+    ipyMgr = IpyGameDataPY.IPY_Data()
+    for dayIndex in xrange(day):
+        nextTime = startTime + datetime.timedelta(days=dayIndex)
+        pastTimeDelta = nextTime - initOpenServerTime
+        pastSeconds = max(0, pastTimeDelta.days * 24 * 60 * 60 + pastTimeDelta.seconds + diffSecond)
+        maxCnt = ipyMgr.GetWorldLVCount()
+        worldLV = 0
+        for i in xrange(maxCnt):
+            curIpyData = ipyMgr.GetWorldLVByIndex(i)
+            if i == maxCnt - 1:
+                worldLV = curIpyData.GetWorldLV()
+            else:
+                nextIpyData = ipyMgr.GetWorldLVByIndex(i+1)
+                if curIpyData.GetOpenServerSecond() <= pastSeconds < nextIpyData.GetOpenServerSecond():
+                    worldLV = curIpyData.GetWorldLV()
+                    break
+        worldlvList.append(worldLV)
+        
+    GameWorld.DebugLog('    GetWorldLVByTime startTime=%s,day=%s,worldlvList=%s'%(str(startTime), day, worldlvList))
+    return worldlvList
\ No newline at end of file

--
Gitblit v1.8.0