| | |
| | | import PlayerRune
|
| | | import NPCCommon
|
| | | import ChConfig
|
| | | import ChEquip
|
| | | import ChItem
|
| | |
|
| | | import random
|
| | |
| | | return
|
| | |
|
| | | showType = chestsIpyData.GetShowType() # 规定有开箱表现的默认只能开启1个
|
| | | if showType:
|
| | | useCnt = 1
|
| | | |
| | | #if showType:
|
| | | # useCnt = 1
|
| | | useCnt = min(curRoleItem.GetCount(), useCnt)
|
| | | |
| | | isBind = int(chestsIpyData.GetIsBind()) # 奖励物品是否绑定
|
| | | costItemID = chestsIpyData.GetCostItemID()
|
| | | costItemCountTotal = chestsIpyData.GetCostItemCount() * useCnt
|
| | | costGoldTotal = chestsIpyData.GetCostGold() * useCnt
|
| | | auctionItemCanSell = chestsIpyData.GetAucionItemCanSell()
|
| | | aucionItemDiffSellIDList = chestsIpyData.GetAucionItemDiffSellIDList()
|
| | |
|
| | | if costGoldTotal and not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGoldTotal):
|
| | | return
|
| | |
| | | if not awardInfo:
|
| | | return
|
| | | needSpaceDict, jobAwardItemList, moneyType, moneyCount, notifyItemList, updOpenCount = awardInfo
|
| | | GameWorld.DebugLog(" needSpaceDict=%s,jobAwardItemList=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s,updOpenCount=%s,auctionItemCanSell=%s" |
| | | % (needSpaceDict, jobAwardItemList, moneyType, moneyCount, notifyItemList, updOpenCount, auctionItemCanSell))
|
| | | GameWorld.DebugLog(" needSpaceDict=%s,jobAwardItemList=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s,updOpenCount=%s,auctionItemCanSell=%s,aucionItemDiffSellIDList=%s" |
| | | % (needSpaceDict, jobAwardItemList, moneyType, moneyCount, notifyItemList, updOpenCount, auctionItemCanSell, aucionItemDiffSellIDList))
|
| | |
|
| | | for packType, needSpace in needSpaceDict.items():
|
| | | packSpace = ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace)
|
| | |
| | | # 给奖励
|
| | | syncItemList = []
|
| | | for itemID, itemCount in jobAwardItemList:
|
| | | isAuctionItem = 1 if auctionItemCanSell and IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemID) else 0
|
| | | 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"
|
| | |
| | | if not itemData:
|
| | | GameWorld.ErrLog("宝箱奖励物品不存在! chestsItemID=%s,itemID=%s,jobItemID=%s" % (chestsItemID, itemID, jobItemID))
|
| | | return
|
| | | packType = ChConfig.GetItemPackType(itemData.GetType())
|
| | | packType = ChConfig.GetItemPackType(itemData)
|
| | | needSpace = int(math.ceil(itemCount / float(itemData.GetPackCount())))
|
| | | needSpaceDict[packType] = needSpaceDict.get(packType, 0) + needSpace
|
| | |
|
| | |
| | | if not placeList:
|
| | | GameWorld.ErrLog("部位集合key不存在!chestsItemID=%s,placeKey=%s" % (chestsItemID, placeKey))
|
| | | continue
|
| | | # 未指定,默认取当前解锁的最大境界装备阶
|
| | | if classLV == 0:
|
| | | classLV = ChEquip.GetPlayerMaxEquipClassLV(curPlayer)
|
| | | GameWorld.DebugLog(" 未指定装备阶,默认取玩家当前解锁的最大阶: classLV=%s" % classLV)
|
| | | |
| | | randEquipIDList = NPCCommon.__GetEquipIDList(chestsItemID, classLV, color, isSuit, placeList, itemJobList, findType="ChestsItem")
|
| | | if not randEquipIDList:
|
| | | continue
|
| | |
| | | # 多条产出记录的,按等级来
|
| | | lvIpyDataList = []
|
| | | for ipyData in awardIpyDataList:
|
| | | lvIpyDataList.append([ipyData.GetAwardLV(), ipyData])
|
| | | lvIpyDataList.append([ipyData.GetRealmLV(), ipyData.GetAwardLV(), ipyData])
|
| | | lvIpyDataList.sort() # 升序排序
|
| | |
|
| | | curLV = curPlayer.GetLV()
|
| | | minLV = lvIpyDataList[0][0]
|
| | | curRealmLV = curPlayer.GetOfficialRank()
|
| | | minRealmLV, minLV = lvIpyDataList[0][0], lvIpyDataList[0][1]
|
| | | if curLV < minLV:
|
| | | GameWorld.ErrLog("当前等级无法开启该宝箱!curLV=%s,minLV=%s,chestsItemID=%s" % (curLV, minLV, chestsItemID), curPlayer.GetPlayerID())
|
| | | GameWorld.ErrLog("当前等级无法开启该宝箱!curLV=%s < minLV=%s,chestsItemID=%s" % (curLV, minLV, chestsItemID), curPlayer.GetPlayerID())
|
| | | return
|
| | | if curRealmLV < minRealmLV:
|
| | | GameWorld.ErrLog("当前境界无法开启该宝箱!curRealmLV=%s < minRealmLV=%s,chestsItemID=%s" % (curRealmLV, minRealmLV, chestsItemID), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | for i, lvIpyInfo in enumerate(lvIpyDataList[1:], 1):
|
| | | awardLV, ipyData = lvIpyInfo
|
| | | if curLV < awardLV:
|
| | | awardLV, ipyData = lvIpyDataList[i - 1]
|
| | | return ipyData
|
| | | realmLV, awardLV, ipyData = lvIpyInfo
|
| | | if realmLV: # 境界优先,二选一
|
| | | if curRealmLV < realmLV:
|
| | | return lvIpyDataList[i - 1][-1]
|
| | | else:
|
| | | if curLV < awardLV:
|
| | | return lvIpyDataList[i - 1][-1]
|
| | | return awardIpyDataList[-1]
|
| | |
|