16 卡牌服务端(优化邮件物品,Mail命令支持发送全服邮件;)
| | |
| | | itemRankList.append(key)
|
| | | itemDict[key] = itemDict[key] + itemCount
|
| | |
|
| | | mailItemCount = 0
|
| | | giveItemList = []
|
| | | for itemInfo in itemRankList:
|
| | | if len(itemInfo) == 4:
|
| | | itemID, itemCount, isBind, userData = itemInfo
|
| | |
| | | userData = ""
|
| | | itemID, isBind = itemInfo
|
| | | itemCount = itemDict.get(itemInfo, 0)
|
| | | |
| | | giveItemList.append([itemID, itemCount, isBind, userData])
|
| | | |
| | | Max_MailItem = 20
|
| | | if len(giveItemList) > Max_MailItem:
|
| | | GameWorld.SendGameErrorEx("MailItemMultiError", "%s|%s|%s|%s" % (guid, len(giveItemList), itemList, giveItemList))
|
| | | #giveItemList = giveItemList[:Max_MailItem] 暂时还是让发,先做下后台邮件警告即可
|
| | | |
| | | for itemID, itemCount, isBind, userData in giveItemList: |
| | | dbData = DBStruct.tagDBMailItem()
|
| | | dbData.GUID = guid
|
| | | dbData.ItemID = itemID
|
| | |
| | | dbData.UserData = userData
|
| | | dbData.UserDataLen = len(dbData.UserData)
|
| | | self.__InitMailItemInstance(dbData)
|
| | | |
| | | mailItemCount += 1
|
| | | if mailItemCount >= 20:
|
| | | #防范某些异常情况,内置单封邮件物品上限,做下限制,并做后台邮件警告
|
| | | GameWorld.SendGameErrorEx("MailItemMultiError", "%s|%s" % (guid, itemList))
|
| | | break
|
| | |
|
| | | return
|
| | |
|
| | |
| | | for _ in xrange(cnt):
|
| | | dbData.clear()
|
| | | pos += dbData.readData(datas, pos, dataslen)
|
| | | self.SetServerMailPlayerState(dbData.GUID, dbData.PlayerID, dbData.MailState)
|
| | | self.SetPlayerMailState(dbData.GUID, dbData.PlayerID, dbData.MailState)
|
| | |
|
| | | # 个人邮件
|
| | | cnt, pos = CommFunc.ReadDWORD(datas, pos)
|
| | |
| | | GameWorld.DebugAnswer(curPlayer, "清空邮件: Mail 0")
|
| | | GameWorld.DebugAnswer(curPlayer, "发送邮件: Mail 几封 物品数 [模板key 参数1 ...]")
|
| | | GameWorld.DebugAnswer(curPlayer, "输出邮件: Mail p")
|
| | | GameWorld.DebugAnswer(curPlayer, "发送全服: Mail s 物品数 [天数]")
|
| | | return
|
| | |
|
| | | value = gmList[0]
|
| | |
| | |
|
| | | if value == "p":
|
| | | PrintPlayerMail(curPlayer)
|
| | | return
|
| | | |
| | | if value == "s":
|
| | | SendServerMail(curPlayer, gmList)
|
| | | return
|
| | |
|
| | | if value > 0:
|
| | |
| | | mailTypeKey = gmList[2] if len(gmList) > 2 else ""
|
| | | paramList = gmList[3:]
|
| | |
|
| | | itemIDList = range(3501, 3530 + 1)
|
| | | moneyIDList = [20, 30]
|
| | | |
| | | mailMgr = DBDataMgr.GetMailMgr()
|
| | | mailCntBef = mailMgr.GetPersonalMailCount(playerID)
|
| | | |
| | | isBind = 0
|
| | | for _ in range(sendCnt):
|
| | | |
| | | itemList = []
|
| | | if mailItemCnt:
|
| | | for moneyID in moneyIDList:
|
| | | itemCount = random.choice([100, 1000, 10000, 20000, 50000, 100000, 200000, 300000, 500000])
|
| | | itemList.append([moneyID, itemCount, isBind])
|
| | | if len(itemList) >= mailItemCnt:
|
| | | break
|
| | | |
| | | random.shuffle(itemIDList)
|
| | | for i in range(mailItemCnt):
|
| | | itemID = itemIDList[i]
|
| | | itemCount = random.randint(1, 100000)
|
| | | itemList.append([itemID, itemCount, isBind])
|
| | | if len(itemList) >= mailItemCnt:
|
| | | break
|
| | | |
| | | itemList = __randMailItem(mailItemCnt)
|
| | | PlayerMail.SendMailByKey(mailTypeKey, playerID, itemList, paramList)
|
| | |
|
| | | mailCntAft = mailMgr.GetPersonalMailCount(playerID)
|
| | | GameWorld.DebugAnswer(curPlayer, "发送个人邮件OK:%s, %s~%s" % (sendCnt, mailCntBef, mailCntAft))
|
| | | return
|
| | |
|
| | | def SendServerMail(curPlayer, gmList):
|
| | | mailItemCnt = gmList[1] if len(gmList) > 1 else 5
|
| | | limitDays = gmList[2] if len(gmList) > 2 else 7
|
| | | |
| | | randValue = random.randint(1, 1000)
|
| | | title = GameWorld.GbkToCode("全服邮件标题%s" % randValue)
|
| | | text = GameWorld.GbkToCode(
|
| | | '''全服邮件内容全服邮件内容全服邮件内容全服邮件内容全服邮件内容
|
| | | 全服邮件内容全服邮件内容全服邮件内容全服邮件内容全服邮件内容%s
|
| | | ''' % randValue
|
| | | )
|
| | | itemList = __randMailItem(mailItemCnt)
|
| | | |
| | | PlayerMail.SendSeverMail("", title, text, itemList, limitDays)
|
| | | GameWorld.DebugAnswer(curPlayer, "发送全服邮件OK!")
|
| | | return
|
| | |
|
| | | def __randMailItem(mailItemCnt):
|
| | | itemIDList = range(3501, 3530 + 1)
|
| | | moneyIDList = [20, 30]
|
| | | |
| | | isBind = 0
|
| | | itemList = []
|
| | | if mailItemCnt:
|
| | | for moneyID in moneyIDList:
|
| | | itemCount = random.choice([100, 1000, 10000, 20000, 50000, 100000, 200000, 300000, 500000])
|
| | | itemList.append([moneyID, itemCount, isBind])
|
| | | if len(itemList) >= mailItemCnt:
|
| | | break
|
| | | |
| | | random.shuffle(itemIDList)
|
| | | for i in range(mailItemCnt):
|
| | | itemID = itemIDList[i%len(itemIDList)]
|
| | | itemCount = random.randint(1, 100000)
|
| | | itemList.append([itemID, itemCount, isBind])
|
| | | if len(itemList) >= mailItemCnt:
|
| | | break
|
| | | |
| | | return itemList
|
| | |
|
| | | def ClearMail(curPlayer):
|
| | | notifyGUIDState = {}
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
| | | def SendGameErrorEx(errType, msgInfo="", playerID=0):
|
| | | ErrLog("SendGameErrorEx: %s -> %s" % (errType, msgInfo), playerID)
|
| | | SendGameError(errType, msgInfo)
|
| | | if GetGameWorld().GetDebugLevel():
|
| | | raise Exception("%s -> %s" % (errType, msgInfo))
|
| | | #if GetGameWorld().GetDebugLevel():
|
| | | # raise Exception("%s -> %s" % (errType, msgInfo))
|
| | | return
|
| | |
|
| | | def SendGameError(errType, msgInfo=""):
|
| | |
| | | return
|
| | |
|
| | | clientPack = ChPyNetSendPack.tagMCMailList()
|
| | | clientPack.IsServerMail = 1
|
| | | clientPack.MailList = mailList
|
| | | clientPack.Count = len(clientPack.MailList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|