| | |
| | | def IsEventItem(item):
|
| | | return (item.GetType() == ChConfig.Def_ItemType_MissionItem)
|
| | |
|
| | | def DelPlayerItemByPacks(curPlayer, itemID, delCount, eventName="", saveDataDict={}, |
| | | packTypeList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]):
|
| | | '''扣除玩家物品,从多个背包检查,一般是用于不是立马扣除的逻辑,防止玩家快速把背包物品放入仓库导致扣除失败
|
| | | 如跨服功能,有些逻辑需要跨服验证或处理后才进行扣除
|
| | | ''' |
| | | remainDelCnt = delCount # 剩余需要扣除数量
|
| | | for packType in packTypeList:
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | for i in range(0, curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | if curItem.IsEmpty():
|
| | | continue
|
| | | if curItem.GetItemTypeID() != itemID:
|
| | | continue
|
| | | if curItem.GetIsLocked():
|
| | | continue
|
| | | |
| | | itemCount = GetItemCount(curItem)
|
| | | |
| | | #身上物品比要删除的物品多
|
| | | if itemCount > remainDelCnt:
|
| | | updItemCount = itemCount - remainDelCnt
|
| | | SetItemCount(curItem, updItemCount)
|
| | | if ItemNeedRecord(curItem):
|
| | | itemNoteDict = ItemCommon.GetItemNoteDict(curItem, remainDelCnt, itemCount, updItemCount)
|
| | | ItemCommon.DR_DelItem(curPlayer, packType, eventName, itemNoteDict, saveDataDict)
|
| | | remainDelCnt = 0
|
| | | else:
|
| | | if ItemNeedRecord(curItem):
|
| | | itemNoteDict = ItemCommon.GetItemNoteDict(curItem, itemCount, itemCount, 0)
|
| | | ItemCommon.DR_DelItem(curPlayer, packType, eventName, itemNoteDict, saveDataDict)
|
| | | curItem.Clear()
|
| | | remainDelCnt -= itemCount
|
| | | |
| | | if remainDelCnt <= 0:
|
| | | return True
|
| | | |
| | | GameWorld.ErrLog("扣除物品失败,物品不足! itemID=%s,delCount=%s,remainDelCnt=%s,eventName=%s" |
| | | % (itemID, delCount, remainDelCnt, eventName), curPlayer.GetPlayerID())
|
| | | return False
|
| | |
|
| | | ## 删除物品
|
| | | # @param curPlayer 当前玩家
|
| | | # @param packindex 背包索引
|
| | |
| | |
|
| | | return True
|
| | |
|
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}], isNotifyAward=True):
|
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}], isNotifyAward=True, notifyDataEx=None):
|
| | | ##给物品,背包满则发邮件
|
| | | if not itemList:
|
| | | return
|
| | |
| | |
|
| | | if isNotifyAward:
|
| | | eventName = event[0] if event else ""
|
| | | NotifyGiveAwardInfo(curPlayer, giveItemList, eventName)
|
| | | NotifyGiveAwardInfo(curPlayer, giveItemList, eventName, dataEx=notifyDataEx)
|
| | | return
|
| | |
|
| | | def NotifyGiveAwardInfo(curPlayer, giveItemInfo, eventName="", exp=0, moneyInfo=None, dataEx=None):
|