5541 【越南】批量使用宝箱获得道具超过65535
| | |
| | | itemCount -= giveCount
|
| | | return isOK
|
| | |
|
| | | def DoGiveItemLoop(curPlayer, itemID, itemCount, isAuctionItem, event=["", False, {}], packIndexList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], |
| | | jsonItemList=None, userDataList=None):
|
| | | ## 循环给物品,一般用于个数超过65535的,循环创建物品给
|
| | | # @warning: 该函数不对物品及背包空间等做验证,仅做循环给物品操作
|
| | | # @return: 给成功总数,0代表给失败了
|
| | | |
| | | giveOKCount = 0
|
| | | for _ in range(itemCount/65535 + 1):
|
| | | if giveOKCount >= itemCount:
|
| | | break
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount - giveOKCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not giveItem:
|
| | | return giveOKCount
|
| | | curCount = GetItemCount(giveItem)
|
| | | |
| | | if type(jsonItemList) == list:
|
| | | jsonItemList.append(ItemCommon.GetJsonItem(giveItem))
|
| | | if type(userDataList) == list:
|
| | | userDataList.append(giveItem.GetUserData())
|
| | | |
| | | if DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList):
|
| | | giveOKCount += curCount
|
| | | |
| | | return giveOKCount
|
| | |
|
| | | def GivePlayerAppointItem(curPlayer, appointID, isAuctionItem, event=["", False, {}]):
|
| | | '''给玩家定制物品表物品,定制物品默认个数1
|
| | |
| | | for itemID, itemCount in jobAwardItemList:
|
| | | canSell = (not auctionItemCanSell) if itemID in aucionItemDiffSellIDList else auctionItemCanSell
|
| | | isAuctionItem = 1 if canSell and IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemID) else 0
|
| | | curItem = ItemControler.GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog("宝箱创建奖励物品异常!chestsItemID=%s,useCnt=%s,itemID=%s,itemCount=%s,isBind=%s" |
| | | % (chestsItemID, useCnt, itemID, itemCount, isBind), curPlayer.GetPlayerID())
|
| | | |
| | | userDataList = []
|
| | | giveOKCount = ItemControler.DoGiveItemLoop(curPlayer, itemID, itemCount, isAuctionItem, |
| | | event=[ChConfig.ItemGive_Chests, False, {"UseItemID":chestsItemID}], |
| | | jsonItemList=syncItemList, userDataList=userDataList)
|
| | | if giveOKCount < itemCount:
|
| | | GameWorld.ErrLog("宝箱给物品异常!chestsItemID=%s,useCnt=%s,itemID=%s,itemCount=%s,isBind=%s,giveOKCount=%s" |
| | | % (chestsItemID, useCnt, itemID, itemCount, isBind, giveOKCount), curPlayer.GetPlayerID())
|
| | | continue
|
| | |
|
| | | if showType:
|
| | | syncItemList.append(ItemCommon.GetJsonItem(curItem)) # 必须在给物品之前先get
|
| | | |
| | | userData = curItem.GetUserData()
|
| | | isOK = ItemControler.DoLogic_PutItemInPack(curPlayer, curItem, event=[ChConfig.ItemGive_Chests, False, {"UseItemID":chestsItemID}])
|
| | | if isOK and itemID in notifyItemList:
|
| | | if itemID in notifyItemList:
|
| | | userData = userDataList[0] if userDataList else ""
|
| | | PlayerControl.WorldNotify(0, "ChooseMessage", [curPlayer.GetPlayerName(), chestsItemID, itemID, isBind, itemCount, userData])
|
| | | |
| | | |
| | | # 货币
|
| | | if moneyType:
|
| | | addDataDict = {ChConfig.Def_Give_Reason_SonKey:chestsItemID}
|
| | |
| | | moneyType, moneyCount = 0, 0
|
| | |
|
| | | # ֪ͨ
|
| | | if syncItemList:
|
| | | if showType and syncItemList:
|
| | | ChItem.SendUseItemGetItemResult(curPlayer, chestsItemID, useCnt, syncItemList, moneyType, moneyCount)
|
| | | return True, useCnt
|
| | |
|