| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package ItemCommon  | 
| # ÎïÆ·Í¨Óà  | 
| #  | 
| # @author alee  | 
| # @date 2017-07-28 14:00  | 
| # @version 1.0  | 
| #  | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
|   | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-07-28 14:00"""  | 
| #---------------------------------------------------------------------  | 
| #ÎïÆ·¹ÜÀíÆ÷  | 
| import GameWorld  | 
| import BuffSkill  | 
| import PlayerControl  | 
| import SkillCommon  | 
| import IPY_GameWorld  | 
| import ChConfig  | 
| import ReadChConfig  | 
| import ShareDefine  | 
| import GameDataControl  | 
| import ItemControler  | 
| import DataRecordPack  | 
| import EventReport  | 
| import ChItem  | 
| import IpyGameDataPY  | 
| import Operate_EquipStone  | 
| import PlayerViewCacheTube  | 
| import Operate_EquipWash  | 
| import FormulaControl  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import PyGameData  | 
| import ChEquip  | 
| import SkillShell  | 
| import random  | 
| import math  | 
| import time  | 
| import json  | 
|   | 
| #---------------------------------------------------------------------  | 
|   | 
| #ʹÓòÄÁÏģʽ ¶¼ÓàֻÓв»°ó¶¨ Ö»ÓÃ°ó¶¨  | 
| [  | 
| UseStuffMode_All, # ¿ÉÒÔʹÓÃÈ«²¿²ÄÁÏ  | 
| UseStuffMode_NoBind, # Ö»Ê¹Ó÷ǰ󶨵IJÄÁÏ  | 
| UseStuffMode_Bind, # Ö»Ê¹Óð󶨵IJÄÁÏ  | 
| ] = range(0 , 2 + 1)  | 
|   | 
| #---------------------------------------------------------------------  | 
| def InitPyItem():  | 
|     if PyGameData.InitPyItem:  | 
|         return  | 
|     GameWorld.Log("¼ÓÔØÎïÆ·Êý¾Ý...")  | 
|       | 
|     PyGameData.DailyUseCountLimitItemIDList = []  | 
|       | 
|     gameData = GameWorld.GetGameData()  | 
|     for i in range(0, gameData.GetItemCount()):  | 
|         findItemData = gameData.GetItemAt(i)  | 
|         if GetCanUseCountDaily(findItemData):  | 
|             PyGameData.DailyUseCountLimitItemIDList.append(findItemData.GetItemTypeID())  | 
|     if PyGameData.DailyUseCountLimitItemIDList:  | 
|         GameWorld.Log("ÿÈÕÓÐʹÓôÎÊýÏÞÖÆµÄÎïÆ·IDÁбí: %s" % PyGameData.DailyUseCountLimitItemIDList)  | 
|           | 
|     PyGameData.InitPyItem = True  | 
|     return  | 
|   | 
| ## ÎïÆ·´¥·¢¼¼ÄÜÔö¼Óbuff  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem ÎïÆ·  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @param needResult ÊÇ·ñÐèҪˢÐÂÊôÐÔ  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks ÎïÆ·´¥·¢¼¼ÄÜÔö¼Óbuff  | 
| def ItemUseSkillAddBuff(curPlayer, curItem, tick, needResult=True, useCnt=1):  | 
|     addSkillList = __GetAddSkillList(curPlayer, curItem)  | 
|       | 
|     #ÎÞ¸½¼Ó¼¼ÄÜ  | 
|     if not addSkillList:  | 
|         return False  | 
|       | 
|     refreshResult = False  | 
|     #buffTypeList = []  | 
|       | 
|     for _ in xrange(useCnt):  | 
|         for addSkill in addSkillList:  | 
|             buffType = SkillCommon.GetBuffType(addSkill)  | 
|             #@warning: ÎïÆ·´¥·¢¼¼ÄÜ, Buff×ÜֵΪµÚ1¸öЧ¹ûµÄAÖµ  | 
|             addBuffValueList = SkillShell.GetAddBuffValue(curPlayer, addSkill, curPlayer)  | 
|             if BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, addSkill, tick, addBuffValueList, curPlayer):  | 
|                 refreshResult = True  | 
|   | 
|       | 
|     #---´¥·¢×°±¸¼¼Äܳɹ¦---  | 
|     if needResult and refreshResult:  | 
|         playerControl = PlayerControl.PlayerControl(curPlayer)  | 
|         playerControl.RefreshPlayerAttrByBuff()  | 
|           | 
|     return True  | 
|   | 
| ## »ñÈ¡ÎïÆ·ËùÓµÓеļ¼ÄÜ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem Ê¹ÓÃÎïÆ·  | 
| #  @return addSkillList ¼¼ÄÜÁÐ±í  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __GetAddSkillList(curPlayer , curItem):  | 
|     addSkillList = []  | 
|     gameData = GameWorld.GetGameData()  | 
|     curItemID = curItem.GetItemTypeID()  | 
|       | 
|     for i in range(0, curItem.GetAddSkillCount()):  | 
|         curSkillID = curItem.GetAddSkill(i)  | 
|           | 
|         if not curSkillID:  | 
|             continue  | 
|           | 
|         curSkill = gameData.GetSkillBySkillID(curSkillID)  | 
|           | 
|         if not curSkill:  | 
|             GameWorld.Log('###²ß»®Ìî±íÒì³££¬ÎïÆ· = %s´¥·¢¼¼ÄÜʧ°Ü = %s' % (curItemID , curSkillID))  | 
|             return []  | 
|           | 
|         buffType = SkillCommon.GetBuffType(curSkill)  | 
|           | 
|         #¼ì²éÊÇ·ñ¿ÉÒÔÌí¼ÓÕâ¸öbuff  | 
|         if not SkillCommon.CheckCanAddBuff(curPlayer , buffType , curSkill.GetSkillTypeID(), curSkill.GetSkillLV()):  | 
|             PlayerControl.NotifyCode(curPlayer, 'XW_ZZ_ResInvalidation')  | 
|             return []  | 
|           | 
|         addSkillList.append(curSkill)  | 
|           | 
|     return addSkillList  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ÎïÆ·xml²ÎÊý  | 
| #  @param curItem ÎïÆ·  | 
| #  @return None  | 
| def GetItemXMLMsg(curItem):  | 
|     itemTypeID = curItem.GetItemTypeID()  | 
|     # s0-s2  | 
|     msgList = ['%s' % itemTypeID, '0' , '0' ]  | 
|       | 
| #===============================================================================  | 
| #    stoneCntMax = ChConfig.Def_EquipMaxHole  # ×î¶à¿×Êý  | 
| #    stoneIDList = []  # ¿×Éϵı¦Ê¯IDÁÐ±í  | 
| #    for i in range(stoneCntMax):  | 
| #          | 
| #        if i >= canPlaceStoneCount:  | 
| #            stoneIDList.append('0')  | 
| #            continue  | 
| #          | 
| #        stoneIDList.append('%s' % curItem.GetStone(i))  | 
| #      | 
| #    #s3-s11 stoneID  | 
| #    msgList.extend(stoneIDList)    | 
| #         | 
| #    curDurg = GameWorld.GetIntUpper(curItem.GetCurDurg(), ChConfig.Def_EndureRepairParameter)  | 
| #    curMaxDurg = GameWorld.GetIntUpper(curItem.GetMaxEndure(), ChConfig.Def_EndureRepairParameter)  | 
| #    curItemMakerName = curItem.GetMakerName()  | 
| # #    #ÎÞÃû×Ö,·¢¿Õ×Ö·û  | 
| # #    if not curItem.GetMaker():  | 
| # #        curItemMakerName = ' '  | 
| #          | 
| #    addSkillCnt = curItem.GetUserAttr(IPY_GameWorld.iudetEquipAddSkillCnt)   | 
| #      | 
| #    #s12 -> ÎåÐÐ,s13 -> Áé»ê¼¼ÄÜID,s14 -> µ±Ç°Ä;Ã,s15 -> ×î´óÄ;Ã,s16 -> °ó¶¨,s17 -> MakeID,s18 ->   | 
| #    msgList.extend(['%s' % curItem.GetItemProperty(),  | 
| #                    '%s' % curItem.GetSoulProperty(),  | 
| #                    '%s' % curDurg, '%s' % curMaxDurg,  | 
| #                    '%s' % curItem.GetIsBind(),  | 
| #                    '%s' % curItemMakerName,  | 
| #                    '%s' % addSkillCnt])  | 
| #      | 
| #    skillCntMax = ChConfig.Def_EquipSkillCntMax  # ¸½¼ÓÊôÐÔ¼¼ÄÜ×î¶à  | 
| #    addSkillList = []  # ¸Ã×°±¸µ±Ç°µÄÁéÎÆÊôÐÔÁÐ±í  | 
| #      | 
| #    for j in range(skillCntMax):  | 
| #        if j >= curItem.GetUserAttrCount(IPY_GameWorld.iudetEquipAddSkillList):  | 
| #            addSkillList.append('0')  | 
| #            continue  | 
| #          | 
| #        skillID = curItem.GetUserAttrByIndex(IPY_GameWorld.iudetEquipAddSkillList, j)  | 
| #        addSkillList.append('%s' % skillID)  | 
| #      | 
| #    #s19-s38 skillID  | 
| #    msgList.extend(addSkillList)  | 
| #      | 
| #    #s39 -> ¿ª¹â,s40 -> ×°±¸ÆõºÏµÈ¼¶,s42 -> ×°±¸ÊìÁ·¶È,s42 -> ÊÇ·ñÌ××°»¯,s43 -> ×îСÉ˺¦,  | 
| #    #s44 -> ×î´óÉ˺¦, s45 -> ÁéÎÆ´ÎÊýÉÏÏÞ, s46 -> ×°±¸·ÀÓùÖµ, s47 -> Ê£Óàʱ¼ä, s48 -> hp»ù´¡Öµ,  | 
| #    #s49 -> ÄÚ·À»ù´¡Öµ, s50 -> ÊÇ·ñ»½ÐÑ s51 -> itemTypeID  | 
| #    msgList.extend(['%s' % curItem.GetUserAttr(IPY_GameWorld.iudetEquipElem), # ¿ª¹â  | 
| #                    '%s' % curItem.GetFitLV(), # ×°±¸ÆõºÏµÈ¼¶  | 
| #                    '%s' % curItem.GetProficiency(), # ×°±¸ÊìÁ·¶È  | 
| #                    '%s' % int(curItem.GetIsSuite()), # ÊÇ·ñÌ××°»¯  | 
| #                    '%s' % curItem.GetEquipMinAtkValue(), # ×îСÉ˺¦  | 
| #                    '%s' % curItem.GetEquipMaxAtkValue(), # ×î´óÉ˺¦  | 
| #                    '%s' % curItem.GetRelMaxAddSkillCnt(), # ÁéÎÆ´ÎÊýÉÏÏÞ  | 
| #                    '%s' % curItem.GetEquipDefenseValue(), # ×°±¸·ÀÓùÖµ  | 
| #                    '%s' % curItem.GetRemainHour(), # Ê£Óàʱ¼ä  | 
| #                    '%s' % curItem.GetBaseHP(), # hp»ù´¡Öµ  | 
| #                    '%s' % curItem.GetBaseMagicDef(), # ÄÚ·À»ù´¡Öµ  | 
| #                    '%s' % curItem.GetUserAttr(IPY_GameWorld.iudetWakeUpCnt), # ÊÇ·ñ»½ÐÑ  | 
| #                    '%s' % itemTypeID])  | 
| #===============================================================================  | 
|       | 
|     return msgList  | 
|   | 
|   | 
| ## Çå³ý°´Ìì¹ýÆÚÎïÆ·  | 
| #  @param curPlayer Íæ¼Ò  | 
| #  @return None  | 
| def ClearDayTimeItem(curPlayer):  | 
|     serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)  | 
|     itemManager = curPlayer.GetItemManager()  | 
|     #±éÀú¿ÉÄÜ´æÔڵı³°ü, Ö´ÐÐÂß¼  | 
|     for packIndex in ChConfig.Def_RealityTimeItem_Pack:  | 
|         curPack = itemManager.GetPack(packIndex)  | 
|         for i in range(0, curPack.GetCount()):  | 
|             curItem = curPack.GetAt(i)  | 
|               | 
|             #Òì³£ÎïÆ·  | 
|             if not CheckItemCanUse(curItem):  | 
|                 continue  | 
|   | 
|             reduceType = curItem.GetEndureReduceType()  | 
|             if reduceType not in [ChConfig.Def_EquipReduceType_Day, ChConfig.Def_EquipReduceType_ServerDay]:  | 
|                 continue  | 
|               | 
|             if reduceType == ChConfig.Def_EquipReduceType_Day:  | 
|                 if curItem.GetRemainHour() > 1:  | 
|                     curItem.SetRemainHour(curItem.GetRemainHour() - 1) # Ã¿Ìì-1  | 
|                     continue  | 
|             elif reduceType == ChConfig.Def_EquipReduceType_ServerDay:  | 
|                 if serverDay < curItem.GetExpireTime():  | 
|                     continue  | 
|                   | 
|             #curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr())  | 
|             #if curTime < curItem.GetRemainHour():  | 
|             #    continue  | 
|               | 
|             curItemID = curItem.GetItemTypeID()  | 
|             if packIndex != IPY_GameWorld.rptRecycle: #»Ø¹ºµÄ²»Ìáʾ  | 
|                 PlayerControl.NotifyCode(curPlayer, "PK_hwj35_82012", [curItemID])  | 
|           | 
|             dataDict = {"ItemID":curItemID,   | 
|                         "CreateTime":curItem.GetCreateTime(),   | 
|                         "IsBind":curItem.GetIsBind(),  | 
|                         "ItemGUID":curItem.GetGUID()}  | 
|             DataRecordPack.DR_DeleteItem(curPlayer, "Time", dataDict)  | 
|               | 
|             #ÎïÆ·Ïûʧ  | 
|             #curItem.Clear()  | 
|       | 
|     return  | 
|   | 
|   | 
| ## »ñµÃÖ¸¶¨ÌìµÄ¹ýÆÚʱ¼ä  | 
| #  @param days ¼¸Ììºó¹ýÆÚ ´Ó1¿ªÊ¼£¬´ú±íµ±Ìì  | 
| #  @return ¹ýÆÚʱ¼äÊý×Ö  | 
| def __GetEndDayTimeNum(days):  | 
|     timeStr = str(GameWorld.GetDatetimeByDiffDays(days - 1)).split(" ")[0] + " 23:59:59"  | 
|     GameWorld.DebugLog("ÎïÆ·¹ýÆÚʱ¼ä" + timeStr)  | 
|     return GameWorld.ChangeTimeStrToNum(timeStr)  | 
|   | 
| 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  | 
|     curSingleItem = GameWorld.GetItemFactory().CreateItem(itemID)  | 
|     if not curSingleItem:  | 
|         return  | 
|       | 
|     #Èç¹ûÊÇÕæÊµÎïÆ·, ²»Í¨¹ýSetRemainHour֪ͨʣÓàʱ¼ä£¬¿Í»§¶Ë×Ô¼º¼ÆË㣬·þÎñ¶Ë·À·¶Ê¹Óà  | 
|     # ´´½¨ºó¿ªÊ¼¼ÆÊ±  | 
|     if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_RTimeItem:  | 
|         #curSingleItem.SetRemainHour(curSingleItem.GetExpireTime())  | 
|         # Í¨Öª¿Í»§¶ËʱЧÎïÆ·µÄ´´½¨Ê±¼ä  | 
|         curSingleItem.SetUserAttr(ShareDefine.Def_IudetCreateTime, int(time.time()))  | 
|       | 
|     # ×°±¸ºó¿ªÊ¼¼ÆÊ±  | 
|     if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_Time:  | 
|         # Í¨Öª¿Í»§¶ËʱЧÎïÆ·µÄ´´½¨Ê±¼ä  | 
|         curSingleItem.SetUserAttr(ShareDefine.Def_IudetCreateTime, 0)  | 
|           | 
|     # ÏÞ¶¨Ê±¼ä¹ýÌìÏûʧµÄÎïÆ·£¬Èç1´ú±íµ±ÌìÏûʧ,onday ´¦Àí  | 
|     if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_Day:  | 
|         # SetRemainHour´Ë´¦ÓÃÓڼǼ¹ýÆÚµÄ¾ßÌåʱ¼äÈç 2014-10-10 23:59:59  | 
|         #timess = __GetEndDayTimeNum(curSingleItem.GetExpireTime())  | 
|         curSingleItem.SetRemainHour(curSingleItem.GetExpireTime())  | 
|       | 
|     if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_ServerDay:  | 
|         outTimeServerDay = curSingleItem.GetExpireTime()  | 
|         serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)  | 
|         if serverDay >= outTimeServerDay:  | 
|             curSingleItem.Clear()  | 
|             GameWorld.ErrLog("ÎïÆ·ÓÐЧÆÚ³¬¹ýÓÐЧµÄ¿ª·þÌì, ²»¿É´´½¨!itemID=%s,serverDay=%s,outTimeServerDay=%s"   | 
|                              % (itemID, serverDay, outTimeServerDay))  | 
|             return  | 
|         curSingleItem.SetRemainHour(outTimeServerDay)  | 
|           | 
|     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:  | 
|         curSingleItem.SetUserAttr(ShareDefine.Def_IudetExpireTime, expireTime)  | 
|           | 
|     #ÕâÀï·µ»ØµÄÊÇ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):  | 
|         GameWorld.DebugLog("²»ÉèÖÃ×°±¸ÆÀ·Ö")  | 
|         return  | 
|     value = CalcEquipGS(curItem)  | 
|     #GameWorld.DebugLog("ÉèÖÃ×°±¸ÆÀ·Ö: ItemID=%s,attrDict=%s,value=%s" % (curItem.GetItemTypeID(), attrDict, value))  | 
|     SetEquipGearScore(curItem, value)  | 
|     return  | 
|   | 
| def CalcEquipGS(curItem):  | 
|     '''¼ÆËã×°±¸ÆÀ·Ö  | 
|         ÆÀ·Ö×é³É£º×°±¸»ù´¡ + ´«ÆæÊôÐÔ + ¾ø°æÊôÐÔ  | 
|     '''  | 
|     if not CheckNoteEquipGS(curItem):  | 
|         #GameWorld.DebugLog("²»ÉèÖÃ×°±¸ÆÀ·Ö")  | 
|         return 0  | 
|       | 
|     attrDict = {}  | 
|     #»ù´¡ÊôÐÔЧ¹û  | 
|     for i in xrange(curItem.GetEffectCount()):  | 
|         curEffect = curItem.GetEffectByIndex(i)  | 
|         if not curEffect:  | 
|             break  | 
|         effectID = curEffect.GetEffectID()  | 
|         if effectID == 0:  | 
|             break  | 
|         attrDict[effectID] = attrDict.get(effectID, 0) + curEffect.GetEffectValue(0)  | 
|           | 
|     skillGS = 0  | 
|     skillGSDict = IpyGameDataPY.GetFuncCfg("EquipGSFormula", 4)  | 
|     for i in xrange(curItem.GetAddSkillCount()):  | 
|         addSkillID = curItem.GetAddSkill(i)  | 
|         if not addSkillID:  | 
|             break  | 
|         skillGS += skillGSDict.get(str(addSkillID), 0)  | 
|           | 
|     classLV = GetItemClassLV(curItem)  | 
|     color = curItem.GetItemColor()  | 
|     isSuit = 1 if curItem.GetSuiteID() > 0 else 0  | 
|     gsParamIpyData = IpyGameDataPY.GetIpyGameData("EquipGSParam", classLV, color, isSuit)  | 
|     # ´«ÆæÊôÐÔ  | 
|     legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)  | 
|     legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)  | 
|     if legendAttrIDCnt and legendAttrIDCnt == legendAttrValueCnt:  | 
|         for i in xrange(legendAttrIDCnt):  | 
|             attrID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i)  | 
|             attrValue = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i)  | 
|             attrDict[attrID] = attrDict.get(attrID, 0) + attrValue  | 
|               | 
|     Atk = attrDict.get(ShareDefine.Def_Effect_Atk, 0)  | 
|     MinAtk = attrDict.get(ShareDefine.Def_Effect_MinAtk, 0) + Atk  | 
|     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 = 0  | 
|     IceAtk = attrDict.get(ShareDefine.Def_Effect_IceAtk, 0)  | 
|     IceDef = attrDict.get(ShareDefine.Def_Effect_IceDef, 0)  | 
|       | 
|     BaseEquipMaxHPAddPer = attrDict.get(ShareDefine.Def_Effect_BaseEquipMaxHPAddPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetBaseEquipMaxHPAddPerC())  | 
|     BaseEquipAtkAddPer = attrDict.get(ShareDefine.Def_Effect_BaseEquipAtkAddPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetBaseEquipAtkAddPerC())  | 
|     AtkPer = 0#attrDict.get(ShareDefine.Def_Effect_AddAtkByPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetAtkPerC())  | 
|     DamagePer = 0#attrDict.get(ShareDefine.Def_Effect_DamagePer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamagePerC())  | 
|     SuperHitRate = 0#attrDict.get(ShareDefine.Def_Effect_SuperHitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitRateC())  | 
|     SuperHit = attrDict.get(ShareDefine.Def_Effect_SuperHit, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitC())  | 
|     SuperHitPer = attrDict.get(ShareDefine.Def_Effect_SuperHitPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitPerC())  | 
|     DamReducePer = 0#attrDict.get(ShareDefine.Def_Effect_DamReducePer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamReducePerC())  | 
|     MaxHPPer = 0#attrDict.get(ShareDefine.Def_Effect_MaxHPPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMaxHPPerC())  | 
|     DefPer = 0#attrDict.get(ShareDefine.Def_Effect_DefPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDefPerC())  | 
|     LuckyHitRate = attrDict.get(ShareDefine.Def_Effect_LuckyHitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetLuckyHitRateC())  | 
|     LuckyHitRateReduce = attrDict.get(ShareDefine.Def_Effect_LuckyHitRateReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetLuckyHitRateReduceC())  | 
|     LuckyHit = attrDict.get(ShareDefine.Def_Effect_LuckyHit, 0)  | 
|     LuckyHitReduce = attrDict.get(ShareDefine.Def_Effect_LuckyHitReduce, 0)  | 
|     LuckPer = attrDict.get(ShareDefine.Def_Effect_LuckPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetLuckPerC())  | 
|     PetDamPer = 0#attrDict.get(ShareDefine.Def_Effect_PetDamPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPetDamPerC())  | 
|     PerLVAtk = attrDict.get(ShareDefine.Def_Effect_PerLVAtk, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPerLVAtkC())  | 
|     MissRate = 0#attrDict.get(ShareDefine.Def_Effect_MissRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMissRateC())  | 
|     HitRate = 0#attrDict.get(ShareDefine.Def_Effect_HitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetHitRateC())  | 
|     DamBackPer = 0#attrDict.get(ShareDefine.Def_Effect_DamBackPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamBackPerC())  | 
|     PerLVMaxHP = attrDict.get(ShareDefine.Def_Effect_PerLVMaxHP, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPerLVMaxHPC())  | 
|     DropEquipPer = 0#attrDict.get(ShareDefine.Def_Effect_DropEquipPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDropEquipPerC())  | 
|     DropMoneyPer = attrDict.get(ShareDefine.Def_Effect_DropMoneyPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDropMoneyPerC())  | 
|     IgnoreDefRateReduce = 0#attrDict.get(ShareDefine.Def_Effect_IgnoreDefRateReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetIgnoreDefRateReduceC())  | 
|     DamChanceDef = 0#attrDict.get(ShareDefine.Def_Effect_DamChanceDef, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamChanceDefC())  | 
|     SuperHitReduce = attrDict.get(ShareDefine.Def_Effect_SuperHitReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitReduceC())  | 
|     SkillAtkRate = 0#attrDict.get(ShareDefine.Def_Effect_SkillAtkRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAtkRateC())  | 
|     SpeedPer = 0#attrDict.get(ShareDefine.Def_Effect_SpeedPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSpeedPerC())  | 
|     SkillAtkRateReduce = 0#attrDict.get(ShareDefine.Def_Effect_SkillAtkRateReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAtkRateReduceC())  | 
|     Hit = attrDict.get(ShareDefine.Def_Effect_Hit, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetHitC())  | 
|     Miss = attrDict.get(ShareDefine.Def_Effect_Miss, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMissC())  | 
|     SkillAddPerA = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer1, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer1C())  | 
|     SkillAddPerB = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer2, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer2C())  | 
|     SkillAddPerC = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer3, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer3C())  | 
|     SkillAddPerD = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer4, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer4C())  | 
|     SkillAddPerE = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer5, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer5C())  | 
|     SkillAddPerF = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer6, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer6C())  | 
|     SkillAddPerG = 0#attrDict.get(ShareDefine.Def_Effect_SkillAddPer7, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAddPer7C())  | 
|     SkillReducePerA = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer1, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer1C())  | 
|     SkillReducePerB = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer2, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer2C())  | 
|     SkillReducePerC = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer3, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer3C())  | 
|     SkillReducePerD = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer4, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer4C())  | 
|     SkillReducePerE = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer5, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer5C())  | 
|     SkillReducePerF = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer6, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer6C())  | 
|     SkillReducePerG = 0#attrDict.get(ShareDefine.Def_Effect_SkillReducePer7, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillReducePer7C())  | 
|       | 
|     # ¹¥ËÙ²»Ä¬Èϳˣ¬½ö×÷Ϊ²ÎÊýÌṩ²ß»®Ê¹Óà  | 
|     AtkSpeed = 0#attrDict.get(ShareDefine.Def_Effect_AtkSpeed, 0)  | 
|     AtkSpeedC = 1#1 if not gsParamIpyData else gsParamIpyData.GetAtkSpeedC()  | 
|       | 
|     # ¾ø°æ  | 
|     outOfPrintAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetOutOfPrintAttrID)  | 
|     outOfPrintAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetOutOfPrintAttrValue)  | 
|     if outOfPrintAttrIDCnt and outOfPrintAttrIDCnt == outOfPrintAttrValueCnt:  | 
|         for i in xrange(legendAttrIDCnt):  | 
|             attrID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetOutOfPrintAttrID, i)  | 
|             attrValue = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetOutOfPrintAttrValue, i)  | 
|             attrDict[attrID] = attrDict.get(attrID, 0) + attrValue  | 
|       | 
|     OnlyFinalHurt = attrDict.get(ShareDefine.Def_Effect_OnlyFinalHurt, 0)  | 
|     PVPAtkBackHP = attrDict.get(ShareDefine.Def_Effect_PVPAtkBackHP, 0)    | 
|       | 
|     if GetIsDogzEquip(curItem):  | 
|         # ÉñÊÞ×°±¸Óò»Í¬¹«Ê½  | 
|         value = eval(FormulaControl.GetCompileFormula("EquipGSFormula3", IpyGameDataPY.GetFuncCfg("EquipGSFormula", 3)))  | 
|     else:  | 
|         value = eval(FormulaControl.GetCompileFormula("EquipGSFormula", IpyGameDataPY.GetFuncCfg("EquipGSFormula")))  | 
|     value += skillGS  | 
|     return value  | 
|   | 
| def GetZhuXianEquipTotalGS(curPlayer):  | 
|     ##ÖïÏÉ×°±¸×ÜÆÀ·Ö  | 
|     equipScoreTotal = 0  | 
|     zhuXianEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptZhuXianEquip)  | 
|     for equipIndex in xrange(zhuXianEquipPack.GetCount()):  | 
|         curEquip = zhuXianEquipPack.GetAt(equipIndex)              | 
|         if curEquip.IsEmpty():  | 
|             continue  | 
|         equipScoreTotal += GetEquipGearScore(curEquip)  | 
|     return equipScoreTotal  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Í¨¹ýЧ¹ûID,¼ì²éÊÇ·ñΪָ¶¨ÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param effectList Ö¸¶¨µÄЧ¹ûIDÁÐ±í  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckItemByEffectID(curPlayer, curItem, effectList):  | 
|     if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|         return False  | 
|       | 
|     if not ItemControler.CheckItemUseLV(curPlayer, curItem, False):  | 
|         return False  | 
|       | 
|     for i in range(curItem.GetEffectCount()):  | 
|         effectID = curItem.GetEffectByIndex(i).GetEffectID()  | 
|           | 
|         #ÕÒµ½¿ÕÏî¾ÍÍ˳ö  | 
|         if effectID == 0:  | 
|             return False  | 
|           | 
|         if effectID in effectList:  | 
|             return True  | 
|       | 
|     return False  | 
|   | 
| #---------------------------------------------------------------------  | 
| def FindItemInPackByEffect(curPlayer, effectID):  | 
|     ## Í¨¹ýЧ¹û±éÀú±³°üÕÒµ½ÎïÆ·,ÕÒµ½·µ»Ø¸ÃÎïÆ·£¬Ã»Óзµ»ØÄ¬ÈÏNone  | 
|     #  @return curItem, index or None  | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     #ËÑË÷±³°ü  | 
|     for i in range(backPack.GetCount()):  | 
|         curItem = backPack.GetAt(i)  | 
|           | 
|         if not CheckItemByEffectID(curPlayer, curItem, [effectID]):  | 
|             continue  | 
|               | 
|         return curItem, i  | 
|       | 
|     return  | 
|   | 
| def FindItemInPackByEffectEx(curPlayer, effectID):  | 
|     ## Í¨¹ýЧ¹û±éÀú±³°üÕÒµ½ÎïÆ·,ÕÒµ½·µ»Ø¸ÃÎïÆ·£¬Ã»Óзµ»ØÄ¬ÈÏNone  | 
|     #  @return curItem or None  | 
|     backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     #ËÑË÷±³°ü  | 
|     for i in range(backPack.GetCount()):  | 
|         curItem = backPack.GetAt(i)  | 
|           | 
|         if not CheckItemByEffectID(curPlayer, curItem, [effectID]):  | 
|             continue  | 
|               | 
|         return curItem  | 
|       | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ## Í¨¹ýÎïÆ·ID±éÀú±³°üÕÒµ½ÎïÆ·, Ã»Óзµ»ØNone  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param findItemID ²éÕÒµÄÎïÆ·  | 
| #  @param packIndex ±³°üÀàÐÍ  | 
| #  @return item or None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def FindItemInPackByItemID(curPlayer , findItemID , packIndex):  | 
|     backPack = curPlayer.GetItemManager().GetPack(packIndex)  | 
|     #ËÑË÷±³°ü  | 
|     for i in range(backPack.GetCount()):  | 
|         curItem = backPack.GetAt(i)  | 
|           | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != findItemID:  | 
|             continue  | 
|               | 
|         return curItem  | 
|       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## »ñµÃ±³°üÊ£Óà¿Õ¼ä(²ÎÊý -> µ±Ç°Íæ¼Ò,±³°üË÷Òý)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return itemSpace  | 
| #  @remarks »ñµÃ±³°üÊ£Óà¿Õ¼ä  | 
| def GetItemPackSpace(curPlayer, packindex, getCount=0):  | 
|     #±³°üÊ£Óà¿Õ¼ä  | 
|     itemSpace = 0  | 
|   | 
|     if packindex in ShareDefine.Def_VPack_TypeList:  | 
|         for i in xrange(GetVPackCnt(packindex)):  | 
|             itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  | 
|             if itemKeyData:  | 
|                 continue  | 
|             itemSpace += 1  | 
|             if getCount > 0 and itemSpace >= getCount:  | 
|                 break  | 
|         return itemSpace  | 
|           | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|         #²»Êǿոñ¹ýÂË  | 
|         if not curItem.IsEmpty():  | 
|             continue  | 
|           | 
|         itemSpace += 1  | 
|         if getCount > 0 and itemSpace >= getCount:  | 
|             break  | 
|           | 
|     return itemSpace  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ¼ì²é±³°üÊÇ·ñÓпÕλ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks ¼ì²é±³°üÊÇ·ñÓпÕλ  | 
| def CheckPackHasSpace(curPlayer, packindex, isNotify=False):  | 
|     if packindex in ShareDefine.Def_VPack_TypeList:  | 
|         for i in xrange(GetVPackCnt(packindex)):  | 
|             itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  | 
|             if not itemKeyData:  | 
|                 return True  | 
|         return False  | 
|       | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|         #ÕÒµ½¿Õ¸ñ  | 
|         if curItem.IsEmpty():  | 
|             return True  | 
|           | 
|     if isNotify:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packindex])  | 
|           | 
|     return False  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ¼ì²é±³°üÊÇ·ñΪ¿Õ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return ²¼¶ûÖµ  | 
| #  @remarks ¼ì²é±³°üÊÇ·ñÓпÕλ  | 
| def CheckPackIsEmpty(curPlayer, packindex):  | 
|     if packindex in ShareDefine.Def_VPack_TypeList:  | 
|         for i in xrange(GetVPackCnt(packindex)):  | 
|             itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  | 
|             if itemKeyData:  | 
|                 return False  | 
|         return True  | 
|       | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|           | 
|         if not curItem.IsEmpty():  | 
|             #ÕÒµ½ÎïÆ·  | 
|             return False  | 
|               | 
|     return True  | 
|   | 
|   | 
| ## »ñµÃ±³°üµÚÒ»¸öΪ¿ÕµÄλÖà  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return ²¼¶ûÖµ  | 
| def GetEmptyIndexInPack(curPlayer, packindex):  | 
|     if packindex in ShareDefine.Def_VPack_TypeList:  | 
|         for i in xrange(GetVPackCnt(packindex)):  | 
|             itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  | 
|             if not itemKeyData:  | 
|                 return i  | 
|         return -1  | 
|       | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|           | 
|         if curItem.IsEmpty():  | 
|             #ÕÒµ½ÎïÆ·  | 
|             return i  | 
|               | 
|     return -1  | 
|   | 
| ## »ñµÃÐéÄâ±³°ü¸ñ×ÓÊý  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return ±³°ü¸ñ×ÓÊý  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetVPackCnt(packindex):  | 
|     if packindex not in ChConfig.Def_VPackCnt_Dict:  | 
|         return 0  | 
|     keyStr = ChConfig.Def_VPackCnt_Dict[packindex]  | 
|     return IpyGameDataPY.GetFuncCfg(keyStr)  | 
|   | 
|   | 
| ## É±¹ÖµôÂäÌáʾ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @return None  | 
| def NotifyItemDropByKill(curPlayer, curItem, npcID, notifyMark='', mapID=0):  | 
|     return #ÂÀ³¬Ëµ´Ë´¦ÆÁ±Î  | 
|   | 
| def GetNotifySuperItemInfo(curPlayer, curEquip, place=None):  | 
|     '''×°±¸Ìáʾ³¬Á´½ÓÐÅÏ¢»ã×Ü  | 
|         <a><Word info=item id=%s0/>|showitem=%s0 itemPlus=%s0</a>  | 
|         {"ItemID":ÎïÆ·ID, "UserData":..., "Star":ÐǼ¶, "EvolveLV":½ø»¯µÈ¼¶,"PlusLV":Ç¿»¯µÈ¼¶,"Stone":[±¦Ê¯ID,...], "Wash":{"LV":Ï´Á·µÈ¼¶,"Value":[Ï´Á·Öµ, ...]}, "Equips":[itemID, itemID, ...]}  | 
|     '''  | 
|       | 
|     packType = curEquip.GetItemPlaceType()  | 
|     packIndex = curEquip.GetItemPlaceIndex()  | 
|     if packType != IPY_GameWorld.rptEquip:  | 
|         return "{}"  | 
|       | 
|     classLV = GetItemClassLV(curEquip)  | 
|     if not classLV:  | 
|         return "{}"  | 
|       | 
|     packType = IPY_GameWorld.rptEquip  | 
|     itemDict = {}  | 
|     itemDict["ItemID"] = curEquip.GetItemTypeID()  | 
|     userData = curEquip.GetUserData()  | 
|     if userData and userData != "{}":  | 
|         itemDict["UserData"] = userData  | 
|           | 
|     #²¿Î»ÉýÐÇÊý¾Ý  | 
|     equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, packIndex, curEquip)  | 
|     if equipStar:  | 
|         itemDict["Star"] = equipStar  | 
|           | 
|     #²¿Î»Ç¿»¯Êý¾Ý  | 
|     equipPartPlusLV = ChEquip.GetEquipPartPlusLVByRank(curPlayer, packType, packIndex, curEquip)  | 
|     equipPartPlusEvolveLV = ChEquip.GetEquipPartPlusEvolveLVByEquip(curPlayer, packType, packIndex, curEquip)  | 
|     if equipPartPlusLV:  | 
|         itemDict["PlusLV"] = equipPartPlusLV  | 
|     if equipPartPlusEvolveLV:  | 
|         itemDict["EvolveLV"] = equipPartPlusEvolveLV  | 
|           | 
|     #²¿Î»±¦Ê¯Êý¾Ý  | 
|     stoneIDList = Operate_EquipStone.GetEquipIndexStoneIDList(curPlayer, packIndex)  | 
|     if stoneIDList and stoneIDList.count(0) != len(stoneIDList):  | 
|         itemDict["Stone"] = stoneIDList  | 
|           | 
|     #²¿Î»Ï´Á·Êý¾Ý  | 
|     washLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashLV % packIndex) + 1  | 
|     valueList = []  | 
|     for attrNum in xrange(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):  | 
|         value = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashValue % (packIndex, attrNum))  | 
|         valueList.append(value)  | 
|     if valueList and valueList.count(0) != len(valueList):  | 
|         itemDict["Wash"] = {"LV":washLV, "Value":valueList}  | 
|           | 
|     classItems = [] # ±¾½×ÒÑ´©×°±¸ID  | 
|     ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'ClassLV':classLV}, True)  | 
|     if ipyDataList:  | 
|         equipPack = curPlayer.GetItemManager().GetPack(packType)  | 
|         for ipyData in ipyDataList:  | 
|             index = ipyData.GetGridIndex()  | 
|             classEquip = equipPack.GetAt(index)  | 
|             if not classEquip or classEquip.IsEmpty():  | 
|                 continue  | 
|             equipID = classEquip.GetItemTypeID()  | 
|             equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, index, classEquip)  | 
|             classItems.append([equipID, equipStar])  | 
|     if classItems:  | 
|         itemDict["Equips"] = classItems  | 
|           | 
|     return json.dumps(itemDict, ensure_ascii=False).replace(" ", "")  | 
|   | 
|   | 
| ## Ê¹ÓÃÎïÆ·µÄÌØÊâÌáʾ  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param useItemID Ê¹ÓÃÎïÆ·  | 
| #  @return None  | 
| #  @remarks Ê¹ÓÃÎïÆ·µÄÌØÊâÌáʾ  | 
| def UseItemSpecialNotify(curPlayer, useItemID):  | 
|     #ÐèÒªÌáʾµÄÎïÆ·ÁÐ±í  | 
|     itemIDDict = ReadChConfig.GetEvalChConfig('need_eff_box_id')  | 
|     if useItemID in itemIDDict.keys():  | 
|         PlayerControl.NotifyCode(curPlayer, itemIDDict.get(useItemID), [useItemID])  | 
|           | 
|     #ÐèҪȫ·þÌáʾµÄÎïÆ·ÁÐ±í  | 
|     wNotifyIDDict = ReadChConfig.GetEvalChConfig('need_wnotify_id')  | 
|     if useItemID in wNotifyIDDict:  | 
|         PlayerControl.WorldNotify(0, wNotifyIDDict[useItemID],   | 
|                                   [curPlayer.GetPlayerName(), useItemID, useItemID])  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| #´Ëº¯ÊýÑéÖ¤µ±Ç°Ö°ÒµÏµ¿ÉÓà  | 
| def CheckJob(curPlayer, curItem):  | 
|     '''ÅжÏÎïÆ·ÊÇ·ñְҵϵ¿ÉÓà  | 
|         ÎïÆ·±íÖÐÖ°ÒµÏÞÖÆ¹æÔò: 0ΪͨÓã»·Ç0°Ùλ´ú±íÖ°Òµ  | 
|     '''  | 
|     itemJobLimit = curItem.GetJobLimit()  | 
|     if not itemJobLimit:  | 
|         return True  | 
|     if curPlayer.GetJob() == itemJobLimit:  | 
|         return True  | 
|       | 
|     return False  | 
|   | 
| ## ÎïÆ·¹«ÓÃÅж¨   | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckItemCanUse(curItem):  | 
|     if not curItem or curItem.IsEmpty():  | 
|         return  | 
|       | 
|     if curItem.GetIsLocked():  | 
|         return  | 
|       | 
|     return True  | 
|   | 
| # ÌØÊâÅж¨¸ù¾ÝʱЧʱ¼äÅж¨ÎïÆ·ÊÇ·ñ¿ÉÒÔʹÓà  | 
| # ¹ýÆÚÎïÆ·²»ÄÜʹÓûò×°±¸µ«ÊÇ¿ÉÒÔ³öÊÛÐø·Ñ  | 
| def CheckItemCanUseByExpireTime(curItem):  | 
| #    curItemCreateTime = curItem.GetCreateTime()  | 
| #    curItemExpireTime = curItem.GetExpireTime()  | 
| #    curItemPastTime = GameWorld.GetPastSeconds(curItemCreateTime)  | 
| #      | 
| #    reduceType = curItem.GetEndureReduceType()  | 
| #    if reduceType == ChConfig.Def_EquipReduceType_RTimeItem and \  | 
| #    curItemPastTime >= curItemExpireTime:  | 
| #        # ¹ýÆÚÁË  | 
| #        return False  | 
| #      | 
| #    if reduceType == ChConfig.Def_EquipReduceType_Time:  | 
| #        # ¿ªÊ¼×°±¸Ê±¼ä  | 
| #        startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)  | 
| #        if startTime == 0:  | 
| #            return True  | 
| #        if time.time() - startTime > curItemExpireTime:  | 
| #            return False  | 
|       | 
|     isExpireItem, expireTime = GetItemRemainingTime(curItem)  | 
|     if isExpireItem:  | 
|         if expireTime <= 0:  | 
|             return False  | 
|     return True  | 
|   | 
| def GetItemRemainingTime(curItem):  | 
|     ''' »ñÈ¡ÎïÆ·Ê£Óàʱ¼ä£¬Ãë  | 
|     @return: ÊÇ·ñʱЧÎïÆ·, Ê£Óàʱ¼ä   | 
|     '''  | 
|       | 
|     isExpireItem = False  | 
|     reduceType = curItem.GetEndureReduceType()  | 
|     remainingTime = 0  | 
|       | 
|     if reduceType in [ChConfig.Def_EquipReduceType_Time, ChConfig.Def_EquipReduceType_RTimeItem]:  | 
|         isExpireItem = True  | 
|         # ×°±¸ºó¿ªÊ¼¼ÆÊ±  | 
|         curItemExpireTime = curItem.GetUserAttr(ShareDefine.Def_IudetExpireTime)  | 
|         if not curItemExpireTime:  | 
|             curItemExpireTime = curItem.GetExpireTime()  | 
|               | 
|         # ¿ªÊ¼×°±¸Ê±¼ä  | 
|         startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)  | 
|         if startTime == 0:  | 
|             remainingTime = curItemExpireTime  | 
|         else:  | 
|             curItemPastTime = max(0, int(time.time()) - startTime)  | 
|             remainingTime = max(0, curItemExpireTime - curItemPastTime)  | 
|         return isExpireItem, remainingTime  | 
|       | 
|     return isExpireItem, remainingTime  | 
|   | 
| ## ¼ì²é×°±¸ÊÇ·ñÓÐÏâǶ±¦Ê¯  | 
| #  @param curItem ×°±¸¶ÔÏó  | 
| #  @return True-ÓР  | 
| def CheckHasStone(curItem):  | 
| #    GetStoneCount          ×î´ó¿É¿ª¿×Êý  | 
| #    GetMaxHoleCount        ÎïÆ·±íÅäÖõÄ×î´ó¿É¿ª¿×Êý£¬²»¿É³¬¹ý×î´ó¿É¿ª¿×Êý  | 
| #    GetCanPlaceStoneCount  ÒÑ¿ª¿×Êý  | 
| #    GetUseStoneCount       ÒÑÏâǶµÄ±¦Ê¯¿×Êý  | 
|     #===========================================================================  | 
|     # stoneCount = curItem.GetCanPlaceStoneCount()  | 
|     # if stoneCount <= 0:  | 
|     #    return False  | 
|     #   | 
|     # # Ò»¼þ×°±¸²»ÄÜÓÐÏâǶÏàͬIDµÄ¸ß¼¶±¦Ê¯  | 
|     # for index in range(stoneCount):  | 
|     #    if curItem.GetStone(index) > 0:  | 
|     #        return True  | 
|     #===========================================================================  | 
|       | 
|     return False  | 
|   | 
| ##¼ì²éÖ¸¶¨Î»ÖÃÊÇ·ñÓÐÎïÆ·  | 
| # @param equipIndex ×°±¸Î»  | 
| # @return bool  | 
| def CheckHasEquip(curPlayer, packIndex, equipIndex):  | 
|     roleEquipPack = curPlayer.GetItemManager().GetPack(packIndex)  | 
|     curEquip = roleEquipPack.GetAt(equipIndex)  | 
|   | 
|     if not curEquip or curEquip.IsEmpty():  | 
|         return False  | 
|       | 
|     #ÓÐÎïÆ·´æÔÚ  | 
|     return True  | 
|   | 
|   | 
| ## Í¨¹ýÎïÆ·ID, »ñµÃÎïÆ·µÄÏêϸЧ¹ûÐÅÏ¢  | 
| #  @param itemID µ±Ç°ÎïÆ·  | 
| #  @param effectIndex Ð§¹ûË÷Òý  | 
| #  @return EffectID£¬EffectValue0£¬ EffectValue1  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItemEffectByEffectID(curItem, effectID):  | 
|     for i in range(curItem.GetEffectCount()):  | 
|           | 
|         effect = curItem.GetEffectByIndex(i)  | 
|         if effect.GetEffectID() != effectID:  | 
|             continue  | 
|           | 
|         return effect  | 
|       | 
|     return  | 
|   | 
| ## »ñÈ¡ÎïÆ·Ê¹Óý׼¶  | 
| #  @param curItem ÎïÆ·¶ÔÏó  | 
| #  @return -1-ÕÒ²»µ½Ð§¹ûÀàÐÍ£¬ÎïÆ·ÅäÖÿÉÄÜÓÐÎó  | 
| #  @remarks ¼¼ÄÜÎïÆ·Ð§¹û±ê¼ÇID, Ïàͬ±ê¼ÇµÄ¼¼ÄÜÖ»ÄÜ·ÅÈë(ÏâǶ/ʹÓÃ)Ò»¸ö£¬AÖµÌî±ê¼ÇID£¬Ä¬ÈÏ´Ó1¿ªÊ¼  | 
| def GetItemUseClassLV(curItem):  | 
|     effect = GetItemEffectByEffectID(curItem, ChConfig.Def_Item_Eff_UseClassLV)  | 
|     if not effect:  | 
|         return -1  | 
|       | 
|     return effect.GetEffectValue(0)  | 
|   | 
| def GetItemNoteDict(curItem, writeCount=1, beforeCount=None, afterCount=None):  | 
|     ''' ÎïÆ·ÐÅÏ¢¼Ç¼   | 
|     @param curItem: ÎïÆ·  | 
|     '''  | 
|     dataDict = {"ItemID":curItem.GetItemTypeID(), "ItemCount":writeCount,   | 
|                 "IsBind":curItem.GetIsBind(), "ItemGUID":curItem.GetGUID()}  | 
|       | 
|     if beforeCount != None:  | 
|         dataDict["BeforeCount"] = beforeCount  | 
|     if afterCount != None:  | 
|         dataDict["AfterCount"] = afterCount  | 
|           | 
|     #if not CheckItemIsEquip(curItem):  | 
|     #    return dataDict  | 
|     if curItem.GetUserData() and curItem.GetUserData() != "{}":  | 
|         dataDict.update({"UserData":curItem.GetUserData()})  | 
|           | 
|     return dataDict  | 
|   | 
| def DR_GetItem(curPlayer, packType, eventName, itemNoteDict, noteDict={}):  | 
|     # ¼Ç¼µÃµ½ÎïÆ·  | 
|     noteDict["PackType"] = packType  | 
|       | 
|     if eventName in ChConfig.ItemGiveTypeList:  | 
|         operateType = eventName  | 
|         if operateType in ChConfig.ItemGiveTypeDict:  | 
|             eventName = ChConfig.ItemGiveTypeDict[operateType]  | 
|     else:  | 
|         operateType = ChConfig.ItemGive_Unknown  | 
|           | 
|     # ±¾µØÁ÷ÏòÖ»¼Ç¼ÓÐʼþÃû³ÆµÄ  | 
|     if eventName:  | 
|         DataRecordPack.DR_SetPlayerItem(curPlayer, eventName, itemNoteDict, noteDict)  | 
|           | 
|     # ¼ÇÂ¼Íæ¼Ò±³°ü»ñµÃÎïÆ·  | 
|     if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:  | 
|         EventReport.WriteEvent_item_record(curPlayer, 1, operateType, itemNoteDict, noteDict)  | 
|           | 
|     return  | 
|   | 
| def DR_DelItem(curPlayer, packType, eventName, itemNoteDict, noteDict={}):  | 
|     # ¼Ç¼ɾ³ýÎïÆ·  | 
|     noteDict["PackType"] = packType  | 
|       | 
|     if eventName in ChConfig.ItemDelTypeList:  | 
|         operateType = eventName  | 
|         if operateType in ChConfig.ItemDelTypeDict:  | 
|             eventName = ChConfig.ItemDelTypeDict[operateType]  | 
|     else:  | 
|         operateType = ChConfig.ItemDel_Unknown  | 
|           | 
|     DataRecordPack.DR_DeleteItem(curPlayer, eventName, itemNoteDict, noteDict)  | 
|       | 
|     # ¼ÇÂ¼Íæ¼Ò±³°üÎïÆ·É¾³ý  | 
|     if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:  | 
|         EventReport.WriteEvent_item_record(curPlayer, 0, operateType, itemNoteDict, noteDict)  | 
|           | 
|     return  | 
|   | 
| def DR_EquipItemChange(curPlayer, curEquip, eventName, addDict={}):  | 
|     # ¼Ç¼װ±¸ÎïÆ·ÊôÐÔ±ä¸ü  | 
|     noteDict = GetItemNoteDict(curEquip, 1)  | 
|     noteDict.update(addDict)  | 
|     noteDict["packType"] = curEquip.GetItemPlaceType()  | 
|     DataRecordPack.DR_EquipMachining(curPlayer, eventName, noteDict)  | 
|     return  | 
|   | 
| #===============================================================================  | 
| ## ¼ì²éÊÇ·ñÊÇ×°±¸  | 
| #  @param curItem   | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckItemIsEquip(curItem):  | 
|     if not CheckItemCanUse(curItem):  | 
|         return False  | 
|           | 
|     if curItem.GetType() not in ChConfig.Def_EquipItemType:  | 
|         return False  | 
|       | 
| #    #²»¿ÉÐÞÀí  | 
| #    if not curItem.GetCanRepair():  | 
| #        return  | 
|       | 
|     #Ä;Ã×ֶβ»Âú×ã  | 
| #    if not curItem.GetEndureReduceType() or not curItem.GetMaxEndure():  | 
| #        return  | 
|       | 
|     return True  | 
|   | 
| def CheckNoteEquipGS(curItem):  | 
|     if not CheckItemCanUse(curItem):  | 
|         return False  | 
|       | 
|     if curItem.GetType() not in IpyGameDataPY.GetFuncEvalCfg("EquipGSTypeForSort", 1):  | 
|         return False  | 
|       | 
|     return True  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  | 
| #  @param findEffectID Ð§¹ûID  | 
| #  @param curItemPack ±³°ü  | 
| #  @param needCount Ö¸¶¨µÄÊýÁ¿  | 
| #  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  | 
| #  @return hasEnough, itemIndexList [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÓвÄÁÏÊÇ·ñ°ó¶¨, ²»×ãÊýÁ¿]  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItem_FromPack_ByEff_Ex(findEffectID, curItemPack, needCount, isBind):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|     findItemIsBind = False  | 
|       | 
|     for i in range(curItemPack.GetCount()):  | 
|         findItem = curItemPack.GetAt(i)  | 
|           | 
|         if not CheckItemCanUse(findItem) or ItemControler.GetIsAuctionItem(findItem):  | 
|             continue  | 
|           | 
|         #²»Ê¹Óð󶨵IJÄÁÏ  | 
|         if not isBind and findItem.GetIsBind():  | 
|             continue  | 
|           | 
|         #²»ÊÇÕâ¸öЧ¹ûµÄ  | 
|         if findItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  | 
|             continue  | 
|           | 
|         #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  | 
|         if not findItemIsBind and findItem.GetIsBind():  | 
|             findItemIsBind = True  | 
|           | 
|         itemCount = findItem.GetCount()  | 
|         #²»¹»  | 
|         if needCount > itemCount:  | 
|             needCount -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             needCount = 0  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÓвÄÁÏÊÇ·ñ°ó¶¨, ²»×ãÊýÁ¿]  | 
|     return hasEnough, itemIndexList, findItemIsBind, needCount  | 
| #---------------------------------------------------------------------  | 
| ## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  | 
| #  @param findEffectID Ð§¹ûID  | 
| #  @param curItemPack ±³°ü  | 
| #  @param needCount Ö¸¶¨µÄÊýÁ¿  | 
| #  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  | 
| #  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItem_FromPack_ByEff(findEffectID, curItemPack, needCount, isBind):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|       | 
|     for i in range(curItemPack.GetCount()):  | 
|         curItem = curItemPack.GetAt(i)  | 
|           | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         #²»Ê¹Óð󶨵IJÄÁÏ  | 
|         if not isBind and curItem.GetIsBind():  | 
|             continue  | 
|           | 
|         #²»ÊÇÕâ¸öЧ¹ûµÄ  | 
|         if curItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  | 
|             continue  | 
|           | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCount > itemCount:  | 
|             needCount -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  | 
|     return hasEnough, itemIndexList  | 
|   | 
| ## Í¨¹ý±³°ü²éÕÒÖ¸¶¨ÎïÆ·IDµÄÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  | 
| #  @param findItemID ÎïÆ·ID  | 
| #  @param findEffectID Ð§¹ûID  | 
| #  @param curItemPack ±³°ü  | 
| #  @param needCount Ö¸¶¨µÄÊýÁ¿  | 
| #  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  | 
| #  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItemFromPack_ByIDAndEff(findItemID, findEffectID, curItemPack, needCount, isBind):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|       | 
|     for i in range(curItemPack.GetCount()):  | 
|         curItem = curItemPack.GetAt(i)  | 
|           | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != findItemID:  | 
|             continue  | 
|           | 
|         #²»Ê¹Óð󶨵IJÄÁÏ  | 
|         if not isBind and curItem.GetIsBind():  | 
|             continue  | 
|           | 
|         #²»ÊÇÕâ¸öЧ¹ûµÄ  | 
|         if curItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  | 
|             continue  | 
|           | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCount > itemCount:  | 
|             needCount -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  | 
|     return hasEnough, itemIndexList  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  | 
| # @param findItemID ²éÕÒµÄÎïÆ·ID  | 
| # @param itemPack ÎïÆ·±³°ü  | 
| # @param needCnt ÐèÒªÊýÁ¿  | 
| # @param useItemMode °ó¶¨Ä£Ê½  | 
| # @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý]  | 
| # @remarks ´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  | 
| def GetItem_FromPack_ByID(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|       | 
|     for i in range(itemPack.GetCount()):  | 
|         curItem = itemPack.GetAt(i)  | 
|         #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != findItemID:  | 
|             continue  | 
|       | 
|         #ÑéÖ¤ÎïÆ·ÊôÐÔ  | 
|         if curItem.GetIsBind():  | 
|             if useItemMode == UseStuffMode_NoBind:  | 
|                 continue  | 
|         else:  | 
|             if useItemMode == UseStuffMode_Bind:  | 
|                 continue  | 
|   | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCnt > itemCount:  | 
|             needCnt -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý]  | 
|     return hasEnough, itemIndexList  | 
|   | 
|   | 
| ##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  | 
| # @param findItemID ²éÕÒµÄÎïÆ·ID  | 
| # @param itemPack ÎïÆ·±³°ü  | 
| # @param needCnt ÐèÒªÊýÁ¿  | 
| # @param useItemMode °ó¶¨Ä£Ê½  | 
| # @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä]  | 
| def GetItem_FromPack_ByID_Ex(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|     findItemIsBind = False  | 
|       | 
|     for i in range(itemPack.GetCount()):  | 
|         curItem = itemPack.GetAt(i)  | 
|         #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != findItemID:  | 
|             continue  | 
|       | 
|         #ÑéÖ¤ÎïÆ·ÊôÐÔ  | 
|         if curItem.GetIsBind():  | 
|             if useItemMode == UseStuffMode_NoBind:  | 
|                 continue  | 
|         else:  | 
|             if useItemMode == UseStuffMode_Bind:  | 
|                 continue  | 
|           | 
|         #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  | 
|         if not findItemIsBind and curItem.GetIsBind():  | 
|             findItemIsBind = True  | 
|               | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCnt > itemCount:  | 
|             needCnt -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä]  | 
|     return hasEnough, itemIndexList, findItemIsBind  | 
|   | 
|   | 
| ##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  | 
| # @param findItemID ²éÕÒµÄÎïÆ·ID  | 
| # @param itemPack ÎïÆ·±³°ü  | 
| # @param needCnt ÐèÒªÊýÁ¿  | 
| # @param useItemMode °ó¶¨Ä£Ê½  | 
| # @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä, ²»×ãµÄ¸öÊý]  | 
| def GetItem_FromPack_ByID_ExEx(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|     findItemIsBind = False  | 
|       | 
|     for i in range(itemPack.GetCount()):  | 
|         curItem = itemPack.GetAt(i)  | 
|         #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != findItemID:  | 
|             continue  | 
|       | 
|         #ÑéÖ¤ÎïÆ·ÊôÐÔ  | 
|         if curItem.GetIsBind():  | 
|             if useItemMode == UseStuffMode_NoBind:  | 
|                 continue  | 
|         else:  | 
|             if useItemMode == UseStuffMode_Bind:  | 
|                 continue  | 
|           | 
|         #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  | 
|         if not findItemIsBind and curItem.GetIsBind():  | 
|             findItemIsBind = True  | 
|               | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCnt > itemCount:  | 
|             needCnt -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             needCnt = 0 # Èç¹û×ã¹»£¬ÔòÉèÖÃȱÉٵĸöÊýΪ0  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä, ²»×ãµÄ¸öÊý]  | 
|     return hasEnough, itemIndexList, findItemIsBind, needCnt  | 
|   | 
|   | 
| def GetPackItemBindStateIndexInfo(curPlayer, itemID, needCount=0, packType=IPY_GameWorld.rptItem):  | 
|     ''' »ñÈ¡±³°üÏûºÄµÀ¾ß°ó¶¨¼°Î´°ó¶¨Ë÷ÒýÇé¿ö  | 
|     @param needCount: ËùÐè¸öÊý, Ä¬Èϰó¶¨ÓÅÏÈ£¬µ±ÕÒµ½ÒѾ×ã¹»µÄ¸öÊýºó²»ÔÙ±éÀú£¬¼õÉÙÎÞÓñéÀú  | 
|     @return: ¿ÉÏûºÄÎïÆ·Áбí[[°ó¶¨ÎïÆ·Ë÷Òý], [²»°ó¶¨ÎïÆ·Ë÷Òý]], °ó¶¨¸öÊý, Î´°ó¶¨¸öÊý  | 
|     '''  | 
|     consumeItemIndexList = [[], []] # ¿ÉÏûºÄÎïÆ·Áбí[[°ó¶¨ÎïÆ·Ë÷Òý], [²»°ó¶¨ÎïÆ·Ë÷Òý]]  | 
|     bindCnt, unBindCnt = 0, 0  | 
|       | 
|     curPack = curPlayer.GetItemManager().GetPack(packType)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         if curItem.GetItemTypeID() != itemID:  | 
|             continue  | 
|           | 
|         itemCount = curItem.GetCount()  | 
|   | 
|         #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  | 
|         if curItem.GetIsBind():  | 
|             consumeItemIndexList[0].append(i)  | 
|             bindCnt += itemCount  | 
|             if needCount > 0 and bindCnt >= needCount:  | 
|                 break  | 
|         else:  | 
|             consumeItemIndexList[1].append(i)  | 
|             unBindCnt += itemCount  | 
|               | 
|     return consumeItemIndexList, bindCnt, unBindCnt  | 
|   | 
| ## ¿Û³ýÏûºÄ²ÄÁÏ, ÓÅÏȿ۳ý°ó¶¨µÄÎïÆ·, ÅäÖú¯ÊýʹÓàGetPackItemBindStateIndexInfo, DelCostItemByBind  | 
| def DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, delEvent, saveDataDict={}):  | 
|     curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     bindIndexList, unBindIndexList = costItemIndexList  | 
|     if bindCnt >= delCnt:  | 
|         ReduceItem(curPlayer, curPack, bindIndexList, delCnt, True, delEvent, saveDataDict)  | 
|     else:  | 
|         ReduceItem(curPlayer, curPack, bindIndexList, bindCnt, True, delEvent, saveDataDict)  | 
|         ReduceItem(curPlayer, curPack, unBindIndexList, delCnt - bindCnt, False, delEvent, saveDataDict)  | 
|     return  | 
|   | 
| ## ÅäºÏ GetItem_FromPack_ByEff, Ê¹ÓÃ, É¾³ýÎïÆ·  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItemPack ÎïÆ·±³°ü  | 
| #  @param itemIndexList ÎïÆ·Ë÷ÒýÁÐ±í  | 
| #  @param reduceCount É¾³ýÊýÁ¿  | 
| #  @param makeItemBind ÎïÆ·°ó¶¨  | 
| #  @return True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ReduceItem(curPlayer, curItemPack, itemIndexList, reduceCount, makeItemBind, eventName="",   | 
|                saveDataDict={}, needSysmsg=True):  | 
|     itemTypeID = 0  | 
|     totalUseCnt = reduceCount  | 
|     if not eventName:  | 
|         eventName = "ReduceItem"  | 
|       | 
|     for itemIndex in itemIndexList:  | 
|         curItem = curItemPack.GetAt(itemIndex)  | 
|           | 
|         if not makeItemBind and curItem.GetIsBind():  | 
|             makeItemBind = True  | 
|               | 
|         itemCount = curItem.GetCount()  | 
|         itemTypeID = curItem.GetItemTypeID()  | 
|           | 
|         if reduceCount > itemCount:  | 
|             if ItemControler.ItemNeedRecord(curItem):  | 
|                 itemNoteDict = GetItemNoteDict(curItem, itemCount, itemCount, 0)  | 
|                 DR_DelItem(curPlayer, IPY_GameWorld.rptItem, eventName, itemNoteDict, saveDataDict)  | 
|                   | 
|             ItemControler.SetItemCount(curItem, 0, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  | 
|                                        curPlayer.GetPlayerName())  | 
|             reduceCount -= itemCount  | 
|         else:  | 
|             if ItemControler.ItemNeedRecord(curItem):  | 
|                 itemNoteDict = GetItemNoteDict(curItem, reduceCount, itemCount, itemCount - reduceCount)  | 
|                 DR_DelItem(curPlayer, IPY_GameWorld.rptItem, eventName, itemNoteDict, saveDataDict)  | 
|               | 
|             ItemControler.SetItemCount(curItem, itemCount - reduceCount, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  | 
|                                        curPlayer.GetPlayerName())  | 
|             break  | 
|       | 
|     #ϵͳÌáʾ LostRes Ê§È¥ÎïÆ·  | 
|     #if needSysmsg:  | 
|     #    PlayerControl.NotifyCode(curPlayer, 'LostRes', [itemTypeID, totalUseCnt])  | 
|     return makeItemBind  | 
|   | 
| def GetCostItemIndexList(costItemInfo, itemPack, bindFirst=True):  | 
|     '''»ñµÃÐèÒªÏûºÄµÄ²ÄÁÏÎïÆ·ÐÅÏ¢, ÓÅÏȿ۳ý°ó¶¨ÎïÆ·  | 
|     @param costItemInfo: ÐèÒªÎïÆ·ÊýÁ¿[(itemID,itemCnt), ...] »ò  {itemID:itemCnt, ...}  | 
|     @param itemPack: ±³°ü  | 
|     @param bindFirst: ÊÇ·ñ°ó¶¨ÓÅÏÈ, True-°ó¶¨ÓÅÏÈ£¬ False-·Ç°ó¶¨ÓÅÏÈ  | 
|     @return: È±ÉÙµÄÎïÆ·¸öÊýÐÅÏ¢×Öµä{itemID:ȱÉÙ¸öÊý}, ¿Û³ýÎïÆ·ÐÅÏ¢×Öµä{itemID:[ɾ³ýË÷ÒýÁбí, É¾³ý¸öÊý], ...}  | 
|     '''  | 
|     lackItemDict = {}  | 
|     delInfoDict = {}  | 
|       | 
|     costItemDict = {}  | 
|     if not isinstance(costItemInfo, dict):  | 
|         for needItemID, needItemCnt in costItemInfo:  | 
|             costItemDict[needItemID] = needItemCnt  | 
|     else:  | 
|         costItemDict = costItemInfo  | 
|           | 
|     bindItemCntDict = {}  | 
|     noBindItemCntDict = {}  | 
|     bindItemIndexDict = {}  | 
|     noBindItemIndexDict = {}  | 
|       | 
|     # ÕâÁ½ÖÖģʽ±ØÐë±éÀú±³°üÒ»±é  | 
|     for i in xrange(itemPack.GetCount()):  | 
|         curItem = itemPack.GetAt(i)  | 
|         #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|         curItemID = curItem.GetItemTypeID()  | 
|         if curItemID not in costItemDict:  | 
|             continue  | 
|           | 
|         curItemCount = curItem.GetCount()  | 
|         if curItem.GetIsBind():  | 
|             indexDict = bindItemIndexDict  | 
|             bindItemCntDict[curItemID] = bindItemCntDict.get(curItemID, 0) + curItemCount  | 
|         else:  | 
|             indexDict = noBindItemIndexDict  | 
|             noBindItemCntDict[curItemID] = noBindItemCntDict.get(curItemID, 0) + curItemCount  | 
|               | 
|         if curItemID not in indexDict:  | 
|             indexDict[curItemID] = []  | 
|         indexList = indexDict[curItemID]  | 
|         indexList.append(i)  | 
|           | 
|     # ±éÀúÍêºóÅжÏÊÇ·ñ×ã¹»  | 
|     for needItemID, needItemCnt in costItemDict.items():  | 
|         itemCntTotal = bindItemCntDict.get(needItemID, 0) + noBindItemCntDict.get(needItemID, 0)  | 
|         lackCnt = max(0, needItemCnt - itemCntTotal)  | 
|         # ²»¹»  | 
|         if lackCnt:  | 
|             lackItemDict[needItemID] = lackCnt  | 
|               | 
|         if itemCntTotal:  | 
|             delCnt = needItemCnt - lackCnt  | 
|             if bindFirst:  | 
|                 indexList = bindItemIndexDict.get(needItemID, []) + noBindItemIndexDict.get(needItemID, [])  | 
|             else:  | 
|                 indexList = noBindItemIndexDict.get(needItemID, []) + bindItemIndexDict.get(needItemID, [])                  | 
|             delInfoDict[needItemID] = [indexList, delCnt]  | 
|           | 
|     return lackItemDict, delInfoDict  | 
|   | 
| ## »ñÈ¡×Ô¶¯¹ºÂò²ÄÁÏÐèÒªÏûºÄµÄ×êʯÊý  | 
| def GetAutoBuyItemNeedGold(lackItemDict):  | 
|     totalGold = 0  | 
|     # ¼ÆËã×Ô¶¯¹ºÂòÏûºÄ  | 
|     for itemID, lackCnt in lackItemDict.items():  | 
|         if lackCnt <= 0:  | 
|             continue  | 
|           | 
|         curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|         if not curItem:  | 
|             return 0  | 
|              | 
|         itemGold = GetShopItemPrice(curItem.GetItemTypeID(), IPY_GameWorld.TYPE_Price_Gold_Money)  | 
|         if itemGold <= 0:  | 
|             GameWorld.ErrLog("É̳DZíδÅäÖÃÎïÆ·×êʯÏûºÄ!itemID=%s" % itemID)  | 
|             return 0  | 
|           | 
|         totalGold += (lackCnt * itemGold)  | 
|           | 
|     return totalGold  | 
|   | 
| def GetShopItemPrice(itemID, priceType):  | 
|     ''' »ñÈ¡É̳ÇÎïÆ·¶ÔÓ¦¼Û¸ñ '''  | 
|     # ÏµÍ³¹Ì¶¨É̵êÀàÐÍ£º ÏÉÓñ£¨2-³£ÓõÀ¾ß£¬3-³É³¤±äÇ¿£©£¬°óÓñ£¨4-°óÓñÉ̳ǣ©  | 
|     priceTypeShopTypeDict = {IPY_GameWorld.TYPE_Price_Gold_Money:[2, 3],  | 
|                              IPY_GameWorld.TYPE_Price_Gold_Paper:[4],  | 
|                              }  | 
|     ipyData = None  | 
|     if priceType in priceTypeShopTypeDict:  | 
|         for shopType in priceTypeShopTypeDict[priceType]:  | 
|             ipyData = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType, "ItemID":itemID, "MoneyType":priceType}, isLogNone=False)  | 
|             if ipyData:  | 
|                 break  | 
|     else:  | 
|         ipyData = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ItemID":itemID, "MoneyType":priceType}, isLogNone=False)  | 
|     if not ipyData:  | 
|         return 0  | 
|     return ipyData.GetMoneyNum()  | 
|   | 
| def DelCostItem(curPlayer, itemPack, delInfoDict, delEvent="ReduceItem"):  | 
|     ## ¿Û³ýÏûºÄ²ÄÁÏ, ÅäÖú¯ÊýʹÓàGetCostItemIndexList, GetAutoBuyItemNeedGold, DelCostItem  | 
|     delItemHasBind = False  | 
|     for indexList, delCnt in delInfoDict.values():  | 
|         if not indexList:  | 
|             continue  | 
|         hasBindItem = ReduceItem(curPlayer, itemPack, indexList, delCnt, False, delEvent)  | 
|         delItemHasBind = True if hasBindItem else delItemHasBind  | 
|     return delItemHasBind  | 
| #---------------------------------------------------------------------  | 
| ##ÈÎÎñϵͳµ÷ÓÃ, É¾³ýÖ¸¶¨±³°üÖеÄÎïÆ·  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param delItemID É¾³ýÎïÆ·ID  | 
| # @param delItemCount É¾³ýÎïÆ·ÊýÁ¿( Îª0È«²¿É¾³ý )  | 
| # @param missionID ÈÎÎñID  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ÈÎÎñϵͳµ÷ÓÃ, É¾³ýÖ¸¶¨±³°üÖеÄÎïÆ·  | 
| def DelMissionItem(curPlayer, packIndex, delItemID, delItemCount, missionID):  | 
|     itemPack = curPlayer.GetItemManager().GetPack(packIndex)  | 
|     #ÊÇ·ñÈ«²¿É¾³ý  | 
|     delAllItem = False  | 
|       | 
|     if delItemCount <= 0:  | 
|         delAllItem = True  | 
|       | 
|     for index in range(0, itemPack.GetCount()):  | 
|         item = itemPack.GetAt(index)  | 
|           | 
|         if not CheckItemCanUse(item) or ItemControler.GetIsAuctionItem(item):  | 
|             continue  | 
|           | 
|         itemTypeID = item.GetItemTypeID()  | 
|         itemCount = item.GetCount()  | 
|           | 
|         if itemTypeID != delItemID:  | 
|             continue  | 
|           | 
|         curBind = item.GetIsBind()  | 
|           | 
|         #È«²¿É¾³ý,»òɾ³ýµÄÊýÁ¿´óÓÚÎïÆ·µÄÊýÁ¿, Çå³ýÕâ¸öÎïÆ·  | 
|         if delAllItem or delItemCount > itemCount:  | 
|             item.Clear()  | 
|             continue  | 
|           | 
|         #ÎïÆ·ÊýÁ¿´óÓÚɾ³ýµÄÊýÁ¿, º¯Êý·µ»Ø  | 
|         ItemControler.SetItemCount(item, itemCount - delItemCount, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  | 
|                                    curPlayer.GetPlayerName())  | 
|         return  | 
|       | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ## ÉèÖÃÎïÆ·°ó¶¨ÊôÐÔ// ChConfig.Def_BindType  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param bindType °ó¶¨ÀàÐÍ  | 
| #  @return None or True  | 
| #  @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)  | 
|     return True  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param switchItem ½»»»µÄÎïÆ·  | 
| #  @param putInPackIndex ·ÅÈëµÄ±³°ü  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  | 
| def DoLogicSwitchItemEx(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex):  | 
|       | 
|     #---ÎïÆ·¼ì²é---  | 
|     srcPack = curPlayer.GetItemManager().GetPack(srcBackpack)  | 
|     if srcIndex < 0 or srcIndex >= srcPack.GetCount():  | 
|         return  | 
|     srcItem = srcPack.GetAt(srcIndex)  | 
|     if not CheckItemCanUse(srcItem):  | 
|         return  | 
|       | 
|     destPack = curPlayer.GetItemManager().GetPack(desBackPack)  | 
|     if destIndex < 0 or destIndex >= destPack.GetCount():  | 
|         return  | 
|     destItem = destPack.GetAt(destIndex)  | 
|     #Ä¿±ê¸ñ×ÓÖ»ÑéÖ¤Ëø¶¨, ¿ÉÒÔÔÊÐí¿Õλ  | 
|     if destItem == None or destItem.GetIsLocked():  | 
|         return  | 
|   | 
|     return DoLogicSwitchItem(curPlayer, srcItem, destItem, desBackPack)  | 
|   | 
| ##¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param switchItem ½»»»µÄÎïÆ·  | 
| #  @param putInPackIndex ·ÅÈëµÄ±³°ü  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  | 
| def DoLogicSwitchItem(curPlayer, curItem, switchItem, packIndex):  | 
|     #¿ÕÎïÆ·, ·ÅÈë  | 
|     if curItem.IsEmpty():  | 
|         return PutIn(curPlayer, curItem, switchItem, packIndex)  | 
|   | 
|     #·Ç¿ÕÎïÆ·½»»»  | 
|     return SwitchItem(curPlayer, curItem, switchItem, packIndex)  | 
|   | 
| ## ½»»»ÎïÆ·  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @param switchItem ½»»»µÄÎïÆ·  | 
| #  @param putInPackIndex ·ÅÈëµÄ±³°ü  | 
| #  @return True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def SwitchItem(curPlayer, curItem, switchItem, putInPackIndex):  | 
|     ##ÎïÆ·°ó¶¨×Ö¶ÎÅж¨ -> ×°±¸°ó¶¨  | 
|     if putInPackIndex in [IPY_GameWorld.rptEquip, ShareDefine.rptZhuXianEquip]:  | 
|         DoLogic_ItemBindType(curPlayer, switchItem, ChConfig.Def_BindType_DoEquipBind)  | 
|           | 
|     # ×°±¸¼¼ÄÜÊé¡¢×øÆï×°±¸°ó¶¨  | 
|     if putInPackIndex in [IPY_GameWorld.rptHorseEquip, ShareDefine.rptZhuXianEquip]:  | 
|         DoLogic_ItemBindType(curPlayer, curItem, ChConfig.Def_BindType_DoEquipBind)  | 
|       | 
|     #½»»»×°±¸  | 
|     curItem.Switch(switchItem)  | 
|     return True  | 
|   | 
| ## ·ÅÈëÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param emptyItem ¿ÕÎïÆ·  | 
| #  @param switchItem ½»»»µÄÎïÆ·  | 
| #  @param putInPackIndex ·ÅÈëµÄ±³°ü  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def PutIn(curPlayer, emptyItem, switchItem, putInPackIndex):  | 
|     #Òì³£Ò»¶¨Òª¿ÕÎïÆ·  | 
|     if not emptyItem.IsEmpty():  | 
|         GameWorld.ErrLog('putInErr' , curPlayer.GetID())  | 
|         return  | 
|       | 
|     ##ÎïÆ·°ó¶¨×Ö¶ÎÅж¨ -> ×°±¸°ó¶¨  | 
|     if putInPackIndex in [IPY_GameWorld.rptEquip, ShareDefine.rptZhuXianEquip]:  | 
|         DoLogic_ItemBindType(curPlayer, switchItem, ChConfig.Def_BindType_DoEquipBind)  | 
|       | 
|     # ×°±¸¼¼ÄÜÊé¡¢×øÆï×°±¸°ó¶¨  | 
|     if putInPackIndex in [IPY_GameWorld.rptHorseEquip, ShareDefine.rptZhuXianEquip]:  | 
|         DoLogic_ItemBindType(curPlayer, emptyItem, ChConfig.Def_BindType_DoEquipBind)  | 
|   | 
|     if switchItem.GetGameWorldItemType() == IPY_GameWorld.gwitRoleItem:  | 
|         emptyItem.PutIn(switchItem)  | 
|     elif switchItem.GetGameWorldItemType() == IPY_GameWorld.gwitSingleItem:  | 
|         emptyItem.AssignItem(switchItem)  | 
|       | 
|     #½»»»×°±¸  | 
|     #emptyItem.PutIn( switchItem )  | 
|     return True  | 
|   | 
| ## ·µ»ØÊÇ·ñÊÇ×°±¸  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetIsEquip(curItem):  | 
|     return curItem.GetType() in ChConfig.Def_EquipItemType  | 
|   | 
| def GetIsDogzEquip(curItem):  | 
|     ## ·µ»ØÊÇ·ñÉñÊÞ×°±¸  | 
|     return curItem.GetType() in ChConfig.Def_DogzEquiipType  | 
|   | 
| def GetIsZhuXianEquip(curItem):  | 
|     ## ·µ»ØÊÇ·ñÖïÏÉ×°±¸  | 
|     return curItem.GetType() in ChConfig.Def_ZhuXianEquiipType  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##±éÀúÊý¾Ý¿â²éÕÒºÏÊʵÄÎïÆ·, Í¨¹ý Ð§¹ûID + Ð§¹ûAֵȷ¶¨ÎïÆ·  | 
| # @param itemType ÎïÆ·ÀàÐÍ  | 
| # @param itemEffectID ÎïÆ·Ð§¹ûID  | 
| # @param itemEffectValue ÎïÆ·Ð§¹ûÖµ  | 
| # @return ÎïÆ·Êý¾Ý  | 
| # @remarks ¿Í»§¶Ë·â°üÏìÓ¦  | 
| # ±éÀúÊý¾Ý¿â²éÕÒºÏÊʵÄÎïÆ·, Í¨¹ý Ð§¹ûID + Ð§¹ûAֵȷ¶¨ÎïÆ·  | 
| def FindItemFromDataByEffValue(itemType, itemEffectID, findEffectValue):  | 
|     gameData = GameWorld.GetGameData()  | 
|     #¹ýÂËÎïÆ·ÀàÐÍ  | 
|     gameData.FilterItemByType(itemType)  | 
|     #²éÕÒÊý¾Ý¿â  | 
|     for i in range(0, gameData.GetFilterItemCount()):  | 
|         curFindItem = gameData.GetFilterItem(i)  | 
| #==================================================  | 
| #        #¹Ì¶¨²»³öÏÖµÄÎïÆ·  | 
| #        if not curFindItem.GetCanIdentifyAppear():  | 
| #            continue  | 
| #==================================================  | 
|           | 
|         curFindItemEffect = curFindItem.GetEffectByIndex(0)  | 
|         curFindItemEffectID = curFindItemEffect.GetEffectID()  | 
|         curFindItemEffectValue = curFindItemEffect.GetEffectValue(0)  | 
|         #¶Ô±ÈЧ¹ûÖµ  | 
|         if itemEffectID == curFindItemEffectID and curFindItemEffectValue == findEffectValue:  | 
|             return curFindItem  | 
|   | 
|     return None  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDºÍAÖµµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  | 
| #  @param effectID Ð§¹ûID  | 
| #  @param effectA Ð§¹ûA  | 
| #  @param curItemPack ±³°ü  | 
| #  @param needCount Ö¸¶¨µÄÊýÁ¿  | 
| #  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý,»¹Ðè¶àÉÙÊýÁ¿ ]  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItemIndexListFromPackByEffA(effectID, effectA, curItemPack, needCount):  | 
|     hasEnough = False  | 
|     itemIndexList = []  | 
|       | 
|     for i in range(curItemPack.GetCount()):  | 
|         curItem = curItemPack.GetAt(i)  | 
|           | 
|         #¼ì²éÎïÆ·  | 
|         if not CheckItemCanUse(curItem) or ItemControler.GetIsAuctionItem(curItem):  | 
|             continue  | 
|           | 
|         effect = curItem.GetEffectByIndex(0)  | 
|           | 
|         #²»ÊÇÕâ¸öЧ¹ûIDµÄ  | 
|         if effect.GetEffectID() != effectID:  | 
|             continue  | 
|           | 
|         #²»ÊÇÕâ¸öЧ¹ûAÖµµÄ  | 
|         if effect.GetEffectValue(0) != effectA:  | 
|             continue  | 
|           | 
|         itemCount = curItem.GetCount()  | 
|         #²»¹»  | 
|         if needCount > itemCount:  | 
|             needCount -= itemCount  | 
|             itemIndexList.append(i)  | 
|         else:  | 
|             needCount = 0 # Èç¹û×ã¹»£¬ÔòÉèÖÃȱÉٵĸöÊýΪ0  | 
|             hasEnough = True  | 
|             itemIndexList.append(i)  | 
|             break  | 
|       | 
|     #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  | 
|     return hasEnough, itemIndexList, needCount  | 
| #---------------------------------------------------------------------  | 
| ##¿Û³ýÎïÆ·  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param delCnt É¾³ýÊýÁ¿  | 
| # @param needSysmsg ÊÇ·ñÐèҪϵͳÌáʾ  | 
| # @param recordName ossÁ÷ÏòÃû  | 
| # @param saveDataDict ¸½¼Ó´æ´¢ÐÅÏ¢  | 
| # @param isForceDR ÊÇ·ñÇ¿ÖÆ¼Ç¼Á÷Ïò  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿Û³ýÎïÆ·  | 
| def DelItem(curPlayer, curItem, delCnt, needSysmsg=True, recordName="", saveDataDict={}, isForceDR=False):  | 
|     curItemTypeID = curItem.GetItemTypeID()  | 
|     curItemCnt = curItem.GetCount()  | 
|     curItemBind = curItem.GetIsBind()  | 
|       | 
|     if curItemCnt < delCnt:  | 
|         GameWorld.ErrLog("DelItem, delCnt = %s, itemCnt = %s, itemTypeID = %s" % (delCnt, curItemCnt, curItemTypeID), curPlayer.GetID())  | 
|         #raise Exception("DelItem, delCnt = %s, itemCnt = %s, itemTypeID = %s" % (delCnt, curItemCnt, curItemTypeID), curPlayer.GetID())  | 
|         return  | 
|       | 
|     #===========================================================================  | 
|     # if needSysmsg:  | 
|     #    PlayerControl.NotifyCode(curPlayer, "LostRes", [curItemTypeID , delCnt])  | 
|     #===========================================================================  | 
|       | 
|     if isForceDR or ItemControler.ItemNeedRecord(curItem):  | 
|         itemNoteDict = GetItemNoteDict(curItem, delCnt, curItemCnt, curItemCnt - delCnt)  | 
|         DR_DelItem(curPlayer, IPY_GameWorld.rptItem, recordName, itemNoteDict, saveDataDict)  | 
|           | 
|     #¿Û³ýÎïÆ·  | 
|     ItemControler.SetItemCount(curItem, curItemCnt - delCnt,  | 
|                                curPlayer.GetPlayerID(), curPlayer.GetAccID(),  | 
|                                curPlayer.GetPlayerName())  | 
|     return  | 
|   | 
| def DelVPackItem(curPlayer, packIndex, placeList, eventName=""):  | 
|     ''' É¾³ýÐéÄâ±³°üÎïÆ· '''  | 
|     if packIndex not in ShareDefine.Def_VPack_TypeList:  | 
|         return  | 
|     for place in placeList:  | 
|         itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  | 
|         if not itemKeyData:  | 
|             continue  | 
|           | 
|         isNeedRecord = False  | 
|         itemID = 0  | 
|         itemName = ""  | 
|         if packIndex == ShareDefine.rptRune:  | 
|             itemID = ItemControler.GetRuneItemID(itemKeyData)  | 
|             plusLV = ItemControler.GetRuneItemPlusLV(itemKeyData)  | 
|             curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|             itemName = str(itemID) if not curItemData else  curItemData.GetName()  | 
|             itemName = "%s LV%s" % (itemName, plusLV + 1)  | 
|             isNeedRecord = curItemData and ItemControler.IsRuneItemNeedRecord(curItemData, plusLV)  | 
|         if packIndex == ShareDefine.rptGatherSoul:  | 
|             itemID = ItemControler.GetGatherSoulItemID(itemKeyData)  | 
|             plusLV = ItemControler.GetGatherSoulItemPlusLV(itemKeyData)  | 
|             curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|             itemName = str(itemID) if not curItemData else  curItemData.GetName()  | 
|             itemName = "%s LV%s" % (itemName, plusLV + 1)  | 
|             isNeedRecord = curItemData and ItemControler.IsGatherSoulItemNeedRecord(curItemData, plusLV)  | 
|               | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_VPackItem % (packIndex, place), 0)  | 
|         if isNeedRecord:  | 
|             dataDict = {"ItemID":itemID, "ItemCount":1, "PlusLV":plusLV + 1}  | 
|             DR_DelItem(curPlayer, packIndex, "VPack_%s" % packIndex if not eventName else eventName, dataDict)  | 
|     ItemControler.Sync_VPackItem_Clear(curPlayer, packIndex, placeList)  | 
|     return  | 
|   | 
| ## »ñÈ¡ÎïÆ·×î¸ßÇ¿»¯µÈ¼¶  | 
| #  @param itemType: ÎïÆ·ÀàÐÍ  | 
| #  @return ×î´óÐǼ¶£¬0Ϊ²»¿ÉÇ¿»¯  | 
| def GetItemMaxPlusLV(curPlayer, equipPackindex, curItem):  | 
|     findType = ChEquip.GetEquipPlusType(curItem)  | 
|     if not findType:  | 
|         return 0  | 
|     equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, equipPackindex, curItem)  | 
|     ipyData = IpyGameDataPY.InterpolationSearch('ItemPlusMax', 'Star', equipStar, {'Type':findType})  | 
|     if not ipyData:  | 
|         return 0  | 
|     return ipyData.GetLevelMax()  | 
|       | 
|   | 
| ## »ñÈ¡ÎïÆ·×î¸ßÇ¿»¯½ø»¯µÈ¼¶  | 
| #  @param itemType: ÎïÆ·ÀàÐÍ  | 
| #  @return ×î´óÐǼ¶£¬0Ϊ²»¿ÉÇ¿»¯  | 
| def GetItemMaxPlusEvolveLV(curPlayer, equipPackindex, curItem):  | 
|     packType = IPY_GameWorld.rptEquip  | 
|     curPlusLV = ChEquip.GetEquipPartPlusLVByRank(curPlayer, packType, equipPackindex, curItem)  | 
|     equipPlace = curItem.GetEquipPlace()  | 
|     ipyData = IpyGameDataPY.InterpolationSearch('EquipPlusEvolve', 'NeedPlusLV', curPlusLV, {'EquipPlace':equipPlace})  | 
|     if not ipyData:  | 
|         return 0  | 
|     return ipyData.GetEvolveLV()  | 
|       | 
|   | 
| ## »ñÈ¡ÎïÆ·×î¸ßÐÇÊý  | 
| #  @param itemType: ÎïÆ·ÀàÐÍ  | 
| #  @return ×î´óÐǼ¶£¬0Ϊ²»¿ÉÇ¿»¯  | 
| def GetItemMaxStar(curItem):  | 
|     itemColor = curItem.GetItemColor()  | 
|     maxStarDict = IpyGameDataPY.GetFuncEvalCfg('EquipPartStar', 1)  | 
|     if str(itemColor) not in maxStarDict:  | 
|         return 0  | 
|     classLV = GetItemClassLV(curItem)  | 
|     return maxStarDict[str(itemColor)].get(str(classLV), 0)  | 
|   | 
| ## »ñÈ¡ÎïÆ·½×¼¶»òÆ·¼¶  | 
| def GetItemClassLV(curItem):  | 
|     return curItem.GetLV()  | 
|   | 
| def GetWingLV(curItem):  | 
|     ## »ñÈ¡³á°ò´úÊýµÈ¼¶  | 
|     wingLVDict = IpyGameDataPY.GetFuncEvalCfg("WingLV", 1)  | 
|     return wingLVDict.get(str(curItem.GetLV()), 0)  | 
|   | 
| ## ×°±¸ÆÀ·Ö  | 
| def GetEquipGearScore(curItem):  | 
|     return curItem.GetGearScore()  | 
|   | 
| def SetEquipGearScore(curItem, value):  | 
|     return curItem.SetGearScore(value)  | 
|   | 
| def GetEquipPackIndex(curItem):  | 
|     ## ¸ù¾ÝÎïÆ·»ñÈ¡¶ÔÓ¦µÄ¿É×°±¸±³°üλÖà  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('EquipPlaceIndexMap', GetItemClassLV(curItem), curItem.GetEquipPlace())  | 
|     if not ipyData:  | 
|         return -1  | 
|     return ipyData.GetGridIndex()  | 
|   | 
| ## Ã¿ÈÕ¿ÉʹÓôÎÊý  | 
| def GetCanUseCountDaily(curItem): return curItem.GetMaxAddSkillCnt()  | 
| ## Ã¿ÖÜ¿ÉʹÓôÎÊý, Ô¤Áô£¬Ôݲ»ÊµÏÖ  | 
| #def GetCanUseCountWeek(curItem): return curItem.GetMaxFitLV()  | 
|   | 
| ## »ñÈ¡·¢ËÍÓʼþÎïÆ·×ÖµäÐÅÏ¢  | 
| def GetMailItemDict(curItem):  | 
|     if not curItem or curItem.IsEmpty():  | 
|         return {}  | 
|       | 
|     isAuctionItem = ItemControler.GetIsAuctionItem(curItem)  | 
|     if not CheckItemIsEquip(curItem):  | 
|         return [curItem.GetItemTypeID(), curItem.GetCount(), isAuctionItem]  | 
|       | 
|     addItemDict = {}  | 
|     addItemDict['ItemID'] = curItem.GetItemTypeID()  | 
|     addItemDict['Count'] = curItem.GetCount()  | 
|     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['MaxDurg'] = GameWorld.GetIntUpper(curItem.GetMaxEndure(), ChConfig.Def_EndureRepairParameter)  | 
|     #addItemDict['ItemProperty'] = curItem.GetItemProperty()  | 
|     #addItemDict['SoulProperty'] = curItem.GetSoulProperty()  | 
|     #addItemDict['CanPlaceStoneCount'] = curItem.GetCanPlaceStoneCount()  | 
|     #addItemDict['Stone1'] = curItem.GetStone(0)  | 
|     #addItemDict['Stone2'] = curItem.GetStone(1)  | 
|     #addItemDict['Stone3'] = curItem.GetStone(2)  | 
|     #addItemDict['Stone4'] = curItem.GetStone(3)  | 
|     #addItemDict['Stone5'] = curItem.GetStone(4)  | 
|     #addItemDict['Stone6'] = curItem.GetStone(5)  | 
|     #addItemDict['Stone7'] = curItem.GetStone(6)  | 
|     #addItemDict['Stone8'] = curItem.GetStone(7)  | 
|     #addItemDict['Stone9'] = curItem.GetStone(8)  | 
|     #addItemDict['RemainHour'] = curItem.GetRemainHour()  | 
|     #addItemDict['IsRenZhu'] = curItem.GetCanRenZhu()  | 
|     #addItemDict['EquipDefenseValue'] = curItem.GetEquipDefenseValue()  | 
|     #addItemDict['EquipMinAtkValue'] = curItem.GetEquipMinAtkValue()  | 
|     #addItemDict['EquipMaxAtkValue'] = curItem.GetEquipMaxAtkValue()  | 
|     #addItemDict['FitLV'] = curItem.GetFitLV()  | 
|     #addItemDict['Proficiency'] = curItem.GetProficiency()  | 
|     #addItemDict['IsSuite'] = int(curItem.GetIsSuite())  | 
|     #addItemDict['BaseHP'] = curItem.GetBaseHP()  | 
|     #addItemDict['BaseMagicDef'] = curItem.GetBaseMagicDef()  | 
|     #addItemDict['MaxAddSkillCnt'] = curItem.GetMaxAddSkillCnt()  | 
|     #addItemDict['EquipMagicDefValue'] = curItem.GetEquipMagicDefValue()  | 
|     #addItemDict['EquipMinMagicAtkValue'] = curItem.GetEquipMinMagicAtkValue()  | 
|     #addItemDict['EquipMaxMagicAtkValue'] = curItem.GetEquipMaxMagicAtkValue()  | 
|     addItemDict['UserData'] = str(curItem.GetUserData())  | 
|     return addItemDict  | 
|   | 
| def GetJsonItem(itemInfo):  | 
|     '''»ñÈ¡ÎïÆ·ÐÅÏ¢¶ÔÓ¦µÄjsonÐÅÏ¢  | 
|     @param itemInfo: Ö§³ÖÁбí [itemID, itemCount, isAuctionItem], Ö§³Ö¶¯Ì¬ÁÐ±í³¤¶È£¬Ë÷Òý´ú±íÊôÐԹ̶¨  | 
|                         Ö§³ÖÎïÆ·ÊµÀý, Èç¹ûÊÇʾÀýʱ±ØÐëÔÚ¸øÍæ¼Ò֮ǰÏÈ»ñÈ¡³öÀ´£¬·ÀÖ¹¸øÍæ¼Òºó¸ÃÎïÆ·ÊµÀý±»Çå¿Õ  | 
|                           | 
|     @return: {"ItemID":101, "Count":10, "IsAuctionItem":1, "UserData":"×Ô¶¨ÒåÊôÐÔ×Ö·û´®"}  | 
|     '''  | 
|     itemDict = {}  | 
|     if isinstance(itemInfo, list) or isinstance(itemInfo, tuple):  | 
|         infolen = len(itemInfo)  | 
|         if infolen > 0:  | 
|             itemDict["ItemID"] = itemInfo[0]  | 
|         if infolen > 1 and itemInfo[1] > 1:  | 
|             itemDict["Count"] = itemInfo[1]  | 
|         if infolen > 2 and itemInfo[2]:  | 
|             itemDict["IsAuctionItem"] = int(itemInfo[2])  | 
|     elif isinstance(itemInfo, int):  | 
|         itemDict["ItemID"] = itemInfo  | 
|     else: #ÎïÆ·ÊµÀý  | 
|         if not CheckItemCanUse(itemInfo):  | 
|             # ÐèÒªÏÈ»ñÈ¡ÐÅÏ¢£¬ÔÙ¸øÎïÆ·£¬²»ÄÜ¿ÉÄܵ¼Ö¸øÎïÆ·ºó£¬ÔÀ´µÄÁÙʱÎïÆ·±»Çå¿Õ£¬µ¼ÖÂÎÞ·¨Õý³£»ñµÃÎïÆ·ÐÅÏ¢  | 
|             GameWorld.ErrLog("ÎïÆ·Îª¿Õ!ÎÞ·¨»ñÈ¡JsonItemÐÅÏ¢!")  | 
|             return {}  | 
|         itemDict["ItemID"] = itemInfo.GetItemTypeID()  | 
|         if itemInfo.GetCount() > 1:  | 
|             itemDict["Count"] = itemInfo.GetCount()  | 
|         if ItemControler.GetIsAuctionItem(itemInfo):  | 
|             itemDict["IsAuctionItem"] = 1  | 
|         if itemInfo.GetUserData():  | 
|             itemDict["UserData"] = itemInfo.GetUserData()  | 
|     return itemDict  | 
|   | 
| def GetWeightItemListByAlchemyDiffLV(curPlayer, weightList, alchemyDiffLV):  | 
|     ## ¸ù¾ÝÁ¶µ¤µÈ¼¶²îÒìµÈ¼¶¹ýÂËÈ¨ÖØÁбíÖв»Âú×ãµÄÎïÆ·£¬·µ»ØÐµÄÈ¨ÖØÁÐ±í  | 
|     resultWeightList = []  | 
|     if alchemyDiffLV:  | 
|         curAlchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV)  | 
|         for itemInfo in weightList:  | 
|             itemID = itemInfo[1][0]  | 
|             itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|             if not itemData:  | 
|                 continue  | 
|             if GetItemClassLV(itemData) > curAlchemyLV + alchemyDiffLV:  | 
|                 continue  | 
|             resultWeightList.append(itemInfo)  | 
|     else:  | 
|         resultWeightList = weightList  | 
|     return resultWeightList  | 
|   | 
| ## =======================================================================================  | 
|   | 
| def SyncMakeItemAnswer(curPlayer, makeType, isSuccess, makeItemID):  | 
|     makeItemAnswer = ChPyNetSendPack.tagMCMakeItemAnswer()  | 
|     makeItemAnswer.Clear()  | 
|     makeItemAnswer.MakeType = makeType  | 
|     makeItemAnswer.Result = isSuccess  | 
|     makeItemAnswer.MakeItemID = makeItemID  | 
|     NetPackCommon.SendFakePack(curPlayer, makeItemAnswer)  | 
|     return  | 
|   | 
|   |