|  |  | 
 |  |  |     GameWorld.DebugLog("物品过期时间" + timeStr)
 | 
 |  |  |     return GameWorld.ChangeTimeStrToNum(timeStr)
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | ## 创建物品
 | 
 |  |  | #  @param itemID 物品ID
 | 
 |  |  | #  @return curSingleItem
 | 
 |  |  | #  @remarks 函数详细说明.
 | 
 |  |  | def CreateSingleItem(itemID, itemCount=1, isBind=1, expireTime=0):
 | 
 |  |  | def CreateSingleItem(itemID, itemCount=1, isAuctionItem=False, expireTime=0):
 | 
 |  |  |     ''' 创建物品
 | 
 |  |  |     @param isAuctionItem: 是否拍品,默认非拍品
 | 
 |  |  |     @param expireTime: 有效时间,时间单位由时效类型决定
 | 
 |  |  |     '''
 | 
 |  |  |     if itemCount < 1:
 | 
 |  |  |         GameWorld.ErrLog("创建物品个数不能少于1! itemID=%s,itemCount=%s" % (itemID, itemCount))
 | 
 |  |  |         return
 | 
 |  |  | 
 |  |  |             return
 | 
 |  |  |         curSingleItem.SetRemainHour(outTimeServerDay)
 | 
 |  |  |         
 | 
 |  |  |     if isBind:
 | 
 |  |  |         curSingleItem.SetIsBind(1)
 | 
 |  |  |          | 
 |  |  |     if isAuctionItem:
 | 
 |  |  |         if IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemID):
 | 
 |  |  |             ItemControler.SetIsAuctionItem(curSingleItem, isAuctionItem)
 | 
 |  |  |         else:
 | 
 |  |  |             GameWorld.ErrLog("拍卖物品表不存在该ID!创建拍品失败,默认转为非拍品!itemID=%s" % itemID)
 | 
 |  |  |              | 
 |  |  |     ItemControler.SetItemCount(curSingleItem, itemCount)
 | 
 |  |  |     
 | 
 |  |  |     if expireTime > 0:
 | 
 |  |  | 
 |  |  |     #这里返回的是SingleItem , 如果创建了,未使用,会找出C++内存泄露!!!
 | 
 |  |  |     return curSingleItem
 | 
 |  |  | 
 | 
 |  |  | def UpdateItemUserData(curItem, updateDict={}, delKeyList=[], isUpdateGS=False):
 | 
 |  |  |     ''' 更新物品UserData数据
 | 
 |  |  |     @param curItem: IPY_SingleItem 或  IPY_RoleItem
 | 
 |  |  |     @param updateDict: 需要更新的数据 {key:value, key:valueList, ...}
 | 
 |  |  |     @param delKeyList: 需要删除的数据 key列表[key, ...]
 | 
 |  |  |     @param isUpdateGS: 是否更新评分
 | 
 |  |  |     @note: UserData格式举例 {'17':['65','7','52'],'50':['0'],'19':['420','380','50'],'50':['1552728662']}
 | 
 |  |  |     '''
 | 
 |  |  |      | 
 |  |  |     isRoleItem = False
 | 
 |  |  |     if not hasattr(curItem, "SetUserData"):
 | 
 |  |  |         item = curItem.GetItem()
 | 
 |  |  |         isRoleItem = True
 | 
 |  |  |     else:
 | 
 |  |  |         item = curItem
 | 
 |  |  |     userData = item.GetUserData()
 | 
 |  |  |     if not userData:
 | 
 |  |  |         userDataDict = {}
 | 
 |  |  |     else:
 | 
 |  |  |         userDataDict = eval(userData)
 | 
 |  |  |          | 
 |  |  |     for delKey in delKeyList:
 | 
 |  |  |         userDataDict.pop(str(delKey), None)
 | 
 |  |  |          | 
 |  |  |     for key, value in updateDict.items():
 | 
 |  |  |         if type(value) == int:
 | 
 |  |  |             valueList = ['%s' % value]
 | 
 |  |  |         elif type(value) == list:
 | 
 |  |  |             valueList = ['%s' % v for v in value]
 | 
 |  |  |         else:
 | 
 |  |  |             continue
 | 
 |  |  |         userDataDict['%s' % key] = valueList
 | 
 |  |  |          | 
 |  |  |     UserData = str(userDataDict).replace(" ", "")
 | 
 |  |  |     item.SetUserData(UserData, len(UserData))
 | 
 |  |  |     if isUpdateGS:
 | 
 |  |  |         MakeEquipGS(curItem)
 | 
 |  |  |     elif isRoleItem:
 | 
 |  |  |         curItem.SetCount(curItem.GetCount()) # 为了触发物品同步
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def MakeEquipGS(curItem):
 | 
 |  |  |     if not CheckNoteEquipGS(curItem):
 | 
 |  |  | 
 |  |  |     MaxAtk = attrDict.get(ShareDefine.Def_Effect_MaxAtk, 0) + Atk
 | 
 |  |  |     MaxHP = attrDict.get(ShareDefine.Def_Effect_MaxHP, 0)
 | 
 |  |  |     Def = attrDict.get(ShareDefine.Def_Effect_Def, 0)
 | 
 |  |  |     ArmorDefPer = attrDict.get(ShareDefine.Def_Effect_ArmorDefAddPer, 0)
 | 
 |  |  |     ArmorDefPer = 0
 | 
 |  |  |     IceAtk = attrDict.get(ShareDefine.Def_Effect_IceAtk, 0)
 | 
 |  |  |     IceDef = attrDict.get(ShareDefine.Def_Effect_IceDef, 0)
 | 
 |  |  |     
 | 
 |  |  | 
 |  |  | #  @return True or False
 | 
 |  |  | #  @remarks 函数详细说明.
 | 
 |  |  | def CheckItemByEffectID(curPlayer, curItem, effectList):
 | 
 |  |  |     if not CheckItemCanUse(curItem):
 | 
 |  |  |     if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |         return False
 | 
 |  |  |     
 | 
 |  |  |     if not ItemControler.CheckItemUseLV(curPlayer, curItem, False):
 | 
 |  |  | 
 |  |  |     for i in range(backPack.GetCount()):
 | 
 |  |  |         curItem = backPack.GetAt(i)
 | 
 |  |  |         
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != findItemID:
 | 
 |  |  | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 |  |  | #此函数验证当前职业阶可用(向下兼容),同CheckJob区分使用
 | 
 |  |  | def JobUseable(curPlayer, curItem):
 | 
 |  |  |     '''判断物品是否职业可用
 | 
 |  |  |         物品表中职业限制规则: 0为通用;非0百位代表职业,十位和个位为职业阶数, 职业阶向下兼容,高阶可使用低阶物品
 | 
 |  |  |     '''
 | 
 |  |  |     itemJobLimit = curItem.GetJobLimit()
 | 
 |  |  |     if not itemJobLimit:
 | 
 |  |  |         return True
 | 
 |  |  |      | 
 |  |  |     # 取消限制的物品
 | 
 |  |  |     if curItem.GetUserAttr(ShareDefine.Def_IudetCancelUseLimit) == 1:
 | 
 |  |  |         return CheckJob(curPlayer, curItem)
 | 
 |  |  |      | 
 |  |  |     if curPlayer.GetJob() == itemJobLimit / 100 and PlayerControl.GetJobRank(curPlayer) >= itemJobLimit % 100:
 | 
 |  |  |         return True
 | 
 |  |  |     return False
 | 
 |  |  | 
 | 
 |  |  | #此函数验证当前职业系可用,同JobUseable区分使用
 | 
 |  |  | #此函数验证当前职业系可用
 | 
 |  |  | def CheckJob(curPlayer, curItem):
 | 
 |  |  |     '''判断物品是否职业系可用
 | 
 |  |  |         物品表中职业限制规则: 0为通用;非0百位代表职业,十位和个位为职业阶数, 职业阶向下兼容,高阶可使用低阶物品
 | 
 |  |  |         物品表中职业限制规则: 0为通用;非0百位代表职业
 | 
 |  |  |     '''
 | 
 |  |  |     itemJobLimit = curItem.GetJobLimit()
 | 
 |  |  |     if not itemJobLimit:
 | 
 |  |  |         return True
 | 
 |  |  |     if curPlayer.GetJob() == itemJobLimit / 100:
 | 
 |  |  |     if curPlayer.GetJob() == itemJobLimit:
 | 
 |  |  |         return True
 | 
 |  |  |     
 | 
 |  |  |     return False
 | 
 |  |  | 
 |  |  |         return isExpireItem, remainingTime
 | 
 |  |  |     
 | 
 |  |  |     return isExpireItem, remainingTime
 | 
 |  |  | 
 | 
 |  |  | ##检查该物品是否合法,类型验证
 | 
 |  |  | # @param curItem 物品实例
 | 
 |  |  | # @param checkType 物品类型  | 
 |  |  | # @return 布尔值(物品是否合法)
 | 
 |  |  | # @remarks 检查该物品是否合法,类型验证
 | 
 |  |  | def CheckItemByType(curItem, checkType):
 | 
 |  |  |     #验证材料
 | 
 |  |  |     if not CheckItemCanUse(curItem):
 | 
 |  |  |         return False
 | 
 |  |  |      | 
 |  |  |     #类型不符合
 | 
 |  |  |     if curItem.GetType() != checkType:
 | 
 |  |  |         return False
 | 
 |  |  |      | 
 |  |  |     return True
 | 
 |  |  | 
 | 
 |  |  | ## 检查装备是否有镶嵌宝石
 | 
 |  |  | #  @param curItem 装备对象
 | 
 |  |  | 
 |  |  |     for i in range(curItemPack.GetCount()):
 | 
 |  |  |         findItem = curItemPack.GetAt(i)
 | 
 |  |  |         
 | 
 |  |  |         if not CheckItemCanUse(findItem):
 | 
 |  |  |         if not CheckItemCanUse(findItem) or ItemControler.GetIsAuctionItem(findItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         #不使用绑定的材料
 | 
 |  |  | 
 |  |  |     for i in range(curItemPack.GetCount()):
 | 
 |  |  |         curItem = curItemPack.GetAt(i)
 | 
 |  |  |         
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         #不使用绑定的材料
 | 
 |  |  | 
 |  |  |     for i in range(curItemPack.GetCount()):
 | 
 |  |  |         curItem = curItemPack.GetAt(i)
 | 
 |  |  |         
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != findItemID:
 | 
 |  |  | 
 |  |  |     for i in range(itemPack.GetCount()):
 | 
 |  |  |         curItem = itemPack.GetAt(i)
 | 
 |  |  |         #过滤不符合其他条件的物品
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != findItemID:
 | 
 |  |  | 
 |  |  |     for i in range(itemPack.GetCount()):
 | 
 |  |  |         curItem = itemPack.GetAt(i)
 | 
 |  |  |         #过滤不符合其他条件的物品
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != findItemID:
 | 
 |  |  | 
 |  |  |     for i in range(itemPack.GetCount()):
 | 
 |  |  |         curItem = itemPack.GetAt(i)
 | 
 |  |  |         #过滤不符合其他条件的物品
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != findItemID:
 | 
 |  |  | 
 |  |  |     curPack = curPlayer.GetItemManager().GetPack(packType)
 | 
 |  |  |     for i in range(0, curPack.GetCount()):
 | 
 |  |  |         curItem = curPack.GetAt(i)
 | 
 |  |  |         if not curItem:
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         if curItem.GetItemTypeID() != itemID:
 | 
 |  |  | 
 |  |  |     for i in xrange(itemPack.GetCount()):
 | 
 |  |  |         curItem = itemPack.GetAt(i)
 | 
 |  |  |         #过滤不符合其他条件的物品
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         curItemID = curItem.GetItemTypeID()
 | 
 |  |  |         if curItemID not in costItemDict:
 | 
 |  |  | 
 |  |  |     for index in range(0, itemPack.GetCount()):
 | 
 |  |  |         item = itemPack.GetAt(index)
 | 
 |  |  |         
 | 
 |  |  |         if not CheckItemCanUse(item):
 | 
 |  |  |         if not CheckItemCanUse(item) or ItemControler.GetIsAuctionItem(item):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         itemTypeID = item.GetItemTypeID()
 | 
 |  |  | 
 |  |  | #  @remarks 函数详细说明.
 | 
 |  |  | def DoLogic_ItemBindType(curPlayer, curItem, bindType):
 | 
 |  |  |     #固定不绑定
 | 
 |  |  |     if bindType == ChConfig.Def_BindType_NoBind:
 | 
 |  |  |         return
 | 
 |  |  |      | 
 |  |  |     #不处理已经绑定的物品
 | 
 |  |  |     if curItem.GetIsBind():
 | 
 |  |  |         return
 | 
 |  |  |     #不是这个功能的绑定类型
 | 
 |  |  |     if curItem.GetBindType() != bindType:
 | 
 |  |  |         return
 | 
 |  |  |     if curItem.GetBindType() == ChConfig.Def_BindType_DoEquipBind:
 | 
 |  |  |         pass
 | 
 |  |  |                  | 
 |  |  |     ItemControler.SetItemIsBind(curItem, True)
 | 
 |  |  |     #拍品去除绑定逻辑,暂屏蔽
 | 
 |  |  | #    if bindType == ChConfig.Def_BindType_NoBind:
 | 
 |  |  | #        return
 | 
 |  |  | #     | 
 |  |  | #    #不处理已经绑定的物品
 | 
 |  |  | #    if curItem.GetIsBind():
 | 
 |  |  | #        return
 | 
 |  |  | #    #不是这个功能的绑定类型
 | 
 |  |  | #    if curItem.GetBindType() != bindType:
 | 
 |  |  | #        return
 | 
 |  |  | #    if curItem.GetBindType() == ChConfig.Def_BindType_DoEquipBind:
 | 
 |  |  | #        pass
 | 
 |  |  | #                 | 
 |  |  | #    ItemControler.SetItemIsBind(curItem, True)
 | 
 |  |  |     return True
 | 
 |  |  | 
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 |  |  | 
 |  |  |     ## 返回是否诛仙装备
 | 
 |  |  |     return curItem.GetType() in ChConfig.Def_ZhuXianEquiipType
 | 
 |  |  | 
 | 
 |  |  | ## 返回是否武器
 | 
 |  |  | #  @param curItem 当前物品
 | 
 |  |  | #  @return None
 | 
 |  |  | #  @remarks 函数详细说明.
 | 
 |  |  | def GetIsWeapon(curItem):
 | 
 |  |  |     return curItem.GetType() in ChConfig.Def_WeaponItemType
 | 
 |  |  | 
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 |  |  | ##遍历数据库查找合适的物品, 通过 效果ID + 效果A值确定物品
 | 
 |  |  | # @param itemType 物品类型
 | 
 |  |  | 
 |  |  |         curItem = curItemPack.GetAt(i)
 | 
 |  |  |         
 | 
 |  |  |         #检查物品
 | 
 |  |  |         if not CheckItemCanUse(curItem):
 | 
 |  |  |         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):
 | 
 |  |  |             continue
 | 
 |  |  |         
 | 
 |  |  |         effect = curItem.GetEffectByIndex(0)
 | 
 |  |  | 
 |  |  | #  @param itemType: 物品类型
 | 
 |  |  | #  @return 最大星级,0为不可强化
 | 
 |  |  | def GetItemMaxPlusLV(curPlayer, equipPackindex, curItem):
 | 
 |  |  |     equipPlace = curItem.GetEquipPlace()
 | 
 |  |  |     plusMaxTypeDict = IpyGameDataPY.GetFuncEvalCfg("StrengthenLevelLimit", 1)
 | 
 |  |  |     if not plusMaxTypeDict:
 | 
 |  |  |         GameWorld.ErrLog("GetItemMaxPlusLV没有强化类型映射表")
 | 
 |  |  |     findType = ChEquip.GetEquipPlusType(curItem)
 | 
 |  |  |     if not findType:
 | 
 |  |  |         return 0
 | 
 |  |  |      | 
 |  |  |     if equipPlace not in plusMaxTypeDict:
 | 
 |  |  |         return 0
 | 
 |  |  |     findType = plusMaxTypeDict[equipPlace]
 | 
 |  |  |     equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, equipPackindex, curItem)
 | 
 |  |  |     ipyData = IpyGameDataPY.GetIpyGameDataNotLog("ItemPlusMax", findType, equipStar)
 | 
 |  |  |     if ipyData:
 | 
 |  |  |         return ipyData.GetLevelMax()
 | 
 |  |  |      | 
 |  |  |     ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('ItemPlusMax', {'Type':findType}, True, False)
 | 
 |  |  |     if not ipyDataList:
 | 
 |  |  |     ipyData = IpyGameDataPY.InterpolationSearch('ItemPlusMax', 'Star', equipStar, {'Type':findType})
 | 
 |  |  |     if not ipyData:
 | 
 |  |  |         return 0
 | 
 |  |  |     maxStar = ipyDataList[-1].GetStar()
 | 
 |  |  |     if equipStar > maxStar:
 | 
 |  |  |         return ipyDataList[-1].GetLevelMax()
 | 
 |  |  |     findMax = 0
 | 
 |  |  |     for ipyData in ipyDataList:
 | 
 |  |  |         if equipStar >= ipyData.GetStar():
 | 
 |  |  |             findMax = ipyData.GetLevelMax()
 | 
 |  |  |     return findMax
 | 
 |  |  |     return ipyData.GetLevelMax()
 | 
 |  |  |     
 | 
 |  |  | 
 | 
 |  |  | ## 获取物品最高强化进化等级
 | 
 |  |  | 
 |  |  |     packType = IPY_GameWorld.rptEquip
 | 
 |  |  |     curPlusLV = ChEquip.GetEquipPartPlusLVByRank(curPlayer, packType, equipPackindex, curItem)
 | 
 |  |  |     equipPlace = curItem.GetEquipPlace()
 | 
 |  |  |     ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlusEvolve', {'EquipPlace':equipPlace}, True)
 | 
 |  |  |     if not ipyDataList:
 | 
 |  |  |     ipyData = IpyGameDataPY.InterpolationSearch('EquipPlusEvolve', 'NeedPlusLV', curPlusLV, {'EquipPlace':equipPlace})
 | 
 |  |  |     if not ipyData:
 | 
 |  |  |         return 0
 | 
 |  |  |     maxEvolvelv = 0
 | 
 |  |  |     for ipyData in ipyDataList:
 | 
 |  |  |         if curPlusLV >= ipyData.GetNeedPlusLV():
 | 
 |  |  |             maxEvolvelv = ipyData.GetEvolveLV()
 | 
 |  |  |         else:
 | 
 |  |  |             break
 | 
 |  |  |     return maxEvolvelv
 | 
 |  |  |     return ipyData.GetEvolveLV()
 | 
 |  |  |      | 
 |  |  | 
 | 
 |  |  | ## 获取物品最高星数
 | 
 |  |  | #  @param itemType: 物品类型
 | 
 |  |  | 
 |  |  |     if not curItem or curItem.IsEmpty():
 | 
 |  |  |         return {}
 | 
 |  |  |     
 | 
 |  |  |     isAuctionItem = ItemControler.GetIsAuctionItem(curItem)
 | 
 |  |  |     if not CheckItemIsEquip(curItem):
 | 
 |  |  |         return [curItem.GetItemTypeID(), curItem.GetCount(), curItem.GetIsBind()]
 | 
 |  |  |         return [curItem.GetItemTypeID(), curItem.GetCount(), isAuctionItem]
 | 
 |  |  |     
 | 
 |  |  |     addItemDict = {}
 | 
 |  |  |     addItemDict['ItemID'] = curItem.GetItemTypeID()
 | 
 |  |  |     addItemDict['Count'] = curItem.GetCount()
 | 
 |  |  |     addItemDict['IsBind'] = int(curItem.GetIsBind())
 | 
 |  |  |     addItemDict['IsAuctionItem'] = isAuctionItem
 | 
 |  |  |     #addItemDict['IsBind'] = int(curItem.GetIsBind())
 | 
 |  |  |     #addItemDict['EquipGS'] = GetEquipGearScore(curItem)
 | 
 |  |  |     #addItemDict['ItemStarLV'] = curItem.GetItemStarLV()
 | 
 |  |  |     #addItemDict['CurDurg'] = GameWorld.GetIntUpper(curItem.GetCurDurg(), ChConfig.Def_EndureRepairParameter)
 | 
 |  |  | 
 |  |  |     #addItemDict['EquipMaxAtkValue'] = curItem.GetEquipMaxAtkValue()
 | 
 |  |  |     #addItemDict['FitLV'] = curItem.GetFitLV()
 | 
 |  |  |     #addItemDict['Proficiency'] = curItem.GetProficiency()
 | 
 |  |  |     addItemDict['IsSuite'] = int(curItem.GetIsSuite())
 | 
 |  |  |     #addItemDict['IsSuite'] = int(curItem.GetIsSuite())
 | 
 |  |  |     #addItemDict['BaseHP'] = curItem.GetBaseHP()
 | 
 |  |  |     #addItemDict['BaseMagicDef'] = curItem.GetBaseMagicDef()
 | 
 |  |  |     #addItemDict['MaxAddSkillCnt'] = curItem.GetMaxAddSkillCnt()
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  | def GetJsonItem(itemInfo):
 | 
 |  |  |     '''获取物品信息对应的json信息
 | 
 |  |  |     @param itemInfo: 支持列表 [itemID, itemCount, isBind], 支持动态列表长度,索引代表属性固定
 | 
 |  |  |     @param itemInfo: 支持列表 [itemID, itemCount, isAuctionItem], 支持动态列表长度,索引代表属性固定
 | 
 |  |  |                         支持物品实例, 如果是示例时必须在给玩家之前先获取出来,防止给玩家后该物品实例被清空
 | 
 |  |  |                         
 | 
 |  |  |     @return: {"ItemID":101, "Count":10, "IsBind":1, "IsSuite":1, "UserData":"自定义属性字符串"}
 | 
 |  |  |     @return: {"ItemID":101, "Count":10, "IsAuctionItem":1, "UserData":"自定义属性字符串"}
 | 
 |  |  |     '''
 | 
 |  |  |     itemDict = {}
 | 
 |  |  |     if isinstance(itemInfo, list) or isinstance(itemInfo, tuple):
 | 
 |  |  | 
 |  |  |         if infolen > 1 and itemInfo[1] > 1:
 | 
 |  |  |             itemDict["Count"] = itemInfo[1]
 | 
 |  |  |         if infolen > 2 and itemInfo[2]:
 | 
 |  |  |             itemDict["IsBind"] = int(itemInfo[2])
 | 
 |  |  |             itemDict["IsAuctionItem"] = int(itemInfo[2])
 | 
 |  |  |     elif isinstance(itemInfo, int):
 | 
 |  |  |         itemDict["ItemID"] = itemInfo
 | 
 |  |  |     else: #物品实例
 | 
 |  |  | 
 |  |  |         itemDict["ItemID"] = itemInfo.GetItemTypeID()
 | 
 |  |  |         if itemInfo.GetCount() > 1:
 | 
 |  |  |             itemDict["Count"] = itemInfo.GetCount()
 | 
 |  |  |         if itemInfo.GetIsBind():
 | 
 |  |  |             itemDict["IsBind"] = int(itemInfo.GetIsBind())
 | 
 |  |  |         if itemInfo.GetIsSuite():
 | 
 |  |  |             itemDict["IsSuite"] = int(itemInfo.GetIsSuite())
 | 
 |  |  |         if ItemControler.GetIsAuctionItem(itemInfo):
 | 
 |  |  |             itemDict["IsAuctionItem"] = 1
 | 
 |  |  |         if itemInfo.GetUserData():
 | 
 |  |  |             itemDict["UserData"] = itemInfo.GetUserData()
 | 
 |  |  |     return itemDict
 | 
 |  |  | 
 | 
 |  |  | ## 将物品列表重复物品堆叠起来返回整理后的列表
 | 
 |  |  | #  @param itemlist
 | 
 |  |  | #  @return 整理后的物品列表
 | 
 |  |  | def GetSimpleItemList(itemlist):
 | 
 |  |  |     sItemList = []
 | 
 |  |  |     sItemDict = {}
 | 
 |  |  |     for item in itemlist:
 | 
 |  |  |         maxPackCount = item.GetPackCount()
 | 
 |  |  |         if maxPackCount == 0:
 | 
 |  |  |             return itemlist
 | 
 |  |  |         itemCnt = item.GetCount()
 | 
 |  |  |         if itemCnt > maxPackCount:
 | 
 |  |  |             return itemlist
 | 
 |  |  |         itemid = item.GetItemTypeID()
 | 
 |  |  |         isBind = item.GetIsBind()
 | 
 |  |  |         key = (itemid,isBind)
 | 
 |  |  |         if key in sItemDict:
 | 
 |  |  |             for sitem in sItemDict[key]:
 | 
 |  |  |                 if sitem.GetCount() >= maxPackCount:
 | 
 |  |  |                     continue
 | 
 |  |  |                 totalCnt = item.GetCount()+ sitem.GetCount()
 | 
 |  |  |                  | 
 |  |  |                 if totalCnt > maxPackCount:
 | 
 |  |  |                     ItemControler.SetItemCount(sitem, maxPackCount)
 | 
 |  |  |                     ItemControler.SetItemCount(item, totalCnt - maxPackCount)
 | 
 |  |  |                     sItemList.append(item)
 | 
 |  |  |                     sItemDict[key].append(item)
 | 
 |  |  |                     break
 | 
 |  |  |                 ItemControler.SetItemCount(sitem, totalCnt)
 | 
 |  |  |                 item.Clear()
 | 
 |  |  |         else:
 | 
 |  |  |             sItemList.append(item)
 | 
 |  |  |             sItemDict[key] = [item]
 | 
 |  |  |              | 
 |  |  |      | 
 |  |  |     return sItemList
 | 
 |  |  | 
 | 
 |  |  | ## =======================================================================================
 | 
 |  |  | ##根据活动类型配置随机装备品质
 | 
 |  |  | # @param itemType  | 
 |  |  | # @return 品质
 | 
 |  |  | def GetRandEquipQualityByTable(itemType, tableName):
 | 
 |  |  |     qualityRandDict = ReadChConfig.GetEvalChConfig(tableName)
 | 
 |  |  |     qualityRandList = qualityRandDict.get(itemType, [])
 | 
 |  |  |     if qualityRandList == []:
 | 
 |  |  |         qualityRandList = qualityRandDict[-1]
 | 
 |  |  |          | 
 |  |  |     return GameWorld.GetResultByRandomList(qualityRandList, 0)
 | 
 |  |  | 
 | 
 |  |  | ## 随机卓越装备,根据规则从数据库中筛选出,等级职业
 | 
 |  |  | #  @param equipType 装备类型
 | 
 |  |  | #  @return 抽奖是否成功  | 
 |  |  | def RandGreateEquip(curPlayer, equipType, isBind, tableName, quality=1):
 | 
 |  |  |     equipList = GameDataControl.GetItemDataListByType(equipType)
 | 
 |  |  |     equipLVRandList, lvFormulaStr, lvRange, jobRand, luckyShotRand, greateNumRand, \
 | 
 |  |  |     broadcastList, plusRand, addAttrRand = ReadChConfig.GetEvalChConfig(tableName)
 | 
 |  |  |      | 
 |  |  |     playerLV = curPlayer.GetLV()
 | 
 |  |  |     step = GameWorld.GetResultByRandomList(equipLVRandList, 0)
 | 
 |  |  |     getLVMin = eval(lvFormulaStr)
 | 
 |  |  |     getLVMax = getLVMin + lvRange
 | 
 |  |  |     checkJob = GameWorld.CanHappen(jobRand)
 | 
 |  |  |      | 
 |  |  |     randList = []
 | 
 |  |  |     findItem = None
 | 
 |  |  |      | 
 |  |  |     for item in equipList:
 | 
 |  |  |         if item.GetUseLV() < getLVMin or item.GetUseLV() > getLVMax:
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         if item.GetItemQuality() != quality:
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         if checkJob:
 | 
 |  |  |             if JobUseable(curPlayer, item):
 | 
 |  |  |                 findItem = item
 | 
 |  |  |                 break
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         randList.append(item)
 | 
 |  |  |      | 
 |  |  |     if randList:
 | 
 |  |  |         findItem = random.choice(randList)
 | 
 |  |  |      | 
 |  |  |     if findItem == None:
 | 
 |  |  |         return None, False
 | 
 |  |  |      | 
 |  |  |     return CreateGreateItem(findItem, luckyShotRand, greateNumRand, broadcastList,
 | 
 |  |  |                      plusRand, addAttrRand, isBind)
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | ## 生成抽奖的卓越装备
 | 
 |  |  | #  @param 各属性
 | 
 |  |  | #  @return 生成的物品,是否广播  | 
 |  |  | def CreateGreateItem(findItem, luckyShotRand, greateNumRand, broadcastList,
 | 
 |  |  |                      plusRand, addAttrRand, isBind):
 | 
 |  |  |     itemID = findItem.GetItemTypeID()
 | 
 |  |  |     equipItem = CreateSingleItem(itemID)
 | 
 |  |  |      | 
 |  |  |     tmpEquipData = ItemControler.SingleEquipTmpData()
 | 
 |  |  |      | 
 |  |  |     tmpEquipData.starLV = random.randint(plusRand[0], plusRand[1])
 | 
 |  |  |     tmpEquipData.holeCnt = 3
 | 
 |  |  |     tmpEquipData.isBind = isBind
 | 
 |  |  |     tmpEquipData.isSuite = 0
 | 
 |  |  |      | 
 |  |  |     # 装备附加属性
 | 
 |  |  |     ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)
 | 
 |  |  |      | 
 |  |  |     broadcast = False
 | 
 |  |  |          | 
 |  |  |     return equipItem, broadcast
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | ## 随机普通装备,根据规则从数据库中筛选出,等级职业
 | 
 |  |  | #  @param equipType 装备类型
 | 
 |  |  | #  @return 抽奖是否成功  | 
 |  |  | def RandNormalEquip(curPlayer, equipType, isBind, tableName):
 | 
 |  |  |     equipList = GameDataControl.GetItemDataListByType(equipType)
 | 
 |  |  |     equipLVRandList, lvFormulaStr, lvRange, jobRand, luckyShotRand, \
 | 
 |  |  |     plusRand, addAttrRand, skillRand = ReadChConfig.GetEvalChConfig(tableName)
 | 
 |  |  |      | 
 |  |  |     playerLV = curPlayer.GetLV()
 | 
 |  |  |     step = GameWorld.GetResultByRandomList(equipLVRandList, 0)
 | 
 |  |  |     getLVMin = eval(lvFormulaStr)
 | 
 |  |  |     getLVMax = getLVMin + lvRange
 | 
 |  |  |     checkJob = GameWorld.CanHappen(jobRand)
 | 
 |  |  |      | 
 |  |  |     randList = []
 | 
 |  |  |     findItem = None
 | 
 |  |  |      | 
 |  |  |     for item in equipList:
 | 
 |  |  |         if item.GetUseLV() < getLVMin or item.GetUseLV() > getLVMax:
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         if item.GetItemQuality() != 0:
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         if checkJob:
 | 
 |  |  |             if JobUseable(curPlayer, item):
 | 
 |  |  |                 findItem = item
 | 
 |  |  |                 break
 | 
 |  |  |             continue
 | 
 |  |  |          | 
 |  |  |         randList.append(item)
 | 
 |  |  |      | 
 |  |  |     if randList:
 | 
 |  |  |         findItem = random.choice(randList)
 | 
 |  |  |      | 
 |  |  |     if findItem == None:
 | 
 |  |  |         return None
 | 
 |  |  |      | 
 |  |  |     return CreateNormalItem(findItem, luckyShotRand, plusRand, addAttrRand, isBind, skillRand)
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | ## 生成抽奖的卓越装备
 | 
 |  |  | #  @param 各属性
 | 
 |  |  | #  @return 生成的物品
 | 
 |  |  | def CreateNormalItem(findItem, luckyShotRand, plusRand, addAttrRand, isBind, skillRand):
 | 
 |  |  |     itemID = findItem.GetItemTypeID()
 | 
 |  |  |     equipItem = CreateSingleItem(itemID)
 | 
 |  |  |      | 
 |  |  |     tmpEquipData = ItemControler.SingleEquipTmpData()
 | 
 |  |  |      | 
 |  |  |     tmpEquipData.starLV = random.randint(plusRand[0], plusRand[1])
 | 
 |  |  |     tmpEquipData.holeCnt = 3
 | 
 |  |  |     tmpEquipData.isBind = isBind
 | 
 |  |  |     tmpEquipData.isSuite = 0
 | 
 |  |  |      | 
 |  |  |     # 装备附加属性
 | 
 |  |  |     ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)
 | 
 |  |  |      | 
 |  |  |     return equipItem
 | 
 |  |  | 
 | 
 |  |  | ## =======================================================================================
 | 
 |  |  | 
 |