| | |
| | | tagItemCount = GetItemCount(tagItem)
|
| | | isBind = tagItem.GetIsBind()
|
| | | isAuctionItem = not isBind
|
| | | auctionGroup = 1 if isAuctionItem else 0 # 物品实例默认一组
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, auctionGroup, defaultPile):
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, isAuctionItem, defaultPile):
|
| | | GameWorld.DebugLog("背包满,不能放入物品 count = %d"%GetItemCount(tagItem))
|
| | | tagItem.Clear()
|
| | | return False
|
| | |
| | | return True
|
| | | defaultPile = True
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif auctionGroup > 0:
|
| | | maxPackCount = max(1, tagItemCount / auctionGroup) # 每组至少1个
|
| | | elif isAuctionItem:
|
| | | maxPackCount = tagItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | #isBind = False
|
| | | isNeedRecord = True # 拍品要记录
|
| | |
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param auctionGroup 拍品组数
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, auctionGroup, defaultPile=True):
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | if GameWorld.IsCrossServer():
|
| | | return True
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, auctionGroup, defaultPile)
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isAuctionItem, defaultPile)
|
| | | return checkRet
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param auctionGroup 拍品组数
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False, 第一个可放入的位置
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, auctionGroup, defaultPile=True):
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | gameData = GameWorld.GetGameData()
|
| | | curItemData = gameData.GetItemByTypeID(curItemID)
|
| | |
|
| | |
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | | return True, 0
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif auctionGroup > 0:
|
| | | maxPackCount = max(1, curItemCount / auctionGroup) # 每组至少1个
|
| | | elif isAuctionItem:
|
| | | maxPackCount = curItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | isBind = False
|
| | | else:
|
| | |
| | | #curItemGUID = curItem.GetGUID()
|
| | | curItemCount = curItem.GetCount()
|
| | | #curItemIsBind = curItem.GetIsBind()
|
| | | auctionGroup = 1 if not curItem.GetIsBind() else 0 # 已经生成的物品实例默认1组
|
| | | isAuctionItem = 0 if curItem.GetIsBind() else 1
|
| | | #toPackIndex = ChConfig.GetItemPackType(curItem.GetType(), toPackIndex)
|
| | |
|
| | | # 常规物品转移到虚拟符印背包
|
| | |
| | | return False
|
| | | return itemControl.PutItemInVPack(toPackIndex, curItem)
|
| | |
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, auctionGroup)
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, isAuctionItem)
|
| | | if not checkRet:
|
| | | return False
|
| | | return DragItem(curPlayer, fromPackIndex, itemIndex, toPackIndex, putIndex, curItemCount)
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, auctionGroup, packIndexList, event=["", False, {}]):
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList, event=["", False, {}]):
|
| | | '''给玩家物品
|
| | | @param auctionGroup: 拍品组数,0为非拍品,大于0为总给的物品数拆成的拍品组数;注意这个不一定按叠加拆分,策划自行决定非几组拍
|
| | | @param isAuctionItem: 是否拍品
|
| | | '''
|
| | | if itemCount <= 0:
|
| | | return False
|
| | |
| | | if not curItemData:
|
| | | return False
|
| | |
|
| | | if auctionGroup > 0:
|
| | | if isAuctionItem:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("非拍卖物品,不能按拍品分组,默认转为非拍品! itemID=%s,itemCount=%s,auctionGroup=%s" |
| | | % (itemID, itemCount, auctionGroup), curPlayer.GetPlayerID())
|
| | | auctionGroup = 0
|
| | | isAuctionItem = True if auctionGroup > 0 else False
|
| | | GameWorld.ErrLog("非拍卖物品,默认转为非拍品! itemID=%s,itemCount=%s,isAuctionItem=%s" |
| | | % (itemID, itemCount, isAuctionItem), curPlayer.GetPlayerID())
|
| | | isAuctionItem = 0
|
| | |
|
| | | defaultPack = IPY_GameWorld.rptItem if not packIndexList else packIndexList[0]
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), defaultPack)
|
| | |
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for packIndex in packIndexList:
|
| | | #可以放入背包
|
| | | if itemControl.CanPutInItem(packIndex, itemID, itemCount, auctionGroup):
|
| | | if itemControl.CanPutInItem(packIndex, itemID, itemCount, isAuctionItem):
|
| | | canPutIn = True
|
| | | break
|
| | | if not canPutIn:
|
| | |
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | |
|
| | | isOK = False
|
| | | doCount = itemCount
|
| | | maxPackCount = max(1, itemCount / auctionGroup) # 每组至少1个
|
| | | while itemCount > 0 and doCount > 0:
|
| | | doCount -= 1
|
| | | giveCount = maxPackCount if itemCount >= maxPackCount else itemCount
|
| | | if giveCount <= 0:
|
| | | break
|
| | | itemCount -= giveCount
|
| | | giveItem = GetOutPutItemObj(itemID, giveCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not giveItem:
|
| | | return isOK
|
| | | if DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | |
| | | return isOK
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not giveItem:
|
| | | return False
|
| | | return DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList)
|
| | |
|
| | |
|
| | | def GivePlayerAppointItem(curPlayer, appointID, isAuctionItem, event=["", False, {}]):
|
| | |
| | | return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
|
| | | return item.GetCount()
|
| | |
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount):
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount, isAuctionItem=0):
|
| | | if isAuctionItem:
|
| | | return 1
|
| | | if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
|
| | | # 货币直接转换的物品如果是放入背包的则不需要暂用格子,放入其他的背包的则按物品叠加上限算
|
| | | if packType == IPY_GameWorld.rptItem:
|
| | |
| | | if itemColor >= ChConfig.Def_Quality_Purple:
|
| | | GameWorld.DebugLog("该装备没有传奇属性: itemID=%s" % (itemID))
|
| | | return
|
| | | fixedLegendAttrCount = attrCountIpyData.GetFixedLegendAttrCount()
|
| | | goodLegendAttrCount = attrCountIpyData.GetGoodLegendAttrCount()
|
| | | otherLegendAttrCount = attrCountIpyData.GetOtherLegendAttrCount()
|
| | | if fixedLegendAttrCount <= 0 and goodLegendAttrCount <= 0 and otherLegendAttrCount <= 0:
|
| | | legendAttrCountInfoList = attrCountIpyData.GetLegendAttrCountInfo() # 传奇属性条数信息 [[条数, [属性类型库编号, ...]], ...]
|
| | | if not legendAttrCountInfoList:
|
| | | return
|
| | |
|
| | | if not curPlayer:
|
| | |
| | | attrTypeIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrType", itemType)
|
| | | if not attrTypeIpyData:
|
| | | return
|
| | | fixedLegendAttrList = attrTypeIpyData.GetFixedLegendAttrList()
|
| | | goodLegendAttrList = attrTypeIpyData.GetGoodLegendAttrList()
|
| | | commLegendAttrList = attrTypeIpyData.GetCommLegendAttrList()
|
| | | legendAttrTypeLibDict = attrTypeIpyData.GetLegendAttrTypeLib() # 传奇属性类型库 {属性类型库编号:[属性ID,...], ...}
|
| | | |
| | | curLegAttrIDList = []
|
| | | curLegAttrValueList = []
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | if isAllAttr:
|
| | | if curPlayer.GetGMLevel() != 90:
|
| | | return
|
| | | curLegAttrIDList = fixedLegendAttrList + goodLegendAttrList + commLegendAttrList
|
| | | for attrIDList in legendAttrTypeLibDict.values():
|
| | | curLegAttrIDList += attrIDList
|
| | | #GameWorld.DebugLog("所有传奇属性: %s" % (curLegAttrIDList), playerID)
|
| | | else:
|
| | | if fixedLegendAttrCount:
|
| | | if len(fixedLegendAttrList) < fixedLegendAttrCount:
|
| | | GameWorld.ErrLog("装备固定传奇属性配置不足!itemID=%s,itemType=%s,fixedLegendAttrCount=%s,fixedLegendAttrList=%s" |
| | | % (itemID, itemType, fixedLegendAttrCount, fixedLegendAttrList), playerID)
|
| | | return
|
| | | curLegAttrIDList += fixedLegendAttrList[:fixedLegendAttrCount]
|
| | | |
| | | if goodLegendAttrCount:
|
| | | if len(goodLegendAttrList) < goodLegendAttrCount:
|
| | | GameWorld.ErrLog("装备追求传奇属性配置不足!itemID=%s,itemType=%s,goodLegendAttrCount=%s,goodLegendAttrList=%s" |
| | | % (itemID, itemType, goodLegendAttrCount, goodLegendAttrList), playerID)
|
| | | return
|
| | | curLegAttrIDList += random.sample(goodLegendAttrList, goodLegendAttrCount)
|
| | | |
| | | if otherLegendAttrCount:
|
| | | otherLegendAttrList = list(goodLegendAttrList) + list(commLegendAttrList)
|
| | | #GameWorld.DebugLog("随机传奇属性: itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s" |
| | | # % (itemID, itemType, itemClassLV, itemColor, isSuit), playerID)
|
| | | for attrCount, libNumList in legendAttrCountInfoList:
|
| | | attrIDList = []
|
| | | for libNum in libNumList:
|
| | | attrIDList.extend(legendAttrTypeLibDict.get(libNum, []))
|
| | | for curAttrID in curLegAttrIDList:
|
| | | if curAttrID in otherLegendAttrList:
|
| | | otherLegendAttrList.remove(curAttrID)
|
| | | if len(otherLegendAttrList) < otherLegendAttrCount:
|
| | | GameWorld.ErrLog("装备一般传奇属性配置不足!itemID=%s,itemType=%s,otherLegendAttrCount=%s,otherLegendAttrList=%s" |
| | | % (itemID, itemType, otherLegendAttrCount, otherLegendAttrList), playerID)
|
| | | if curAttrID in attrIDList:
|
| | | attrIDList.remove(curAttrID)
|
| | | if len(attrIDList) < attrCount:
|
| | | GameWorld.ErrLog("装备传奇属性ID库配置不够条数随机!itemID=%s,itemType=%s,legendAttrCountInfoList=%s,legendAttrTypeLibDict=%s" |
| | | % (itemID, itemType, legendAttrCountInfoList, legendAttrTypeLibDict), playerID)
|
| | | return
|
| | | curLegAttrIDList += random.sample(otherLegendAttrList, otherLegendAttrCount)
|
| | | curLegAttrIDList += random.sample(attrIDList, attrCount)
|
| | | #GameWorld.DebugLog(" 随机传奇属性: attrCount=%s,libNumList=%s,attrIDList=%s,curLegAttrIDList=%s" |
| | | # % (attrCount, libNumList, attrIDList, curLegAttrIDList), playerID)
|
| | |
|
| | | # 3. 定数值
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | attrValueIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrValue", itemType, itemClassLV, itemColor, isSuit)
|
| | | if not attrValueIpyData:
|
| | | GameWorld.ErrLog("传奇属性等级数值表找不到配置!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s"
|
| | | % (itemID, itemType, itemClassLV, itemColor, isSuit), playerID)
|
| | | return
|
| | | #GameWorld.DebugLog("随机传奇属性: itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s" |
| | | # % (itemID, itemType, itemClassLV, itemColor, isSuit, ), playerID)
|
| | | #GameWorld.DebugLog(" 固定条数=%s-%s,追求条数=%s-%s,其他条数=%s-%s" |
| | | # % (fixedLegendAttrCount, fixedLegendAttrList, goodLegendAttrCount, goodLegendAttrList, |
| | | # otherLegendAttrCount, commLegendAttrList), playerID) |
| | | |
| | | attrLVLibNumDict = attrValueIpyData.GetLVLegendAttrLibNumInfo() # {属性ID:{等级:库编号, ...}}
|
| | | for attrID in curLegAttrIDList:
|
| | | if attrID not in attrLVLibNumDict:
|
| | |
| | | curItem.Clear()
|
| | | return
|
| | |
|
| | | def PutItemInTempSwap(curPlayer, itemID, isBind=1):
|
| | | def PutItemInTempSwap(curPlayer, itemID, isAuctionItem=0):
|
| | | ## 临时背包放入物品
|
| | | # 临时交换背包目前只开放1个格子,每次放入前先清空再放入
|
| | | ClearPack(curPlayer, ShareDefine.rptTempSwap)
|
| | | auctionGroup = 1 if not isBind else 0
|
| | | return GivePlayerItem(curPlayer, itemID, 1, auctionGroup, [ShareDefine.rptTempSwap])
|
| | | return GivePlayerItem(curPlayer, itemID, 1, isAuctionItem, [ShareDefine.rptTempSwap])
|
| | |
|
| | | def OpenPickupItemPutInTemp(curPlayer, isClearItem):
|
| | | ''' 开启拾取的物品放入临时存放背包
|
| | |
| | | mailItemList = []
|
| | | for tempItem in tempItemList:
|
| | | mailItemList.append(ItemCommon.GetMailItemDict(tempItem))
|
| | | mailItemList +=extraItemList
|
| | | mailItemList += extraItemList
|
| | | mailTypeKey = ShareDefine.DefaultLackSpaceMailType if not mailTypeKey else mailTypeKey
|
| | | PlayerControl.SendMailByKey(mailTypeKey, [curPlayer.GetPlayerID()], mailItemList)
|
| | | else:
|
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for tempItem in tempItemList:
|
| | | itemControl.PutInItem(IPY_GameWorld.rptItem, tempItem, event=event)
|
| | | for itemID, itemCnt, isBind in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], event=event)
|
| | | for itemID, itemCnt, isAuctionItem in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | |
|
| | | ClearPack(curPlayer, ShareDefine.rptTempItem)
|
| | | return
|
| | |
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
|
| | | ##给物品,背包满则发邮件
|
| | | needPackSpaceDict = {}
|
| | | for itemID, itemCnt, isBind in itemList:
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog('GivePlayerItemOrMail 物品ID不存在 itemID=%s'%itemID, curPlayer.GetID())
|
| | | return
|
| | | packType = ChConfig.GetItemPackType(curItem.GetType())
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt)
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | | isSendMail = False
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | |
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)
|
| | | GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())
|
| | | else:
|
| | | for itemID, itemCnt, isBind in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem], event=event)
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | | return
|