| | |
| | |
|
| | | import math
|
| | | import time
|
| | | import json
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | ## 获得背包的一个空格子
|
| | |
| | |
|
| | | return True
|
| | |
|
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
|
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}], isNotifyAward=True):
|
| | | ##给物品,背包满则发邮件
|
| | | if not itemList:
|
| | | return
|
| | |
| | | else:
|
| | | for itemID, itemCnt, isAuctionItem in giveItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | | |
| | | if isNotifyAward:
|
| | | eventName = event[0] if event else ""
|
| | | NotifyGiveAwardInfo(curPlayer, giveItemList, eventName)
|
| | | return
|
| | |
|
| | | def NotifyGiveAwardInfo(curPlayer, giveItemInfo, eventName="", exp=0, moneyInfo=None, dataEx=None):
|
| | | '''通知玩家获得奖励信息
|
| | | @param giveItemInfo: 可以是列表 [[itemID,count,isBind], ...] 或 [[itemID,count], ...] 或 {itemID:count, ...}
|
| | | @param moneyInfo: 奖励货币信息 {moneyType:moneyValue, ...} moneyType 可以是字符串或数值
|
| | | '''
|
| | | notifyItemList = []
|
| | | if isinstance(giveItemInfo, dict):
|
| | | notifyItemList = [[a, b] for a, b in giveItemInfo.items()]
|
| | | else:
|
| | | notifyItemList = giveItemInfo
|
| | | eventName = ChConfig.ItemGiveTypeDict.get(eventName, str(eventName))
|
| | | clientPack = ChPyNetSendPack.tagMCGiveAwardInfo()
|
| | | clientPack.EventName = eventName
|
| | | clientPack.EventLen = len(clientPack.EventName)
|
| | | clientPack.ExpPoint = exp / ChConfig.Def_PerPointValue
|
| | | clientPack.Exp = exp % ChConfig.Def_PerPointValue
|
| | | if moneyInfo and isinstance(moneyInfo, dict):
|
| | | for moneyType, moneyValue in moneyInfo.items():
|
| | | if isinstance(moneyType, str):
|
| | | moneyType = int(moneyType)
|
| | | if not moneyType or not moneyValue:
|
| | | continue
|
| | | money = ChPyNetSendPack.tagMCGiveAwardMoney()
|
| | | money.MoneyType = moneyType
|
| | | money.MoneyValue = moneyValue
|
| | | clientPack.MoneyList.append(money)
|
| | | clientPack.MoneyLen = len(clientPack.MoneyList)
|
| | | for itemInfo in notifyItemList:
|
| | | itemID, itemCount = itemInfo[:2]
|
| | | isBind = itemInfo[2] if len(itemInfo) > 2 else 1
|
| | | if not itemID or not itemCount:
|
| | | continue
|
| | | item = ChPyNetSendPack.tagMCGiveAwardItem()
|
| | | item.ItemID = itemID
|
| | | item.Count = itemCount
|
| | | item.IsBind = isBind
|
| | | clientPack.ItemList.append(item)
|
| | | clientPack.ItemLen = len(clientPack.ItemList)
|
| | | if dataEx:
|
| | | if isinstance(dataEx, dict):
|
| | | dataEx = json.dumps(dataEx, ensure_ascii=False)
|
| | | elif not isinstance(dataEx, str):
|
| | | dataEx = str(dataEx)
|
| | | dataEx = dataEx.replace(" ", "")
|
| | | clientPack.DataEx = dataEx
|
| | | clientPack.DataLen = len(clientPack.DataEx)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def RecycleItem(curPlayer, itemID, notifyMailKey):
|