16 卡牌服务端(邮件过期删除优化;邮件支持发送定制属性装备;Mail命令优化支持发送指定天数、物品、定制属性物品邮件;)
| | |
| | | import traceback
|
| | | import shutil
|
| | | import zlib
|
| | | import json
|
| | | #---------------------------------------------------------------------
|
| | | #全局变量
|
| | |
|
| | |
| | | except ZeroDivisionError:
|
| | | return "Division is Zero"
|
| | |
|
| | | def JsonDump(dumpObj):
|
| | | return json.dumps(dumpObj, ensure_ascii=False)
|
| | |
|
| | | ##生成指定文件(如par:r'E:\开发版本\Data\logo\formName1.log')
|
| | | #def MakeAppointFile(par):
|
| | | # dir = os.path.dirname(par) # 获得文件目录
|
| | |
| | | import PlayerMail
|
| | | import ShareDefine
|
| | | import DataRecordPack
|
| | | import IpyGameDataPY
|
| | | import DBDataMgr
|
| | | import ItemCommon
|
| | | import CommFunc
|
| | | import random
|
| | |
|
| | | ## 执行逻辑
|
| | |
| | | GameWorld.DebugAnswer(curPlayer, "发送邮件: Mail 几封 物品数 [模板key 参数1 ...]")
|
| | | GameWorld.DebugAnswer(curPlayer, "输出邮件: Mail p")
|
| | | GameWorld.DebugAnswer(curPlayer, "发送全服: Mail s 物品数 [天数]")
|
| | | GameWorld.DebugAnswer(curPlayer, "发送邮件: Mail pw 天数 物品ID 个数 [ID 个数 ...]")
|
| | | GameWorld.DebugAnswer(curPlayer, "个数:如果是装备则个数默认1个,个数参数改为定制属性ID")
|
| | | return
|
| | |
|
| | | value = gmList[0]
|
| | |
| | | SendServerMail(curPlayer, gmList)
|
| | | return
|
| | |
|
| | | if value == "pw":
|
| | | SendPlayerMailItem(curPlayer, gmList)
|
| | | return
|
| | | |
| | | if value > 0:
|
| | | SendPlayerMail(curPlayer, gmList)
|
| | | return
|
| | |
|
| | | return
|
| | |
|
| | | def SendPlayerMailItem(curPlayer, gmList):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | limitDays = gmList[1] if len(gmList) > 1 else 1
|
| | | itemList = gmList[2:]
|
| | | |
| | | mailItemList = []
|
| | | while len(itemList) >= 2:
|
| | | itemID = itemList.pop(0)
|
| | | itemCount = itemList.pop(0)
|
| | | |
| | | itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not itemData:
|
| | | GameWorld.DebugAnswer(curPlayer, "物品ID不存在! %s" % itemID)
|
| | | continue
|
| | | |
| | | if ItemCommon.GetIsEquip(itemData):
|
| | | appointID = itemCount
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", appointID)
|
| | | if not ipyData:
|
| | | GameWorld.DebugAnswer(curPlayer, "定制属性ID不存在! %s" % appointID)
|
| | | continue
|
| | | userData = CommFunc.JsonDump({ShareDefine.Def_CItemKey_AppointID:appointID})
|
| | | itemInfo = [itemID, 1, 0, userData] # 装备默认1个
|
| | | else:
|
| | | itemInfo = [itemID, itemCount]
|
| | | |
| | | mailItemList.append(itemInfo)
|
| | | |
| | | PlayerMail.SendMailByKey("", playerID, mailItemList, limitDays=limitDays)
|
| | | GameWorld.DebugAnswer(curPlayer, "发送个人邮件物品OK")
|
| | | return
|
| | |
|
| | | def SendPlayerMail(curPlayer, gmList):
|
| | |
| | | mailCntBef = mailMgr.GetPersonalMailCount(playerID)
|
| | | for _ in range(sendCnt):
|
| | | itemList = __randMailItem(mailItemCnt)
|
| | | PlayerMail.SendMailByKey(mailTypeKey, playerID, itemList, paramList)
|
| | | PlayerMail.SendMailByKey(mailTypeKey, playerID, itemList, paramList, limitDays=random.randint(1, 7))
|
| | |
|
| | | mailCntAft = mailMgr.GetPersonalMailCount(playerID)
|
| | | GameWorld.DebugAnswer(curPlayer, "发送个人邮件OK:%s, %s~%s" % (sendCnt, mailCntBef, mailCntAft))
|
| | |
| | | if not mailObj:
|
| | | continue
|
| | | createTime = GameWorld.ChangeTimeStrToNum(mailObj.GetCreateTime())
|
| | | limitTime = createTime + (mailObj.GetLimitDays() + 7) * 3600 * 24
|
| | | if curTime < limitTime:
|
| | | #GameWorld.DebugLog("全服邮件未超时,不删除! %s,createTime=%s,limitTime=%s" % (guid, mailObj.GetCreateTime(), GameWorld.ChangeTimeNumToStr(limitTime)))
|
| | | passDays = GameWorld.GetDiff_Day(curTime, createTime) + 1 # 过期判断按0点算天数
|
| | | limitDays = mailObj.GetLimitDays()
|
| | | if passDays <= limitDays:
|
| | | #GameWorld.DebugLog("全服邮件未超时,不删除! %s,createTime=%s,passDays=%s <= limitDays=%s" % (guid, mailObj.GetCreateTime(), passDays, limitDays))
|
| | | continue
|
| | |
|
| | | DelServerMail(guid, "Timeout")
|
| | |
| | | notifyGUIDState = {}
|
| | | for guid, mailObj in mailDict.items():
|
| | | createTime = GameWorld.ChangeTimeStrToNum(mailObj.GetCreateTime())
|
| | | limitTime = createTime + (mailObj.GetLimitDays() + 0) * 3600 * 24
|
| | | if curTime < limitTime:
|
| | | #GameWorld.DebugLog("个人邮件未超时,不删除! %s,createTime=%s,limitTime=%s" % (guid, mailObj.GetCreateTime(), GameWorld.ChangeTimeNumToStr(limitTime)), playerID)
|
| | | passDays = GameWorld.GetDiff_Day(curTime, createTime) + 1 # 过期判断按0点算天数
|
| | | limitDays = mailObj.GetLimitDays()
|
| | | if passDays <= limitDays:
|
| | | #GameWorld.DebugLog("个人邮件未超时,不删除! %s,createTime=%s,passDays=%s <= limitDays=%s" % (guid, mailObj.GetCreateTime(), passDays, limitDays), playerID)
|
| | | continue
|
| | |
|
| | | mailState = mailObj.GetMailState()
|
| | | mailItemCount = mailMgr.GetMailItemCount(guid)
|
| | | if mailItemCount and mailState != ShareDefine.MailState_Got:
|
| | | #GameWorld.DebugLog("个人邮件有物品未领取不删除! %s" % guid, playerID)
|
| | | continue
|
| | | #mailState = mailObj.GetMailState()
|
| | | #mailItemCount = mailMgr.GetMailItemCount(guid)
|
| | | #if mailItemCount and mailState != ShareDefine.MailState_Got:
|
| | | # #GameWorld.DebugLog("个人邮件有物品未领取不删除! %s" % guid, playerID)
|
| | | # continue
|
| | |
|
| | | mailMgr.DelPersonalMail(playerID, guid)
|
| | | DataRecordPack.DR_MailDel(playerID, guid, "Timeout")
|
| | |
| | | itemCount = mailItem.GetCount()
|
| | | isBind = mailItem.GetIsBind()
|
| | | userData = mailItem.GetUserData()
|
| | | #setAttrDict = {} if not userData else eval(userData) 之后扩展有指定属性的,可参考砍树版本
|
| | | setAttrDict = None
|
| | | if userData:
|
| | | try:
|
| | | setAttrDict = eval(userData)
|
| | | except:
|
| | | setAttrDict = None
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem],
|
| | | event=[ChConfig.ItemGive_Mail, False, {"MailGUID":guid}]):
|
| | | event=[ChConfig.ItemGive_Mail, False, {"MailGUID":guid}], setAttrDict=setAttrDict):
|
| | | continue
|
| | |
|
| | | DataRecordPack.DR_MailGiveSuccess(playerID, guid)
|
| | |
| | | import GMCommon
|
| | | import DataRecordPack
|
| | | import PlayerMail
|
| | | import IpyGameDataPY
|
| | | import ShareDefine
|
| | | import CommFunc
|
| | |
|
| | | ## 收到gm命令执行
|
| | | # @param gmCmdDict:gm命令字典
|
| | |
| | | itemCount = GameWorld.ToIntDef(gmCmdDict.get('ItemCnt%s' % itemIndexStr, '0'))
|
| | | if not itemCount:
|
| | | continue
|
| | | itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not itemData:
|
| | | GameWorld.ErrLog("GM发送邮件物品不存在! itemID=%s,itemCount=%s" % (itemID, itemCount))
|
| | | continue
|
| | | isBind = GameWorld.ToIntDef(gmCmdDict.get('IsBind%s' % itemIndexStr, '0'))
|
| | | appointID = GameWorld.ToIntDef(gmCmdDict.get('AppointID%s' % itemIndexStr, '0'))
|
| | | userData = ""
|
| | | if appointID:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", appointID)
|
| | | if not ipyData:
|
| | | continue
|
| | | userData = CommFunc.JsonDump({ShareDefine.Def_CItemKey_AppointID:appointID})
|
| | |
|
| | | #添加到物品信息列表
|
| | | itemList.append([itemID, itemCount, isBind])
|
| | | itemList.append([itemID, itemCount, isBind, userData])
|
| | |
|
| | | GameWorld.DebugLog("GetGMTMailItemList %s" % itemList)
|
| | | return itemList
|