From 765be4208f647c11b235029fb5157af7b3bbcdda Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 10 五月 2021 16:42:54 +0800
Subject: [PATCH] 8932 【BT2】【主干】【后端】物品转移背包类型后,支持上线刷新(删除根据物品ID判断所属背包逻辑)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
index ae54f4e..d019343 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
@@ -15,7 +15,6 @@
 # @change: "2013-03-20 18:00" Alee 添加DEBUG输出函数DebugLog
 # @change: "2013-09-10 20:10" Alee 函数DebugLog改用GetDebugLevel才有效
 # @change: "2014-05-16 10:30" xmnathan 增加交易所管理器接口
-# @change: "2014-08-01 15:30" xmnathan 增加天梯竞技场管理器接口
 # @change: "2014-09-22 10:00" xmnathan 增加GM工具补偿管理器接口
 # @change: "2015-01-14 00:30" hxp 增加服务器平台区服ID获取
 # @change: "2015-01-14 20:30" hxp 增加CanHappen函数
@@ -571,6 +570,11 @@
 # @remarks 获得系统时间
 def GetServerTime():
     return datetime.datetime.today()
+
+def GetWeekOfYear():
+    ## 一年中的第几周, 1代表第1周
+    return datetime.datetime.isocalendar(datetime.datetime.today())[1]
+
 #---------------------------------------------------------------------
 ##获取2个时间之间差异的TimeDelta类实例
 # @param compareTimeStr 比较的时间字符, 如"2010-05-26 11:21:25"
@@ -916,8 +920,9 @@
 #  @param itemList 待选列表
 #  @return object
 def GetResultByRandomList(randList, defValue=None, maxRateValue=ChConfig.Def_MaxRateValue):
-    rate = random.randint(0, maxRateValue)
-    
+    if not randList:
+        return defValue
+    rate = random.randint(0, randList[-1][0])
     return GetResultByRiseList(randList, rate, defValue)
 
 ## 增长列表(类似饼图)从中获得指定的信息
@@ -1049,15 +1054,25 @@
     
     return inputText
 
+def RaiseException(errorMsg, playerID=0):
+    ## 处理抛出异常信息,debug下直接抛出异常报错信息,否则发送运维邮件提醒
+    ErrLog(errorMsg, playerID)
+    if GetGameWorld().GetDebugLevel():
+        raise Exception(errorMsg)
+    else:
+        SendGameError("GameServerRaiseException", errorMsg)
+    return
 
-# 向运维发送邮件,用于需要紧急处理的信息
-# 此处不包含服务器报错的汇报
-def SendGameStateMail(msgInfo):
-    # 使用方式 向OpenStateUrl 发送Type为GameWarning,那么就会收到一封游戏内容警告邮件,信息为MsgInfo
+def SendGameError(errType, msgInfo=""):
+    ''' 向运维发送邮件,用于需要紧急处理的信息
+    @param errType: 错误类型,自定义即可
+    @param msgInfo: 错误信息,可选
+    '''
     getUrl = ReadChConfig.GetPyMongoConfig("EventReport", "OpenStateUrl")
     groupID = ReadChConfig.GetPyMongoConfig("platform", "GroupID")
     userDBName = ReadChConfig.GetPyMongoConfig("connect", "USER_DB_NAME")
-    getUrl = getUrl + "?Type=GameWarning&groupID=%s&userDBName=%s&MsgInfo=%s"%(groupID, userDBName, urllib.quote_plus(msgInfo))
-    
+    getUrl = getUrl + "?Type=%s&groupID=%s&userDBName=%s"%(errType, groupID, userDBName)
+    if msgInfo:
+        getUrl = getUrl + "&MsgInfo=%s" % urllib.quote_plus(msgInfo)
     GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)
-    
\ No newline at end of file
+    return

--
Gitblit v1.8.0