| | |
| | | import Operate_EquipStone
|
| | | import Operate_EquipSuitCompose
|
| | | import IpyGameDataPY
|
| | | import EventShell
|
| | |
|
| | | import math
|
| | | #---------------------------------------------------------------------
|
| | | ## 放不下主角背包放入万能背包的逻辑, curGiveItem 要先 SetCount
|
| | | # @param curPlayer 当前玩家
|
| | |
| | | Operate_EquipStone.DoMoveEquipStone(curPlayer, packEquipIndex)
|
| | | #套装降级处理
|
| | | Operate_EquipSuitCompose.CheckEquipSuitReduce(curPlayer, packEquipIndex)
|
| | | |
| | | EventShell.EventRespons_EquipStar(curPlayer)
|
| | | self.RefreshStartEquipCount()
|
| | | return packEquipIndex if result else -1
|
| | |
|
| | |
| | | self.RefreshStartEquipCount()
|
| | | #套装降级处理
|
| | | Operate_EquipSuitCompose.CheckEquipSuitReduce(curPlayer, equipIndex)
|
| | | EventShell.EventRespons_EquipStar(curPlayer)
|
| | | #===============================================================================
|
| | | # #destItemPlace = 卸下物品的位置
|
| | | # destItemPlace = curPack.GetAt(packIndex)
|
| | |
| | | eventName, isForceEvent, addDict = event
|
| | | isNeedRecord = isForceEvent or ItemNeedRecord(tagItem)
|
| | | if packIndex == ShareDefine.rptRune:
|
| | | setItemKeyData = GetRuneItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetRuneLV))
|
| | | runeSource = tagItem.GetUserAttr(ShareDefine.Def_IudetRuneSource) or 1
|
| | | setItemKeyData = GetRuneItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetRuneLV), source=runeSource)
|
| | |
|
| | | refreshPlaceList = []
|
| | | for place in xrange(ItemCommon.GetVPackCnt(packIndex)):
|
| | |
| | | def PutInItem(self, packIndex, tagItem, defaultPile=True, event=["", False, {}]):
|
| | | curPlayer = self.__Player
|
| | |
|
| | | if packIndex != ShareDefine.rptTreasure and self.DoTransformItem(curPlayer, tagItem):
|
| | | tagItem.Clear() # 需清除,不然会导致内存泄露 寻宝仓库可暂存直接转化数值的物品
|
| | | return True
|
| | | |
| | | isEquip = ItemCommon.CheckItemIsEquip(tagItem)
|
| | | if isEquip:
|
| | | defaultPile = False # 装备默认不判断堆叠
|
| | |
| | |
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), packIndex)
|
| | |
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItem.GetCount(), tagItem.GetIsBind(), defaultPile):
|
| | | GameWorld.DebugLog("背包满,不能放入物品 count = %d"%tagItem.GetCount())
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), GetItemCount(tagItem), tagItem.GetIsBind(), defaultPile):
|
| | | GameWorld.DebugLog("背包满,不能放入物品 count = %d"%GetItemCount(tagItem))
|
| | | tagItem.Clear()
|
| | | return False
|
| | |
|
| | | itemID = tagItem.GetItemTypeID()
|
| | | if itemID in ChConfig.Def_TransformItemIDList:
|
| | | # 直接转化为对应货币的物品仅在放入背包时直接转化,否则还是以真实物品的形式存在,但堆叠上限需要做特殊处理
|
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | | self.DoTransformItem(curPlayer, tagItem)
|
| | | tagItem.Clear() # 需清除,不然会导致内存泄露
|
| | | return True
|
| | | defaultPile = True
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | else:
|
| | | maxPackCount = curItemData.GetPackCount()
|
| | | |
| | | # 虚拟背包, 默认不做叠加
|
| | | if packIndex in ShareDefine.Def_VPack_TypeList:
|
| | | return self.PutItemInVPack(packIndex, tagItem, event)
|
| | |
| | | if item.GetIsLocked() == True:
|
| | | continue
|
| | |
|
| | | packItemCount = item.GetCount()
|
| | | curItemCount = tagItem.GetCount()
|
| | | canPutinCount = tagItem.GetPackCount() - packItemCount
|
| | | packItemCount = GetItemCount(item)
|
| | | curItemCount = GetItemCount(tagItem)
|
| | | canPutinCount = maxPackCount - packItemCount
|
| | | if canPutinCount <= 0:
|
| | | continue
|
| | | #可以摆放
|
| | |
| | | if item.IsEmpty() != True:
|
| | | continue
|
| | |
|
| | | packItemCount = item.GetCount() # Ϊ0
|
| | | curItemCount = tagItem.GetCount()
|
| | | canPutinCount = tagItem.GetPackCount() - packItemCount
|
| | | packItemCount = GetItemCount(item) # Ϊ0
|
| | | curItemCount = GetItemCount(tagItem)
|
| | | canPutinCount = maxPackCount - packItemCount
|
| | | if canPutinCount <= 0:
|
| | | continue
|
| | | #可以摆放
|
| | | if curItemCount > canPutinCount:
|
| | | #需要创建新物品放入
|
| | | curCreateItem = ItemCommon.CreateSingleItem(tagItem.GetItemTypeID())
|
| | | curCreateItem = GetOutPutItemObj(tagItem.GetItemTypeID(), canPutinCount, isBind)
|
| | | #注意: 不能在这里AssignItem, 否则会有2个物品指针指向同一个物品实例 . 巨大的错误在这一句 : curCreateItem.Assign(tagItem)
|
| | | SetItemCount(curCreateItem, canPutinCount)
|
| | | SetItemIsBind(curCreateItem, isBind)
|
| | | #此处不做装备拆解,如有需求外传for处理
|
| | | #如果是装备,那么 maxPackCount 为1 这里会循环自动创建新物品,所以直接 GetOutPutItemObj 即可, 暂不支持定制装备拆解
|
| | |
|
| | | item.AssignItem(curCreateItem)
|
| | | SetItemCount(tagItem, curItemCount - canPutinCount)
|
| | |
| | | ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)
|
| | | else:
|
| | | #可以放下
|
| | | if isEquip:
|
| | | self.CheckEquipAttr(packIndex, tagItem)
|
| | | |
| | | if tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitRoleItem:
|
| | | item.PutIn(tagItem)
|
| | | elif tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitSingleItem:
|
| | |
| | | putResult = True
|
| | |
|
| | | if isNeedRecord:
|
| | | itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, item.GetCount())
|
| | | itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, GetItemCount(item))
|
| | | ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)
|
| | | break
|
| | |
|
| | | #放入东西
|
| | | return putResult
|
| | |
|
| | | def CheckEquipAttr(self, packType, curItem):
|
| | | legendAttrIDCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)
|
| | | legendAttrValueCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)
|
| | | |
| | | if legendAttrIDCount and legendAttrValueCount and legendAttrIDCount == legendAttrValueCount:
|
| | | return
|
| | | |
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem)
|
| | | if not legendAttrInfo:
|
| | | return
|
| | | |
| | | curPlayer = self.__Player
|
| | | srcScore = ItemCommon.GetEquipGearScore(curItem)
|
| | | legendAttrIDList, legendAttrValueList = legendAttrInfo
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
|
| | | for i in xrange(len(legendAttrIDList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, legendAttrIDList[i])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, legendAttrValueList[i])
|
| | | ItemCommon.MakeEquipGS(curItem)
|
| | | updScore = ItemCommon.GetEquipGearScore(curItem)
|
| | | GameWorld.ErrLog("传奇属性异常,重新刷新一次属性: packType=%s,itemID=%s,legendAttrIDList=%s,legendAttrValueList=%s,srcScore=%s,updScore=%s" |
| | | % (packType, curItem.GetItemTypeID(), legendAttrIDList, legendAttrValueList, srcScore, updScore), curPlayer.GetPlayerID())
|
| | | return
|
| | | |
| | | def CheckRolePackEquipAttr(self):
|
| | | curPlayer = self.__Player
|
| | | key = "LoginCheckEquipAttr"
|
| | | if curPlayer.NomalDictGetProperty(key):
|
| | | return
|
| | | checkPackList = [IPY_GameWorld.rptEquip, IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]
|
| | | for packType in checkPackList:
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | for i in xrange(curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | #GameWorld.DebugLog("packType=%s,i=%s" % (packType, i))
|
| | | if curItem.IsEmpty():
|
| | | continue
|
| | | isEquip = ItemCommon.CheckItemIsEquip(curItem)
|
| | | if not isEquip:
|
| | | continue
|
| | | self.CheckEquipAttr(packType, curItem)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, key, 1)
|
| | | return
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | |
| | | return False, 0
|
| | |
|
| | | if curItemID in ChConfig.Def_TransformItemIDList:
|
| | | #特殊物品无需判断数量
|
| | | return True, 0
|
| | | |
| | | maxPackCount = curItemData.GetPackCount()
|
| | | |
| | | # 货币直接转换的物品如果是放入背包的则直接转化,无需暂用格子
|
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | | return True, 0
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | else:
|
| | | maxPackCount = curItemData.GetPackCount()
|
| | | |
| | | if maxPackCount == 0:
|
| | | GameWorld.Log("策划填表错误 %s -> maxPackCount = %s" % (curItemID , maxPackCount))
|
| | | return False, 0
|
| | | |
| | | # 特殊处理不同的物品放入不同的背包,如神兽背包
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), packIndex)
|
| | |
|
| | | maxCanPutItem = 0
|
| | | curPlayer = self.__Player
|
| | |
| | |
|
| | | itemIndex = -1
|
| | | curPack = self.__PlayerItemManager.GetPack(packIndex)
|
| | | for i in range(0, curPack.GetCount()):
|
| | | for i in xrange(curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | |
|
| | | if item.IsEmpty():
|
| | |
| | | continue
|
| | |
|
| | | if (CanPackItemByItemType(item.GetItemTypeID(), item.GetIsBind(), curItemID, isBind) and
|
| | | maxPackCount > item.GetCount()):
|
| | | maxPackCount > GetItemCount(item)):
|
| | | #该物品锁定不执行==============================================
|
| | | #可堆叠
|
| | | maxCanPutItem += maxPackCount - item.GetCount()
|
| | | maxCanPutItem += maxPackCount - GetItemCount(item)
|
| | | if itemIndex == -1:
|
| | | itemIndex = i
|
| | |
|
| | |
| | | return True, itemIndex
|
| | |
|
| | | #==============================================================================
|
| | | # 符印物品存储字典数值数据结构: 前5位为物品ID, 6~8位为强化等级, 第10位为是否锁定
|
| | | def GetRuneItemKeyData(itemID, RuneLV, lockState=0):
|
| | | # 符印物品存储字典数值数据结构: 前5位为物品ID, 6~8位为强化等级, 第9位为来源(老号0,默认1,合成2),第10位为是否锁定
|
| | | def GetRuneItemKeyData(itemID, RuneLV, lockState=0, source=1):
|
| | | lockState = 1 if lockState > 0 else 0
|
| | | return lockState * 1000000000 + min(RuneLV, 999) * 100000 + itemID
|
| | | return lockState * 1000000000 + source * 100000000 + min(RuneLV, 999) * 100000 + itemID
|
| | | def GetRuneItemID(keyData): return keyData % 100000
|
| | | def GetRuneItemPlusLV(keyData): return keyData % 100000000 / 100000
|
| | | def GetRuneItemIsLock(keyData): return keyData / 1000000000
|
| | | def GetRuneItemSource(keyData): return keyData % 1000000000 / 100000000
|
| | | def IsRuneItemNeedRecord(curItem, plusLV):
|
| | | return plusLV > 0 or curItem.GetItemColor() >= ChConfig.Def_Quality_Orange
|
| | |
|
| | |
| | | errorInfo = "%s %s %s -- ItemControler->SetItemCount::" % (playerID, accID, playerName)
|
| | | GameWorld.ErrLog(errorInfo + str(traceback.extract_stack()) + "\n" + traceback.format_exc())
|
| | | raise
|
| | | |
| | | def GetItemCount(item):
|
| | | if item.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
|
| | | return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
|
| | | return item.GetCount()
|
| | |
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount):
|
| | | if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
|
| | | # 货币直接转换的物品如果是放入背包的则不需要暂用格子,放入其他的背包的则按物品叠加上限算
|
| | | if packType == IPY_GameWorld.rptItem:
|
| | | return 0
|
| | | packCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的
|
| | | else:
|
| | | packCount = itemData.GetPackCount()
|
| | | return int(math.ceil(itemCount / float(packCount)))
|
| | |
|
| | | ## 双手武器,需要两只手才拿得动
|
| | | # @param curEquip
|
| | |
| | | # {属性ID:{颜色:数值, ...}, ...}
|
| | | if isDogzEquip:
|
| | | # 神兽装备数值不一样
|
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor2")
|
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor2", 1, {})
|
| | | legAttrValueClassLVColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor2", 2, {})
|
| | | else:
|
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor")
|
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor", 1, {})
|
| | | legAttrValueClassLVColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor", 2, {})
|
| | | legAttrValueClassLVDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByClassLV")
|
| | | for attrID in randAttrIDList:
|
| | | if attrID in legAttrValueColorDict:
|
| | |
| | | GameWorld.ErrLog("没有配置传奇属性ID装备颜色对应的数值, attrID=%s,itemColor=%s" % (attrID, itemColor))
|
| | | continue
|
| | | attrValue = colorValueDict[itemColor]
|
| | | # {属性ID:{阶:{颜色:数值, ...}, ...}, ...}
|
| | | elif attrID in legAttrValueClassLVColorDict:
|
| | | classLVColorValueDict = legAttrValueClassLVColorDict[attrID]
|
| | | if itemClassLV in classLVColorValueDict:
|
| | | colorValueDict = classLVColorValueDict[itemClassLV]
|
| | | else:
|
| | | minClassLV, maxClassLV = min(classLVColorValueDict), max(classLVColorValueDict)
|
| | | if itemClassLV <= minClassLV:
|
| | | colorValueDict = classLVColorValueDict[minClassLV]
|
| | | elif itemClassLV >= maxClassLV:
|
| | | colorValueDict = classLVColorValueDict[maxClassLV]
|
| | | else:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备阶级颜色对应的数值, attrID=%s,itemClassLV=%s" % (attrID, itemClassLV))
|
| | | continue
|
| | | if itemColor not in colorValueDict:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备阶级颜色对应的数值, attrID=%s,itemClassLV=%s,itemColor=%s" % (attrID, itemClassLV, itemColor))
|
| | | continue
|
| | | attrValue = colorValueDict[itemColor]
|
| | | elif attrID in legAttrValueClassLVDict:
|
| | | classLVValueDict = legAttrValueClassLVDict[attrID]
|
| | | if itemClassLV in classLVValueDict:
|