| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package ItemControler  | 
| # @todo: ÎïÆ·¹ÜÀíÆ÷  | 
| #  | 
| # @author: eggxp  | 
| # @date 2017-07-28 14:00  | 
| # @version 1.0  | 
| #  | 
| # @note:   | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-07-28 14:00"""  | 
| #---------------------------------------------------------------------  | 
| import IPY_GameWorld  | 
| import GameWorld  | 
| import ChConfig  | 
| import PlayerControl  | 
| import ItemCommon  | 
| import ShareDefine  | 
| import traceback  | 
| import random  | 
| import ReadChConfig  | 
| import ChItem  | 
| import PlayerSuccess  | 
| import PlayerFamily  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import Operate_EquipStone  | 
| import PlayerFairyCeremony  | 
| import PlayerActBossTrial  | 
| import PlayerMagicWeapon  | 
| import IpyGameDataPY  | 
| import DataRecordPack  | 
| import PlayerGubao  | 
| import PyGameData  | 
| import EventShell  | 
| import PlayerVip  | 
| import ChEquip  | 
|   | 
| import math  | 
| import time  | 
| #---------------------------------------------------------------------  | 
|   | 
| ## »ñµÃ±³°üµÄÒ»¸ö¿Õ¸ñ×Ó  | 
| def GetItemPackSpaceIndex(curPlayer, packindex):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if item.IsEmpty():  | 
|             return i  | 
|       | 
|     return -1  | 
|   | 
|   | 
|   | 
| ## »ñµÃ±³°üÊ£Óà¿Õ¼ä  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetItemPackSpace(curPlayer, packindex):  | 
|     #ÎïÆ·±³°üÊÇ·ñÓÐÊ£Óà¿Õ¼ä  | 
|     itemSpace = 0  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if item.IsEmpty():  | 
|             itemSpace += 1  | 
|       | 
|     return itemSpace  | 
|   | 
| ## ¼ì²é±³°üÊÇ·ñÓÐÊ£Óà¿Õ¼ä   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckPackHasSpace(curPlayer, packindex=IPY_GameWorld.rptItem, isNotify=False):  | 
|     #ÎïÆ·±³°üÊÇ·ñÓÐÊ£Óà¿Õ¼ä  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if item.IsEmpty():  | 
|             return True  | 
|           | 
|     if isNotify:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packindex])  | 
|           | 
|     return False  | 
|   | 
|   | 
| ## ¼ì²éÊÇ·ñΪ¿ÕµÄ±³°ü  | 
| #  @param itemPack ±³°ü  | 
| #  @return True£¨Ã»ÓÐÈκζ«Î÷£© or None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetPackIsEmpty(itemPack):  | 
|     for i in range(itemPack.GetCount()):  | 
|         item = itemPack.GetAt(i)  | 
|         #ÓÐÎïÆ·  | 
|         if not item.IsEmpty() :  | 
|             return  | 
|       | 
|     return True  | 
|   | 
|   | 
| ## ÕÒµ½ÎïÆ·ÊýÁ¿  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @param id ²éÕÒµÄID   | 
| #  @return value  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def FindPlayerItemCountByItemID(curPlayer, packindex, id):  | 
|     value = 0  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if not ItemCommon.CheckItemCanUse(item):  | 
|             continue  | 
|           | 
|         if item.GetItemTypeID() == id:  | 
|             value += item.GetCount()  | 
|               | 
|     return value  | 
|   | 
|   | 
| ## ÕÒµ½ÎïÆ·(ͨ¹ýID)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @param id ²éÕÒµÄID  | 
| #  @return None or Item  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def FindPlayerItemByItemID(curPlayer, packindex, id):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if not ItemCommon.CheckItemCanUse(item):  | 
|             continue  | 
|           | 
|         if item.GetItemTypeID() == id:  | 
|             return item  | 
|           | 
|     return None  | 
|   | 
| ## ÕÒµ½ÎïÆ·(ͨ¹ýЧ¹ûID)   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @param id ²éÕÒµÄЧ¹ûID  | 
| #  @return None or Item  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def FindPlayerItemByEffID(curPlayer, packindex, id):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|           | 
|         if not ItemCommon.CheckItemCanUse(item):  | 
|             continue  | 
|           | 
|         effect = item.GetEffectByIndex(0)  | 
|           | 
|         if effect == None:  | 
|             continue  | 
|           | 
|         if effect.GetEffectID() == id:  | 
|             return item  | 
|           | 
|     return None  | 
|   | 
|   | 
| ## ¼ì²éÊÇ·ñ¿ÉÒÔ»»ÂíÆ¥  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckCanEquipHorse(curPlayer):  | 
|     if curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvHorse :  | 
|         #DJ_Res_Horses_AlreadyEquip  ¶Ô²»Æð£¬Äú´¦ÓÚÆïÂí״̬ÖÐ,²Ù×÷ÎÞЧ  | 
|         PlayerControl.NotifyCode(curPlayer, "DJ_Res_Horses_AlreadyEquip")  | 
|         return  | 
|       | 
|     horsePack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptHorse)  | 
|     if not GetPackIsEmpty(horsePack):  | 
|         #Horses_Bag_NoRoom ¶Ô²»Æð£¬ÄúµÄÂíÆ¥±³°üÖÐÓÐÎïÆ·,²Ù×÷ÎÞЧ!  | 
|         PlayerControl.NotifyCode(curPlayer, "Horses_Bag_NoRoom")  | 
|         return  | 
|       | 
|     return True  | 
|   | 
| #===============================================================================  | 
| # #½«ÎïÆ··ÅÈëÔöÖµÀ¸µÄÒ»¸ö¿ÕλÖÃÖÐ,Èç¹ûʧ°Ü,Ìæ»»µÚÒ»¸öλÖà  | 
| # #ÈÎÎñÎïÆ·:  | 
| # #1.ÈÎÎñÎïÆ·ÎÞ·¨Òƶ¯µ½°ü¹üÀ¸ÍâµÄÆäËûÎïÆ·´æ·ÅλÖ㨰üÀ¨²Ö¿â¡¢À¬»øÏ䣩  | 
| # #2.ÈÎÎñÎïÆ·ÎÞ·¨³öÊÛ£¬É¾³ý£¬½»Òס¢Ê¹Óã¬×°±¸¡££¨Ò²¾ÍÊÇÎÞ·¨ÓÉÍæ¼ÒÊÖ¶¯ÒƳö°ü¹üÀ¸£©  | 
| # #if ItemControler.IsEventItem(item) == True:  | 
| # #    return  | 
| #===============================================================================  | 
| ## ÊÇ·ñÈÎÎñÎïÆ·   | 
| #  @param item µ±Ç°ÎïÆ·  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def IsEventItem(item):  | 
|     return (item.GetType() == ChConfig.Def_ItemType_MissionItem)  | 
|   | 
| ## É¾³ýÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @param id ID  | 
| #  @param count É¾³ýÊýÁ¿  | 
| #  @param delEventItem ÊÇ·ñɾ³ýÈÎÎñÎïÆ·  | 
| #  @param guidList  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DelPlayerItem(curPlayer, packindex, id, count, delEventItem=False, guidList=None):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     curDelCount = count     #µ±Ç°Ê£ÓàµÄÊýÁ¿  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|           | 
|         item = curPack.GetAt(i)  | 
|         if item.IsEmpty():  | 
|             continue  | 
|           | 
|         if item.GetItemTypeID() != id:  | 
|             continue  | 
|           | 
|         #¸ÃÎïÆ·Ëø¶¨²»ÄÜɾ³ý=========================================  | 
|         if item.GetIsLocked():  | 
|             continue  | 
|           | 
|         if not delEventItem  and IsEventItem(item):  | 
|             #GameWorld.Log("ÈÎÎñÎïÆ·²»ÄÜɾ³ý")  | 
|             continue  | 
|           | 
|         #¸ÃÎïÆ·¿ÉÒÔɾ³ý  | 
|         if item.GetCount() > curDelCount:  | 
|             #ÉíÉÏÎïÆ·±ÈҪɾ³ýµÄÎïÆ·¶à  | 
|             SetItemCount(item, item.GetCount() - curDelCount)  | 
|             return True  | 
|           | 
|         elif item.GetCount() == curDelCount:  | 
|             #Ö±½ÓÇå¿ÕÕâ¸öÎïÆ·  | 
|             if guidList != None:   | 
|                 guidList.append(item.GetGUID())  | 
|             item.Clear()  | 
|             return True  | 
|           | 
|         else:  | 
|             #µ±Ç°ÎïÆ·²»¹»  | 
|             if guidList != None:   | 
|                 guidList.append(item.GetGUID())  | 
|                   | 
|             curDelCount = curDelCount - item.GetCount()  | 
|             item.Clear()  | 
|               | 
|             if curDelCount == 0:  | 
|                 return True  | 
|               | 
|     return False  | 
|   | 
|   | 
| ## É¾³ýÎïÆ·Åж¨°ó¶¨(²ÎÊý -> µ±Ç°Íæ¼Ò,±³°üË÷Òý,ID,ÊýÁ¿,ÊÇ·ñɾ³ýÈÎÎñÎïÆ·)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packindex ±³°üË÷Òý  | 
| #  @param id ID  | 
| #  @param count É¾³ýÊýÁ¿  | 
| #  @param isbind ÊÇ·ñÊǰó¶¨ÎïÆ·  | 
| #  @param delEventItem ÊÇ·ñɾ³ýÈÎÎñÎïÆ·  | 
| #  @param guidList  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DelPlayerItem_Bind(curPlayer, packindex, id, count, isbind, delEventItem=False, guidList=None):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packindex)  | 
|     curDelCount = count     #µ±Ç°Ê£ÓàµÄÊýÁ¿  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|           | 
|         item = curPack.GetAt(i)  | 
|         if not ItemCommon.CheckItemCanUse(item):  | 
|             continue  | 
|           | 
|         if item.GetItemTypeID() != id:  | 
|             continue  | 
|           | 
|         if not delEventItem  and IsEventItem(item):  | 
|             #GameWorld.Log("ÈÎÎñÎïÆ·²»ÄÜɾ³ý")  | 
|             continue  | 
|           | 
|         #ɾ³ý²»°ó¶¨µÄ²¢ÇÒÎïÆ·Êǰ󶨵쬲»´¦Àí  | 
|         if not isbind and item.GetIsBind():  | 
|             continue  | 
|           | 
|         #¸ÃÎïÆ·¿ÉÒÔɾ³ý  | 
|         if item.GetCount() > curDelCount:  | 
|             #ÉíÉÏÎïÆ·±ÈҪɾ³ýµÄÎïÆ·¶à  | 
|             SetItemCount(item, item.GetCount() - curDelCount)  | 
|             return True  | 
|           | 
|         elif item.GetCount() == curDelCount:  | 
|             #Ö±½ÓÇå¿ÕÕâ¸öÎïÆ·  | 
|             if guidList != None:   | 
|                 guidList.append(item.GetGUID())  | 
|             item.Clear()  | 
|             return True  | 
|           | 
|         else:  | 
|             #µ±Ç°ÎïÆ·²»¹»  | 
|             if guidList != None:   | 
|                 guidList.append(item.GetGUID())  | 
|                   | 
|             curDelCount = curDelCount - item.GetCount()  | 
|             item.Clear()  | 
|               | 
|             if curDelCount == 0:  | 
|                 return True  | 
|               | 
|     return False  | 
|   | 
| ## ÊÇ·ñÄܵþ¼Ó(ÎïÆ·ÀàÐÍ) ÏàͬÎïÆ·£¬Ïàͬ°ó¶¨  | 
| #  @param srcItemID ÆðµãÎïÆ·ID,  | 
| #  @param srcItemIsBind ÆðµãÎïÆ·ÊÇ·ñ°ó¶¨  | 
| #  @param destItemID Ä¿±êÎïÆ·ID  | 
| #  @param destItemIsBind Ä¿±êÎïÆ·ÊÇ·ñ°ó¶¨  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CanPackItemByItemType(srcItemID, srcItemIsBind, destItemID, destItemIsBind):  | 
|     ## ÅÄÆ·ÏîÄ¿£¬Ö»ÓзÇÅÄÆ·¿É¶Ñµþ£¬¼´°ó¶¨ÎïÆ·  | 
|     # 20201223 Ö÷¸ÉÈ¡ÏûÅÄÆ·ÓÐЧʱ³¤É趨  | 
|     #if srcItemID == destItemID and srcItemIsBind == destItemIsBind and not srcItemIsBind:  | 
|     if srcItemID == destItemID and srcItemIsBind == destItemIsBind:  | 
|         return True  | 
|     return False  | 
|   | 
| ## ÊÇ·ñÄܵþ¼Ó(ÎïÆ·ÊÇ·ñ°ó¶¨) ÏàͬÎïÆ·£¬²»Í¬°ó¶¨  | 
| #  @param srcItemID ÆðµãÎïÆ·ID,  | 
| #  @param srcItemIsBind ÆðµãÎïÆ·ÊÇ·ñ°ó¶¨  | 
| #  @param destItemID Ä¿±êÎïÆ·ID  | 
| #  @param destItemIsBind Ä¿±êÎïÆ·ÊÇ·ñ°ó¶¨  | 
| #  @return True or False  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CanPackItemByItemBind(srcItemID, srcItemIsBind, destItemID, destItemIsBind):  | 
|     if srcItemID == destItemID and srcItemIsBind != destItemIsBind:  | 
|         return True  | 
|     return False  | 
|   | 
| ## ÅжÏ2¸öÎïÆ·ÊÇ·ñ¿ÉÒԶѵþ  | 
| #  @param srcItem ÆðµãÎïÆ·  | 
| #  @param destItem Ä¿±êÎïÆ·  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CanPackItem(srcItem, destItem):  | 
|     return CanPackItemByItemType(srcItem.GetItemTypeID(), srcItem.GetIsBind(), destItem.GetItemTypeID(), destItem.GetIsBind())  | 
|   | 
| ## °ó¶¨ÎïÆ·µÄ¶Ñµþ  | 
| #  @param srcItem ÆðµãÎïÆ·  | 
| #  @param destItem Ä¿±êÎïÆ·  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def CheckDragItemBind(srcItem, destItem):  | 
|     return CanPackItemByItemBind(srcItem.GetItemTypeID(), srcItem.GetIsBind(), destItem.GetItemTypeID(), destItem.GetIsBind())  | 
|   | 
| ## Í϶¯Åж¨   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param fromPackPlace Æðµã±³°üÀàÐÍ  | 
| #  @param fromIndex ÆðµãË÷Òý  | 
| #  @param toPackPlace Ä¿±ê±³°üÀàÐÍ  | 
| #  @param toIndex Ä¿±êË÷Òý  | 
| #  @param count  ÊýÁ¿  | 
| #  @return False or srcItem,destItem,putCount  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __CanDragItem(curPlayer, fromPackPlace, fromIndex, toPackPlace, toIndex, count):  | 
|     itemManager = curPlayer.GetItemManager()  | 
|     if fromPackPlace == IPY_GameWorld.rptDeleted or toPackPlace == IPY_GameWorld.rptDeleted:  | 
|         GameWorld.Log("CanDragItem -> ²»ÔÊÐí²Ù×÷ÒÑɾ³ýµÄÎïÆ· = %s" % (fromPackPlace) , curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     curPack = itemManager.GetPack(fromPackPlace)  | 
|     if curPack == None:  | 
|         GameWorld.Log("CanDragItem ->±³°üÒì³£ = %s" % (fromPackPlace) , curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     toPack = itemManager.GetPack(toPackPlace)  | 
|     if toPack == None:  | 
|         GameWorld.Log("CanDragItem ->Ä¿µÄ±³°üÒì³£ = %s" % (toPackPlace) , curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     if fromIndex >= curPack.GetCount() or fromIndex < 0:  | 
|         GameWorld.Log("CanDragItem ->³õʼ±³°üË÷ÒýÒì³£ = %s,%s" % (fromIndex, curPack.GetCount()) , curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     if toIndex >= toPack.GetCount() or toIndex < 0:  | 
|         GameWorld.Log("CanDragItem ->Ä¿µÄ±³°üË÷ÒýÒì³£ = %s,%s" % (toIndex, toPack.GetCount()) , curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     srcItem = curPack.GetAt(fromIndex)  | 
|     destItem = toPack.GetAt(toIndex)  | 
|     putCount = count  | 
|     #GameWorld.Log("fromPackPlace:%d,fromIndex:%d,toPackPlace:%d,toIndex:%d,count:%d"%(fromPackPlace, fromIndex, toPackPlace, toIndex, count))  | 
|     #¸ÃÎïÆ·Ëø¶¨²»Ö´ÐÐ==============================================  | 
|     if srcItem == None:  | 
|         #GameWorld.Log("ÆðʼÎïÆ·Îª²»´æÔÚ")  | 
|         return False  | 
|       | 
|     if destItem == None:  | 
|         #GameWorld.Log("Ä¿±êÎïÆ·Îª²»´æÔÚ")  | 
|         return False  | 
|       | 
|     if srcItem.IsEmpty():  | 
|         #GameWorld.Log("ÆðʼλÖÃΪ¿Õ")  | 
|         return False  | 
|       | 
|     #¸ÃÎïÆ·Ëø¶¨²»Ö´ÐÐ==============================================  | 
|       | 
|     if srcItem.GetIsLocked():  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")  | 
|         #GameWorld.Log("¸ÃÎïÆ·ÒÑËø¶¨")  | 
|         return False  | 
|       | 
|     if putCount > srcItem.GetCount():  | 
|         #Í϶¯µÄÎïÆ·ÊýÁ¿´óÓÚÆðʼλÖõÄÎïÆ·ÊýÁ¿  | 
|         #GameWorld.Log("Í϶¯µÄÎïÆ·ÊýÁ¿´óÓÚÆðʼλÖõÄÎïÆ·ÊýÁ¿")  | 
|         return False  | 
|       | 
|     if putCount < 0:  | 
|         #GameWorld.Log("Í϶¯ÎïÆ·ÊýÁ¿Îª0")  | 
|         return False  | 
|       | 
|     elif putCount == 0:  | 
|         putCount = srcItem.GetCount()  | 
|       | 
|     if fromPackPlace != toPackPlace and IsEventItem(srcItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")  | 
|         return False  | 
|       | 
|     if fromPackPlace != toPackPlace and IsEventItem(destItem):  | 
|         PlayerControl.NotifyCode(curPlayer, "itemuse_chenxin_31379")  | 
|         return False  | 
|       | 
|     return srcItem, destItem, putCount  | 
|   | 
| def ItemNeedRecord(curItem):  | 
|     '''ÅжÏÊÇ·ñÐèÒª¼Ç¼  | 
|         ¼Ç¼ÓÅÏȼ¶£º ¿ª¹Ø > ÐèÒª¼Ç¼µÄ > ²»ÐèÒª¼Ç¼µÄ > Î´ÖªÉ趨  | 
|     '''  | 
|     recordOpen = IpyGameDataPY.GetFuncCfg("ItemRecord", 1)  | 
|     if not recordOpen:  | 
|         #GameWorld.DebugLog("ÎïÆ·¼Ç¼Ϊ¿ªÆô!")  | 
|         return False  | 
|       | 
|     itemType = curItem.GetType()  | 
|     itemID = curItem.GetItemTypeID()  | 
|     itemTypeMinColorDict = IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 1)  | 
|     if itemType in itemTypeMinColorDict:  | 
|         minColor = itemTypeMinColorDict[itemType]  | 
|     else:  | 
|         minColor = itemTypeMinColorDict[0]  | 
|     if curItem.GetItemColor() >= minColor:  | 
|         #GameWorld.DebugLog("ÐèÒª¼Ç¼µÄÎïÆ·ÑÕÉ«! itemType=%s,color=%s" % (itemType, curItem.GetItemColor()))  | 
|         return True  | 
|       | 
|     if itemType in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 2) \  | 
|         or itemID in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 3):  | 
|         #GameWorld.DebugLog("ÐèÒª¼Ç¼µÄÎïÆ·ÀàÐÍ»òID! itemType=%s,itemID=%s" % (itemType, itemID))  | 
|         return True  | 
|       | 
|     if itemType in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 4) \  | 
|         or itemID in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 5):  | 
|         #GameWorld.DebugLog("²»ÐèÒª¼Ç¼µÄÎïÆ·ÀàÐÍ»òID! itemType=%s,itemID=%s" % (itemType, itemID))  | 
|         return False  | 
|       | 
|     #if itemType == ChConfig.Def_ItemType_Rune:  | 
|     #    return IsRuneItemNeedRecord(curItem, curItem.GetUserAttr(ShareDefine.Def_IudetRuneLV))  | 
|     defaultNeed = IpyGameDataPY.GetFuncCfg("ItemRecord", 2)  | 
|     #GameWorld.DebugLog("ÆäËû¹æÔò£¬Ê¹ÓÃĬÈϼǼÉ趨! defaultNeed=%s" % defaultNeed)  | 
|     return defaultNeed  | 
|   | 
| def ItemNotNeedRecord(curItem):  | 
|     ## ÊÇ·ñΪ²»ÐèÒª¼Ç¼µÄÎïÆ·  | 
|     itemType = curItem.GetType()  | 
|     itemID = curItem.GetItemTypeID()  | 
|     if itemType in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 4) \  | 
|         or itemID in IpyGameDataPY.GetFuncEvalCfg("ItemRecordRule", 5):  | 
|         #GameWorld.DebugLog("²»ÐèÒª¼Ç¼µÄÎïÆ·ÀàÐÍ»òID! itemType=%s,itemID=%s" % (itemType, itemID))  | 
|         return True  | 
|     return False  | 
|   | 
| #ÎïÆ·Ê¹Óõȼ¶ÅжÏ----------------------------------------------------------------  | 
| ## ÎïÆ·Ê¹Óõȼ¶ÅÐ¶Ï  | 
| #  @param curPlayer Íæ¼Ò  | 
| #  @param item ÎïÆ·  | 
| #  @param needNotify ÊÇ·ñÐèÒªÌáʾ  | 
| #  @return True or False  | 
| def CheckItemUseLV(curPlayer, item, needNotify=True):   | 
|     # È¡ÏûµÈ¼¶ÏÞÖÆµÄÎïÆ·  | 
|     if item.GetUserAttr(ShareDefine.Def_IudetCancelUseLimit) == 1:  | 
|         return True  | 
|       | 
|     if curPlayer.GetLV() < GetItemUseLV(item):  | 
|         if needNotify:  | 
|             PlayerControl.NotifyCode(curPlayer, "LvErr")  | 
|         return False  | 
|       | 
|     if curPlayer.GetReincarnationLv() < item.GetReincarnationLv():  | 
|         if needNotify:  | 
|             PlayerControl.NotifyCode(curPlayer, "07F159E1-0974-4946-BE4942EAB8B5DBBE")  | 
|         return False  | 
|       | 
|     itemUseRealmLimit = item.GetEventCanUse() # ´Ë×Ö¶ÎÔÝÓÃÓÚÏÞÖÆ¾³½çÌõ¼þ  | 
|     if curPlayer.GetOfficialRank() < itemUseRealmLimit:  | 
|         if needNotify:  | 
|             PlayerControl.NotifyCode(curPlayer, "RealmLimitUnuse")  | 
|         return False  | 
|       | 
|     return True  | 
|   | 
|   | 
| ## »ñµÃÎïÆ·µÄʹÓõȼ¶  | 
| #  @param curItem µ±Ç°ÎïÆ·  | 
| #  @return Ê¹Óõȼ¶  | 
| def GetItemUseLV(curItem):  | 
|       | 
|     initLV = curItem.GetUseLV()  | 
|     return initLV  | 
| #===============================================================================  | 
| #    itemType = curItem.GetType()  | 
| #      | 
| #    # [[Ö¸¶¨µÄÎïÆ·ÀàÐÍ,], µÈ¼¶¹«Ê½]  | 
| #    useLVByPlusItemType, useLVExp = ReadChConfig.GetEvalChConfig("UseItemLVLimitInfo")  | 
| #          | 
| #    # Ö¸¶¨ÎïÆ·ÀàÐ͵ÄʹÓõȼ¶£¬Ðè¸ü¾ßÇ¿»¯µÈ¼¶  | 
| #    if itemType not in useLVByPlusItemType:  | 
| #        return initLV  | 
| #   | 
| #    # ¼ÆËã³á°òʹÓõȼ¶²ÎÊý(plusLV, initLV)  | 
| #    plusLV = 0#curItem.GetItemStarLV()      | 
| #    return eval(useLVExp)  | 
| #===============================================================================  | 
|   | 
| #------------------------------------------------------------------  | 
| ## ÅжÏÊÇ·ñÊǹóÖØÆ·  | 
| #  @param itemMark µ±Ç°ÎïÆ·  | 
| #  @return ÊÇ·ñÊǹóÖØÆ·  | 
| def IsValuableItem(curItem):  | 
|     return False  | 
|   | 
|   | 
| ## Ö´ÐÐÍ϶¯ÎïÆ·Âß¼   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param fromPackPlace Æðµã±³°üλÖà  | 
| #  @param fromIndex ÆðµãË÷Òý  | 
| #  @param toPackPlace Ä¿±ê±³°üλÖà  | 
| #  @param toIndex Ä¿±êË÷Òý  | 
| #  @param count ÊýÁ¿  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DoDragItem(curPlayer, fromPackPlace, fromIndex, toPackPlace, toIndex, count):  | 
|     result = __CanDragItem(curPlayer, fromPackPlace, fromIndex, toPackPlace, toIndex, count)  | 
|       | 
|     if not result :  | 
|         return  | 
|       | 
|     srcItem, destItem, putCount = result  | 
|       | 
|     #1. Ä¿±êλÖÃΪ¿Õ  | 
|     if destItem.IsEmpty() == 1:  | 
|         #°ÑÆðʼµãµÄÎïÆ··Åµ½Ò»¸öÐÂλÖà  | 
|         if putCount == srcItem.GetCount():  | 
|             #ÎïÆ··ÅÈë¿ÕλÖÃ, ½»»»Î»Öà  | 
|             srcItem.Switch(destItem)  | 
|             return True  | 
|         else:  | 
|             needPutItem = ItemCommon.CreateSingleItem(srcItem.GetItemTypeID())  | 
|             if needPutItem == None:  | 
|                 GameWorld.Log("ÎïÆ· = %sÍ϶¯´´½¨Òì³£" % (srcItem.GetItemTypeID()) , curPlayer.GetPlayerID())  | 
|                 return  | 
|               | 
|             #"ÒòÍÏ×§²ð·Ö¶ø´´½¨ÎïÆ·",         //157  | 
|             if ItemNeedRecord(srcItem):  | 
|                 pass  | 
|               | 
|             #´´½¨Ä¿±êÎïÆ·  | 
|             destItem.AssignItem(needPutItem)  | 
|             #GameWorld.Log("´´½¨Ä¿±êÎïÆ·")  | 
|             SetItemCount(destItem, putCount)  | 
|             destItem.SetIsBind(srcItem.GetIsBind())  | 
|             SetItemCount(srcItem, srcItem.GetCount() - putCount)  | 
|               | 
|         return True  | 
|       | 
|     if destItem.GetIsLocked():  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_644055")  | 
|         return  | 
|       | 
|     maxPackCount = destItem.GetPackCount()  | 
|     #ÎïÆ·À¸±³°ü£¬  Á½±ßIDÏàͬ £¬ °ó¶¨×´Ì¬²»Ò»Ñù  | 
|     if (fromPackPlace == IPY_GameWorld.rptItem and toPackPlace == IPY_GameWorld.rptItem and CheckDragItemBind(srcItem, destItem) and maxPackCount > destItem.GetCount()):  | 
|         destRemainCount = destItem.GetPackCount() - destItem.GetCount()   | 
|         realPutCount = min(putCount, destRemainCount)  | 
|         if realPutCount <= 0:  | 
|             return  | 
|           | 
|         SetItemCount(srcItem, srcItem.GetCount() - realPutCount)  | 
|         SetItemCount(destItem, destItem.GetCount() + realPutCount)  | 
|           | 
|         #SetItemIsBind(destItem, True)  | 
|         return True  | 
|     #2. Ä¿±êλÖÃÓж«Î÷, ²¢ÇÒ¿ÉÒԶѵþ  | 
|     if (CanPackItem(srcItem, destItem) and maxPackCount > destItem.GetCount()):  | 
|         #¶Ñµþ  | 
|         destRemainCount = maxPackCount - destItem.GetCount()   | 
|         realPutCount = min(putCount, destRemainCount)  | 
|         if realPutCount <= 0:  | 
|             GameWorld.Log("ÎïÆ·¶ÑµþÒì³£ = %s,%s" % (putCount, destRemainCount) , curPlayer.GetPlayerID())  | 
|             return  | 
|           | 
| #        GameWorld.Log("realPutCount = %d putCount = %d fromPackPlace = %d toPackPlace = %d"%  | 
| #                                          (realPutCount, putCount, fromPackPlace, toPackPlace))  | 
|         if realPutCount != putCount and fromPackPlace != toPackPlace:  | 
|             #Èç¹û±³°ü²»Í¬£¬ ²¢ÇÒ²»ÄÜÈ«²¿·ÅÈ룬 ÄÇôʣÓàÎïÆ··ÅÈë¶ÔÏó±³°ü  | 
|             playerItemControl = PlayerItemControler(curPlayer)  | 
|             playerItemControl.PutInItem(toPackPlace, srcItem)  | 
|             return True  | 
|           | 
|   | 
|         if srcItem.GetCount() - realPutCount == 0:  | 
|             #"ÒòÍÏ×§²ð·Ö¶øÉ¾³ýÎïÆ·"         //157  | 
|             if ItemNeedRecord(srcItem):  | 
|                 pass  | 
|               | 
|         SetItemCount(srcItem, srcItem.GetCount() - realPutCount)  | 
|         SetItemCount(destItem, destItem.GetCount() + realPutCount)  | 
|           | 
|     #3. Ä¿±êλÖÃÓж«Î÷, ²»Äܶѵþ  | 
|     else:  | 
|         if fromPackPlace != toPackPlace:  | 
|             #Èç¹û±³°ü²»Í¬£¬ ²¢ÇÒ²»ÄÜÈ«²¿·ÅÈ룬 ÄÇôʣÓàÎïÆ··ÅÈë¶ÔÏó±³°ü  | 
|             playerItemControl = PlayerItemControler(curPlayer)  | 
|             playerItemControl.PutInItem(toPackPlace, srcItem)  | 
|             return True  | 
|         #½»»»Î»Öà  | 
|         srcItem.Switch(destItem)  | 
|     return True  | 
|   | 
| ## Í϶¯ÎïÆ·   | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param fromPackPlace Æðµã±³°üλÖà  | 
| #  @param fromIndex ÆðµãË÷Òý  | 
| #  @param toPackPlace Ä¿±ê±³°üλÖà  | 
| #  @param toIndex Ä¿±êË÷Òý  | 
| #  @param count ÊýÁ¿  | 
| #  @return None or True  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DragItem(curPlayer, fromPackPlace, fromIndex, toPackPlace, toIndex, count):  | 
|     if fromPackPlace == toPackPlace and fromIndex == toIndex:  | 
|         #ÆðʼλÖúÍÖÕֹλÖÃÏàͬ, ²»´¦Àí  | 
|         GameWorld.Log('###ÆðʼλÖúÍÖÕֹλÖÃÏàͬ, ²»´¦Àí')  | 
|         return  | 
|       | 
|     result = __DoDragItem(curPlayer, fromPackPlace, fromIndex, toPackPlace, toIndex, count)  | 
|       | 
|     if result != True:  | 
|         curPlayer.Notify_ItemPutFail(fromPackPlace, fromIndex, toPackPlace, toIndex)  | 
|         return  | 
|       | 
|     return result  | 
| #---------------------------------------------------------------------  | 
| #################################################################  | 
| #Íæ¼ÒµÄÎïÆ·¹ÜÀíÆ÷¿ØÖÆÀà  | 
| ## Íæ¼ÒµÄÎïÆ·¹ÜÀíÆ÷¿ØÖÆÀà  | 
| #  | 
| #  PyClassÀàµÄÏêϸ˵Ã÷.  | 
| class PlayerItemControler:  | 
|     __Player = None  | 
|     __PlayerItemManager = None  | 
|     __PlayerEquip = None  | 
|     __PlayerItem = None  | 
|       | 
|     ## ³õʼ»¯  | 
|     #  @param iPlayer Íæ¼Ò  | 
|     #  @return None  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def __init__(self, iPlayer):  | 
|         self.__Player = iPlayer  | 
|         self.__PlayerItemManager = self.__Player.GetItemManager()  | 
|         self.__PlayerEquip = self.__PlayerItemManager.GetPack(IPY_GameWorld.rptEquip)  | 
|         self.__PlayerItem = self.__PlayerItemManager.GetPack(IPY_GameWorld.rptItem)  | 
|         return  | 
|       | 
|     ## Íæ¼ÒÊÇ·ñÄÜ×°±¸ÎïÆ·   | 
|     #  @param curItem µ±Ç°ÎïÆ·  | 
|     #  @param needNotify ÊÇ·ñÐèҪ֪ͨ¿Í»§¶Ë  | 
|     #  @return ²¼¶ûÖµ  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def PlayerCanEquipItem(self, curItem, needNotify):  | 
|         curPlayer = self.__Player  | 
|         #·Ç·¨×°±¸¼ì²é  | 
|         if curItem.GetIsLocked():  | 
|             if needNotify:  | 
|                 PlayerControl.NotifyCode(curPlayer, "RescannotEquip")  | 
|               | 
|             return False  | 
|           | 
|         #ÈÎÎñÎïÆ·¼ì²é  | 
|         if IsEventItem(curItem):  | 
|             if needNotify:  | 
|                 PlayerControl.NotifyCode(curPlayer, "TaskRes")  | 
|               | 
|             return False  | 
|           | 
|         #Êý¾Ý¿âÖÐÊÇ1¿ªÊ¼  | 
| #        if curItem.GetEquipPlace() == 0:  | 
| #            if needNotify:  | 
| #                #ÎïÆ·²»ÄÜ×°±¸  | 
| #                PlayerControl.NotifyCode(curPlayer, "GeRen_hgg_595819")  | 
| #  | 
| #            return False  | 
|           | 
|         #Ö°Òµ¼ì²é  | 
|         if not ItemCommon.CheckJob(curPlayer, curItem):  | 
|             if needNotify:  | 
|                 PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_31379")  | 
|   | 
|             return False  | 
|   | 
|         #ÐÔ±ð¼ì²é  | 
|         curItemNeedSexReq = curItem.GetSexReq()  | 
|           | 
|         if curItemNeedSexReq != ChConfig.Def_PlayerSex_All and curItemNeedSexReq != curPlayer.GetSex() :  | 
|             if needNotify:  | 
|                 PlayerControl.NotifyCode(curPlayer, "SexErr")  | 
|   | 
|             return False  | 
|   | 
|         #µÈ¼¶¼ì²é  | 
|         if not CheckItemUseLV(curPlayer, curItem, needNotify):  | 
|             return False  | 
|           | 
|         #=======================================================================  | 
|         # #ÂíÆ¥¼ì²é  | 
|         # if curItem.GetType() == ChConfig.Def_Item_Type_Horse and not CheckCanEquipHorse(curPlayer):  | 
|         #    return False  | 
|         #=======================================================================  | 
|   | 
|       | 
|         return True  | 
|       | 
|       | 
|     ## ½»»»×°±¸  | 
|     #  @param curItem µ±Ç°ÎïÆ·  | 
|     #  @param equipPackIndex ×°±¸±³°ü¸ñ×Ó  | 
|     #  @return True or False  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.     | 
|     def SwitchEquip(self, curItem, equipPackIndex):  | 
|         curPlayer = self.__Player  | 
|         equipPack = self.__PlayerEquip  | 
|           | 
|         curEquip = equipPack.GetAt(equipPackIndex)  | 
|           | 
|         #GameWorld.Log("×°±¸Î»ÖÃ%d"%equipPlace)  | 
|         if curEquip.IsEmpty():  | 
|             return ItemCommon.PutIn(curPlayer, curEquip, curItem, IPY_GameWorld.rptEquip)  | 
|           | 
|         #°Ñ±³°üÖÐҪװ±¸ÎïÆ·È¡³ö£¬·ÅÈë×°±¸À¸µÄ¸ÃλÖà  | 
|         #°ÑжÏÂ×°±¸·ÅÈë±³°üҪװ±¸ÎïÆ·µÄλÖà  | 
|         if self.SwitchCanSpliceEquip(curEquip, curItem) != True:  | 
|             #curEquip.SetItemStarLV(0) # ½»»»ÏµÄ×°±¸ÐǼ¶ÉèÖÃΪ0  | 
|             return ItemCommon.SwitchItem(curPlayer, curEquip, curItem, IPY_GameWorld.rptEquip)  | 
|           | 
|         return False      | 
|       | 
|     # ¼ÆËã×°±¸µÄÕ䯷ÊýÁ¿  | 
|     def RefreshStartEquipCount(self):  | 
| #        curPlayer = self.__Player  | 
| #        count = 0  | 
| #        equipPack = self.__PlayerEquip  | 
| #        for i in xrange(equipPack.GetCount()):  | 
| #            curEquip = equipPack.GetAt(i)  | 
| #              | 
| #            if curEquip.IsEmpty():  | 
| #                continue  | 
| #              | 
| #            if not curEquip.GetItemQuality():  | 
| #                continue  | 
| #              | 
| #            count += 1  | 
| #              | 
| #        curPlayer.SetDict(ChConfig.Def_PlayerKey_StartEquipCnt, count)  | 
|         return  | 
|       | 
|     def GetStartEquipCount(self):  | 
|         return 0  | 
|         #curPlayer = self.__Player  | 
|         #return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StartEquipCnt)  | 
|   | 
|     ## ×°±¸µ±Ç°ÎïÆ·  | 
|     #  @param curItem µ±Ç°ÎïÆ·  | 
|     #  @param equipPackIndex ¿Í»§¶Ë·¢À´×°±¸Î»ÖÃ(IPY_GameWorld.retMax ´ú±í·þÎñÆ÷×Ô¶¯×°±¸)  | 
|     #  @return Ìæ»»µÄλÖà-1±íÊ¾Ìæ»»Ê§°Ü  | 
|     def EquipItem(self, curItem, equipPackIndex):  | 
|         if not self.PlayerCanEquipItem(curItem, True):  | 
|             return -1  | 
|           | 
|         classLV = ItemCommon.GetItemClassLV(curItem)  | 
|         equipPlace = curItem.GetEquipPlace()  | 
|           | 
|         curPlayer = self.__Player  | 
|         equipPack = self.__PlayerEquip  | 
|         equipItem = equipPack.GetAt(equipPackIndex)  | 
|         if not equipItem:  | 
|             return -1  | 
|         desItemID, desUserData = [0, ''] if equipItem.IsEmpty() else [equipItem.GetItemTypeID(), equipItem.GetUserData()]  | 
|         srcItemID, srcUserData = curItem.GetItemTypeID(), curItem.GetUserData()  | 
|           | 
|         befIsOrangeEquip = 1 if (not equipItem.IsEmpty() and equipItem.GetItemColor() >= ChConfig.Def_Quality_Orange) else 0  | 
|         aftIsOrangeEquip = 1 if curItem.GetItemColor() >= ChConfig.Def_Quality_Orange else 0  | 
|           | 
|         #--ÆäËû×°±¸ÎïÆ·---  | 
|         #itemColor = curItem.GetItemColor()  | 
|         result = self.SwitchEquip(curItem, equipPackIndex)  | 
|         if result:  | 
|             #´©´÷ij½×ijƷÖʵÄ×°±¸³É¾Í  | 
|             PlayerSuccess.DoEquipSuccessLogic(curPlayer, classLV)  | 
|             #»»×°±¦Ê¯´¦Àí  | 
|             Operate_EquipStone.DoMoveEquipStone(curPlayer, equipPackIndex)  | 
|             EventShell.EventRespons_EquipItem(curPlayer)  | 
|             dataDict = {'dotype':'EquipItem', 'desItemID':desItemID, 'desUserData':desUserData,'srcItemID':srcItemID,'srcUserData':srcUserData}  | 
|             DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_EquipChange, dataDict)  | 
|             self.__UpdEquipOrangeCount(befIsOrangeEquip, aftIsOrangeEquip)  | 
|               | 
|         self.RefreshStartEquipCount()  | 
|         return equipPlace if result else -1  | 
|       | 
|     def __UpdEquipOrangeCount(self, befIsOrangeEquip, aftIsOrangeEquip):  | 
|         #¸üгÈ×°ÊýÁ¿  | 
|         curPlayer = self.__Player  | 
|         befEquipOrangeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_EquipOrangeCount)  | 
|         aftEquipOrangeCount = max(0, befEquipOrangeCount + aftIsOrangeEquip - befIsOrangeEquip)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_EquipOrangeCount, aftEquipOrangeCount)  | 
|         GameWorld.DebugLog("¸üгÈ×°¼°ÒÔÉϼþÊý: befIsOrangeEquip=%s,aftIsOrangeEquip=%s,befEquipOrangeCount=%s,aftEquipOrangeCount=%s"   | 
|                            % (befIsOrangeEquip, aftIsOrangeEquip, befEquipOrangeCount, aftEquipOrangeCount))  | 
|         return  | 
|       | 
|     ## Ìæ»»¿ÉÒÔµþ¼ÓÎïÆ·Âß¼   | 
|     #  @param curEquip µ±Ç°×°±¸  | 
|     #  @param curItem µ±Ç°ÎïÆ·  | 
|     #  @return True or False  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def SwitchCanSpliceEquip(self, curEquip, curItem):  | 
|         #°ó¶¨ÊôÐÔ²»Í¬, ²»¿Éµþ¼Ó  | 
|         if curEquip.GetIsBind() != curItem.GetIsBind():  | 
|             return False  | 
|           | 
|         #Ч¹ûID²»Ò»Ñù, ²»¿Éµþ¼Ó  | 
|         if curItem.GetEffectByIndex(0).GetEffectID() != curEquip.GetEffectByIndex(0).GetEffectID():  | 
|             return False  | 
|           | 
|         #×°±¸µ±Ç°ÊýÁ¿  | 
|         euqipCount = curEquip.GetCount()  | 
|         #×°±¸¿Éµþ¼ÓÊýÁ¿  | 
|         equipPackCount = curEquip.GetPackCount()  | 
|           | 
|         #¶ÑµþÉÏÏÞΪ1, ²»¿Éµþ¼Ó  | 
|         if equipPackCount == 1 or curItem.GetPackCount() == 1:  | 
|             return False  | 
|           | 
|         #ÒѾÊÇ×î´ó¶Ñµþ, ²»¿Éµþ¼Ó  | 
|         if euqipCount >= equipPackCount:  | 
|             return False  | 
|           | 
|         #---Ö´Ðеþ¼ÓÎïÆ·Âß¼---  | 
|         itemCount = curItem.GetCount()  | 
|           | 
|         sumValue = euqipCount + itemCount  | 
|           | 
|         if sumValue <= equipPackCount:  | 
|             SetItemCount(curEquip, sumValue)  | 
|             curItem.Clear()  | 
|         else:  | 
|             SetItemCount(curEquip, equipPackCount)  | 
|             SetItemCount(curItem, sumValue - equipPackCount)  | 
|           | 
|         return True  | 
|       | 
|     ## Ð¶ÔØÎïÆ·   | 
|     #  @param equipIndex ×°±¸Ë÷Òý  | 
|     #  @param packIndex ±³°üË÷Òý  | 
|     #  @return equipID , equipPlace  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def UnEquipItem(self, equipIndex, packIndex):  | 
|         curPlayer = self.__Player  | 
|         equipItem = self.__PlayerEquip  | 
|         curEquip = equipItem.GetAt(equipIndex)  | 
|         #Ä¿±ê×°±¸¼ì²é  | 
|         if curEquip == None or curEquip.IsEmpty():  | 
|             return  | 
|           | 
|         equipID = curEquip.GetItemTypeID()  | 
|         userData = curEquip.GetUserData()  | 
|         equipPlace = curEquip.GetEquipPlace()  | 
|         suiteID = curEquip.GetSuiteID()  | 
|         itemClassLV = ItemCommon.GetItemClassLV(curEquip)  | 
|         #¸ÃÎïÆ·Ëø¶¨²»Ö´ÐÐ==============================================  | 
|         if curEquip.GetIsLocked():  | 
|             PlayerControl.NotifyCode(curPlayer, "RescannotEquip")  | 
|             return  | 
|           | 
|         if IsEventItem(curEquip):  | 
|             PlayerControl.NotifyCode(curPlayer, "TaskRes")  | 
|             return  | 
|           | 
|         #ÎïÆ·À¸±³°ü  | 
|         curPack = self.__PlayerItemManager.GetPack(IPY_GameWorld.rptItem)  | 
|           | 
|         if packIndex < 0 or packIndex >= curPack.GetCount():  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])  | 
|             return  | 
|           | 
|         curEquipCount = curEquip.GetCount()  | 
|           | 
|         #×°±¸Îªµ¥ÊýÁ¿ÎïÆ·ÎÞÐè±éÀú±³°üÅж¨£¬ÒÔÍÏÈëµÄij¸ö¸ñ×ÓÊÇ·ñ¿ÉÒÔÌî³äΪÅж¨ __CanDragItem  | 
|         #=======================================================================  | 
|         # if not self.CanPutInItem(IPY_GameWorld.rptItem, equipID, curEquipCount, curEquip.GetIsBind()):  | 
|         #    #GameWorld.Log("Íæ¼Ò±³°üÎÞ·¨·ÅÈëÕâ¸öÎïÆ·")  | 
|         #    return  | 
|         #=======================================================================  | 
|           | 
|         #ÉèÖÃÎïÆ·¼¤»î״̬ΪFalse  | 
|         #curEquip.SetIsSoulActive(False)  | 
| #        if curEquip.GetItemStarLV() != 0:  | 
| #            curEquip.SetItemStarLV(0) # ÍÑϵÄÎïÆ·ÐǼ¶ÉèÖÃΪ0  | 
|           | 
|         befIsOrangeEquip = 1 if curEquip.GetItemColor() >= ChConfig.Def_Quality_Orange else 0  | 
|         aftIsOrangeEquip = 0  | 
|           | 
|         #±³°üÎïÆ··ÅÈë²Ö¿â  | 
|         if not DragItem(curPlayer, IPY_GameWorld.rptEquip, equipIndex, IPY_GameWorld.rptItem, packIndex, curEquipCount):  | 
|             return  | 
|         self.RefreshStartEquipCount()  | 
|         self.__UpdEquipOrangeCount(befIsOrangeEquip, aftIsOrangeEquip)  | 
|           | 
|         # ¹ã²¥Ð¶×°  | 
|         if equipIndex in PlayerControl.GetFaceEquipIndexList(curPlayer) or equipPlace in ChConfig.Def_SyncEquipStateByIndex:  | 
|             curPlayer.Sync_UnEquipItem(equipID, equipIndex)  | 
|         if suiteID and itemClassLV == ChEquip.GetEquipFacadeClassLV(curPlayer):  | 
|             #Íѵ±Ç°Íâ¹Û½×µÄÌ××°  | 
|             ChEquip.ChangeEquipfacadeByClassLV(curPlayer, itemClassLV)  | 
|           | 
|         EventShell.EventRespons_EquipItem(curPlayer)  | 
|         dataDict = {'dotype':'UnEquipItem', 'equipID':equipID, 'userData':userData}  | 
|         DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_EquipChange, dataDict)  | 
| #===============================================================================  | 
| #        #destItemPlace = Ð¶ÏÂÎïÆ·µÄλÖà         | 
| #        destItemPlace = curPack.GetAt(packIndex)  | 
| #          | 
| #        if destItemPlace == None or destItemPlace.IsEmpty() == 0:  | 
| #            #жÏÂÄ¿±ê²»ÊÇ¿ÕµÄ  | 
| #            GameWorld.Log("жÏÂÄ¿±ê²»ÊǿյÄ")  | 
| #            return  | 
| #          | 
| #        destItemPlace.PutIn(curEquip)  | 
| #===============================================================================  | 
|         return equipID, equipPlace, itemClassLV  | 
|       | 
|     #ÊÇ·ñÄÜ·ÅÈëÎïÆ·(µÚ¼¸¸öÎïÆ·À¸, ÎïÆ·ÐòºÅ, ·ÅÈëµÄÎïÆ·, ·ÅÈëÎïÆ·ID,  ÎïÆ·ÊÇ·ñ°ó¶¨)  | 
| #===============================================================================  | 
| #    ´Ë´¦´úÂë¸Ä¶¯ÇëÉ÷ÖØ  | 
| #    Ð¡ÐÄ, Ð¡ÐÄ, Ð¡ÐÄ, Ð¡ÐÄ, Ð¡ÐÄ  | 
| #    eggxp  | 
| #===============================================================================  | 
|     def PutItemInVPack(self, packIndex, tagItem, event=["", False, {}]):  | 
|         # ÐéÄâ±³°ü, Ä¬Èϲ»×öµþ¼Ó  | 
|         curPlayer = self.__Player  | 
|         canPutInCnt = 1  | 
|         setItemKeyData = 0  | 
|         eventName, isForceEvent, addDict = event  | 
|         isNeedRecord = isForceEvent or ItemNeedRecord(tagItem)  | 
|         if packIndex == ShareDefine.rptRune:  | 
|             runeSource = tagItem.GetUserAttr(ShareDefine.Def_IudetRuneSource) or 1  | 
|             setItemKeyData = GetRuneItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetRuneLV), source=runeSource)  | 
|         elif packIndex == ShareDefine.rptGatherSoul:  | 
|             setItemKeyData = GetGatherSoulItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetGatherSoulLV))  | 
|   | 
|         refreshPlaceList = []  | 
|         for place in xrange(ItemCommon.GetVPackCnt(packIndex)):  | 
|             itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  | 
|             if itemKeyData:  | 
|                 continue  | 
|               | 
|             if isNeedRecord:  | 
|                 itemNoteDict = ItemCommon.GetItemNoteDict(tagItem, canPutInCnt)  | 
|                 noteDict = {"packIndex":packIndex, "packPlace":place, "ItemKeyData":setItemKeyData, "eventName":eventName}  | 
|                 noteDict.update(addDict)  | 
|                 ItemCommon.DR_GetItem(curPlayer, packIndex, "VPack_%s" % packIndex if not eventName else eventName, itemNoteDict, noteDict)  | 
|               | 
|             refreshPlaceList.append(place)  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_VPackItem % (packIndex, place), setItemKeyData)  | 
|             if tagItem.GetCount() > canPutInCnt:  | 
|                 SetItemCount(tagItem, tagItem.GetCount() - canPutInCnt)  | 
|             else:  | 
|                 tagItem.Clear()  | 
|                 break  | 
|               | 
|         #֪ͨ¿Í»§¶Ë  | 
|         if refreshPlaceList:  | 
|             Sync_VPackItem_Refresh(curPlayer, packIndex, refreshPlaceList)  | 
|   | 
|         if tagItem and not tagItem.IsEmpty():  | 
|             #tagItem.Clear()  | 
|             return False  | 
|         return True  | 
|       | 
|     def DoTransformItem(self, curPlayer, tagItem, event=["", False, {}]):  | 
|         ## ½«ÌØÊâÎïÆ·×ª»¯Îª¶ÔÓ¦ÊýÖµ  | 
|         itemID = tagItem.GetItemTypeID()  | 
|         itemCount = max(tagItem.GetUserAttr(ShareDefine.Def_IudetItemCount), tagItem.GetCount())  | 
|         eventName, isForceEvent, addDict = event  | 
|         if isForceEvent:  | 
|             pass  | 
|         addDict["reason_name_son"] = itemID  | 
|         addDict["GiveItemEvent"] = ChConfig.ItemGiveTypeDict.get(eventName, eventName) # »ñÈ¡¸ÃÎïÆ·µÄʼþ  | 
|         moneyEventName = ChConfig.Def_GiveMoney_TransformItem # »õ±ÒµÄʼþÀàÐÍ£¬ÒòΪ´«½øÀ´µÄʼþÀàÐÍÊÇÎïÆ·µÄ  | 
|         if tagItem.GetType() == ChConfig.Def_ItemType_AutoUseMoney:  | 
|             curEff = tagItem.GetEffectByIndex(0)  | 
|             moneyCount = curEff.GetEffectValue(0) * itemCount  | 
|             moneyType = curEff.GetEffectValue(1)  | 
|             PlayerControl.GiveMoney(curPlayer, moneyType, moneyCount, moneyEventName, addDict)  | 
|             return True  | 
|         if itemID not in ChConfig.Def_TransformItemIDList:  | 
|             return False  | 
|         if itemID == ChConfig.Def_ItemID_FamilyContribution:  | 
|             PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, itemCount, True, ShareDefine.Def_AddFAVReason_UseItem, True)  | 
|         elif itemID == ChConfig.Def_ItemID_SilverMoney:  | 
|             PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_FamilyActive:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_SP:  | 
|             PlayerControl.PlayerAddZhenQi(curPlayer, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_GoldPaper:  | 
|             PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, itemCount, moneyEventName, addDict)  | 
|         elif itemID == ChConfig.Def_ItemID_RealmPoint:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_RealmPoint, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_BossReborn:  | 
|             msgStr = str(itemCount)  | 
|             GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'AddBossRebornPoint', msgStr, len(msgStr))  | 
|         elif itemID == ChConfig.Def_ItemID_Ysog:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Ysog, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_SoulDust:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_SoulSplinters:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulSplinters, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_SoulCore:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulCore, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_Honor:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Honor, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_GoldMoney:  | 
|             PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, itemCount, moneyEventName, addDict)  | 
|         elif itemID == ChConfig.Def_ItemID_FuncSysPrivilege:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FuncSysPrivilege, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_FCPartyPoint:  | 
|             PlayerFairyCeremony.AddFCPartyPoint(curPlayer, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_BTGMPoint:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_BTGMPoint, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_GuShenMoney:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_GuShenMoney, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_GongdePoint:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_GongdePoint, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_FamilyFlagWarPoint:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyFlagWarPoint, itemCount)  | 
|         elif itemID == ChConfig.Def_ItemID_SuccessScore:  | 
|             PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SuccessSocre, itemCount, moneyEventName, addDict)  | 
|         return True  | 
|       | 
|     def __CrossServerPutInItem(self, packIndex, tagItem, event=["", False, {}]):  | 
|         ## ¿ç·þ»ñµÃÎïÆ·  | 
|         if packIndex not in [IPY_GameWorld.rptItem, ShareDefine.rptDogzItem]:  | 
|             #GameWorld.DebugLog("¿ç·þ»ñµÃÎïÆ·²»Í¬²½, packIndex=%s" % (packIndex))  | 
|             return  | 
|         curPlayer = self.__Player  | 
|         serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)  | 
|         itemData = [tagItem.GetItemTypeID(), tagItem.GetCount(), tagItem.GetIsBind(), tagItem.GetUserData()]  | 
|         itemMsg = {"PlayerID":curPlayer.GetPlayerID(), "ItemData":itemData, "PackIndex":packIndex, "Event":event}  | 
|         GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_PutInItem, itemMsg, [serverGroupID])  | 
|         return  | 
|       | 
|     ## ·ÅÈëÎïÆ·   | 
|     #  @param packIndex ±³°üË÷Òý  | 
|     #  @param tagItem ÎïÆ·  | 
|     #  @param defaultPile Ä¬ÈÏÊÇ·ñÏÈÅжÏÄÜ·ñ¶Ñµþ  | 
|     #  @return True or False  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def PutInItem(self, packIndex, tagItem, defaultPile=True, event=["", False, {}]):  | 
|         curPlayer = self.__Player  | 
|           | 
|         isEquip = ItemCommon.CheckItemIsEquip(tagItem)  | 
|         if isEquip:  | 
|             defaultPile = False # ×°±¸Ä¬Èϲ»Åж϶ѵþ  | 
|               | 
|         curItemData = GameWorld.GetGameData().GetItemByTypeID(tagItem.GetItemTypeID())  | 
|         if not curItemData:  | 
|             return False  | 
|           | 
|         if GameWorld.IsCrossServer():  | 
|             self.__CrossServerPutInItem(packIndex, tagItem, event)  | 
|             tagItem.Clear()  | 
|             return True  | 
|         packIndex = ChConfig.GetItemPackType(curItemData, packIndex)  | 
|           | 
|         tagItemCount = GetItemCount(tagItem)  | 
|         isAuctionItem = GetIsAuctionItem(tagItem)  | 
|         if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, isAuctionItem, defaultPile):  | 
|             GameWorld.DebugLog("±³°üÂú£¬²»ÄÜ·ÅÈëÎïÆ· count = %d"%GetItemCount(tagItem))  | 
|             tagItem.Clear()  | 
|             return False  | 
|           | 
|         isNeedRecord = False  | 
|         itemID = tagItem.GetItemTypeID()  | 
|         #¼¤»î³É¾ÍµÄµÀ¾ß  | 
|         if tagItem.GetType() in [ChConfig.Def_ItemType_ActiveMWItem, ChConfig.Def_ItemType_ActiveMWItem2]:  | 
|             PlayerMagicWeapon.DoActiveMW(curPlayer, tagItem.GetEffectByIndex(0).GetEffectValue(0))  | 
|             tagItem.Clear()  | 
|             return True  | 
|         itemEff = tagItem.GetEffectByIndex(0)  | 
|         #ÎïÆ·Ë鯬  | 
|         if itemEff.GetEffectID() == ChConfig.Def_Effect_ItemCount:  | 
|             SetItemCountByID(curPlayer, itemID, GetItemCountByID(curPlayer, itemID) + tagItemCount)  | 
|             tagItem.Clear()  | 
|             return True  | 
|         #¹Å±¦Ë鯬  | 
|         if itemEff.GetEffectID() == ChConfig.Def_Effect_GubaoPiece:  | 
|             gubaoID = itemEff.GetEffectValue(0)  | 
|             if gubaoID:  | 
|                 PlayerGubao.AddGubaoPiece(curPlayer, gubaoID, tagItemCount, itemID)  | 
|                 tagItem.Clear()  | 
|                 return True  | 
|         #Ö±ÉýVIP  | 
|         if itemEff.GetEffectID() == ChConfig.Def_Effect_VIPLVCard:  | 
|             isAutoUse = itemEff.GetEffectValue(1)  | 
|             if isAutoUse:  | 
|                 tagVIPLV = itemEff.GetEffectValue(0)  | 
|                 isOK, _ = PlayerVip.UpgradeVIPLV(curPlayer, tagVIPLV)  | 
|                 if isOK:  | 
|                     #GameWorld.DebugLog("Ö±ÉýVIPĬÈÏʹÓÃ")  | 
|                     tagItem.Clear()  | 
|                     return True  | 
|         #Ôö¼Ó¸±±¾´ÎÊý  | 
|         if itemEff.GetEffectID() == ChConfig.Def_Effect_AddFBCnt:  | 
|             isAutoUse = itemEff.GetEffectValue(1)  | 
|             if isAutoUse:  | 
|                 import FBCommon  | 
|                 mapID = itemEff.GetEffectValue(0)  | 
|                 FBCommon.AddFBCntByItem(curPlayer, itemID, mapID, tagItem.GetCount())  | 
|                 #GameWorld.DebugLog("Ôö¼Ó¸±±¾´ÎÊýĬÈÏʹÓÃ! mapID=%s" % mapID)  | 
|                 tagItem.Clear()  | 
|                 return True  | 
|         #»î¶¯µÀ¾ß×Ô¶¯×ª»¯  | 
|         if PlayerActBossTrial.CheckActItemAutoTransform(curPlayer, tagItem, itemID, tagItemCount):  | 
|             tagItem.Clear()  | 
|             return True  | 
|           | 
|         if itemID in ChConfig.Def_TransformItemIDList or tagItem.GetType() == ChConfig.Def_ItemType_AutoUseMoney:  | 
|             # Ö±½Óת»¯Îª¶ÔÓ¦»õ±ÒµÄÎïÆ·½öÔÚ·ÅÈë±³°üʱֱ½Óת»¯£¬·ñÔò»¹ÊÇÒÔÕæÊµÎïÆ·µÄÐÎʽ´æÔÚ£¬µ«¶ÑµþÉÏÏÞÐèÒª×öÌØÊâ´¦Àí  | 
|             if packIndex == IPY_GameWorld.rptItem:  | 
|                 self.DoTransformItem(curPlayer, tagItem, event)  | 
|                 tagItem.Clear() # ÐèÇå³ý£¬²»È»»áµ¼ÖÂÄÚ´æÐ¹Â¶  | 
|                 return True  | 
|             defaultPile = True  | 
|             maxPackCount = ChConfig.Def_UpperLimit_DWord # ×ª»¯ÎïÆ·µþ¼ÓÉÏÏÞ²»È¡ÎïÆ·±íµÄ, Ôݶ¨¶ÑµþÉÏÏÞ20ÒÚ  | 
|         # 20201223 Ö÷¸ÉÈ¡ÏûÅÄÆ·ÓÐЧʱ³¤É趨  | 
| #        elif isAuctionItem:  | 
| #            maxPackCount = tagItemCount  | 
| #            defaultPile = False # Ð·ÅÈëµÄÅÄÆ·Ö»ÄÜ·Å¿ÕλÖã¬ËùÒÔ²»Åж϶ѵþ  | 
| #            #isBind = False  | 
| #            isNeedRecord = True # ÅÄÆ·Òª¼Ç¼  | 
|         else:  | 
|             maxPackCount = curItemData.GetPackCount()  | 
|               | 
|         # ÐéÄâ±³°ü, Ä¬Èϲ»×öµþ¼Ó  | 
|         if packIndex in ShareDefine.Def_VPack_TypeList:  | 
|             return self.PutItemInVPack(packIndex, tagItem, event)  | 
|           | 
|         eventName, isForceEvent, addDict = event  | 
|   | 
|         #¼Ç¼´´½¨ÎïÆ·Ê±µÄµÇ¼Ìì  | 
|         if tagItem.GetItemTypeID() in ReadChConfig.GetEvalChConfig('OpenBoxByLoginDayCfg'):  | 
|             if tagItem.GetUserAttr(ShareDefine.Def_IudetCreateItemLoginDay) == 0:#ûÓÐÉèÖùý²ÅÉèÖà  | 
|                 tagItem.SetUserAttr(ShareDefine.Def_IudetCreateItemLoginDay, curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginDayCnt))  | 
|           | 
|         curPack = self.__PlayerItemManager.GetPack(packIndex)  | 
|         #itemFactory = GameWorld.GetItemFactory()  | 
|         #isBind = tagItem.GetIsBind()  | 
|         # Ä¿Ç°ÔÝÖ»¼Ç¼·ÅÈë±³°üµÄ  | 
|         if not isNeedRecord and packIndex in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure, ShareDefine.rptRune, ShareDefine.rptGatherSoul, ShareDefine.rptDogzItem]:  | 
|             isNeedRecord = ItemNeedRecord(tagItem) or isForceEvent  | 
|         putResult = False  | 
|           | 
|         #ĬÈÏÏȽøÐÐÎïÆ·¶Ñµþ  | 
|         if defaultPile:  | 
|             #Ïȶѵþ, ÔÙ·ÅÔÚ¿ÕλÖà  | 
|             #########################Åж϶ѵþ  | 
|             for i in xrange(0, curPack.GetCount()):  | 
|                 item = curPack.GetAt(i)  | 
|                 if item.IsEmpty() == True:  | 
|                     continue  | 
|       | 
|                 if (item.IsEmpty() == 0 and not CanPackItem(item, tagItem)):  | 
|                     continue  | 
|                 #¸ÃÎïÆ·Ëø¶¨²»Ö´ÐÐ==============================================  | 
|                 if item.GetIsLocked() == True:  | 
|                     continue  | 
|                   | 
|                 packItemCount = GetItemCount(item)  | 
|                 curItemCount = GetItemCount(tagItem)  | 
|                 canPutinCount = maxPackCount - packItemCount  | 
|                 if canPutinCount <= 0:  | 
|                     continue      | 
|                 #¿ÉÒÔ°Ú·Å  | 
|                 #¿É¶Ñµþ  | 
|                 if curItemCount > canPutinCount:                          | 
|                     updCount = packItemCount + canPutinCount  | 
|                     SetItemCount(item, updCount)  | 
|                     SetItemCount(tagItem, curItemCount - canPutinCount)  | 
|                       | 
|                     if isNeedRecord:  | 
|                         itemNoteDict = ItemCommon.GetItemNoteDict(item, canPutinCount, packItemCount, updCount)  | 
|                         ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)  | 
|                 else:  | 
|                     updCount = packItemCount + curItemCount  | 
|                     #¿ÉÒÔÍêÈ«¶Ñµþ  | 
|                     SetItemCount(item, updCount)  | 
|                     tagItem.Clear()  | 
|                     putResult = True  | 
|                       | 
|                     if isNeedRecord:  | 
|                         itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, updCount)  | 
|                         ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)  | 
|                           | 
|                     break  | 
|           | 
|         if putResult == True:  | 
|             #GameWorld.Log("ÒѾ³É¹¦·ÅÈë")  | 
|             #ÒѾ³É¹¦·ÅÈë  | 
|             return True  | 
|         ##########################ÅжϷÅÔÚ¿ÕλÖà  | 
|         for i in xrange(0, curPack.GetCount()):  | 
|             item = curPack.GetAt(i)  | 
|             if item.IsEmpty() != True:  | 
|                 continue  | 
|               | 
|             packItemCount = GetItemCount(item) # Îª0  | 
|             curItemCount = GetItemCount(tagItem)  | 
|             canPutinCount = maxPackCount - packItemCount  | 
|             if canPutinCount <= 0:  | 
|                 continue  | 
|             #¿ÉÒÔ°Ú·Å  | 
|             if curItemCount > canPutinCount:  | 
|                 #ÐèÒª´´½¨ÐÂÎïÆ··ÅÈë  | 
|                 curCreateItem = GetOutPutItemObj(tagItem.GetItemTypeID(), canPutinCount, isAuctionItem)  | 
|                 #×¢Òâ: ²»ÄÜÔÚÕâÀïAssignItem, ·ñÔò»áÓÐ2¸öÎïÆ·Ö¸ÕëÖ¸Ïòͬһ¸öÎïÆ·ÊµÀý . ¾Þ´óµÄ´íÎóÔÚÕâÒ»¾ä : curCreateItem.Assign(tagItem)  | 
|                 #Èç¹ûÊÇ×°±¸£¬ÄÇô maxPackCount Îª1 ÕâÀï»áÑ»·×Ô¶¯´´½¨ÐÂÎïÆ·£¬ËùÒÔÖ±½Ó GetOutPutItemObj ¼´¿É, Ôݲ»Ö§³Ö¶¨ÖÆ×°±¸²ð½â  | 
|                   | 
|                 item.AssignItem(curCreateItem)  | 
|                 SetItemCount(tagItem, curItemCount - canPutinCount)  | 
|                   | 
|                 if isNeedRecord:  | 
|                     itemNoteDict = ItemCommon.GetItemNoteDict(item, canPutinCount, packItemCount, canPutinCount)  | 
|                     ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)  | 
|             else:  | 
|                 #¿ÉÒÔ·ÅÏÂ  | 
|                 if isEquip:  | 
|                     self.CheckEquipAttr(packIndex, tagItem)  | 
|                       | 
|                 if tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitRoleItem:  | 
|                     item.PutIn(tagItem)  | 
|                 elif tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitSingleItem:  | 
|                     item.AssignItem(tagItem)  | 
|                 else:  | 
|                     GameWorld.Log("ÎïÆ· = %s·ÅÈë´íÎó" % (tagItem.GetItemTypeID()) , curPlayer.GetPlayerID())  | 
|                 putResult = True  | 
|                   | 
|                 if isNeedRecord:  | 
|                     itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, GetItemCount(item))  | 
|                     ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)  | 
|                 break  | 
|                                                   | 
|         #·ÅÈë¶«Î÷  | 
|         return putResult  | 
|       | 
|     def CheckEquipAttr(self, packType, curItem):  | 
|         legendAttrIDCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)  | 
|         legendAttrValueCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)  | 
|           | 
|         if legendAttrIDCount and legendAttrValueCount and legendAttrIDCount == legendAttrValueCount:  | 
|             return  | 
|           | 
|         curPlayer = self.__Player  | 
|         legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)  | 
|         if not legendAttrInfo:  | 
|             return  | 
|           | 
|         curPlayer = self.__Player  | 
|         srcScore = ItemCommon.GetEquipGearScore(curItem)  | 
|         SetEquipLegendAttr(curItem, legendAttrInfo)  | 
|         ItemCommon.MakeEquipGS(curItem)  | 
|         updScore = ItemCommon.GetEquipGearScore(curItem)  | 
|         GameWorld.DebugLog("´«ÆæÊôÐÔÒì³££¬ÖØÐÂË¢ÐÂÒ»´ÎÊôÐÔ: packType=%s,itemID=%s,srcScore=%s,updScore=%s"   | 
|                          % (packType, curItem.GetItemTypeID(), srcScore, updScore), curPlayer.GetPlayerID())  | 
|         return  | 
|   | 
|     ## ÊÇ·ñÄÜ·ÅÈëÎïÆ·   | 
|     #  @param packIndex ±³°üË÷Òý  | 
|     #  @param curItemID µ±Ç°ÎïÆ·ID  | 
|     #  @param curItemCount µ±Ç°ÎïÆ·ÊýÁ¿  | 
|     #  @param isAuctionItem ÊÇ·ñÅÄÆ·  | 
|     #  @param defaultPile Ä¬ÈÏÏÈÅжÏÊÇ·ñÄܽøÐÐÎïÆ·¶Ñµþ  | 
|     #  @return True or False  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def CanPutInItem(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):  | 
|         if GameWorld.IsCrossServer():  | 
|             return True  | 
|         checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isAuctionItem, defaultPile)  | 
|         return checkRet  | 
|       | 
|     ## ÊÇ·ñÄÜ·ÅÈëÎïÆ·   | 
|     #  @param packIndex ±³°üË÷Òý  | 
|     #  @param curItemID µ±Ç°ÎïÆ·ID  | 
|     #  @param curItemCount µ±Ç°ÎïÆ·ÊýÁ¿  | 
|     #  @param isAuctionItem ÊÇ·ñÅÄÆ·  | 
|     #  @param defaultPile Ä¬ÈÏÏÈÅжÏÊÇ·ñÄܽøÐÐÎïÆ·¶Ñµþ  | 
|     #  @return True or False, µÚÒ»¸ö¿É·ÅÈëµÄλÖà  | 
|     #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
|     def CanPutInItemEx(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):  | 
|         gameData = GameWorld.GetGameData()  | 
|         curItemData = gameData.GetItemByTypeID(curItemID)  | 
|           | 
|         if curItemData == None :  | 
|             GameWorld.Log("ÕÒ²»µ½ItemID = %d" % curItemID)  | 
|             return False, 0   | 
|           | 
|         if IsPutinAutoTransformItem(curItemData):  | 
|             # »õ±ÒÖ±½Óת»»µÄÎïÆ·Èç¹ûÊÇ·ÅÈë±³°üµÄÔòÖ±½Óת»¯£¬ÎÞÐèÔÝÓøñ×Ó  | 
|             if packIndex == IPY_GameWorld.rptItem:  | 
|                 return True, 0  | 
|             maxPackCount = ChConfig.Def_UpperLimit_DWord # ×ª»¯ÎïÆ·µþ¼ÓÉÏÏÞ²»È¡ÎïÆ·±íµÄ, Ôݶ¨¶ÑµþÉÏÏÞ20ÒÚ  | 
|         elif isAuctionItem:  | 
|             maxPackCount = curItemCount  | 
|             defaultPile = False # Ð·ÅÈëµÄÅÄÆ·Ö»ÄÜ·Å¿ÕλÖã¬ËùÒÔ²»Åж϶ѵþ  | 
|         else:  | 
|             maxPackCount = curItemData.GetPackCount()  | 
|               | 
|         if maxPackCount == 0:  | 
|             GameWorld.Log("²ß»®Ìî±í´íÎó %s -> maxPackCount = %s" % (curItemID , maxPackCount))  | 
|             return False, 0  | 
|           | 
|         # ÌØÊâ´¦Àí²»Í¬µÄÎïÆ··ÅÈ벻ͬµÄ±³°ü£¬ÈçÉñÊÞ±³°ü  | 
|         packIndex = ChConfig.GetItemPackType(curItemData, packIndex)  | 
|           | 
|         maxCanPutItem = 0  | 
|         curPlayer = self.__Player  | 
|         # ÐéÄâ±³°ü  | 
|         if packIndex in ShareDefine.Def_VPack_TypeList:  | 
|             # ÐéÄâ±³°ü²»×ö¶ÑµþÖ§³Ö  | 
|             for place in xrange(ItemCommon.GetVPackCnt(packIndex)):  | 
|                 itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  | 
|                 if itemKeyData:  | 
|                     continue  | 
|                 maxCanPutItem += 1  | 
|                 if maxCanPutItem >= curItemCount:  | 
|                     return True, place  | 
|             return False, 0  | 
|           | 
|         itemIndex = -1  | 
|         curPack = self.__PlayerItemManager.GetPack(packIndex)  | 
|         for i in xrange(curPack.GetCount()):  | 
|             item = curPack.GetAt(i)  | 
|   | 
|             if item.IsEmpty():  | 
|                 maxCanPutItem += maxPackCount  | 
|                 if itemIndex == -1:  | 
|                     itemIndex = i  | 
|             else:  | 
|                 #Èç¹ûÐèÒªÅжϿɶѵþ  | 
|                 if defaultPile:  | 
|                     if item.GetIsLocked():  | 
|                         continue  | 
|       | 
|                     if (CanPackItemByItemType(item.GetItemTypeID(), item.GetIsBind(), curItemID, isAuctionItem) and  | 
|                         maxPackCount > GetItemCount(item)):  | 
|                         #¸ÃÎïÆ·Ëø¶¨²»Ö´ÐÐ==============================================  | 
|                         #¿É¶Ñµþ  | 
|                         maxCanPutItem += maxPackCount - GetItemCount(item)  | 
|                         if itemIndex == -1:  | 
|                             itemIndex = i  | 
|               | 
|             if maxCanPutItem >= curItemCount:  | 
|                 return True, itemIndex  | 
|               | 
|         if maxCanPutItem < curItemCount:  | 
|             return False, 0  | 
|         return True, itemIndex  | 
|       | 
| #==============================================================================  | 
| # ·ûÓ¡ÎïÆ·´æ´¢×ÖµäÊýÖµÊý¾Ý½á¹¹: Ç°5λΪÎïÆ·ID, 6~8λΪǿ»¯µÈ¼¶, µÚ9λΪÀ´Ô´£¨ÀϺÅ0,ĬÈÏ1£¬ºÏ³É2£©,µÚ10λΪÊÇ·ñËø¶¨  | 
| def GetRuneItemKeyData(itemID, RuneLV, lockState=0, source=1):  | 
|     lockState = 1 if lockState > 0 else 0  | 
|     return lockState * 1000000000 + source * 100000000 + min(RuneLV, 999) * 100000 + itemID  | 
| def GetRuneItemID(keyData): return keyData % 100000  | 
| def GetRuneItemPlusLV(keyData): return keyData % 100000000 / 100000  | 
| def GetRuneItemIsLock(keyData): return keyData / 1000000000  | 
| def GetRuneItemSource(keyData): return keyData % 1000000000 / 100000000  | 
| def IsRuneItemNeedRecord(curItem, plusLV):  | 
|     return plusLV > 0 or curItem.GetItemColor() >= ChConfig.Def_Quality_Orange  | 
|   | 
| # ¾Û»êÎïÆ·´æ´¢×ÖµäÊýÖµÊý¾Ý½á¹¹: Ç°5λΪÎïÆ·ID, 6~8λΪǿ»¯µÈ¼¶  | 
| def GetGatherSoulItemKeyData(itemID, GatherSoulLV):  | 
|     return min(GatherSoulLV, 999) * 100000 + itemID  | 
| def GetGatherSoulItemID(keyData): return keyData % 100000  | 
| def GetGatherSoulItemPlusLV(keyData): return keyData % 100000000 / 100000  | 
| def IsGatherSoulItemNeedRecord(curItem, plusLV):  | 
|     return plusLV > 0 or curItem.GetItemColor() >= ChConfig.Def_Quality_Orange  | 
|   | 
| def SetVPackItemKeyData(curPlayer, packIndex, place, keyData, isSync=True):  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_VPackItem % (packIndex, place), keyData)  | 
|     if isSync:  | 
|         if keyData > 0:  | 
|             Sync_VPackItem_Refresh(curPlayer, packIndex, [place])  | 
|         else:  | 
|             Sync_VPackItem_Clear(curPlayer, packIndex, [place])  | 
|     return  | 
|   | 
| def Sync_VPackItem_Refresh(curPlayer, packIndex, placeList=[]):  | 
|     if not placeList:  | 
|         placeList = xrange(ItemCommon.GetVPackCnt(packIndex))  | 
|     vpackRefresh = ChPyNetSendPack.tagMCVPackRefresh()  | 
|     vpackRefresh.Clear()  | 
|     vpackRefresh.PackType = packIndex  | 
|     for place in placeList:  | 
|         itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  | 
|         if not itemKeyData:  | 
|             # ¿ÕÎïÆ·²»Í¨Öª  | 
|             continue  | 
|         vpackItem = ChPyNetSendPack.tagMCVPackItem()  | 
|         vpackItem.Clear()  | 
|         vpackItem.ItemPlace = place  | 
|         vpackItem.ItemData = itemKeyData  | 
|         vpackRefresh.VPacklItemList.append(vpackItem)  | 
|     vpackRefresh.Count = len(vpackRefresh.VPacklItemList)  | 
|     NetPackCommon.SendFakePack(curPlayer, vpackRefresh)  | 
|     return  | 
|   | 
| def Sync_VPackItem_Clear(curPlayer, packIndex, placeList):  | 
|     if not placeList:  | 
|         return  | 
|     vpackClear = ChPyNetSendPack.tagMCVPackClear()  | 
|     vpackClear.Clear()  | 
|     vpackClear.PackType = packIndex  | 
|     vpackClear.ItemPlaceList = placeList  | 
|     vpackClear.Count = len(vpackClear.ItemPlaceList)  | 
|     NetPackCommon.SendFakePack(curPlayer, vpackClear)  | 
|     return  | 
|   | 
| def Sync_AutoItemCount(curPlayer, itemIDList=None):  | 
|     ## Í¨Öª×Ô¶¯×ª»¯ÎªÎïÆ·¸öÊýµÄÎïÆ·¸öÊýÐÅÏ¢  | 
|     if not itemIDList:  | 
|         force = False  | 
|         itemIDList = PyGameData.AutoTransformCountItemIDList  | 
|     else:  | 
|         force = True # Ö¸¶¨IDµÄÇ¿ÖÆÍ¨Öª  | 
|           | 
|     itemCountList = []  | 
|     for itemID in itemIDList:  | 
|         itemCount = GetItemCountByID(curPlayer, itemID)  | 
|         if not itemCount and not force:  | 
|             continue  | 
|         countInfo = ChPyNetSendPack.tagMCAutoItemCount()  | 
|         countInfo.Clear()  | 
|         countInfo.ItemID = itemID  | 
|         countInfo.ItemCount = itemCount  | 
|         itemCountList.append(countInfo)  | 
|           | 
|     if not itemCountList:  | 
|         return  | 
|       | 
|     clientPack = ChPyNetSendPack.tagMCAutoItemCountRefresh()  | 
|     clientPack.Clear()  | 
|     clientPack.ItemCountList = itemCountList  | 
|     clientPack.Count = len(clientPack.ItemCountList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| #// A3 09 ×ªÒÆÎïÆ·µ½ÆäËû±³°ü #tagCMDropItemToOtherPack  | 
| #  | 
| #struct tagCMDropItemToOtherPack  | 
| #{  | 
| #    tagHead         Head;  | 
| #    BYTE        SrcBackpack;    //Ô´±³°üÀàÐÍ  | 
| #    BYTE        DesBackPack;    //Ä¿±ê±³°üÀàÐÍ  | 
| #    WORD        SrcIndex;        //×ªÒÆÎïÆ·Ë÷ÒýλÖ㻵±È«²¿×ªÒÆÊ±´ËÖµÎÞЧ  | 
| #    BYTE        IsAll;        //ÊÇ·ñÈ«²¿×ªÒÆ          | 
| #};  | 
| def OnDropItemToOtherPack(index, clientData, tick):      | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     DropItemToOtherPack(curPlayer, clientData.SrcBackpack, clientData.DesBackPack, clientData.SrcIndex, clientData.IsAll)  | 
|     return  | 
|   | 
| def DropItemToOtherPack(curPlayer, fromPackIndex, desPackIndex, index, isAll=False):  | 
|     '''Í϶¯Ä³¸ö±³°üÎïÆ·µ½Íæ¼ÒÎïÆ·±³°ü  | 
|     '''  | 
|     movePack = curPlayer.GetItemManager().GetPack(fromPackIndex)  | 
|     if not movePack:  | 
|         return  | 
|       | 
|     itemControl = PlayerItemControler(curPlayer)  | 
|       | 
|     #Õû¸ö±³°ü×ªÒÆ  | 
|     if isAll:  | 
|         fullPackList = []  | 
|         for itemIndex in xrange(movePack.GetCount()):  | 
|             curItem = movePack.GetAt(itemIndex)  | 
|             if not curItem or curItem.IsEmpty():  | 
|                 continue  | 
|             toPackIndex = ChConfig.GetItemPackType(curItem, desPackIndex)  | 
|             if toPackIndex in fullPackList:  | 
|                 continue  | 
|             if not __DoDropItemToOtherPack(curPlayer, itemControl, fromPackIndex, toPackIndex, itemIndex, curItem):  | 
|                 if toPackIndex not in fullPackList:  | 
|                     fullPackList.append(toPackIndex)  | 
|                       | 
|         for fullPackIndex in fullPackList:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [fullPackIndex])  | 
|               | 
|     #µ¥¸öÎïÆ·×ªÒÆ  | 
|     else:  | 
|         curItem = movePack.GetAt(index)  | 
|         if not curItem or curItem.IsEmpty():  | 
|             return  | 
|         toPackIndex = ChConfig.GetItemPackType(curItem, desPackIndex)  | 
|         __DoDropItemToOtherPack(curPlayer, itemControl, fromPackIndex, toPackIndex, index, curItem)  | 
|     return  | 
|   | 
| def __DoDropItemToOtherPack(curPlayer, itemControl, fromPackIndex, toPackIndex, itemIndex, curItem):  | 
|     if itemControl.DoTransformItem(curPlayer, curItem):  | 
|         curItem.Clear()  | 
|         return True  | 
|     curItemTypeID = curItem.GetItemTypeID()  | 
|     #curItemGUID = curItem.GetGUID()  | 
|     curItemCount = curItem.GetCount()  | 
|     #curItemIsBind = curItem.GetIsBind()  | 
|     isAuctionItem = GetIsAuctionItem(curItem)  | 
|     #toPackIndex = ChConfig.GetItemPackType(curItem, toPackIndex)  | 
|       | 
|     # ³£¹æÎïÆ·×ªÒÆµ½ÐéÄâ·ûÓ¡±³°ü  | 
|     if toPackIndex == ShareDefine.rptRune:  | 
|         if not ItemCommon.CheckPackHasSpace(curPlayer, toPackIndex, True):  | 
|             return False  | 
|         return itemControl.PutItemInVPack(toPackIndex, curItem)  | 
|       | 
|     checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, isAuctionItem)  | 
|     if not checkRet:  | 
|         return False  | 
|     return DragItem(curPlayer, fromPackIndex, itemIndex, toPackIndex, putIndex, curItemCount)  | 
|   | 
| ## ±³°üÖØÕû  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packIndex ±³°üË÷Òý  | 
| #  @param beingIndex ¿ªÊ¼Î»ÖÃË÷Òý  | 
| #  @param endIndex ½áÊøÎ»ÖÃË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __DoResetItem(curPlayer, packIndex, beingIndex, endIndex, tick):  | 
|     #ÅжϿÉÒÔÕûÀíÎïÆ·µÄ״̬  | 
|     if curPlayer.GetPlayerAction() not in ChConfig.Def_Player_ResetItem_State:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_254483")  | 
|         #GameWorld.Log("µ±Ç°×´Ì¬ÎÞ·¨ÕûÀí±³°ü")  | 
|         return  | 
|           | 
|     # ÎÞÖ±½Ó½»Ò×  | 
|     #===========================================================================  | 
|     # if curPlayer.GetPlayerAction() == IPY_GameWorld.paEvent:  | 
|     #    #Èç¹ûÍæ¼ÒÔÚʼþÖÐ, ÌØÊâÔÙ´ÎÅж¨  | 
|     #    if curPlayer.GetForbiddenResetItem() != 0:  | 
|     #        PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_254483")  | 
|     #        return  | 
|     #===========================================================================  | 
|       | 
|     curPack = curPlayer.GetItemManager().GetPack(packIndex)  | 
|     if curPack == None:  | 
|         #GameWorld.Log("ÖØÕû±³°üÀàÐͲ»¶Ô")  | 
|         return  | 
|     if endIndex == 0:  | 
|         endIndex = curPack.GetCount() - 1  | 
|     #¼ì²éÊÇ·ñÄÜÕûÀí  | 
|     for i in range(0, curPack.GetCount()):  | 
|         curItem = curPack.GetAt(i)  | 
|         if curItem.GetIsLocked():  | 
|             #GameWorld.Log("ÎïÆ·ÓÐËø, ²»ÔÊÐíÖØÕû")  | 
|             return  | 
|       | 
|     # ÕûÀí·½Ê½²»Í¬Çø·Ö  | 
|     if packIndex == IPY_GameWorld.rptWarehouse:  | 
|         #ÑéÖ¤¼ä¸ô  | 
|         if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_WareHouseSort) < \  | 
|                 ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_WareHouseSort]:  | 
|             #ûµ½¼ä¸ô  | 
|             #GameWorld.DebugLog("ÖØÕû²Ö¿âʱ¼ä¼ä¸ôÌ«¶Ì")  | 
|             return  | 
|         curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_WareHouseSort, tick)  | 
|         ResetWareHouse(curPlayer, curPack, beingIndex, endIndex)  | 
|     else:  | 
|         if tick - curPlayer.GetResetItemTick() <= ChConfig.Def_ItemPackResetInterval:  | 
|             #GameWorld.DebugLog("ÖØÕû±³°üʱ¼ä¼ä¸ôÌ«¶Ì")  | 
|             return  | 
|           | 
|         curPlayer.SetResetItemTick(tick)  | 
|           | 
|         ResetRolePack(curPlayer, curPack, beingIndex, endIndex)  | 
|     #curPack.ResetPack(beingIndex, endIndex)    #C++°æ±³°üÕûÀí  | 
|     curPack.Sync_Refresh()  | 
|     return  | 
|      | 
| ## ±³°üÕûÀí  | 
| def ResetItem(curPlayer, packIndex, beingIndex, endIndex, tick):  | 
|   | 
|     #¿ªÊ¼ÕûÀí  | 
|     __DoResetItem(curPlayer, packIndex, beingIndex, endIndex, tick)  | 
|     curPlayer.Notify_PackResetOK()  | 
|     return  | 
|   | 
|   | 
| def ResetWareHouse(curPlayer, curPack, beingIndex, endIndex):  | 
|     itemDict = {}   # ID£º[[Ë÷Òý1£¬ÊýÁ¿1]£¬ [Ë÷Òý2£¬ÊýÁ¿2]]  | 
|       | 
|     # 1.ÏȱéÀúÒ»´Îµþ¼ÓÊýÁ¿£¬2.ÔÙ±éÀúн¨×ֵ䴿·ÅÎïÆ·ÁÐ±í£¬3.ÔÙ¸ù¾Ýsort¹æÔòÅÅÐò  | 
|     #µþ¼Ó´¦Àí  | 
|     for i in range(beingIndex, endIndex + 1):  | 
|         curRoleItem = curPack.GetAt(i)  | 
|         if curRoleItem.IsEmpty():  | 
|             continue  | 
|         curItem = curRoleItem.GetItem()   | 
|         itemID = curRoleItem.GetItemTypeID()  | 
|         if itemID not in itemDict:  | 
|             itemDict[itemID] = []  | 
|           | 
|         __ResetItem_AddItemInList(itemDict[itemID], curItem)  | 
|   | 
|     itemList = []     | 
|     equipGSList = []  | 
|     #×éºÏÁÐ±í  | 
|     for tmpList in itemDict.values():  | 
|         for tmpItem in tmpList:  | 
|             if ItemCommon.CheckNoteEquipGS(tmpItem):  | 
|                 equipGSList.append(tmpItem)  | 
|             else:  | 
|                 itemList.append(tmpItem)  | 
|   | 
|     equipGSList.sort(__CmpWareHouseEquip)  | 
|     itemList.sort(__CmpRolePack)  | 
|   | 
| #===============================================================================  | 
| #    GameWorld.DebugLog("equipGSList")  | 
| #    for item in equipGSList:  | 
| #        GameWorld.DebugLog("%s-%s"%(item.GetName(), [item.GetCount(), item.GetLV(), ItemCommon.GetEquipGearScore(item),   | 
| #                                                               item.GetItemColor(), item.GetItemQuality(),  | 
| #                                                               item.GetType(), item.GetItemTypeID() ]))  | 
| #   | 
| #    GameWorld.DebugLog("itemList")  | 
| #    for item in itemList:  | 
| #        GameWorld.DebugLog("%s-%s"%(item.GetName(), [item.GetCount(), item.GetLV(), ItemCommon.GetEquipGearScore(item),   | 
| #                                                               item.GetItemColor(), item.GetItemQuality(),  | 
| #                                                               item.GetType(), item.GetItemTypeID() ]))  | 
| #===============================================================================  | 
|   | 
|     curPack.WipePack(beingIndex, endIndex)  | 
|     putPlace = beingIndex  | 
|   | 
|     for item in equipGSList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     for item in itemList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     return  | 
|   | 
| def __CmpWareHouseEquip(item1, item2):  | 
|     # ²Ö¿â ½×Êý¸ß-ÑÕÉ«¸ß-ÐÇÊý¸ß - ×°±¸ÀàÐÍ - ID£¬ÄÚ²ã±È½Ï ÔÝʱ²»×öʱ¼äÅÐ¶Ï  | 
|     # ½×Êý GetLV»ñµÃ  | 
|       | 
|     if item1.GetLV() == item2.GetLV():  | 
|       | 
|         if item1.GetItemColor() == item2.GetItemColor():  | 
|             if item1.GetItemQuality() == item2.GetItemQuality():  | 
|                 itemType1 = item1.GetType()  | 
|                 itemType2 = item2.GetType()  | 
|                 if itemType1 == itemType2:  | 
|                     return cmp(item1.GetItemTypeID(), item2.GetItemTypeID())  | 
|                 else:  | 
|                     #ÀàÐÍÓж¨ÒåÅäÖÃ˳Ðò  | 
|                     typeList = IpyGameDataPY.GetFuncEvalCfg("DepotSortPriority", 1)  | 
|                     if itemType1 in typeList and itemType2 in typeList:  | 
|                         return cmp(typeList.index(item1.GetType()), typeList.index(item2.GetType()))  | 
|                     elif itemType1 in typeList:  | 
|                         #ÅÅÔÚÇ°Ãæ  | 
|                         return -1  | 
|                     elif itemType2 in typeList:  | 
|                         return 1  | 
|                     else:  | 
|                         return cmp(itemType1, itemType2)  | 
|             else:  | 
|                 return cmp(0-item1.GetItemQuality(), 0-item2.GetItemQuality())  | 
|         else:  | 
|             return cmp(0-item1.GetItemColor(), 0-item2.GetItemColor())  | 
|     else:  | 
|         return cmp(0-item1.GetLV(), 0-item2.GetLV())  | 
|     return  | 
|   | 
|   | 
| def ResetRolePack(curPlayer, curPack, beingIndex, endIndex):  | 
|     itemDict = {}   # ID£º[[Ë÷Òý1£¬ÊýÁ¿1]£¬ [Ë÷Òý2£¬ÊýÁ¿2]]  | 
|       | 
|     # 1.ÏȱéÀúÒ»´Îµþ¼ÓÊýÁ¿£¬2.ÔÙ±éÀúн¨×ֵ䴿·ÅÎïÆ·ÁÐ±í£¬3.ÔÙ¸ù¾Ýsort¹æÔòÅÅÐò  | 
|     #µþ¼Ó´¦Àí  | 
|     for i in range(beingIndex, endIndex + 1):  | 
|         curRoleItem = curPack.GetAt(i)  | 
|         if curRoleItem.IsEmpty():  | 
|             continue  | 
|         curItem = curRoleItem.GetItem()   | 
|         itemID = curRoleItem.GetItemTypeID()  | 
|         if itemID not in itemDict:  | 
|             itemDict[itemID] = []  | 
|           | 
|         __ResetItem_AddItemInList(itemDict[itemID], curItem)  | 
|   | 
|     itemList = []   # ·Ç×°±¸ÆÕͨÎïÆ·  | 
|     equipGSGreaterList = [] # ÊôÓÚ±¾Ö°ÒµµÄ¸ßÆÀ·Ö×°±¸  | 
|     equipGSLesserList = []  # µÍÆÀ·Ö×°±¸ºÍ·Ç±¾Ö°Òµ  | 
|     runeItemList = []   # ·ûÓ¡  | 
|       | 
|     #EquipGSTypeForSort  | 
|     equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     #×éºÏÁÐ±í  | 
|     for tmpList in itemDict.values():  | 
|         for tmpItem in tmpList:  | 
|             equipGS = 0  | 
|             cmpEquipGS = 0  | 
|   | 
|             if ItemCommon.CheckJob(curPlayer, tmpItem) and ItemCommon.CheckNoteEquipGS(tmpItem):  | 
|                 #ÐèÒª±È½ÏÆÀ·ÖµÄ×°±¸  | 
|                 equipGS = ItemCommon.GetEquipGearScore(tmpItem)  | 
|                 #²éÕÒµ±Ç°×°±¸±È½ÏGS  | 
|                 cmpItem = equipPack.GetAt(ItemCommon.GetEquipPackIndex(tmpItem))  | 
|                 if ItemCommon.CheckNoteEquipGS(cmpItem):  | 
|                     cmpEquipGS = ItemCommon.GetEquipGearScore(cmpItem)  | 
|             elif ItemCommon.CheckNoteEquipGS(tmpItem):  | 
|                 #·Ç±¾Ö°Òµ»òÕß²»¿ÉÓõÄ×°±¸  | 
|                 equipGS = 1  | 
|                 cmpEquipGS = 2  | 
|                   | 
|             if tmpItem.GetType() in [ChConfig.Def_ItemType_Rune, ChConfig.Def_ItemType_RuneExp]:  | 
|                 runeItemList.append(tmpItem)  | 
|             elif equipGS == 0:  | 
|                 itemList.append(tmpItem)  | 
|             elif equipGS > cmpEquipGS:  | 
|                 equipGSGreaterList.append(tmpItem)  | 
|             else:  | 
|                 equipGSLesserList.append(tmpItem)  | 
|   | 
|     equipGSGreaterList.sort(__CmpRolePack)  | 
|     itemList.sort(__CmpRolePack)  | 
|     equipGSLesserList.sort(__CmpRolePack)  | 
|     runeItemList.sort(__CmpRolePack)  | 
|       | 
|     #===========================================================================  | 
|     # GameWorld.DebugLog("equipGSGreaterList")  | 
|     # for item in equipGSGreaterList:  | 
|     #    GameWorld.DebugLog("%s-%s"%(item.GetName(), [item.GetCount(), ItemCommon.GetEquipGearScore(item),   | 
|     #                                                           item.GetItemColor(), item.GetItemQuality(),  | 
|     #                                                           item.GetType(), item.GetItemTypeID() ]))  | 
|     #   | 
|     # GameWorld.DebugLog("itemList")  | 
|     # for item in itemList:  | 
|     #    GameWorld.DebugLog("%s-%s"%(item.GetName(), [item.GetCount(), ItemCommon.GetEquipGearScore(item),   | 
|     #                                                           item.GetItemColor(), item.GetItemQuality(),  | 
|     #                                                           item.GetType(), item.GetItemTypeID() ]))  | 
|     #   | 
|     # GameWorld.DebugLog("equipGSLesserList")  | 
|     # for item in equipGSLesserList:  | 
|     #    GameWorld.DebugLog("%s-%s"%(item.GetName(), [item.GetCount(), ItemCommon.GetEquipGearScore(item),   | 
|     #                                                           item.GetItemColor(), item.GetItemQuality(),  | 
|     #                                                           item.GetType(), item.GetItemTypeID() ]))  | 
|     #===========================================================================  | 
|       | 
|     curPack.WipePack(beingIndex, endIndex)  | 
|     putPlace = beingIndex  | 
|       | 
|     for item in equipGSGreaterList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     for item in itemList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     for item in equipGSLesserList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     for item in runeItemList:  | 
|         curPack.GetAt(putPlace).AssignItem(item, False)  | 
|         putPlace += 1  | 
|           | 
|     return  | 
|   | 
|   | 
| def __CmpRolePack(item1, item2):  | 
|     # ×°±¸ÆÀ·Ö¸ß  ÆÀ·Ö0  ÆÀ·ÖµÍ£¬Íâ²ã·ÖÁÐ±í  | 
|     #===========================================================================  | 
|     # # ÑÕÉ«-ÐÇÊý - ×°±¸ÀàÐÍ - ID£¬ÄÚ²ã±È½Ï ÔÝʱ²»×öʱ¼äÅÐ¶Ï  | 
|     #   | 
|     # if item1.GetItemColor() == item2.GetItemColor():  | 
|     #    if item1.GetItemQuality() == item2.GetItemQuality():  | 
|     #        itemType1 = item1.GetType()  | 
|     #        itemType2 = item2.GetType()  | 
|     #        if itemType1 == itemType2:  | 
|     #            return cmp(item1.GetItemTypeID(), item2.GetItemTypeID())  | 
|     #        else:  | 
|     #            #ÀàÐÍÓж¨ÒåÅäÖÃ˳Ðò  | 
|     #            typeList = IpyGameDataPY.GetFuncEvalCfg("PackageSortPriority", 1)  | 
|     #            if itemType1 in typeList and itemType2 in typeList:  | 
|     #                return cmp(typeList.index(item1.GetType()), typeList.index(item2.GetType()))  | 
|     #            elif itemType1 in typeList:  | 
|     #                #ÅÅÔÚÇ°Ãæ  | 
|     #                return -1  | 
|     #            elif itemType2 in typeList:  | 
|     #                return 1  | 
|     #            else:  | 
|     #                return cmp(itemType1, itemType2)  | 
|     #    else:  | 
|     #        return cmp(0-item1.GetItemQuality(), 0-item2.GetItemQuality())  | 
|     # else:  | 
|     #    return cmp(0-item1.GetItemColor(), 0-item2.GetItemColor())  | 
|     #===========================================================================  | 
|   | 
|     # ×°±¸ÀàÐÍ-ÑÕÉ«-ÐÇÊý - ID£¬ÄÚ²ã±È½Ï ÔÝʱ²»×öʱ¼äÅÐ¶Ï  | 
|     itemType1 = item1.GetType()  | 
|     itemType2 = item2.GetType()  | 
|     if itemType1 == itemType2:  | 
|         if item1.GetItemColor() == item2.GetItemColor():  | 
|             if item1.GetItemQuality() == item2.GetItemQuality():  | 
|                 if item1.GetItemTypeID() == item2.GetItemTypeID():  | 
|                     if item1.GetIsBind() == item2.GetIsBind():  | 
|                         return -cmp(item1.GetCount(), item2.GetCount())  | 
|                     return -cmp(item1.GetIsBind(), item2.GetIsBind())  | 
|                 return cmp(item1.GetItemTypeID(), item2.GetItemTypeID())  | 
|             else:  | 
|                 return cmp(0-item1.GetItemQuality(), 0-item2.GetItemQuality())  | 
|         else:  | 
|             return cmp(0-item1.GetItemColor(), 0-item2.GetItemColor())  | 
|     else:  | 
|         #ÀàÐÍÓж¨ÒåÅäÖÃ˳Ðò  | 
|         typeList = IpyGameDataPY.GetFuncEvalCfg("PackageSortPriority", 1)  | 
|         if itemType1 in typeList and itemType2 in typeList:  | 
|             return cmp(typeList.index(item1.GetType()), typeList.index(item2.GetType()))  | 
|         elif itemType1 in typeList:  | 
|             #ÅÅÔÚÇ°Ãæ  | 
|             return -1  | 
|         elif itemType2 in typeList:  | 
|             return 1  | 
|         else:  | 
|             return cmp(itemType1, itemType2)  | 
|           | 
|           | 
|   | 
| def __ResetItem_AddItemInList(curList, addItem):  | 
|     #°ÑÎïÆ··Åµ½ÁбíÖÐ, ÒªÅжϵþ¼Ó  | 
|     itemCount = addItem.GetCount()  | 
|     packCount = addItem.GetPackCount()  | 
|       | 
|   | 
|     for curItem in curList:  | 
|         curCount = curItem.GetCount()  | 
|           | 
|         if not CanPackItem(curItem, addItem):  | 
|             continue  | 
|           | 
|         if curCount >= packCount:  | 
|             continue  | 
|         canPlaceCount = packCount - curCount  | 
|         if itemCount <= canPlaceCount:  | 
|             #¿ÉÒÔÈ«²¿·ÅÈë  | 
|             curItem.SetCount(itemCount + curCount)  | 
|             return  | 
|         curItem.SetCount(packCount)  | 
|         itemCount = itemCount - canPlaceCount  | 
|       | 
|     #      | 
|     if itemCount != 0:  | 
|         #·ÅÈ뵱ǰÎïÆ·  | 
|         addItem.SetCount(itemCount)  | 
|         curList.append(addItem)  | 
|    | 
|     return  | 
|   | 
|   | 
| #===============================================================================  | 
| #Python °æÖØÕûÎïÆ·  | 
| # def ResetItem(curPlayer, curPackIndex, tick):  | 
| #    if tick - curPlayer.GetResetItemTick() <= ChConfig.Def_ItemPackResetInterval:  | 
| #        GameWorld.Log("ÖØÕû±³°üʱ¼ä¼ä¸ôÌ«¶Ì")  | 
| #        return  | 
| #      | 
| #    curPlayer.SetResetItemTick(tick)  | 
| #      | 
| #    curPack = curPlayer.GetItemManager().GetPack(curPackIndex)  | 
| #    if curPack == None:  | 
| #        GameWorld.Log("ÖØÕû±³°üÀàÐͲ»¶Ô")  | 
| #        return  | 
| #      | 
| #    ##############################################################  | 
| #    #itemList ÄÚÈÝ:   | 
| #    #ÈÝÆ÷×¼±¸  | 
| #    #ÈÝÆ÷½á¹¹:  | 
| #    #-----------------dict key = Prior----|     -----------------dict key = Prior----|      -----------------dict key = Prior----|     -----------------dict key = Prior----|  | 
| #    #|    -----------          -----------|     |    -----------          -----------|      |    -----------        -------------|     |    -----------          -----------|  | 
| #    #|    -UnBind Item-        -Bind Item-|     |    -UnBind Item-        -Bind Item-|      |    -Bind Item-        -Unbind Item-|     |    -UnBind Item-        -Bind Item-|  | 
| #    #|    -----------          -----------|     |    -----------          -----------|      |    -----------        -------------|     |    -----------          -----------|  | 
| #    #-------------------------------------|     -------------------------------------|      -------------------------------------|     -------------------------------------|  | 
| #      | 
| #         | 
| #    #1. ×¼±¸Ò»¸ökeyΪÎïÆ·ÀàÐ͵Ä×Öµä  | 
| #    itemList = dict()  | 
| #    for i in range(curPack.GetCount()):  | 
| #        curRoleItem = curPack.GetAt(i)  | 
| #        if curRoleItem.IsEmpty():  | 
| #            continue  | 
| #        curItem = curRoleItem.GetItem()   | 
| #        itemType = curItem.GetType()  | 
| #          | 
| #        if not itemList.has_key(itemType) :  | 
| #            itemList[itemType] = list()  | 
| #            itemList[itemType].append(list())   #δ°ó¶¨ÎïÆ·  | 
| #            itemList[itemType].append(list())   #°ó¶¨ÎïÆ·  | 
| # #            GameWorld.Log("´´½¨dict ItemType = %d"%itemType)  | 
| #          | 
| #        isBind = curItem.GetIsBind()  | 
| #        #GameWorld.Log("===============================List Start : itemType = %d isBind = %d"%  | 
| #        #                      (itemType,isBind))  | 
| #        __ResetItem_AddItemInList(itemList[itemType][isBind], curItem)  | 
| #      | 
| #    #°ÑÎïÆ·È«²¿·Å»Ø  | 
| #    curPack.WipePack()  | 
| #    putPlace = 0  | 
| #   | 
| #    #GameWorld.Log("×î´óÀàÐÍÊýÄ¿: %d"%len(ChConfig.Def_ItemResetPrior))  | 
| #    for itemType in ChConfig.Def_ItemResetPrior:  | 
| #        if not itemList.has_key(itemType) :  | 
| #            continue  | 
| #          | 
| #        #GameWorld.Log("µÚ¶þ²ã: Î´°ó¶¨/°ó¶¨")  | 
| #        #µÚ¶þ²ã: Î´°ó¶¨/°ó¶¨  | 
| #        for isBind in range(0, len(itemList[itemType])):  | 
| #            #µÚÈý²ã: ÎïÆ·ÊýÁ¿  | 
| #            #GameWorld.Log("µÚÈý²ã: ÎïÆ·ÊýÁ¿ %d"%len(itemList[itemType][isBind]))  | 
| #            itemList[itemType][isBind].sort(__cmpFunc)  | 
| #            for curItem in itemList[itemType][isBind]:  | 
| #                curPack.GetAt(putPlace).AssignItem(curItem)  | 
| #                putPlace = putPlace + 1  | 
| #                #GameWorld.Log("·ÅÈëÎïÆ· : %s"%curItem.GetName())  | 
| #                  | 
| #        del itemList[itemType]  | 
| #          | 
| #    #δÃüÃûÓÅÏȼ¶µÄÎïÆ··Åµ½×îºó  | 
| #    for itemType in itemList.keys():  | 
| #        #µÚ¶þ²ã: Î´°ó¶¨/°ó¶¨  | 
| #        for isBind in range(0, len(itemList[itemType])):  | 
| #            #µÚÈý²ã: ÎïÆ·ÊýÁ¿  | 
| #            #GameWorld.Log("µÚÈý²ã: ÎïÆ·ÊýÁ¿ %d"%len(itemList[itemType][isBind]))  | 
| #            itemList[itemType][isBind].sort(__cmpFunc)  | 
| #            for curItem in itemList[itemType][isBind]:  | 
| #                curPack.GetAt(putPlace).AssignItem(curItem)  | 
| #                putPlace = putPlace + 1  | 
| #                #GameWorld.Log("·ÅÈëÎïÆ· : %s"%curItem.GetName())  | 
| #      | 
| #          | 
| #    #GameWorld.Log("ÖØÕû½áÊø")  | 
| #      | 
| #      | 
| # def __ResetItem_AddItemInList(curList, addItem):  | 
| #    #°ÑÎïÆ··Åµ½ÁбíÖÐ, ÒªÅжϵþ¼Ó  | 
| #    itemCount = addItem.GetCount()  | 
| #    packCount = addItem.GetPackCount()  | 
| #      | 
| #    for curItem in curList:  | 
| #        curCount = curItem.GetCount()  | 
| #          | 
| #        #GameWorld.Log("List: itemID = %d, count = %d, packCount = %d"%(  | 
| #                        #curItem.GetItemTypeID(), curItem.GetCount(), curItem.GetPackCount()))  | 
| #          | 
| #        if not ItemControler.CanPackItem(curItem, addItem) :  | 
| #            continue  | 
| #          | 
| #          | 
| #        if curCount >= packCount:  | 
| #            continue  | 
| #        canPlaceCount = packCount - curCount  | 
| #        if itemCount <= canPlaceCount:  | 
| #            #¿ÉÒÔÈ«²¿·ÅÈë  | 
| #            curItem.SetCount(itemCount + curCount)  | 
| #            return  | 
| #        curItem.SetCount(packCount)  | 
| #        itemCount = itemCount - canPlaceCount  | 
| #          | 
| #    if itemCount != 0:  | 
| #        #·ÅÈ뵱ǰÎïÆ·  | 
| #        addItem.SetCount(itemCount)  | 
| #        curList.append(addItem)  | 
| #   | 
| #    return  | 
| #   | 
| # def __cmpFunc(start, end):  | 
| #    if start.GetItemTypeID() > end.GetItemTypeID():  | 
| #        return 1  | 
| #    if start.GetItemTypeID() < end.GetItemTypeID():  | 
| #        return -1  | 
| #    return 0  | 
| #===============================================================================  | 
| #==============================================================================  | 
| def OnPlayerLogin(curPlayer):  | 
|     __CheckTransferItemPack(curPlayer)  | 
|     Sync_AutoItemCount(curPlayer)  | 
|     return  | 
|   | 
| def __CheckTransferItemPack(curPlayer):  | 
|     ## ¼ì²é×ªÒÆÎïÆ·  | 
|       | 
|     # {µ÷Õû°æ±¾±àºÅ:{(Ô±³°üÀàÐÍ, Ä¿±ê±³°üÀàÐÍ):[ÎïÆ·ID, ...], ...}, ...}  | 
|     transferItemPackRecordDict = IpyGameDataPY.GetFuncEvalCfg("TransferItemPack", 1, {})  | 
|     if not transferItemPackRecordDict:  | 
|         return  | 
|     verList = transferItemPackRecordDict.keys()  | 
|     verList.sort()  | 
|     lastVersion = verList[-1]  | 
|       | 
|     key = "TransferItemPackVer"  | 
|     curVersion = curPlayer.NomalDictGetProperty(key)  | 
|       | 
|     if curVersion >= lastVersion:  | 
|         #GameWorld.DebugLog("ÒÑ´¦Àí¹ý×ªÒÆÎïÆ·£¡curVersion=%s >= lastVersion=%s" % (curVersion, lastVersion))  | 
|         return  | 
|       | 
|     mailItemList = []  | 
|     itemControl = PlayerItemControler(curPlayer)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     for newVerNum in verList:  | 
|         if newVerNum <= curVersion:  | 
|             continue  | 
|         transferItemPackRule = transferItemPackRecordDict[newVerNum]  | 
|         GameWorld.Log("Íæ¼ÒÉÏÏß´¦ÀíÎïÆ·×ªÒÆ±³°ü! curVersion=%s,newVerNum=%s" % (curVersion, newVerNum), playerID)  | 
|         for transferPackInfo, itemIDList in transferItemPackRule.items():  | 
|             fromPackType, toPackType = transferPackInfo  | 
|             fromPack = curPlayer.GetItemManager().GetPack(fromPackType)  | 
|             #toPack = curPlayer.GetItemManager().GetPack(toPackType)  | 
|             for itemIndex in xrange(fromPack.GetCount()):  | 
|                 item = fromPack.GetAt(itemIndex)  | 
|                 if not ItemCommon.CheckItemCanUse(item):  | 
|                     continue  | 
|                 itemID = item.GetItemTypeID()  | 
|                 if itemID not in itemIDList:  | 
|                     continue  | 
|                 itemCount = item.GetCount()  | 
|                   | 
|                 if __DoDropItemToOtherPack(curPlayer, itemControl, fromPackType, toPackType, itemIndex, item):  | 
|                     # Íϳɹ¦µÄ²»ÔÙ´¦Àí  | 
|                     GameWorld.Log("    Ö±½Ó×ªÒÆ: fromPackType=%s,toPackType=%s,itemIndex=%s,itemID=%s,itemCount=%s"   | 
|                                   % (fromPackType, toPackType, itemIndex, itemID, itemCount), playerID)  | 
|                     continue  | 
|                   | 
|                 GameWorld.Log("    Óʼþ×ªÒÆ: fromPackType=%s,toPackType=%s,itemIndex=%s,itemID=%s,itemCount=%s"   | 
|                               % (fromPackType, toPackType, itemIndex, itemID, itemCount), playerID)  | 
|                   | 
|                 # ²»³É¹¦µÄ£¬×ª·¢µ½Óʼþ£¬×îºóÇå³ýÎïÆ·  | 
|                 mailItemList.append(ItemCommon.GetMailItemDict(item))  | 
|                 item.Clear()  | 
|                   | 
|         PlayerControl.NomalDictSetProperty(curPlayer, key, newVerNum)  | 
|         curVersion = newVerNum  | 
|           | 
|     if mailItemList:  | 
|         PlayerControl.SendMailByKey("TransferItemPack", [playerID], mailItemList)  | 
|           | 
|     return  | 
|   | 
| ## Çå³ý±³°üÖеÄÈÎÎñÎïÆ·  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param packIndex ±³°üÀàÐÍ  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ClearPackEventItem(curPlayer , packIndex):  | 
|     curPack = curPlayer.GetItemManager().GetPack(packIndex)  | 
|     itemList = []  | 
|       | 
|     for i in range(0, curPack.GetCount()):  | 
|         item = curPack.GetAt(i)  | 
|         #¿ÕÎïÆ·  | 
|         if not item or item.IsEmpty():  | 
|             continue  | 
|           | 
|         #²»ÊÇÈÎÎñÎïÆ·  | 
|         if not IsEventItem(item):  | 
|             continue  | 
|           | 
|         itemList.append(item)  | 
|       | 
|     curPlayerID = curPlayer.GetID()  | 
|       | 
|     for item in itemList:  | 
|         GameWorld.Log('###Çå¿Õ±³°ü = %s ÖеÄÈÎÎñÎïÆ· = %s' % (packIndex , item.GetItemTypeID()) , curPlayerID)  | 
|         item.Clear()  | 
|           | 
|     return  | 
|   | 
| def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList, event=["", False, {}]):  | 
|     '''¸øÍæ¼ÒÎïÆ·  | 
|     @param isAuctionItem: ÊÇ·ñÅÄÆ·  | 
|     '''  | 
|     if itemCount <= 0:  | 
|         return False  | 
|       | 
|     curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     if not curItemData:  | 
|         return False  | 
|       | 
|     if isAuctionItem:  | 
|         ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)  | 
|         if not ipyData:  | 
|             GameWorld.ErrLog("·ÇÅÄÂôÎïÆ·£¬Ä¬ÈÏתΪ·ÇÅÄÆ·! itemID=%s,itemCount=%s,isAuctionItem=%s"   | 
|                              % (itemID, itemCount, isAuctionItem), curPlayer.GetPlayerID())  | 
|             isAuctionItem = 0  | 
|       | 
|     defaultPack = IPY_GameWorld.rptItem if not packIndexList else packIndexList[0]  | 
|     packIndex = ChConfig.GetItemPackType(curItemData, defaultPack)  | 
|     if packIndex != defaultPack or not packIndexList:  | 
|         packIndexList = [packIndex]  | 
|       | 
|     #ÎïÆ·¹ÜÀíÆ÷  | 
|     canPutIn = False  | 
|     itemControl = PlayerItemControler(curPlayer)  | 
|     for packIndex in packIndexList:  | 
|         #¿ÉÒÔ·ÅÈë±³°ü  | 
|         if itemControl.CanPutInItem(packIndex, itemID, itemCount, isAuctionItem):  | 
|             canPutIn = True  | 
|             break  | 
|     if not canPutIn:  | 
|         #²»¿É·ÅÈë  | 
|         return False  | 
|       | 
|     #¶¨ÖÆÎïÆ·  | 
|     if GetAppointItemRealID(itemID):  | 
|         isOK = False  | 
|         for _ in xrange(itemCount):  | 
|             if GivePlayerAppointItem(curPlayer, itemID, isAuctionItem, event):  | 
|                 isOK = True # Ö»ÒªÓгɹ¦µÄ¾Í·µ»Ø³É¹¦£¬·ÀÖ¹Òì³£Çé¿öʧ°Ü¿ÉÄܵ¼Ö±»Ë¢  | 
|         return isOK  | 
|       | 
|     #×°±¸  | 
|     if ItemCommon.GetIsEquip(curItemData):  | 
|         isOK = False  | 
|         for _ in xrange(itemCount):  | 
|             outPutEquip = GetOutPutItemObj(itemID, 1, isAuctionItem, curPlayer=curPlayer)  | 
|             if not outPutEquip:  | 
|                 return isOK  | 
|             if DoLogic_PutItemInPack(curPlayer, outPutEquip, event, packIndexList):  | 
|                 isOK = True # Ö»ÒªÓгɹ¦µÄ¾Í·µ»Ø³É¹¦£¬·ÀÖ¹Òì³£Çé¿öʧ°Ü¿ÉÄܵ¼Ö±»Ë¢  | 
|         return isOK  | 
|       | 
|     #³£¹æÎïÆ·  | 
|     isOK = False  | 
|     for _ in range(itemCount/65535 + 1):  | 
|         if itemCount <= 0:  | 
|             break  | 
|         giveItem = GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)  | 
|         if not giveItem:  | 
|             return isOK  | 
|         giveCount = GetItemCount(giveItem)  | 
|         if DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList):  | 
|             isOK = True  | 
|             itemCount -= giveCount  | 
|     return isOK  | 
|   | 
| def DoGiveItemLoop(curPlayer, itemID, itemCount, isAuctionItem, event=["", False, {}], packIndexList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],   | 
|                    jsonItemList=None, userDataList=None):  | 
|     ## Ñ»·¸øÎïÆ·£¬Ò»°ãÓÃÓÚ¸öÊý³¬¹ý65535µÄ£¬Ñ»·´´½¨ÎïÆ·¸ø  | 
|     # @warning: ¸Ãº¯Êý²»¶ÔÎïÆ·¼°±³°ü¿Õ¼äµÈ×öÑéÖ¤£¬½ö×öÑ»·¸øÎïÆ·²Ù×÷  | 
|     # @return: ¸ø³É¹¦×ÜÊý£¬0´ú±í¸øÊ§°ÜÁË  | 
|       | 
|     giveOKCount = 0  | 
|     for _ in range(itemCount/65535 + 1):  | 
|         if giveOKCount >= itemCount:  | 
|             break  | 
|         giveItem = GetOutPutItemObj(itemID, itemCount - giveOKCount, isAuctionItem, curPlayer=curPlayer)  | 
|         if not giveItem:  | 
|             return giveOKCount  | 
|         curCount = GetItemCount(giveItem)  | 
|           | 
|         if type(jsonItemList) == list:  | 
|             jsonItemList.append(ItemCommon.GetJsonItem(giveItem))  | 
|         if type(userDataList) == list:  | 
|             userDataList.append(giveItem.GetUserData())  | 
|               | 
|         if DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList):  | 
|             giveOKCount += curCount  | 
|               | 
|     return giveOKCount  | 
|   | 
| def GivePlayerAppointItem(curPlayer, appointID, isAuctionItem, event=["", False, {}]):  | 
|     '''¸øÍæ¼Ò¶¨ÖÆÎïÆ·±íÎïÆ·£¬¶¨ÖÆÎïÆ·Ä¬ÈϸöÊý1  | 
|     @param appointID ¶¨ÖƱíID  | 
|     @param isAuctionItem ÊÇ·ñÅÄÆ·  | 
|     '''  | 
|     itemDictData = GetAppointItemDictData(appointID, isAuctionItem)  | 
|     if not itemDictData:  | 
|         return False  | 
|       | 
|     return GivePlayerEquip(curPlayer, itemDictData, event=event)  | 
|   | 
| def GetAppointItemDictData(appointID, isAuctionItem):  | 
|     '''»ñÈ¡¶¨ÖƱíÎïÆ·Êý¾Ý£¬¶¨ÖÆÎïÆ·Ä¬ÈϸöÊý1  | 
|     @param appointID ¶¨ÖƱíID  | 
|     @param isAuctionItem ÊÇ·ñÅÄÆ·  | 
|     '''  | 
|     itemID = GetAppointItemRealID(appointID)  | 
|     if not itemID:  | 
|         return {}  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", appointID)  | 
|     if not ipyData:  | 
|         return {}  | 
|     itemDictData = {}  | 
|      | 
|     itemDictData['legendAttrID'] = ipyData.GetLegendAttrID()  | 
|     itemDictData['legendAttrValue'] = ipyData.GetLegendAttrValue()  | 
|     itemDictData['ItemID'] = itemID  | 
|     itemDictData['CancelUseLimit'] = ipyData.GetCancelUseLimit()  | 
|       | 
|     itemDictData['IsAuctionItem'] = isAuctionItem  | 
|       | 
|     return itemDictData  | 
|   | 
| def GetAppointItemRealID(itemID):  | 
|     '''»ñÈ¡¶¨ÖÆÎïÆ·¶ÔÓ¦µÄÕæÊµÎïÆ·ID'''  | 
|     curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     if not curItem:  | 
|         return 0  | 
|     curEff = curItem.GetEffectByIndex(0)  | 
|     curEffID = curEff.GetEffectID()  | 
|     if curEffID != ChConfig.Def_Effect_AppointItem:  | 
|         return 0  | 
|     return curEff.GetEffectValue(0)  | 
|   | 
| ## ¸ù¾ÝÎïÆ·data×Öµä¸øÍæ¼Ò×°±¸/³á°ò  | 
| #  @param curPlayer£ºÍæ¼ÒʵÀý  | 
| #  @param itemData£ºÎïÆ·Êý¾Ý  | 
| #  @param packType£º±³°üÀàÐÍ  | 
| #  @param defaultPile Ä¬ÈÏÏÈÅжÏÊÇ·ñÄܽøÐÐÎïÆ·¶Ñµþ  | 
| #  @return None  | 
| def GivePlayerEquip(curPlayer, itemData, event=["", False, {}], packType=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],  | 
|                     defaultPile=True):  | 
|     equipItem = GetItemByData(itemData)  | 
|     #½«ÎïÆ··ÅÈë±³°ü  | 
|     return DoLogic_PutItemInPack(curPlayer, equipItem, event, packType, defaultPile)  | 
|   | 
|   | 
| ## ¸ù¾ÝÎïÆ·data×ֵ䴴½¨ÎïÆ·  | 
| #  @param itemData£ºÎïÆ·Êý¾Ý  | 
| #  @return ItemObj  | 
| def GetItemByData(itemData):  | 
|     if not itemData:  | 
|         return  | 
|       | 
|     itemID = int(itemData.get('ItemID', 0))  | 
|     isAuctionItem = int(itemData.get('IsAuctionItem', 0))  | 
|     equipItem = ItemCommon.CreateSingleItem(itemID, isAuctionItem=isAuctionItem)  | 
|     if not equipItem:  | 
|         return  | 
|       | 
|     tmpEquipData = SingleEquipTmpData()  | 
|       | 
|     #tmpEquipData.starLV = int(itemData.get('StarLV', '0'))  | 
|     #tmpEquipData.holeCnt = int(itemData.get('HoleCount', '0'))  | 
|     #tmpEquipData.stoneData = eval(itemData.get('StoneData', '[]'))  | 
|     tmpEquipData.isBind = isAuctionItem  | 
|     #tmpEquipData.isSuite = int(itemData.get('IsSuit', '0'))  | 
|     #tmpEquipData.suiteLV = int(itemData.get('SuiteLV', '0'))  | 
|     #if tmpEquipData.suiteLV:  | 
|     #    tmpEquipData.isSuite = 1  | 
|     tmpEquipData.source = int(itemData.get('Source', str(ShareDefine.Item_Source_Unkown)))  | 
|       | 
|     tmpEquipData.legendAttrIDList = itemData.get('legendAttrID', [])  | 
|     tmpEquipData.legendAttrValueList = itemData.get('legendAttrValue', [])  | 
|       | 
|     # ×°±¸¸½¼ÓÊôÐÔ  | 
|     ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)  | 
|       | 
|     if "UserData" in itemData:  | 
|         userData = itemData["UserData"]  | 
|         ItemCommon.SetItemUserData(equipItem, userData)  | 
|           | 
|     if "EquipGS" in itemData:  | 
|         equipGS = int(itemData["EquipGS"])  | 
|         ItemCommon.SetEquipGearScore(equipItem, equipGS)  | 
|       | 
|           | 
|     # È¡ÏûµÈ¼¶ÏÞÖÆ  | 
|     if itemData.get('CancelUseLimit', 0):  | 
|         equipItem.SetUserAttr(ShareDefine.Def_IudetCancelUseLimit, 1)  | 
|           | 
|     return equipItem  | 
|   | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Ö´ÐÐÎïÆ··ÅÈë±³°üÂß¼  | 
| #  @param curPlayer ±³°üÓµÓÐÕß  | 
| #  @param curGiveItem ·ÅÈëµÄÎïÆ·  | 
| #  @param packIndexList ±³°üË÷ÒýÁÐ±í  | 
| #  @param showEff ·ÅÈë±³°üÌØÐ§  | 
| #  @param defaultPile Ä¬ÈÏÏÈÅжÏÊÇ·ñÄܽøÐÐÎïÆ·¶Ñµþ  | 
| #  @param showSysInfo ÊÇ·ñÏÔʾϵͳÌáʾ  | 
| #  @return ²¼¶ûÖµ  | 
| def DoLogic_PutItemInPack(curPlayer, curGiveItem, event=["", False, {}], packIndexList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], defaultPile=True):  | 
|     #itemID = curGiveItem.GetItemTypeID()  | 
|     #count = curGiveItem.GetCount()  | 
|     itemControl = PlayerItemControler(curPlayer)  | 
|     #±éÀú±³°üË÷Òý·ÅÈëÎïÆ·  | 
|     for packIndex in packIndexList:  | 
|         #·ÅÈë³É¹¦  | 
|         if itemControl.PutInItem(packIndex, curGiveItem, defaultPile, event):  | 
|             #===================================================================  | 
|             # if packIndex == IPY_GameWorld.rptItem and showEff:  | 
|             #    curPlayer.Sync_GetItemView(itemID, count)  | 
|             #      | 
|             # if showSysInfo:  | 
|             #    PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, count])  | 
|             #===================================================================  | 
|               | 
|             return True  | 
|   | 
|     #Íæ¼Ò±³°üÒÑÂú, Çå¿ÕÎïÆ·,·ñÔò´´½¨ÎïÆ·²»É¾³ý,½«µ¼ÖÂÄÚ´æÒç³ö  | 
|     curGiveItem.Clear()  | 
|     #Ç°ÃæÑéÖ¤¹ýÁË, ×ßµ½ÕâÀï¾ÍÊÇÂß¼BugÁË  | 
|     GameWorld.ErrLog('DoLogic_PutItemInPack Error ÎïÆ·ÎÞ·¨·ÅÈë±³°ü')  | 
|     return False  | 
|   | 
| ## ÊÇ·ñÅÄÆ·  | 
| def GetIsAuctionItem(curItem): return curItem.GetIsBind()  | 
| def SetIsAuctionItem(curItem, isAuctionItem, curPlayer=None):  | 
|     curItem.SetIsBind(isAuctionItem)  | 
|       | 
|     if isAuctionItem:  | 
|         curItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, int(time.time()))  | 
|         return  | 
|       | 
|     if not curPlayer:  | 
|         return  | 
|       | 
|     if ItemCommon.GetIsEquip(curItem):  | 
|         legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)  | 
|         legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)  | 
|         if legendAttrIDCnt and legendAttrIDCnt == legendAttrValueCnt:  | 
|             legendAttrInfo = GetEquipLegendAttrGroup(curItem)  | 
|             #GameWorld.DebugLog("ÒѾÓд«ÆæÊôÐÔµÄÅÄÆ·£º %s" % str(legendAttrInfo))  | 
|         else:  | 
|             # Éú³É´«ÆæÊôÐÔ  | 
|             legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)  | 
|             #GameWorld.DebugLog("ÖØÐÂÉú³É´«ÆæÊôÐÔµÄÅÄÆ·£º %s" % str(legendAttrInfo))  | 
|             if not legendAttrInfo:  | 
|                 return  | 
|               | 
|         updateDict = {}  | 
|         if legendAttrInfo[0]:  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrID] = legendAttrInfo[0]  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrValue] = legendAttrInfo[1]  | 
|         if legendAttrInfo[2]:  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrIDShen] = legendAttrInfo[2]  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrValueShen] = legendAttrInfo[3]  | 
|         if legendAttrInfo[4]:  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrIDXian] = legendAttrInfo[4]  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrValueXian] = legendAttrInfo[5]  | 
|         if legendAttrInfo[6]:  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrIDJi] = legendAttrInfo[6]  | 
|             updateDict[ShareDefine.Def_IudetLegendAttrValueJi] = legendAttrInfo[7]  | 
|               | 
|         delKeyList = [ShareDefine.Def_IudetAuctionItemCreateTime]  | 
|         ItemCommon.UpdateItemUserData(curItem, updateDict, delKeyList, isUpdateGS=True)  | 
|           | 
|     return  | 
|   | 
| def GetItemCountByID(curPlayer, itemID):  | 
|     return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemCount % itemID)  | 
| def SetItemCountByID(curPlayer, itemID, itemCount, isSync=True):  | 
|     itemCount = max(0, min(itemCount, ChConfig.Def_UpperLimit_DWord))  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ItemCount % itemID, itemCount)  | 
|     if isSync:  | 
|         Sync_AutoItemCount(curPlayer, [itemID])  | 
|     return itemCount  | 
|   | 
| ## ÉèÖÃÎïÆ·ÊýÁ¿  | 
| #  @param item ÎïÆ·ÊµÀý  | 
| #  @param cnt ÊýÁ¿  | 
| #  @param playerID Íæ¼ÒID  | 
| #  @param accID Õ˺Š | 
| #  @param playerName Ãû×Ö  | 
| #  @return None  | 
| def SetItemCount(item, cnt, playerID=0, accID=0, playerName=""):  | 
|     if not item.IsEmpty():  | 
|         if cnt > 0 and IsPutinAutoTransformItem(item):  | 
|             item.SetUserAttr(ShareDefine.Def_IudetItemCount, min(cnt, ChConfig.Def_UpperLimit_DWord))  | 
|         else:  | 
|             item.SetCount(min(cnt, 65535))  | 
|     else:  | 
|         try:  | 
|             1 / 0  | 
|         except:  | 
|             errorInfo = "%s %s %s -- ItemControler->SetItemCount::" % (playerID, accID, playerName)  | 
|             GameWorld.ErrLog(errorInfo + str(traceback.extract_stack()) + "\n" + traceback.format_exc())  | 
|             raise  | 
|           | 
| def GetItemCount(item):  | 
|     if IsPutinAutoTransformItem(item):  | 
|         return item.GetUserAttr(ShareDefine.Def_IudetItemCount)  | 
|     return item.GetCount()  | 
|   | 
| def GetItemNeedPackCount(packType, itemData, itemCount, isAuctionItem=0):  | 
|     # 20201223 Ö÷¸ÉÈ¡ÏûÅÄÆ·ÓÐЧʱ³¤É趨  | 
| #    if isAuctionItem:  | 
| #        if IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemData.GetItemTypeID()):  | 
| #            return 1  | 
|     if IsPutinAutoTransformItem(itemData):  | 
|         # »õ±ÒÖ±½Óת»»µÄÎïÆ·Èç¹ûÊÇ·ÅÈë±³°üµÄÔò²»ÐèÒªÔÝÓøñ×Ó£¬·ÅÈëÆäËûµÄ±³°üµÄÔò°´ÎïÆ·µþ¼ÓÉÏÏÞËã  | 
|         if packType == IPY_GameWorld.rptItem:  | 
|             return 0  | 
|         packCount = ChConfig.Def_UpperLimit_DWord # ×ª»¯ÎïÆ·µþ¼ÓÉÏÏÞ²»È¡ÎïÆ·±íµÄ  | 
|     else:  | 
|         packCount = itemData.GetPackCount()  | 
|     return int(math.ceil(itemCount / float(packCount)))  | 
|   | 
| def IsPutinAutoTransformItem(itemData):  | 
|     ## ·ÅÈë±³°üʱÊÇ·ñÖ±½Óת»¯Îª¶ÔÓ¦ÊýÖµµÄÎïÆ·  | 
|     if not itemData or not itemData.GetItemTypeID():  | 
|         return False  | 
|     if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList or itemData.GetType() == ChConfig.Def_ItemType_AutoUseMoney:  | 
|         return True  | 
|     itemEff = itemData.GetEffectByIndex(0)  | 
|     if itemEff.GetEffectID() == ChConfig.Def_Effect_ItemCount:  | 
|         return True  | 
|     if itemEff.GetEffectID() == ChConfig.Def_Effect_GubaoPiece:  | 
|         gubaoID = itemEff.GetEffectValue(0)  | 
|         if gubaoID:  | 
|             return True  | 
|     return False  | 
|   | 
| ## Ë«ÊÖÎäÆ÷£¬ÐèÒªÁ½Ö»ÊÖ²ÅÄõö¯  | 
| #  @param curEquip  | 
| #  @return bool  | 
| def IsTwoHandedWeapon(curEquip):  | 
|     return curEquip.IsBothHands() == ShareDefine.Def_Weapon_Two_Handed  | 
|   | 
|   | 
| ## Ë«³ÖÎäÆ÷£¬×óÓÒÊÖ¶¼¿ÉÒÔÄ̵̮ðÀ´µÄÎäÆ÷  | 
| #  @param curEquip  | 
| #  @return bool  | 
| def IsDualWeapons(curEquip):  | 
|     return curEquip.IsBothHands() == ShareDefine.Def_Weapon_Dual_Hands  | 
|   | 
|   | 
| ## ×°±¸¶àλÖÃ×°±¸´¦Àí  | 
| #  @param equipPack µ±Ç°×°±¸±³°ü  | 
| #  @param packEquipIndex ¿Í»§¶Ë·¢À´×°±¸Î»ÖÃ(IPY_GameWorld.retMax ´ú±í·þÎñÆ÷×Ô¶¯×°±¸)  | 
| #  @param placeList ¿É×°±¸µÄλÖÃÁÐ±í  | 
| #  @return ×°±¸Î»Öà  | 
| def GetMultiPlaceEquipPlace(equipPack, packEquipIndex, placeList):  | 
|               | 
|     #---¿Í»§¶ËÖ¸¶¨Î»ÖÃ---  | 
|     if packEquipIndex in placeList:  | 
|         return packEquipIndex  | 
|       | 
|     #---·þÎñ¶ËÅжϿÕλÖÃ---  | 
|     for placeIndex in placeList:  | 
|         curEquip = equipPack.GetAt(placeIndex)  | 
|           | 
|         if curEquip.IsEmpty():  | 
|             return placeIndex  | 
|           | 
|         elif IsTwoHandedWeapon(curEquip):  | 
|             #ÎäÆ÷ÌØÊâ´¦Àí£¬Ë«ÊÖÖ±½Ó½»»»  | 
|             return placeIndex  | 
|           | 
|     #---ÎÞ¿ÕλÖã¬Ìæ»»---  | 
|     return placeList[0]  | 
|   | 
| def GetOutPutItemObj(itemID, itemCount=1, isAuctionItem=False, expireTime=0, curPlayer=None, isAllAttr=False):  | 
|     ''' »ñÈ¡¹¦Äܲú³öµÄÎïÆ·ÊµÀý  | 
|     @param isAuctionItem: ÊÇ·ñÅÄÆ·£¬Ä¬ÈÏ·ÇÅÄÆ·  | 
|     @param expireTime: ÓÐЧʱ¼ä£¬Ê±¼äµ¥Î»ÓÉʱЧÀàÐ;ö¶¨  | 
|     @param curPlayer: ²ú³ö¸ÃÎïÆ·Ê±µÄÍæ¼Ò£¬ÎïÆ·Ä³Ð©ÊôÐÔÓÉÍæ¼ÒµÈ¼¶¾ö¶¨£¬Èç´«ÆæÊôÐÔ  | 
|     @param isAllAttr: ÊÇ·ñÉú³É¸Ã×°±¸ËùÓÐÊôÐÔ£¬GM´´½¨ÎïÆ·Ê±Óã¬ÐèÑéÖ¤Ïà¹ØÈ¨ÏÞ  | 
|     '''  | 
|     curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem, expireTime)  | 
|     if not curItem:  | 
|         GameWorld.ErrLog("²ú³öÎïÆ·Òì³£,ÎÞ·¨´´½¨ÎïÆ· = %s" % (itemID))  | 
|         return  | 
|       | 
|     # ·Ç×°±¸£¬ÎÞÐèÉèÖÃÊôÐÔ  | 
|     if not ItemCommon.CheckItemIsEquip(curItem):  | 
|         return curItem  | 
|       | 
|     # ¶¨ÖÆÎïÆ·  | 
|     if GetAppointItemRealID(itemID):  | 
|         curItem.Clear()  | 
|         #GameWorld.DebugLog("Çå³ý¸ø¶¨ÖÆÎïÆ·Ö®Ç°ÒѾ´´½¨µÄÎïÆ·ID=%s" % itemID)  | 
|         return GetItemByData(GetAppointItemDictData(itemID, isAuctionItem))  | 
|       | 
| #    # ÅÄÆ·²»´¦ÀíÆäËûÊôÐÔ  | 
| #    if isAuctionItem:  | 
| #        return curItem  | 
|       | 
|     tmpEquipData = SingleEquipTmpData()  | 
|       | 
|     # ´«ÆæÊôÐÔ  | 
|     legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr)  | 
|     if legendAttrInfo:  | 
|         tmpEquipData.legendAttrIDList = legendAttrInfo[0]  | 
|         tmpEquipData.legendAttrValueList = legendAttrInfo[1]  | 
|         tmpEquipData.legendAttrIDListShen = legendAttrInfo[2]  | 
|         tmpEquipData.legendAttrValueListShen = legendAttrInfo[3]  | 
|         tmpEquipData.legendAttrIDListXian = legendAttrInfo[4]  | 
|         tmpEquipData.legendAttrValueListXian = legendAttrInfo[5]  | 
|         tmpEquipData.legendAttrIDListJi = legendAttrInfo[6]  | 
|         tmpEquipData.legendAttrValueListJi = legendAttrInfo[7]  | 
|           | 
|     # ÆäËû×°±¸ÊôÐÔ  | 
|     ChItem.EquipAddAdditionEx(curItem, tmpEquipData)  | 
|     return curItem  | 
|   | 
| def GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr=False):  | 
|     '''»ñÈ¡Éú³Éµ½×°±¸ÉϵĴ«ÆæÊôÐÔ  | 
|     @return: None »òÕß  [´«ÆæÊôÐÔЧ¹ûIDÁбí], [ÊôÐÔÖµÁбí], [ÉñID], [ÉñÖµ], [ÏÉID], [ÏÉÖµ], [¼«ID], [¼«Öµ]  | 
|     '''  | 
| #    if GetIsAuctionItem(curItem):  | 
| #        #GameWorld.DebugLog("ÅÄÆ·ÎÞ·¨Éú³É´«ÆæÊôÐÔ!")  | 
| #        return  | 
|     itemID = curItem.GetItemTypeID()  | 
|     itemType = curItem.GetType()  | 
|     itemColor = curItem.GetItemColor()  | 
|     itemQuality = curItem.GetItemQuality()  | 
|     isSuit = 1 if curItem.GetSuiteID() else 0  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameDataNotLog("EquipShenAttr", itemID)  | 
|     if ipyData:  | 
|         return ipyData.GetLegendAttrIDList(), ipyData.GetLegendAttrValueList(), \  | 
|                 ipyData.GetShenAttrIDList(), ipyData.GetShenAttrValueList(), \  | 
|                 ipyData.GetXianAttrIDList(), ipyData.GetXianAttrValueList(), \  | 
|                 ipyData.GetJiAttrIDList(), ipyData.GetJiAttrValueList()  | 
|                   | 
|     # 1. ¶¨ÌõÊý  | 
|     attrCountIpyData = IpyGameDataPY.GetIpyGameDataNotLog("EquipLegendAttrCount", itemType, itemColor, isSuit, itemQuality)  | 
|     if not attrCountIpyData:  | 
|         if itemColor >= ChConfig.Def_Quality_Purple:  | 
|             GameWorld.DebugLog("¸Ã×°±¸Ã»Óд«ÆæÊôÐÔ: itemID=%s" % (itemID))  | 
|         return  | 
|     legendAttrCountInfoList = attrCountIpyData.GetLegendAttrCountInfo() # ´«ÆæÊôÐÔÌõÊýÐÅÏ¢ [[ÌõÊý, [ÊôÐÔÀàÐÍ¿â±àºÅ, ...]], ...]  | 
|     if not legendAttrCountInfoList:  | 
|         return  | 
|       | 
|     if curPlayer:  | 
|         playerID, playerLV = curPlayer.GetPlayerID(), curPlayer.GetLV()  | 
|     else:  | 
|         playerID = 0  | 
|         playerLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)  | 
|         GameWorld.Log("Éú³É×°±¸´«ÆæÊôÐÔʱûÓÐÍæ¼ÒµÈ¼¶, È¡µ±Ç°ÊÀ½çµÈ¼¶! itemID=%s,worldLV=%s" % (itemID, playerLV))  | 
|           | 
|     # 2. ¶¨ÊôÐÔID  | 
|     attrTypeIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrType", itemType)  | 
|     if not attrTypeIpyData:  | 
|         return  | 
|     legendAttrTypeLibDict = attrTypeIpyData.GetLegendAttrTypeLib() # ´«ÆæÊôÐÔÀàÐÍ¿â {ÊôÐÔÀàÐÍ¿â±àºÅ:[ÊôÐÔID,...], ...}  | 
|       | 
|     curLegAttrIDList = []  | 
|     curLegAttrValueList = []  | 
|     itemClassLV = ItemCommon.GetItemClassLV(curItem)  | 
|     if isAllAttr:  | 
|         if curPlayer.GetGMLevel() != 90:  | 
|             return  | 
|         for attrIDList in legendAttrTypeLibDict.values():  | 
|             curLegAttrIDList += attrIDList  | 
|         #GameWorld.DebugLog("ËùÓд«ÆæÊôÐÔ: %s" % (curLegAttrIDList), playerID)  | 
|     else:  | 
|         #GameWorld.DebugLog("Ëæ»ú´«ÆæÊôÐÔ: itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s"   | 
|         #                   % (itemID, itemType, itemClassLV, itemColor, isSuit), playerID)  | 
|         for attrCount, libNumList in legendAttrCountInfoList:  | 
|             attrIDList = []  | 
|             for libNum in libNumList:  | 
|                 attrIDList.extend(legendAttrTypeLibDict.get(libNum, []))  | 
|             for curAttrID in curLegAttrIDList:  | 
|                 if curAttrID in attrIDList:  | 
|                     attrIDList.remove(curAttrID)  | 
|             if len(attrIDList) < attrCount:  | 
|                 GameWorld.ErrLog("×°±¸´«ÆæÊôÐÔID¿âÅäÖò»¹»ÌõÊýËæ»ú!itemID=%s,itemType=%s,legendAttrCountInfoList=%s,legendAttrTypeLibDict=%s"   | 
|                                  % (itemID, itemType, legendAttrCountInfoList, legendAttrTypeLibDict), playerID)  | 
|                 return  | 
|             curLegAttrIDList += random.sample(attrIDList, attrCount)  | 
|             #GameWorld.DebugLog("    Ëæ»ú´«ÆæÊôÐÔ: attrCount=%s,libNumList=%s,attrIDList=%s,curLegAttrIDList=%s"   | 
|             #                   % (attrCount, libNumList, attrIDList, curLegAttrIDList), playerID)  | 
|               | 
|     # 3. ¶¨ÊýÖµ  | 
|     attrValueIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrValue", itemType, itemClassLV, itemColor, isSuit, itemQuality)  | 
|     if not attrValueIpyData:  | 
|         GameWorld.ErrLog("´«ÆæÊôÐԵȼ¶ÊýÖµ±íÕÒ²»µ½ÅäÖÃ!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,itemQuality=%s"   | 
|                          % (itemID, itemType, itemClassLV, itemColor, isSuit, itemQuality), playerID)  | 
|         return  | 
|       | 
|     attrLVLibNumDict = attrValueIpyData.GetLVLegendAttrLibNumInfo() # {ÊôÐÔID:{µÈ¼¶:¿â±àºÅ, ...}}  | 
|     for attrID in curLegAttrIDList:  | 
|         if attrID not in attrLVLibNumDict:  | 
|             GameWorld.ErrLog("´«ÆæÊôÐԵȼ¶ÊýÖµ±íûÓÐÅäÖÃÊôÐÔID¶ÔÓ¦µÈ¼¶¿â±àºÅ!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,attrID=%s"   | 
|                              % (itemID, itemType, itemClassLV, itemColor, isSuit, attrID), playerID)  | 
|             return  | 
|         curLibNum = None  | 
|         lvAttrLibList = attrLVLibNumDict[attrID]  | 
|         for lv, libNum in lvAttrLibList:  | 
|             if playerLV <= lv:  | 
|                 curLibNum = libNum  | 
|                 break  | 
|         if curLibNum == None:  | 
|             GameWorld.ErrLog("´«ÆæÊôÐԵȼ¶ÊýÖµ±íÕÒ²»µ½ÊôÐÔID¶ÔÓ¦µÈ¼¶¿â±àºÅ!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,attrID=%s,playerLV=%s"   | 
|                              % (itemID, itemType, itemClassLV, itemColor, isSuit, attrID, playerLV), playerID)  | 
|             return  | 
|         attrLibIpyData = attrValueIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrLib", attrID)  | 
|         if not attrLibIpyData:  | 
|             GameWorld.ErrLog("´«ÆæÊôÐÔ¿â²»´æÔÚ´«ÆæÊôÐÔIDÅäÖÃ!itemID=%s,attrID=%s" % (itemID, attrID), playerID)  | 
|             return  | 
|         attrLibDict = attrLibIpyData.GetLegendAttrLib() # {¿â±àºÅ:[Ëæ»úÊýÖµ, ...], ...}  | 
|         if curLibNum not in attrLibDict:  | 
|             GameWorld.ErrLog("´«ÆæÊôÐÔ¿â±àºÅ²»´æÔÚ!itemID=%s,attrID=%s,curLibNum=%s" % (itemID, attrID, curLibNum), playerID)  | 
|             return  | 
|         valueList = attrLibDict[curLibNum]  | 
|         attrValue = random.choice(valueList)  | 
|         curLegAttrValueList.append(attrValue)  | 
|         #GameWorld.DebugLog("    Ëæ»úÊôÐÔ: attrID=%s,attrValue=%s,playerLV=%s,curLibNum=%s,valueList=%s"   | 
|         #                   % (attrID, attrValue, playerLV, curLibNum, valueList), playerID)  | 
|     return curLegAttrIDList, curLegAttrValueList, [], [], [], [], [], []  | 
|   | 
| def GetEquipLegendAttrAll(curItem):  | 
|     ## »ñȡװ±¸´«ÆæÊôÐÔ - ËùÓзÖ×éºÏ²¢·µ»Ø  | 
|     legendAttrInfo = GetEquipLegendAttrGroup(curItem)  | 
|     legAttrIDList = legendAttrInfo[0] + legendAttrInfo[2] + legendAttrInfo[4] + legendAttrInfo[6]  | 
|     legAttrValueList = legendAttrInfo[1] + legendAttrInfo[3] + legendAttrInfo[5] + legendAttrInfo[7]  | 
|     return legAttrIDList, legAttrValueList  | 
|   | 
| def GetEquipLegendAttrGroup(curItem):  | 
|     ## »ñȡװ±¸´«ÆæÊôÐÔ - °´ÀàÐÍ·Ö×é·µ»Ø  | 
|       | 
|     legAttrIDList, legAttrValueList = [], []  | 
|     legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)  | 
|     legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)  | 
|     if legendAttrIDCnt == legendAttrValueCnt:  | 
|         for i in xrange(legendAttrIDCnt):  | 
|             legAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i))  | 
|             legAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i))  | 
|               | 
|     shenAttrIDList, shenAttrValueList = [], []  | 
|     shenAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDShen)  | 
|     shenAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueShen)  | 
|     if shenAttrIDCnt == shenAttrValueCnt:  | 
|         for i in xrange(shenAttrIDCnt):  | 
|             shenAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDShen, i))  | 
|             shenAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueShen, i))  | 
|               | 
|     xianAttrIDList, xianAttrValueList = [], []  | 
|     xianAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDXian)  | 
|     xianAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueXian)  | 
|     if xianAttrIDCnt == xianAttrValueCnt:  | 
|         for i in xrange(xianAttrIDCnt):  | 
|             xianAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDXian, i))  | 
|             xianAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueXian, i))  | 
|               | 
|     jiAttrIDList, jiAttrValueList = [], []  | 
|     jiAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDJi)  | 
|     jiAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueJi)  | 
|     if jiAttrIDCnt == jiAttrValueCnt:  | 
|         for i in xrange(jiAttrIDCnt):  | 
|             jiAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDJi, i))  | 
|             jiAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueJi, i))  | 
|               | 
|     return legAttrIDList, legAttrValueList, shenAttrIDList, shenAttrValueList, xianAttrIDList, xianAttrValueList, jiAttrIDList, jiAttrValueList  | 
|   | 
| def SetEquipLegendAttr(curItem, legendAttrInfo):  | 
|     ## ÉèÖÃ×°±¸´«ÆæÊôÐÔ  | 
|       | 
|     legAttrIDList, legAttrValueList, shenAttrIDList, shenAttrValueList, \  | 
|         xianAttrIDList, xianAttrValueList, jiAttrIDList, jiAttrValueList = legendAttrInfo  | 
|                          | 
|     # ÆÕͨ´«ÆæÊôÐÔ  | 
|     if legAttrIDList and legAttrValueList and len(legAttrIDList) == len(legAttrValueList):  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)  | 
|         for i in xrange(len(legAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, legAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, legAttrValueList[i])  | 
|       | 
|     # Éñ ´«ÆæÊôÐÔ  | 
|     if shenAttrIDList and shenAttrValueList and len(shenAttrIDList) == len(shenAttrValueList):  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDShen)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueShen)  | 
|         for i in xrange(len(shenAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDShen, shenAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueShen, shenAttrValueList[i])  | 
|       | 
|     # ÏÉ ´«ÆæÊôÐÔ  | 
|     if xianAttrIDList and xianAttrValueList and len(xianAttrIDList) == len(xianAttrValueList):  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDXian)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueXian)  | 
|         for i in xrange(len(xianAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDXian, xianAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueXian, xianAttrValueList[i])  | 
|               | 
|     # ¼« ´«ÆæÊôÐÔ  | 
|     if jiAttrIDList and jiAttrValueList and len(jiAttrIDList) == len(jiAttrValueList):  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDJi)  | 
|         curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueJi)  | 
|         for i in xrange(len(jiAttrIDList)):  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDJi, jiAttrIDList[i])  | 
|             curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueJi, jiAttrValueList[i])  | 
|               | 
|     return  | 
|   | 
| ##´´½¨ÎïÆ·ËùÐèµÄ¶¯Ì¬Êý¾Ý  | 
| #  | 
| # ±ãÓÚͳһÐÞ¸Ä  | 
| class SingleEquipTmpData():  | 
|       | 
|     ## ³õʼ»¯  | 
|     #  @param   | 
|     #  @return None  | 
|     def __init__(self):  | 
|         self.starLV = 0 # Ç¿»¯µÈ¼¶(ÐÇÊý)  | 
|         self.holeCnt = 0  | 
|         self.stoneData = [] # ±¦Ê¯ÁÐ±í  | 
|         self.isSuite = False  | 
|         self.suiteLV = 0 #Ì××°µÈ¼¶  | 
|         self.isBind = False  | 
|           | 
|         self.source = ShareDefine.Item_Source_Unkown    #ÎïÆ·À´Ô´  | 
|         self.legendAttrIDList = [] # ´«ÆæÊôÐÔID  | 
|         self.legendAttrValueList = [] # ´«ÆæÊôÐÔÖµ  | 
|         self.legendAttrIDListShen = [] # ´«ÆæÊôÐÔID - Éñ  | 
|         self.legendAttrValueListShen = [] # ´«ÆæÊôÐÔÖµ - Éñ  | 
|         self.legendAttrIDListXian = [] # ´«ÆæÊôÐÔID - ÏÉ  | 
|         self.legendAttrValueListXian = [] # ´«ÆæÊôÐÔÖµ - ÏÉ  | 
|         self.legendAttrIDListJi = [] # ´«ÆæÊôÐÔID - ¼«  | 
|         self.legendAttrValueListJi = [] # ´«ÆæÊôÐÔÖµ - ¼«  | 
|         return  | 
|       | 
| def ClearPack(curPlayer, packType):  | 
|     ## Çå¿ÕÖ¸¶¨±³°ü  | 
|     pack = curPlayer.GetItemManager().GetPack(packType)  | 
|     for i in xrange(pack.GetCount()):  | 
|         curItem = pack.GetAt(i)  | 
|         if not curItem or curItem.IsEmpty():  | 
|             continue  | 
|         curItem.Clear()  | 
|     return  | 
|   | 
| def ClearItemID(curPlayer, clearItemIDList, packTypeList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]):  | 
|     ## Çå³ýÖ¸¶¨µÄÎïÆ·IDÁÐ±í  | 
|     clearCountDict = {}  | 
|     for packType in packTypeList:  | 
|         pack = curPlayer.GetItemManager().GetPack(packType)  | 
|         for i in xrange(pack.GetCount()):  | 
|             curItem = pack.GetAt(i)  | 
|             if not curItem or curItem.IsEmpty():  | 
|                 continue  | 
|             itemID = curItem.GetItemTypeID()  | 
|             if itemID not in clearItemIDList:  | 
|                 continue  | 
|             itemCount = curItem.GetCount()  | 
|             curItem.Clear()  | 
|             clearCountDict[itemID] = clearCountDict.get(itemID, 0) + itemCount  | 
|     return clearCountDict  | 
|   | 
| def PutItemInTempSwap(curPlayer, itemID, isAuctionItem=0):  | 
|     ## ÁÙʱ±³°ü·ÅÈëÎïÆ·  | 
|     # ÁÙʱ½»»»±³°üĿǰֻ¿ª·Å1¸ö¸ñ×Ó£¬Ã¿´Î·ÅÈëǰÏÈÇå¿ÕÔÙ·ÅÈë  | 
|     ClearPack(curPlayer, ShareDefine.rptTempSwap)  | 
|     return GivePlayerItem(curPlayer, itemID, 1, isAuctionItem, [ShareDefine.rptTempSwap])  | 
|   | 
| def OpenPickupItemPutInTemp(curPlayer, isClearItem):  | 
|     ''' ¿ªÆôʰȡµÄÎïÆ··ÅÈëÁÙʱ´æ·Å±³°ü  | 
|     @param isClearItem: ÊÇ·ñÇå³ýÁÙʱ´æ·Å±³°üÎïÆ·; Ò»°ã¼¤»î¸Ã¹¦ÄÜʱÉèÖÃΪ True£»  | 
|                         ÓÉÓÚ±ê¼Ç¸Ã״̬µÄkey¼Ç¼²»´æÓÚÊý¾Ý¿â£¬¹ÊÔÚ¸ÃÉ趨ÓÐЧÆÚÄÚÍæ¼ÒÀëÏßÖØÉϻᵼÖÂÉ趨±»ÖØÖà  | 
|                         ËùÒÔµÃÔÚÌØ¶¨µÄ¹¦ÄÜÂß¼ÀÈ縱±¾µÄ DoEnterFB ÖØÐÂÉ趨£©£¬µ«´Ëʱ²»ÄÜÇå¿Õ´Ë±³°üÎïÆ·£¬ÐèÉèÖÃΪ False  | 
|                         ·ñÔò»áµ¼ÖÂÖØÐÂÉÏÏߺó֮ǰÒѾʰȡµÄÁÙʱÎïÆ·±»Çå¿Õ  | 
|     '''  | 
|     if isClearItem:  | 
|         ClearPack(curPlayer, ShareDefine.rptTempItem)  | 
|     curPlayer.SetDict(ChConfig.Def_PlayerKey_PickupItemPutInTemp, 1)  | 
|     return  | 
|   | 
| def ClosePickupItemPutInTemp(curPlayer):  | 
|     # ¹Ø±ÕʰȡµÄÎïÆ··ÅÈëÁÙʱ´æ·Å±³°ü  | 
|     curPlayer.SetDict(ChConfig.Def_PlayerKey_PickupItemPutInTemp, 0)  | 
|     return  | 
|   | 
| def DoGivePlayerTempPackItem(curPlayer, event=["", False, {}], mailTypeKey=None, extraItemList=[]):  | 
|     ''' ½«ÁÙʱ±³°üÖеÄÎïÆ··ÅÈëÍæ¼ÒÎïÆ·±³°ü  | 
|     @param mailType: ÎïÆ·±³°ü¿Õ¼ä²»¹»Ê±Ê¹ÓÃÓʼþ·¢ÎïÆ·¸øÍæ¼ÒµÄÓʼþÄ£°å  | 
|     '''  | 
|     tempItemList = []  | 
|     pack = curPlayer.GetItemManager().GetPack(ShareDefine.rptTempItem)  | 
|     for i in xrange(pack.GetCount()):  | 
|         curItem = pack.GetAt(i)  | 
|         if not curItem or curItem.IsEmpty():  | 
|             continue  | 
|         tempItemList.append(curItem)  | 
|           | 
|     if not tempItemList and not extraItemList:  | 
|         return []  | 
|   | 
|     needSpace = len(tempItemList) + len(extraItemList)  | 
|     isSendMail = needSpace > ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)  | 
|     if isSendMail:  | 
|         mailItemList = []  | 
|         for tempItem in tempItemList:  | 
|             mailItemList.append(ItemCommon.GetMailItemDict(tempItem))  | 
|         mailItemList += extraItemList  | 
|         mailTypeKey = ShareDefine.DefaultLackSpaceMailType if not mailTypeKey else mailTypeKey  | 
|         PlayerControl.SendMailByKey(mailTypeKey, [curPlayer.GetPlayerID()], mailItemList)  | 
|     else:  | 
|         itemControl = PlayerItemControler(curPlayer)  | 
|         for tempItem in tempItemList:  | 
|             itemControl.PutInItem(IPY_GameWorld.rptItem, tempItem, event=event)  | 
|         for itemID, itemCnt, isAuctionItem in extraItemList:  | 
|             GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)  | 
|               | 
|     ClearPack(curPlayer, ShareDefine.rptTempItem)  | 
|     return  | 
|   | 
| def CheckPackSpaceEnough(curPlayer, itemList, isNotify=True):  | 
|     ## ¼ì²éÍæ¼Ò¶ÔÓ¦±³°üÊÇ·ñ×ã¹»·ÅÈëÎïÆ·  | 
|     needPackSpaceDict = {}  | 
|     for itemID, itemCnt, isAuctionItem in itemList:  | 
|         curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|         if not curItem:  | 
|             return False  | 
|         packType = ChConfig.GetItemPackType(curItem)  | 
|         needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)  | 
|         needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace  | 
|           | 
|     for packType, needSpace in needPackSpaceDict.items():  | 
|         if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):  | 
|             if isNotify:  | 
|                 PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])  | 
|             return False  | 
|           | 
|     return True  | 
|   | 
| def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):  | 
|     ##¸øÎïÆ·£¬±³°üÂúÔò·¢Óʼþ  | 
|     if not itemList:  | 
|         return  | 
|     needPackSpaceDict = {}  | 
|     for itemID, itemCnt, isAuctionItem in itemList:  | 
|         curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|         if not curItem:  | 
|             GameWorld.ErrLog('GivePlayerItemOrMail ÎïÆ·ID²»´æÔÚ itemID=%s'%itemID, curPlayer.GetID())  | 
|             return  | 
|         packType = ChConfig.GetItemPackType(curItem)  | 
|         needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)  | 
|         needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace  | 
|     isSendMail = False  | 
|     for packType, needSpace in needPackSpaceDict.items():  | 
|         if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):  | 
|             isSendMail = True  | 
|             break  | 
|              | 
|     if isSendMail:  | 
|         PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)  | 
|         GameWorld.DebugLog("GivePlayerItemOrMail±³°ü¿Õ¼ä²»¹»£¬·¢ËÍÓʼþ: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())  | 
|     else:  | 
|         for itemID, itemCnt, isAuctionItem in itemList:  | 
|             GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)  | 
|     return  | 
|   |