| | |
| | | import PlayerDBGSEvent
|
| | | import ChConfig
|
| | | import IpyGameDataPY
|
| | |
|
| | | import datetime
|
| | | #------------------------------------------------------------------------------
|
| | |
|
| | |
|
| | |
| | | # @return:
|
| | | def __IsWorldAverageLv():
|
| | | # 跨服服务器功能限制
|
| | | if GameWorld.IsMergeServer():
|
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | return True
|
| | |
|
| | |
| | | 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()
|
| | |
| | | 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 |