| | |
| | | # @param curItemDict
|
| | | # @return IpyCompensationItem
|
| | | def MakeCompensationItem(curItemDict):
|
| | | if not __checkMailItemDict(curItemDict):
|
| | | return
|
| | | curItemData = IPY_GameServer.IpyCompensationItem()
|
| | | #curItemData.GUID = curItemDict['GUID']
|
| | | curItemData.ItemID = curItemDict['ItemID']
|
| | |
| | | SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList)
|
| | | return
|
| | |
|
| | | def __checkMailItemIDCount(itemID, itemCount, isAuctionItem):
|
| | | ## 检查是否合法的邮件物品ID Count 数据
|
| | | if not (isinstance(itemID, int) or isinstance(itemID, long)):
|
| | | return
|
| | | if not (isinstance(itemCount, int) or isinstance(itemCount, long)):
|
| | | return
|
| | | if not (isinstance(isAuctionItem, int) or isinstance(isAuctionItem, long) or isinstance(isAuctionItem, bool)):
|
| | | return
|
| | | if itemID > ShareDefine.Def_UpperLimit_DWord or itemCount > ShareDefine.Def_UpperLimit_DWord or isAuctionItem > 255:
|
| | | return
|
| | | return True
|
| | |
|
| | | def __checkMailItemDict(curItemDict):
|
| | | ## 检查是否合法的邮件物品dict信息 {"ItemID":xxx, "Count":xxx, "IsAuctionItem":xxx}
|
| | | if not isinstance(curItemDict, dict):
|
| | | return
|
| | | if "ItemID" not in curItemDict or "Count" not in curItemDict:
|
| | | return
|
| | | itemID = curItemDict["ItemID"]
|
| | | itemCount = curItemDict["Count"]
|
| | | isAuctionItem = curItemDict.get("IsAuctionItem", 0)
|
| | | if not __checkMailItemIDCount(itemID, itemCount, isAuctionItem):
|
| | | return
|
| | | return curItemDict
|
| | |
|
| | | def __checkMailItemList(addItemList):
|
| | | ## 检查是否合法的邮件物品列表
|
| | | addItemDictList = []
|
| | | for itemInfo in addItemList:
|
| | | if isinstance(itemInfo, dict):
|
| | | if not __checkMailItemDict(itemInfo):
|
| | | return False, []
|
| | | addItemDictList.append(itemInfo)
|
| | | continue
|
| | | |
| | | if (isinstance(itemInfo, list) or isinstance(itemInfo, tuple)) and (len(itemInfo) == 3 or len(itemInfo) == 2):
|
| | | itemID, itemCount = itemInfo[:2]
|
| | | isAuctionItem = itemInfo[2] if len(itemInfo) > 2 else 0
|
| | | if not __checkMailItemIDCount(itemID, itemCount, isAuctionItem):
|
| | | return False, []
|
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = itemID
|
| | | addItemDict['Count'] = itemCount
|
| | | addItemDict['IsAuctionItem'] = isAuctionItem
|
| | | addItemDictList.append(addItemDict)
|
| | | else:
|
| | | return False, []
|
| | | return True, addItemDictList
|
| | |
|
| | | # 此处货币playerIDList发放统一,如根据玩家不同而变,则应需修改
|
| | | ## 功能发放物品补偿/奖励邮件
|
| | | # @param addItemList [(itemID, itemCnt, 是否拍品), {或物品信息字典}, ...]
|
| | |
| | | if not curServerTime or curServerTime >= limitTime:
|
| | | GameWorld.DebugLog("功能发放物品补偿/奖励邮件,领取时间已超时,默认不添加!LimitTime=%s" % limitTime)
|
| | | return ""
|
| | | isOK, addItemDictList = __checkMailItemList(addItemList)
|
| | | if not isOK:
|
| | | GameWorld.ErrLog("发送个人邮件错误: title=%s,content=%s,playerIDList=%s,addItemList=%s,gold=%s,goldPaper=%s,silver=%s,detail=%s,moneySource=%s,crossMail=%s" |
| | | % (title, content, playerIDList, addItemList, gold, goldPaper, silver, detail, moneySource, crossMail))
|
| | | return
|
| | |
|
| | | addItemDictList = []
|
| | | for itemInfo in addItemList:
|
| | | if isinstance(itemInfo, dict):
|
| | | addItemDictList.append(itemInfo)
|
| | | continue
|
| | | |
| | | |
| | | if len(itemInfo) == 3:
|
| | | itemID, itemCnt, isAuctionItem = itemInfo
|
| | | else:
|
| | | continue
|
| | | |
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = itemID
|
| | | addItemDict['Count'] = itemCnt
|
| | | addItemDict['IsAuctionItem'] = isAuctionItem
|
| | | addItemDictList.append(addItemDict)
|
| | | |
| | | gold = min(gold, ShareDefine.Def_UpperLimit_DWord)
|
| | | goldPaper = min(goldPaper, ShareDefine.Def_UpperLimit_DWord)
|
| | | silver = min(silver, ShareDefine.Def_UpperLimit_DWord)
|
| | | |
| | | perMailItemCnt = IpyGameDataPY.GetFuncCfg("MailMaxItemCnt")
|
| | | mailCnt = max(1, int(math.ceil(len(addItemDictList)/float(perMailItemCnt)))) # 一封邮件最多5个物品
|
| | | for i in xrange(mailCnt):
|
| | |
| | | if not mailTypeKey or getDays <= 0:
|
| | | return
|
| | |
|
| | | addItemDictList = []
|
| | | for itemInfo in addItemList:
|
| | | if isinstance(itemInfo, dict):
|
| | | addItemDictList.append(itemInfo)
|
| | | continue
|
| | | |
| | | if len(itemInfo) == 3:
|
| | | itemID, itemCnt, isAuctionItem = itemInfo
|
| | | else:
|
| | | continue
|
| | | |
| | | addItemDict = {}
|
| | | addItemDict['ItemID'] = itemID
|
| | | addItemDict['Count'] = itemCnt
|
| | | addItemDict['IsAuctionItem'] = isAuctionItem
|
| | | addItemDictList.append(addItemDict)
|
| | | |
| | | isOK, addItemDictList = __checkMailItemList(addItemList)
|
| | | if not isOK:
|
| | | GameWorld.ErrLog("发送全服邮件错误: mailTypeKey=%s,addItemList=%s,paramList=%s,gold=%s,goldPaper=%s,silver=%s,detail=%s,moneySource=%s" |
| | | % (mailTypeKey, addItemList, paramList, gold, goldPaper, silver, detail, moneySource))
|
| | | return
|
| | | |
| | | gold = min(gold, ShareDefine.Def_UpperLimit_DWord)
|
| | | goldPaper = min(goldPaper, ShareDefine.Def_UpperLimit_DWord)
|
| | | silver = min(silver, ShareDefine.Def_UpperLimit_DWord)
|
| | | |
| | | if not GUID:
|
| | | GUID = str(uuid.uuid1())
|
| | |
|
| | |
| | | #添加补偿包的所有物品
|
| | | for addItemDict in addItemDictList:
|
| | | curItemData = MakeCompensationItem(addItemDict)
|
| | | if not curItemData:
|
| | | return
|
| | | GameWorld.GetCompensationMgr().AddCompensationItem(GUID, curItemData)
|
| | |
|
| | | createTime = GameWorld.GetCurrentDataTimeStr()
|
| | |
|
| | | #添加全服领取补偿条件
|
| | | gold = min(gold, ShareDefine.Def_UpperLimit_DWord)
|
| | | goldPaper = min(goldPaper, ShareDefine.Def_UpperLimit_DWord)
|
| | | silver = min(silver, ShareDefine.Def_UpperLimit_DWord)
|
| | | GameWorld.GetCompensationMgr().AddEntireCompensationItem(GUID, createTime, LimitTime, mailInfo,
|
| | | PlayerJob, Text, gold, goldPaper, silver, serverID)
|
| | | checkState, limitLVType, limitLV = ParseEntireCompensationInfo(mailInfo)
|
| | |
| | |
|
| | | #此处没有下发通知
|
| | | mailType = moneySource - ChConfig.Def_GiveMoney_Unknown # type类型为byte,存值时需要处理下
|
| | | gold = min(gold, ShareDefine.Def_UpperLimit_DWord)
|
| | | goldPaper = min(goldPaper, ShareDefine.Def_UpperLimit_DWord)
|
| | | silver = min(silver, ShareDefine.Def_UpperLimit_DWord)
|
| | | GameWorld.GetCompensationMgr().AddPersonalCompensation(GUID, PlayerID, CreateTime,
|
| | | LimitTime, Text, mailType, gold, goldPaper, silver)
|
| | | if PlayerID in PyGameData.g_playerDelMailGUIDDict:
|
| | |
| | | #添加补偿包的所有物品
|
| | | for addItemDict in addItemDictList:
|
| | | curItemData = MakeCompensationItem(addItemDict)
|
| | | if not curItemData:
|
| | | return
|
| | | GameWorld.GetCompensationMgr().AddCompensationItem(GUID, curItemData)
|
| | |
|
| | | #offlinePlayerIDList = []
|