From 8c4a6ea04317bc70d2ecf55f9661c32deeb2c726 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 19 十二月 2023 15:46:49 +0800 Subject: [PATCH] 10028 【港台】港台0.1折充值验证精确度优化 --- ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py | 89 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 84 insertions(+), 5 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py index 8fc20e4..c6504ef 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py @@ -538,6 +538,13 @@ #--------------------------------------------------------------------- +def GetTemplateID(ipyData, cfgID, dayIndex): + if cfgID == None or dayIndex == None or not ipyData: + return 0 + templateIDList = ipyData.GetTemplateIDList() + templateID = templateIDList[-1] if dayIndex >= len(templateIDList) else templateIDList[dayIndex] + return templateID + def GetOperationActionDateStr(ipyData): ## 获取运营活动对应日期,存数字代表开服天配置,需要转化为对应的日期 curDateTime = datetime.datetime.today() @@ -918,6 +925,17 @@ return ReadChConfig.GetPyMongoConfig("Merge", "CrossZoneName") return PyGameData.g_crossZoneName +def GetCrossServerTimeStr(): + ## 跨服服务器时间 + if IsCrossServer(): + return GetCurrentDataTimeStr() + lastCrossServerTime, lastServerTime, _ = PyGameData.g_crossServerTimeInfo + if not lastCrossServerTime: + return GetCurrentDataTimeStr() + curTime = int(time.time()) + crossServerTime = lastCrossServerTime + (curTime - lastServerTime) + return ChangeTimeNumToStr(crossServerTime) + ## 获取玩家的区服名,仅在跨服有效 # @param curPlayer 玩家实例 # @return: 区服名 @@ -985,16 +1003,59 @@ ## 从列表中产生物品,[[权重, object], ....] # @param weightList 待选列表 -def GetResultByWeightList(weightList): +def GetResultByWeightList(weightList, defValue=None): randList = [] weight = 0 for info in weightList: weight += info[0] randList.append([weight, info[1] if len(info) == 2 else info[1:]]) if not randList: - return + return defValue rate = random.randint(1, randList[-1][0]) - return GetResultByRiseList(randList, rate) + return GetResultByRiseList(randList, rate, defValue) + +## 获得对应数位的值 +# @param numValue 数值 +# @param dataIndex 数位索引 +# @return 获得的值 +def GetDataByDigitPlace(numValue, dataIndex): + return (numValue/pow(10, dataIndex))%10 + + +## 设置对应数位的值 +# @param numValue 数值 +# @param dataIndex 数位索引 +# @param dataValue 当前修改数值 +# @return 获得的值 +def ChangeDataByDigitPlace(numValue, dataIndex, dataValue): + + if dataValue < 0 or dataValue > 9 or dataIndex > ShareDefine.Def_PDictDigitCnt: + return numValue + + # 获得对应数位的值 + lastTagLV = GetDataByDigitPlace(numValue, dataIndex) + + numValue += pow(10, dataIndex)*(dataValue - lastTagLV) + return numValue + +def GetBitValue(dataValue, index): + """ 得到某个字节值中某一位(Bit)的值 + @param dataValue: 待取值的字节值 + @param index: 待读取位的序号,从右向左0开始,0-7为一个完整字节的8个位 + @return: 返回读取该位的值,0或1 + """ + return 1 if dataValue & (1 << index) else 0 + +def SetBitValue(dataValue, index, val): + """ 更改某个字节值中某一位(Bit)的值 + @param dataValue: 准备更改的字节原值 + @param index: 待更改位的序号,从右向左0开始,0-7为一个完整字节的8个位 + @param val: 目标位预更改的值,0或1 + @return: 返回更改后字节的值 + """ + if val: + return dataValue | (1 << index) + return dataValue & ~(1 << index) ## 根据字典key获取value值 # @return @@ -1037,7 +1098,7 @@ # @param order 名次,从1开始 # @param isDefaultLast 找不到的名次是否默认取最后一名的 # @return obj or None -def GetOrderValueByDict(orderDict, order, isDefaultLast=True): +def GetOrderValueByDict(orderDict, order, isDefaultLast=True, defaultValue=None): if order in orderDict: return orderDict[order] @@ -1048,7 +1109,7 @@ return orderDict[dOrder] # 找不到的默认取最后一名 - return orderDict[orderList[-1]] if isDefaultLast else None + return orderDict[orderList[-1]] if isDefaultLast else defaultValue ##概率相关, 这个事件是否能够出现 # @param rate 基础几率 @@ -1072,6 +1133,24 @@ curPlayer.DebugAnswer(text) return +def CrossServerMsg_DebugAnswer(msgData): + playerID, text = msgData + curPlayer = GetPlayerManager().FindPlayerByID(playerID) + if not curPlayer: + return + curPlayer.DebugAnswer(text) + return + +def DebugAnswerCross(playerID, serverGroupID, text): + DebugLog(text) + text = text.decode(ShareDefine.Def_Game_Character_Encoding).encode(GetCharacterEncoding()) + + import CrossRealmMsg + dataMsg = [playerID, text] + serverGroupIDList = [serverGroupID] + CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_DebugAnswer, dataMsg, serverGroupIDList) + return + def GetMap(mapID): return IpyGameDataPY.GetIpyGameData("ChinMap", mapID) def GetNPCData(npcID): return IpyGameDataPY.GetIpyGameData("ChinNPC", npcID) -- Gitblit v1.8.0