#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#---------------------------------------------------------------------  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
##@package ItemCommon  
 | 
# ÎïÆ·Í¨Óà  
 | 
#  
 | 
# @author alee  
 | 
# @date 2017-07-28 14:00  
 | 
# @version 1.0  
 | 
#  
 | 
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#"""Version = 2017-07-28 14:00"""  
 | 
#---------------------------------------------------------------------  
 | 
#ÎïÆ·¹ÜÀíÆ÷  
 | 
import GameWorld  
 | 
import BuffSkill  
 | 
import PlayerControl  
 | 
import SkillCommon  
 | 
import IPY_GameWorld  
 | 
import ChConfig  
 | 
import ReadChConfig  
 | 
import ShareDefine  
 | 
import GameDataControl  
 | 
import ItemControler  
 | 
import DataRecordPack  
 | 
import EventReport  
 | 
import ChItem  
 | 
import IpyGameDataPY  
 | 
import Operate_EquipStone  
 | 
import PlayerViewCacheTube  
 | 
import Operate_EquipWash  
 | 
import FormulaControl  
 | 
import ChPyNetSendPack  
 | 
import NetPackCommon  
 | 
import PyGameData  
 | 
import ChEquip  
 | 
import SkillShell  
 | 
import random  
 | 
import math  
 | 
import time  
 | 
import json  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#ʹÓòÄÁÏģʽ ¶¼ÓàֻÓв»°ó¶¨ Ö»ÓÃ°ó¶¨  
 | 
[  
 | 
UseStuffMode_All, # ¿ÉÒÔʹÓÃÈ«²¿²ÄÁÏ  
 | 
UseStuffMode_NoBind, # Ö»Ê¹Ó÷ǰ󶨵IJÄÁÏ  
 | 
UseStuffMode_Bind, # Ö»Ê¹Óð󶨵IJÄÁÏ  
 | 
] = range(0 , 2 + 1)  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
def InitPyItem():  
 | 
    if PyGameData.InitPyItem:  
 | 
        return  
 | 
    GameWorld.Log("¼ÓÔØÎïÆ·Êý¾Ý...")  
 | 
      
 | 
    PyGameData.DailyUseCountLimitItemIDList = []  
 | 
      
 | 
    gameData = GameWorld.GetGameData()  
 | 
    for i in range(0, gameData.GetItemCount()):  
 | 
        findItemData = gameData.GetItemAt(i)  
 | 
        if GetCanUseCountDaily(findItemData):  
 | 
            PyGameData.DailyUseCountLimitItemIDList.append(findItemData.GetItemTypeID())  
 | 
    if PyGameData.DailyUseCountLimitItemIDList:  
 | 
        GameWorld.Log("ÿÈÕÓÐʹÓôÎÊýÏÞÖÆµÄÎïÆ·IDÁбí: %s" % PyGameData.DailyUseCountLimitItemIDList)  
 | 
          
 | 
    PyGameData.InitPyItem = True  
 | 
    return  
 | 
  
 | 
## ÎïÆ·´¥·¢¼¼ÄÜÔö¼Óbuff  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem ÎïÆ·  
 | 
#  @param tick Ê±¼ä´Á  
 | 
#  @param needResult ÊÇ·ñÐèҪˢÐÂÊôÐÔ  
 | 
#  @return ²¼¶ûÖµ  
 | 
#  @remarks ÎïÆ·´¥·¢¼¼ÄÜÔö¼Óbuff  
 | 
def ItemUseSkillAddBuff(curPlayer, curItem, tick, needResult=True, useCnt=1):  
 | 
    addSkillList = __GetAddSkillList(curPlayer, curItem)  
 | 
      
 | 
    #ÎÞ¸½¼Ó¼¼ÄÜ  
 | 
    if not addSkillList:  
 | 
        return False  
 | 
      
 | 
    refreshResult = False  
 | 
    #buffTypeList = []  
 | 
      
 | 
    for _ in xrange(useCnt):  
 | 
        for addSkill in addSkillList:  
 | 
            buffType = SkillCommon.GetBuffType(addSkill)  
 | 
            #@warning: ÎïÆ·´¥·¢¼¼ÄÜ, Buff×ÜֵΪµÚ1¸öЧ¹ûµÄAÖµ  
 | 
            addBuffValueList = SkillShell.GetAddBuffValue(curPlayer, addSkill, curPlayer)  
 | 
            if BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, addSkill, tick, addBuffValueList, curPlayer):  
 | 
                refreshResult = True  
 | 
  
 | 
      
 | 
    #---´¥·¢×°±¸¼¼Äܳɹ¦---  
 | 
    if needResult and refreshResult:  
 | 
        playerControl = PlayerControl.PlayerControl(curPlayer)  
 | 
        playerControl.RefreshPlayerAttrByBuff()  
 | 
          
 | 
    return True  
 | 
  
 | 
## »ñÈ¡ÎïÆ·ËùÓµÓеļ¼ÄÜ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem Ê¹ÓÃÎïÆ·  
 | 
#  @return addSkillList ¼¼ÄÜÁÐ±í  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __GetAddSkillList(curPlayer , curItem):  
 | 
    addSkillList = []  
 | 
    gameData = GameWorld.GetGameData()  
 | 
    curItemID = curItem.GetItemTypeID()  
 | 
      
 | 
    for i in range(0, curItem.GetAddSkillCount()):  
 | 
        curSkillID = curItem.GetAddSkill(i)  
 | 
          
 | 
        if not curSkillID:  
 | 
            continue  
 | 
          
 | 
        curSkill = gameData.GetSkillBySkillID(curSkillID)  
 | 
          
 | 
        if not curSkill:  
 | 
            GameWorld.Log('###²ß»®Ìî±íÒì³££¬ÎïÆ· = %s´¥·¢¼¼ÄÜʧ°Ü = %s' % (curItemID , curSkillID))  
 | 
            return []  
 | 
          
 | 
        buffType = SkillCommon.GetBuffType(curSkill)  
 | 
          
 | 
        #¼ì²éÊÇ·ñ¿ÉÒÔÌí¼ÓÕâ¸öbuff  
 | 
        if not SkillCommon.CheckCanAddBuff(curPlayer , buffType , curSkill.GetSkillTypeID(), curSkill.GetSkillLV()):  
 | 
            PlayerControl.NotifyCode(curPlayer, 'XW_ZZ_ResInvalidation')  
 | 
            return []  
 | 
          
 | 
        addSkillList.append(curSkill)  
 | 
          
 | 
    return addSkillList  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## ÎïÆ·xml²ÎÊý  
 | 
#  @param curItem ÎïÆ·  
 | 
#  @return None  
 | 
def GetItemXMLMsg(curItem):  
 | 
    itemTypeID = curItem.GetItemTypeID()  
 | 
    # s0-s2  
 | 
    msgList = ['%s' % itemTypeID, '0' , '0' ]  
 | 
      
 | 
#===============================================================================  
 | 
#    stoneCntMax = ChConfig.Def_EquipMaxHole  # ×î¶à¿×Êý  
 | 
#    stoneIDList = []  # ¿×Éϵı¦Ê¯IDÁÐ±í  
 | 
#    for i in range(stoneCntMax):  
 | 
#          
 | 
#        if i >= canPlaceStoneCount:  
 | 
#            stoneIDList.append('0')  
 | 
#            continue  
 | 
#          
 | 
#        stoneIDList.append('%s' % curItem.GetStone(i))  
 | 
#      
 | 
#    #s3-s11 stoneID  
 | 
#    msgList.extend(stoneIDList)    
 | 
#         
 | 
#    curDurg = GameWorld.GetIntUpper(curItem.GetCurDurg(), ChConfig.Def_EndureRepairParameter)  
 | 
#    curMaxDurg = GameWorld.GetIntUpper(curItem.GetMaxEndure(), ChConfig.Def_EndureRepairParameter)  
 | 
#    curItemMakerName = curItem.GetMakerName()  
 | 
# #    #ÎÞÃû×Ö,·¢¿Õ×Ö·û  
 | 
# #    if not curItem.GetMaker():  
 | 
# #        curItemMakerName = ' '  
 | 
#          
 | 
#    addSkillCnt = curItem.GetUserAttr(IPY_GameWorld.iudetEquipAddSkillCnt)   
 | 
#      
 | 
#    #s12 -> ÎåÐÐ,s13 -> Áé»ê¼¼ÄÜID,s14 -> µ±Ç°Ä;Ã,s15 -> ×î´óÄ;Ã,s16 -> °ó¶¨,s17 -> MakeID,s18 ->   
 | 
#    msgList.extend(['%s' % curItem.GetItemProperty(),  
 | 
#                    '%s' % curItem.GetSoulProperty(),  
 | 
#                    '%s' % curDurg, '%s' % curMaxDurg,  
 | 
#                    '%s' % curItem.GetIsBind(),  
 | 
#                    '%s' % curItemMakerName,  
 | 
#                    '%s' % addSkillCnt])  
 | 
#      
 | 
#    skillCntMax = ChConfig.Def_EquipSkillCntMax  # ¸½¼ÓÊôÐÔ¼¼ÄÜ×î¶à  
 | 
#    addSkillList = []  # ¸Ã×°±¸µ±Ç°µÄÁéÎÆÊôÐÔÁÐ±í  
 | 
#      
 | 
#    for j in range(skillCntMax):  
 | 
#        if j >= curItem.GetUserAttrCount(IPY_GameWorld.iudetEquipAddSkillList):  
 | 
#            addSkillList.append('0')  
 | 
#            continue  
 | 
#          
 | 
#        skillID = curItem.GetUserAttrByIndex(IPY_GameWorld.iudetEquipAddSkillList, j)  
 | 
#        addSkillList.append('%s' % skillID)  
 | 
#      
 | 
#    #s19-s38 skillID  
 | 
#    msgList.extend(addSkillList)  
 | 
#      
 | 
#    #s39 -> ¿ª¹â,s40 -> ×°±¸ÆõºÏµÈ¼¶,s42 -> ×°±¸ÊìÁ·¶È,s42 -> ÊÇ·ñÌ××°»¯,s43 -> ×îСÉ˺¦,  
 | 
#    #s44 -> ×î´óÉ˺¦, s45 -> ÁéÎÆ´ÎÊýÉÏÏÞ, s46 -> ×°±¸·ÀÓùÖµ, s47 -> Ê£Óàʱ¼ä, s48 -> hp»ù´¡Öµ,  
 | 
#    #s49 -> ÄÚ·À»ù´¡Öµ, s50 -> ÊÇ·ñ»½ÐÑ s51 -> itemTypeID  
 | 
#    msgList.extend(['%s' % curItem.GetUserAttr(IPY_GameWorld.iudetEquipElem), # ¿ª¹â  
 | 
#                    '%s' % curItem.GetFitLV(), # ×°±¸ÆõºÏµÈ¼¶  
 | 
#                    '%s' % curItem.GetProficiency(), # ×°±¸ÊìÁ·¶È  
 | 
#                    '%s' % int(curItem.GetIsSuite()), # ÊÇ·ñÌ××°»¯  
 | 
#                    '%s' % curItem.GetEquipMinAtkValue(), # ×îСÉ˺¦  
 | 
#                    '%s' % curItem.GetEquipMaxAtkValue(), # ×î´óÉ˺¦  
 | 
#                    '%s' % curItem.GetRelMaxAddSkillCnt(), # ÁéÎÆ´ÎÊýÉÏÏÞ  
 | 
#                    '%s' % curItem.GetEquipDefenseValue(), # ×°±¸·ÀÓùÖµ  
 | 
#                    '%s' % curItem.GetRemainHour(), # Ê£Óàʱ¼ä  
 | 
#                    '%s' % curItem.GetBaseHP(), # hp»ù´¡Öµ  
 | 
#                    '%s' % curItem.GetBaseMagicDef(), # ÄÚ·À»ù´¡Öµ  
 | 
#                    '%s' % curItem.GetUserAttr(IPY_GameWorld.iudetWakeUpCnt), # ÊÇ·ñ»½ÐÑ  
 | 
#                    '%s' % itemTypeID])  
 | 
#===============================================================================  
 | 
      
 | 
    return msgList  
 | 
  
 | 
  
 | 
## Ìáʾ³¬¼¶×°±¸  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem µÃµ½µÄÎïÆ·  
 | 
#  @param notifyType ¼ø¶¨1 ´òÔì2 ÉýÐÇ3 ÉñÆ÷ÉýÐÇ4 ÉñÆ÷»½ÐÑ5 ³èÎï×°±¸ºÏ³É6 ¶ª±¦Ïä×°±¸7  
 | 
#  @param useItemID Ê¹ÓõÄÎïÆ·id  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def Notify_SuperItem(curPlayer, curItem, notifyType, useItemID=0):  
 | 
#===============================================================================  
 | 
#Item_Link_Appraisal ¼ø¶¨³öÁËÒ»¼þ¾ªÊÀÉñ×°  
 | 
#Item_Link_Factory   ´òÔì³öÁËÒ»¼þ¾ªÊÀÉñ×°  
 | 
#S1 -> playID,S2 -> playname,S3 -> playname,s4 -> itemID,s5 -> start,s6 -> hole,s7-s15 stoneID,s16 -> ÎåÐÐ,  
 | 
#s17 -> Áé»ê¼¼ÄÜID,s18 -> µ±Ç°Ä;Ã,s19 -> ×î´óÄ;Ã,s20 -> °ó¶¨,s21 -> MakeID,s22 -> ÎïÆ·Ãû×Ö  
 | 
#===============================================================================  
 | 
  
 | 
      
 | 
    #ÉýÐǼ°ÉñÆ÷  
 | 
    if notifyType in [3]:  
 | 
#===============================================================================  
 | 
#        #ÉýÐǵÄϵͳÌáʾ²ÎÊýÁÐ±í  
 | 
#        roleName = curPlayer.GetName()  
 | 
#                  
 | 
#        #S1 -> playID,S2 -> playname,S3 -> playname,  
 | 
#        msgList = ['%s' % curPlayer.GetID(), '%s' % roleName, '%s' % roleName]  
 | 
#          
 | 
#        # ÎïÆ·xml²ÎÊýs4-s55  
 | 
#        msgList.extend(GetItemXMLMsg(curItem))  
 | 
#          
 | 
# #        GameWorld.Log('ÉýÐÇ,msgList = %s, %s'%(len(msgList), msgList))  
 | 
#        if notifyType == 3:  
 | 
#            msgList.extend(["%s" % curItem.GetItemStarLV()])  # ÉýÐÇ×îºóÒ»¸ö²ÎÊýΪÐÇÊý  
 | 
#            #ÆÕͨÉýÐÇ  
 | 
#            PlayerControl.WorldNotify(0, "Item_Link_UpGrade", msgList)  
 | 
#===============================================================================  
 | 
  
 | 
        return  
 | 
  
 | 
          
 | 
    #---³ýÉýÐÇÍâµÄϵͳÌáʾ²ÎÊýÁбí---  
 | 
    msgList = ['%s' % curPlayer.GetID(), '%s' % curPlayer.GetName(), '%s' % curPlayer.GetName(),  
 | 
               '%s' % curItem.GetItemTypeID(),'%s' % curItem.GetIsBind(), '%s' % curItem.GetItemTypeID()  
 | 
               ]  
 | 
    #¼ø¶¨  
 | 
    if notifyType == 1:  
 | 
        PlayerControl.WorldNotify(0, "Item_Link_Appraisal", msgList)  
 | 
    #´òÔì  
 | 
    elif notifyType == 2:  
 | 
        PlayerControl.WorldNotify(0, "Item_Link_Factory", msgList)  
 | 
    #³èÎï×°±¸ºÏ³É  
 | 
    elif notifyType == 6:  
 | 
        PlayerControl.WorldNotify(0, "Pet_liubo_436832", msgList)  
 | 
    # mu×°±¸È«·þ¹ã²¥  
 | 
    elif notifyType == 7:  
 | 
        # ²åÈëʹÓõÄÎïÆ·Ãû  
 | 
        if not useItemID:  
 | 
            return  
 | 
        msgList.insert(3, '%s' % useItemID)  
 | 
        msgList.insert(4, '%s' % useItemID)  
 | 
        itemInfo = GetNotifySuperItemInfo(curPlayer, curItem)  
 | 
        msgList = msgList[:5] + itemInfo  
 | 
        PlayerControl.WorldNotify(0, "GeRen_lhs_318691", msgList)  
 | 
    return  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
  
 | 
## Çå³ý°´Ìì¹ýÆÚÎïÆ·  
 | 
#  @param curPlayer Íæ¼Ò  
 | 
#  @return None  
 | 
def ClearDayTimeItem(curPlayer):  
 | 
    serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)  
 | 
    itemManager = curPlayer.GetItemManager()  
 | 
    #±éÀú¿ÉÄÜ´æÔڵı³°ü, Ö´ÐÐÂß¼  
 | 
    for packIndex in ChConfig.Def_RealityTimeItem_Pack:  
 | 
        curPack = itemManager.GetPack(packIndex)  
 | 
        for i in range(0, curPack.GetCount()):  
 | 
            curItem = curPack.GetAt(i)  
 | 
              
 | 
            #Òì³£ÎïÆ·  
 | 
            if not CheckItemCanUse(curItem):  
 | 
                continue  
 | 
  
 | 
            reduceType = curItem.GetEndureReduceType()  
 | 
            if reduceType not in [ChConfig.Def_EquipReduceType_Day, ChConfig.Def_EquipReduceType_ServerDay]:  
 | 
                continue  
 | 
              
 | 
            if reduceType == ChConfig.Def_EquipReduceType_Day:  
 | 
                if curItem.GetRemainHour() > 1:  
 | 
                    curItem.SetRemainHour(curItem.GetRemainHour() - 1) # Ã¿Ìì-1  
 | 
                    continue  
 | 
            elif reduceType == ChConfig.Def_EquipReduceType_ServerDay:  
 | 
                if serverDay < curItem.GetExpireTime():  
 | 
                    continue  
 | 
                  
 | 
            #curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr())  
 | 
            #if curTime < curItem.GetRemainHour():  
 | 
            #    continue  
 | 
              
 | 
            curItemID = curItem.GetItemTypeID()  
 | 
            if packIndex != IPY_GameWorld.rptRecycle: #»Ø¹ºµÄ²»Ìáʾ  
 | 
                PlayerControl.NotifyCode(curPlayer, "PK_hwj35_82012", [curItemID])  
 | 
          
 | 
            dataDict = {"ItemID":curItemID,   
 | 
                        "CreateTime":curItem.GetCreateTime(),   
 | 
                        "IsBind":curItem.GetIsBind(),  
 | 
                        "ItemGUID":curItem.GetGUID()}  
 | 
            DataRecordPack.DR_DeleteItem(curPlayer, "Time", dataDict)  
 | 
              
 | 
            #ÎïÆ·Ïûʧ  
 | 
            #curItem.Clear()  
 | 
      
 | 
    return  
 | 
  
 | 
  
 | 
## »ñµÃÖ¸¶¨ÌìµÄ¹ýÆÚʱ¼ä  
 | 
#  @param days ¼¸Ììºó¹ýÆÚ ´Ó1¿ªÊ¼£¬´ú±íµ±Ìì  
 | 
#  @return ¹ýÆÚʱ¼äÊý×Ö  
 | 
def __GetEndDayTimeNum(days):  
 | 
    timeStr = str(GameWorld.GetDatetimeByDiffDays(days - 1)).split(" ")[0] + " 23:59:59"  
 | 
    GameWorld.DebugLog("ÎïÆ·¹ýÆÚʱ¼ä" + timeStr)  
 | 
    return GameWorld.ChangeTimeStrToNum(timeStr)  
 | 
  
 | 
  
 | 
## ´´½¨ÎïÆ·  
 | 
#  @param itemID ÎïÆ·ID  
 | 
#  @return curSingleItem  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def CreateSingleItem(itemID, itemCount=1, isBind=0, expireTime=0):  
 | 
    curSingleItem = GameWorld.GetItemFactory().CreateItem(itemID)  
 | 
    if not curSingleItem:  
 | 
        return  
 | 
      
 | 
    #Èç¹ûÊÇÕæÊµÎïÆ·, ²»Í¨¹ýSetRemainHour֪ͨʣÓàʱ¼ä£¬¿Í»§¶Ë×Ô¼º¼ÆË㣬·þÎñ¶Ë·À·¶Ê¹Óà  
 | 
    # ´´½¨ºó¿ªÊ¼¼ÆÊ±  
 | 
    if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_RTimeItem:  
 | 
        #curSingleItem.SetRemainHour(curSingleItem.GetExpireTime())  
 | 
        # Í¨Öª¿Í»§¶ËʱЧÎïÆ·µÄ´´½¨Ê±¼ä  
 | 
        curSingleItem.SetUserAttr(ShareDefine.Def_IudetCreateTime, int(time.time()))  
 | 
      
 | 
    # ×°±¸ºó¿ªÊ¼¼ÆÊ±  
 | 
    if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_Time:  
 | 
        # Í¨Öª¿Í»§¶ËʱЧÎïÆ·µÄ´´½¨Ê±¼ä  
 | 
        curSingleItem.SetUserAttr(ShareDefine.Def_IudetCreateTime, 0)  
 | 
          
 | 
    # ÏÞ¶¨Ê±¼ä¹ýÌìÏûʧµÄÎïÆ·£¬Èç1´ú±íµ±ÌìÏûʧ,onday ´¦Àí  
 | 
    if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_Day:  
 | 
        # SetRemainHour´Ë´¦ÓÃÓڼǼ¹ýÆÚµÄ¾ßÌåʱ¼äÈç 2014-10-10 23:59:59  
 | 
        #timess = __GetEndDayTimeNum(curSingleItem.GetExpireTime())  
 | 
        curSingleItem.SetRemainHour(curSingleItem.GetExpireTime())  
 | 
      
 | 
    if curSingleItem.GetEndureReduceType() == ChConfig.Def_EquipReduceType_ServerDay:  
 | 
        outTimeServerDay = curSingleItem.GetExpireTime()  
 | 
        serverDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)  
 | 
        if serverDay >= outTimeServerDay:  
 | 
            curSingleItem.Clear()  
 | 
            GameWorld.ErrLog("ÎïÆ·ÓÐЧÆÚ³¬¹ýÓÐЧµÄ¿ª·þÌì, ²»¿É´´½¨!itemID=%s,serverDay=%s,outTimeServerDay=%s"   
 | 
                             % (itemID, serverDay, outTimeServerDay))  
 | 
            return  
 | 
        curSingleItem.SetRemainHour(outTimeServerDay)  
 | 
          
 | 
    if isBind:  
 | 
        curSingleItem.SetIsBind(1)  
 | 
          
 | 
    ItemControler.SetItemCount(curSingleItem, itemCount)  
 | 
      
 | 
    if expireTime > 0:  
 | 
        curSingleItem.SetUserAttr(ShareDefine.Def_IudetExpireTime, expireTime)  
 | 
          
 | 
    #ÕâÀï·µ»ØµÄÊÇSingleItem , Èç¹û´´½¨ÁË,δʹÓÃ,»áÕÒ³öC++ÄÚ´æÐ¹Â¶!!!  
 | 
    return curSingleItem  
 | 
  
 | 
  
 | 
def MakeEquipGS(curItem):  
 | 
    if not CheckNoteEquipGS(curItem):  
 | 
        GameWorld.DebugLog("²»ÉèÖÃ×°±¸ÆÀ·Ö")  
 | 
        return  
 | 
    value = CalcEquipGS(curItem)  
 | 
    #GameWorld.DebugLog("ÉèÖÃ×°±¸ÆÀ·Ö: ItemID=%s,attrDict=%s,value=%s" % (curItem.GetItemTypeID(), attrDict, value))  
 | 
    SetEquipGearScore(curItem, value)  
 | 
    return  
 | 
  
 | 
def CalcEquipGS(curItem):  
 | 
    '''¼ÆËã×°±¸ÆÀ·Ö  
 | 
        ÆÀ·Ö×é³É£º×°±¸»ù´¡ + ´«ÆæÊôÐÔ + ¾ø°æÊôÐÔ  
 | 
    '''  
 | 
    if not CheckNoteEquipGS(curItem):  
 | 
        #GameWorld.DebugLog("²»ÉèÖÃ×°±¸ÆÀ·Ö")  
 | 
        return 0  
 | 
      
 | 
    attrDict = {}  
 | 
    #»ù´¡ÊôÐÔЧ¹û  
 | 
    for i in xrange(curItem.GetEffectCount()):  
 | 
        curEffect = curItem.GetEffectByIndex(i)  
 | 
        if not curEffect:  
 | 
            break  
 | 
        effectID = curEffect.GetEffectID()  
 | 
        if effectID == 0:  
 | 
            break  
 | 
        attrDict[effectID] = attrDict.get(effectID, 0) + curEffect.GetEffectValue(0)  
 | 
          
 | 
    classLV = GetItemClassLV(curItem)  
 | 
    color = curItem.GetItemColor()  
 | 
    itemQuality = curItem.GetItemQuality()  
 | 
    gsParamIpyData = IpyGameDataPY.GetIpyGameData("EquipGSParam", classLV, color, itemQuality)  
 | 
    # ´«ÆæÊôÐÔ  
 | 
    legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)  
 | 
    legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)  
 | 
    if legendAttrIDCnt and legendAttrIDCnt == legendAttrValueCnt:  
 | 
        for i in xrange(legendAttrIDCnt):  
 | 
            attrID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i)  
 | 
            attrValue = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i)  
 | 
            attrDict[attrID] = attrDict.get(attrID, 0) + attrValue  
 | 
              
 | 
    Atk = attrDict.get(ShareDefine.Def_Effect_Atk, 0)  
 | 
    MinAtk = attrDict.get(ShareDefine.Def_Effect_MinAtk, 0) + Atk  
 | 
    MaxAtk = attrDict.get(ShareDefine.Def_Effect_MaxAtk, 0) + Atk  
 | 
    MaxHP = attrDict.get(ShareDefine.Def_Effect_MaxHP, 0)  
 | 
    Def = attrDict.get(ShareDefine.Def_Effect_Def, 0)  
 | 
    ArmorDefPer = attrDict.get(ShareDefine.Def_Effect_ArmorDefAddPer, 0)  
 | 
    IceAtk = attrDict.get(ShareDefine.Def_Effect_IceAtk, 0)  
 | 
    IceDef = attrDict.get(ShareDefine.Def_Effect_IceDef, 0)  
 | 
      
 | 
    AtkPer = attrDict.get(ShareDefine.Def_Effect_AddAtkByPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetAtkPerC())  
 | 
    DamagePer = attrDict.get(ShareDefine.Def_Effect_DamagePer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamagePerC())  
 | 
    SuperHitRate = attrDict.get(ShareDefine.Def_Effect_SuperHitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitRateC())  
 | 
    SuperHitPer = attrDict.get(ShareDefine.Def_Effect_SuperHitPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitPerC())  
 | 
    DamReducePer = attrDict.get(ShareDefine.Def_Effect_DamReducePer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamReducePerC())  
 | 
    MaxHPPer = attrDict.get(ShareDefine.Def_Effect_MaxHPPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMaxHPPerC())  
 | 
    DefPer = attrDict.get(ShareDefine.Def_Effect_DefPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDefPerC())  
 | 
    LuckyHitRate = attrDict.get(ShareDefine.Def_Effect_LuckyHitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetLuckyHitRateC())  
 | 
    PetDamPer = attrDict.get(ShareDefine.Def_Effect_PetDamPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPetDamPerC())  
 | 
    PerLVAtk = attrDict.get(ShareDefine.Def_Effect_PerLVAtk, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPerLVAtkC())  
 | 
    MissRate = attrDict.get(ShareDefine.Def_Effect_MissRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMissRateC())  
 | 
    HitRate = attrDict.get(ShareDefine.Def_Effect_HitRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetHitRateC())  
 | 
    DamBackPer = attrDict.get(ShareDefine.Def_Effect_DamBackPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamBackPerC())  
 | 
    PerLVMaxHP = attrDict.get(ShareDefine.Def_Effect_PerLVMaxHP, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetPerLVMaxHPC())  
 | 
    DropEquipPer = attrDict.get(ShareDefine.Def_Effect_DropEquipPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDropEquipPerC())  
 | 
    DropMoneyPer = attrDict.get(ShareDefine.Def_Effect_DropMoneyPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDropMoneyPerC())  
 | 
    IgnoreDefRateReduce = attrDict.get(ShareDefine.Def_Effect_IgnoreDefRateReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetIgnoreDefRateReduceC())  
 | 
    DamChanceDef = attrDict.get(ShareDefine.Def_Effect_DamChanceDef, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetDamChanceDefC())  
 | 
    SuperHitReduce = attrDict.get(ShareDefine.Def_Effect_SuperHitReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSuperHitReduceC())  
 | 
    SkillAtkRate = attrDict.get(ShareDefine.Def_Effect_SkillAtkRate, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAtkRateC())  
 | 
    SpeedPer = attrDict.get(ShareDefine.Def_Effect_SpeedPer, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSpeedPerC())  
 | 
    SkillAtkRateReduce = attrDict.get(ShareDefine.Def_Effect_SkillAtkRateReduce, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetSkillAtkRateReduceC())  
 | 
    Hit = attrDict.get(ShareDefine.Def_Effect_Hit, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetHitC())  
 | 
    Miss = attrDict.get(ShareDefine.Def_Effect_Miss, 0) * (1 if not gsParamIpyData else gsParamIpyData.GetMissC())  
 | 
      
 | 
    # ¹¥ËÙ²»Ä¬Èϳˣ¬½ö×÷Ϊ²ÎÊýÌṩ²ß»®Ê¹Óà  
 | 
    AtkSpeed = attrDict.get(ShareDefine.Def_Effect_AtkSpeed, 0)  
 | 
    AtkSpeedC = 1 if not gsParamIpyData else gsParamIpyData.GetAtkSpeedC()  
 | 
      
 | 
    # ¾ø°æ  
 | 
    outOfPrintAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetOutOfPrintAttrID)  
 | 
    outOfPrintAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetOutOfPrintAttrValue)  
 | 
    if outOfPrintAttrIDCnt and outOfPrintAttrIDCnt == outOfPrintAttrValueCnt:  
 | 
        for i in xrange(legendAttrIDCnt):  
 | 
            attrID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetOutOfPrintAttrID, i)  
 | 
            attrValue = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetOutOfPrintAttrValue, i)  
 | 
            attrDict[attrID] = attrDict.get(attrID, 0) + attrValue  
 | 
      
 | 
    OnlyFinalHurt = attrDict.get(ShareDefine.Def_Effect_OnlyFinalHurt, 0)  
 | 
    PVPAtkBackHP = attrDict.get(ShareDefine.Def_Effect_PVPAtkBackHP, 0)    
 | 
      
 | 
    if GetIsDogzEquip(curItem):  
 | 
        # ÉñÊÞ×°±¸Óò»Í¬¹«Ê½  
 | 
        value = eval(FormulaControl.GetCompileFormula("EquipGSFormula3", IpyGameDataPY.GetFuncCfg("EquipGSFormula", 3)))  
 | 
    else:  
 | 
        value = eval(FormulaControl.GetCompileFormula("EquipGSFormula", IpyGameDataPY.GetFuncCfg("EquipGSFormula")))  
 | 
    return value  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Í¨¹ýЧ¹ûID,¼ì²éÊÇ·ñΪָ¶¨ÎïÆ·   
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @param effectList Ö¸¶¨µÄЧ¹ûIDÁÐ±í  
 | 
#  @return True or False  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def CheckItemByEffectID(curPlayer, curItem, effectList):  
 | 
    if not CheckItemCanUse(curItem):  
 | 
        return False  
 | 
      
 | 
    if not ItemControler.CheckItemUseLV(curPlayer, curItem, False):  
 | 
        return False  
 | 
      
 | 
    for i in range(curItem.GetEffectCount()):  
 | 
        effectID = curItem.GetEffectByIndex(i).GetEffectID()  
 | 
          
 | 
        #ÕÒµ½¿ÕÏî¾ÍÍ˳ö  
 | 
        if effectID == 0:  
 | 
            return False  
 | 
          
 | 
        if effectID in effectList:  
 | 
            return True  
 | 
      
 | 
    return False  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
def FindItemInPackByEffect(curPlayer, effectID):  
 | 
    ## Í¨¹ýЧ¹û±éÀú±³°üÕÒµ½ÎïÆ·,ÕÒµ½·µ»Ø¸ÃÎïÆ·£¬Ã»Óзµ»ØÄ¬ÈÏNone  
 | 
    #  @return curItem, index or None  
 | 
    backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  
 | 
    #ËÑË÷±³°ü  
 | 
    for i in range(backPack.GetCount()):  
 | 
        curItem = backPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemByEffectID(curPlayer, curItem, [effectID]):  
 | 
            continue  
 | 
              
 | 
        return curItem, i  
 | 
      
 | 
    return  
 | 
  
 | 
def FindItemInPackByEffectEx(curPlayer, effectID):  
 | 
    ## Í¨¹ýЧ¹û±éÀú±³°üÕÒµ½ÎïÆ·,ÕÒµ½·µ»Ø¸ÃÎïÆ·£¬Ã»Óзµ»ØÄ¬ÈÏNone  
 | 
    #  @return curItem or None  
 | 
    backPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  
 | 
    #ËÑË÷±³°ü  
 | 
    for i in range(backPack.GetCount()):  
 | 
        curItem = backPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemByEffectID(curPlayer, curItem, [effectID]):  
 | 
            continue  
 | 
              
 | 
        return curItem  
 | 
      
 | 
    return  
 | 
#---------------------------------------------------------------------  
 | 
## Í¨¹ýÎïÆ·ID±éÀú±³°üÕÒµ½ÎïÆ·, Ã»Óзµ»ØNone  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param findItemID ²éÕÒµÄÎïÆ·  
 | 
#  @param packIndex ±³°üÀàÐÍ  
 | 
#  @return item or None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def FindItemInPackByItemID(curPlayer , findItemID , packIndex):  
 | 
    backPack = curPlayer.GetItemManager().GetPack(packIndex)  
 | 
    #ËÑË÷±³°ü  
 | 
    for i in range(backPack.GetCount()):  
 | 
        curItem = backPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != findItemID:  
 | 
            continue  
 | 
              
 | 
        return curItem  
 | 
      
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## »ñµÃ±³°üÊ£Óà¿Õ¼ä(²ÎÊý -> µ±Ç°Íæ¼Ò,±³°üË÷Òý)  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param packindex ±³°üË÷Òý  
 | 
#  @return itemSpace  
 | 
#  @remarks »ñµÃ±³°üÊ£Óà¿Õ¼ä  
 | 
def GetItemPackSpace(curPlayer, packindex, getCount=0):  
 | 
    #±³°üÊ£Óà¿Õ¼ä  
 | 
    itemSpace = 0  
 | 
  
 | 
    if packindex in ShareDefine.Def_VPack_TypeList:  
 | 
        for i in xrange(GetVPackCnt(packindex)):  
 | 
            itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  
 | 
            if itemKeyData:  
 | 
                continue  
 | 
            itemSpace += 1  
 | 
            if getCount > 0 and itemSpace >= getCount:  
 | 
                break  
 | 
        return itemSpace  
 | 
          
 | 
    curPack = curPlayer.GetItemManager().GetPack(packindex)  
 | 
      
 | 
    for i in range(0, curPack.GetCount()):  
 | 
        curItem = curPack.GetAt(i)  
 | 
        #²»Êǿոñ¹ýÂË  
 | 
        if not curItem.IsEmpty():  
 | 
            continue  
 | 
          
 | 
        itemSpace += 1  
 | 
        if getCount > 0 and itemSpace >= getCount:  
 | 
            break  
 | 
          
 | 
    return itemSpace  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## ¼ì²é±³°üÊÇ·ñÓпÕλ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param packindex ±³°üË÷Òý  
 | 
#  @return ²¼¶ûÖµ  
 | 
#  @remarks ¼ì²é±³°üÊÇ·ñÓпÕλ  
 | 
def CheckPackHasSpace(curPlayer, packindex, isNotify=False):  
 | 
    if packindex in ShareDefine.Def_VPack_TypeList:  
 | 
        for i in xrange(GetVPackCnt(packindex)):  
 | 
            itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  
 | 
            if not itemKeyData:  
 | 
                return True  
 | 
        return False  
 | 
      
 | 
    curPack = curPlayer.GetItemManager().GetPack(packindex)  
 | 
      
 | 
    for i in range(0, curPack.GetCount()):  
 | 
        curItem = curPack.GetAt(i)  
 | 
        #ÕÒµ½¿Õ¸ñ  
 | 
        if curItem.IsEmpty():  
 | 
            return True  
 | 
          
 | 
    if isNotify:  
 | 
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packindex])  
 | 
          
 | 
    return False  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## ¼ì²é±³°üÊÇ·ñΪ¿Õ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param packindex ±³°üË÷Òý  
 | 
#  @return ²¼¶ûÖµ  
 | 
#  @remarks ¼ì²é±³°üÊÇ·ñÓпÕλ  
 | 
def CheckPackIsEmpty(curPlayer, packindex):  
 | 
    if packindex in ShareDefine.Def_VPack_TypeList:  
 | 
        for i in xrange(GetVPackCnt(packindex)):  
 | 
            itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  
 | 
            if itemKeyData:  
 | 
                return False  
 | 
        return True  
 | 
      
 | 
    curPack = curPlayer.GetItemManager().GetPack(packindex)  
 | 
      
 | 
    for i in range(0, curPack.GetCount()):  
 | 
        curItem = curPack.GetAt(i)  
 | 
          
 | 
        if not curItem.IsEmpty():  
 | 
            #ÕÒµ½ÎïÆ·  
 | 
            return False  
 | 
              
 | 
    return True  
 | 
  
 | 
  
 | 
## »ñµÃ±³°üµÚÒ»¸öΪ¿ÕµÄλÖà  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param packindex ±³°üË÷Òý  
 | 
#  @return ²¼¶ûÖµ  
 | 
def GetEmptyIndexInPack(curPlayer, packindex):  
 | 
    if packindex in ShareDefine.Def_VPack_TypeList:  
 | 
        for i in xrange(GetVPackCnt(packindex)):  
 | 
            itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packindex, i))  
 | 
            if not itemKeyData:  
 | 
                return i  
 | 
        return -1  
 | 
      
 | 
    curPack = curPlayer.GetItemManager().GetPack(packindex)  
 | 
      
 | 
    for i in range(0, curPack.GetCount()):  
 | 
        curItem = curPack.GetAt(i)  
 | 
          
 | 
        if curItem.IsEmpty():  
 | 
            #ÕÒµ½ÎïÆ·  
 | 
            return i  
 | 
              
 | 
    return -1  
 | 
  
 | 
## »ñµÃÐéÄâ±³°ü¸ñ×ÓÊý  
 | 
#  @param packindex ±³°üË÷Òý  
 | 
#  @return ±³°ü¸ñ×ÓÊý  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetVPackCnt(packindex):  
 | 
    if packindex not in ChConfig.Def_VPackCnt_Dict:  
 | 
        return 0  
 | 
    keyStr = ChConfig.Def_VPackCnt_Dict[packindex]  
 | 
    return IpyGameDataPY.GetFuncCfg(keyStr)  
 | 
#---------------------------------------------------------------------  
 | 
## »ñµÃÎïÆ·ÐÅÏ¢Ìáʾ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param useItemID Ê¹ÓÃÎïÆ·  
 | 
#  @param singleItem Í¨ÖªµÄÎïÆ·¶ÔÏó  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def NeedNotifyItem(curPlayer, useItemID , singleItem):  
 | 
    #ÐèÒªÌáʾµÄÎïÆ·ÁÐ±í  
 | 
    #===========================================================================  
 | 
    # itemIDDict = ReadChConfig.GetEvalChConfig('need_notify_id_dict')  
 | 
    # if useItemID not in itemIDDict.keys():  
 | 
    #    return  
 | 
    #   
 | 
    # notifyList = itemIDDict.get(useItemID, [])  
 | 
    #   
 | 
    # if not notifyList:  
 | 
    #    GameWorld.Log("NeedNotifyItem() need_notify_id_dict.txt error useItemID=%s not data" % (useItemID))  
 | 
    #    return  
 | 
    #   
 | 
    # isQualityNotify = notifyList[0] # ×¿Ô½ÊÇ·ñÌáʾ  
 | 
    # notifyStarLV = notifyList[1] # Í¨ÖªµÄÇ¿»¯ÐǼ¶  
 | 
    # itemIdList = notifyList[2:] # È¥³ýÐǼ¶Í¨ÖªµÄ£¬ÆäËûµÄΪ¾ßÌåid֪ͨ  
 | 
    #   
 | 
    # curItemID = singleItem.GetItemTypeID()  
 | 
    # curItemCount = singleItem.GetCount()  
 | 
    # # Èç¹ûÊÇÖ¸¶¨±êµÄÎï  
 | 
    # if (curItemID, curItemCount) in itemIdList:  
 | 
    #    PlayerControl.WorldNotify(0, "itemuse_chenxin_0", [curPlayer.GetPlayerName(),  
 | 
    #                             useItemID, useItemID, curItemID, curItemID, curItemCount])  
 | 
    #    return  
 | 
    #   
 | 
    # # ÆäËûµÄ×°±¸ÅÐ¶Ï  
 | 
    # itemQuality = singleItem.GetItemQuality()  
 | 
    # isSuite = singleItem.GetIsSuite()  
 | 
    # plusLV = singleItem.GetItemStarLV()  
 | 
    # # ×¿Ô½¹ã²¥,Ì××°¹ã²¥,ÐǼ¶¹ã²¥  
 | 
    # if (isQualityNotify and itemQuality) or isSuite or plusLV >= notifyStarLV:  
 | 
    #    Notify_SuperItem(curPlayer, singleItem, 7, useItemID)  
 | 
    #===========================================================================  
 | 
      
 | 
    return  
 | 
  
 | 
  
 | 
## É±¹ÖµôÂäÌáʾ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @return None  
 | 
def NotifyItemDropByKill(curPlayer, curItem, npcID, notifyMark='', mapID=0):  
 | 
    return #ÂÀ³¬Ëµ´Ë´¦ÆÁ±Î  
 | 
    #ÐèÒªÌáʾµÄÎïÆ·ÁÐ±í  
 | 
    itemIDDict = ReadChConfig.GetEvalChConfig('need_notify_id_dict')  
 | 
  
 | 
    notifyList = itemIDDict.get(0, [])  
 | 
    if not notifyList:  
 | 
        #GameWorld.Log("NotifyItemDropByKill() need_notify_id_dict.txt error useItemID=0")  
 | 
        return  
 | 
      
 | 
    playerName = curPlayer.GetPlayerName()  
 | 
    notifyQuality = notifyList[0] # ÐèÒªÌáʾµÄÆ·Öʵȼ¶  
 | 
    notifyStarLV = notifyList[1] # Í¨ÖªµÄÇ¿»¯ÐǼ¶  
 | 
    itemIdList = notifyList[2:] # È¥³ýÐǼ¶Í¨ÖªµÄ£¬ÆäËûµÄΪ¾ßÌåid֪ͨ  
 | 
      
 | 
    curItemID = curItem.GetItemTypeID()  
 | 
    curItemCount = curItem.GetCount()  
 | 
    mapID = GameWorld.GetMap().GetMapID() if not mapID else mapID  
 | 
    # Èç¹ûÊÇÖ¸¶¨±êµÄÎï  
 | 
    if (curItemID, curItemCount) in itemIdList:  
 | 
        itemIDMarkDict = ReadChConfig.GetEvalChConfig('need_notify_id_mark_dict')  
 | 
        notifyMark = itemIDMarkDict.get(curItemID, "GeRen_admin_272921")  
 | 
        PlayerControl.WorldNotify(0, notifyMark, [playerName, mapID, npcID, curItemID, curItemID])  
 | 
        return  
 | 
      
 | 
    # ÆäËûµÄ×°±¸ÅÐ¶Ï  
 | 
#    itemQuality = curItem.GetItemQuality()  
 | 
#    isSuite = curItem.GetIsSuite()  
 | 
#    plusLV = curItem.GetItemStarLV()  
 | 
#    # ×¿Ô½¹ã²¥,Ì××°¹ã²¥,ÐǼ¶¹ã²¥  
 | 
#    if not ((itemQuality >= notifyQuality) or isSuite or plusLV >= notifyStarLV):  
 | 
#        return  
 | 
      
 | 
    msgList = ['%s' % playerName,   
 | 
               '%s' % mapID,   
 | 
               '%s' % npcID,  
 | 
               #'%s' % 0,  
 | 
               ] + GetNotifySuperItemInfo(curPlayer, curItem)  
 | 
      
 | 
    notifyMark = notifyMark if notifyMark else "GeRen_admin_671654"  
 | 
    PlayerControl.WorldNotify(0, notifyMark , msgList)  
 | 
    return  
 | 
  
 | 
def GetNotifySuperItemInfo(curPlayer, curItem, place=None):  
 | 
    '''×°±¸Ìáʾ³¬Á´½ÓÐÅÏ¢»ã×Ü  
 | 
    <a><Word info=item id=%s0/>|showitem=%s0 isbind=%s1 itemcnt=%s2 stone=%s3 userdata=%s4 place=%s5 equippartsuite=%s6 strengthenlv=%s7 equipwash=%s8 equipitems=%s9</a>  
 | 
    isbind£ºÊÇ·ñ°ó¶¨  
 | 
    itemcnt£ºÎïÆ·ÊýÁ¿  
 | 
    stone£º±¦Ê¯ÐÅÏ¢ [stoneItemID, ...]  
 | 
    userdata£º´«ÆæÊôÐÔ  
 | 
    place£º×°±¸Î»  
 | 
    equippartsuite£ºÌ××°ÐÅÏ¢ Í¬²é¿´Íæ¼Ò  
 | 
    strengthenlv£ºÇ¿»¯µÈ¼¶  
 | 
    equipwash£ºÏ´Á·ÐÅÏ¢ Í¬²é¿´Íæ¼Ò£¬µ¥²¿Î»  
 | 
    equipitems£º¸÷²¿Î»ÎïÆ·id [[×°±¸Î»,ÎïÆ·id] ...]  
 | 
    '''  
 | 
    if place == None:  
 | 
        place = curItem.GetEquipPlace()  
 | 
          
 | 
    notifyList = [""] * 10  
 | 
    notifyList[0] = curItem.GetItemTypeID()  
 | 
    notifyList[1] = curItem.GetIsBind()  
 | 
    notifyList[2] = curItem.GetCount()  
 | 
    notifyList[3] = "%s" % Operate_EquipStone.GetEquipIndexStoneIDList(curPlayer, place)  
 | 
    userData = curItem.GetUserData()  
 | 
    notifyList[4] = userData if (userData and userData != "{}") else ""  
 | 
    notifyList[5] =  place  
 | 
    suiteInfo = PlayerViewCacheTube.__GetEquipPartSuiteInfo(curPlayer)  
 | 
    notifyList[6] = "" if not suiteInfo else json.dumps(suiteInfo, ensure_ascii=False)  
 | 
    notifyList[7] = ChEquip.GetEquipPartStarLV(curPlayer, IPY_GameWorld.rptEquip, place)  
 | 
      
 | 
    # µ¥²¿Î»Ï´Á·ÐÅÏ¢  
 | 
    washLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashLV % place) + 1  
 | 
    valueList = [curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashValue % (place, attrNum)) \  
 | 
                    for attrNum in xrange(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1)]  
 | 
    notifyList[8] = "%s" % {"Place":place, "LV":washLV, "Value":valueList}  
 | 
      
 | 
    # ÉíÉÏËù´©×°±¸IDÐÅÏ¢  
 | 
    equipItems = []  
 | 
    playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  
 | 
    for equipIndex in xrange(playerEquip.GetCount()):  
 | 
        if equipIndex not in ShareDefine.RoleEquipType :  
 | 
            continue  
 | 
        curEquip = playerEquip.GetAt(equipIndex)  
 | 
        if not curEquip or curEquip.IsEmpty():  
 | 
            continue  
 | 
        equipItems.append([curEquip.GetItemPlaceIndex(), curEquip.GetItemTypeID()])  
 | 
    notifyList[9] = "%s" % equipItems  
 | 
      
 | 
    return notifyList  
 | 
  
 | 
## Ê¹ÓÃÎïÆ·µÄÌØÊâÌáʾ  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param useItemID Ê¹ÓÃÎïÆ·  
 | 
#  @return None  
 | 
#  @remarks Ê¹ÓÃÎïÆ·µÄÌØÊâÌáʾ  
 | 
def UseItemSpecialNotify(curPlayer, useItemID):  
 | 
    #ÐèÒªÌáʾµÄÎïÆ·ÁÐ±í  
 | 
    itemIDDict = ReadChConfig.GetEvalChConfig('need_eff_box_id')  
 | 
    if useItemID in itemIDDict.keys():  
 | 
        PlayerControl.NotifyCode(curPlayer, itemIDDict.get(useItemID), [useItemID])  
 | 
          
 | 
    #ÐèҪȫ·þÌáʾµÄÎïÆ·ÁÐ±í  
 | 
    wNotifyIDDict = ReadChConfig.GetEvalChConfig('need_wnotify_id')  
 | 
    if useItemID in wNotifyIDDict:  
 | 
        PlayerControl.WorldNotify(0, wNotifyIDDict[useItemID],   
 | 
                                  [curPlayer.GetPlayerName(), useItemID, useItemID])  
 | 
    return  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#´Ëº¯ÊýÑéÖ¤µ±Ç°Ö°Òµ½×¿ÉÓã¨ÏòϼæÈÝ£©£¬Í¬CheckJobÇø·ÖʹÓà  
 | 
def JobUseable(curPlayer, curItem):  
 | 
    '''ÅжÏÎïÆ·ÊÇ·ñÖ°Òµ¿ÉÓà  
 | 
        ÎïÆ·±íÖÐÖ°ÒµÏÞÖÆ¹æÔò: 0ΪͨÓã»·Ç0°Ùλ´ú±íÖ°Òµ£¬Ê®Î»ºÍ¸öλΪְҵ½×Êý, Ö°Òµ½×ÏòϼæÈÝ£¬¸ß½×¿ÉʹÓõͽ×ÎïÆ·  
 | 
    '''  
 | 
    itemJobLimit = curItem.GetJobLimit()  
 | 
    if not itemJobLimit:  
 | 
        return True  
 | 
      
 | 
    # È¡ÏûÏÞÖÆµÄÎïÆ·  
 | 
    if curItem.GetUserAttr(ShareDefine.Def_IudetCancelUseLimit) == 1:  
 | 
        return CheckJob(curPlayer, curItem)  
 | 
      
 | 
    if curPlayer.GetJob() == itemJobLimit / 100 and PlayerControl.GetJobRank(curPlayer) >= itemJobLimit % 100:  
 | 
        return True  
 | 
    return False  
 | 
  
 | 
#´Ëº¯ÊýÑéÖ¤µ±Ç°Ö°ÒµÏµ¿ÉÓã¬Í¬JobUseableÇø·ÖʹÓà  
 | 
def CheckJob(curPlayer, curItem):  
 | 
    '''ÅжÏÎïÆ·ÊÇ·ñְҵϵ¿ÉÓà  
 | 
        ÎïÆ·±íÖÐÖ°ÒµÏÞÖÆ¹æÔò: 0ΪͨÓã»·Ç0°Ùλ´ú±íÖ°Òµ£¬Ê®Î»ºÍ¸öλΪְҵ½×Êý, Ö°Òµ½×ÏòϼæÈÝ£¬¸ß½×¿ÉʹÓõͽ×ÎïÆ·  
 | 
    '''  
 | 
    itemJobLimit = curItem.GetJobLimit()  
 | 
    if not itemJobLimit:  
 | 
        return True  
 | 
    if curPlayer.GetJob() == itemJobLimit / 100:  
 | 
        return True  
 | 
      
 | 
    return False  
 | 
  
 | 
## ÎïÆ·¹«ÓÃÅж¨   
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @return None or True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def CheckItemCanUse(curItem):  
 | 
    if not curItem or curItem.IsEmpty():  
 | 
        return  
 | 
      
 | 
    if curItem.GetIsLocked():  
 | 
        return  
 | 
      
 | 
    return True  
 | 
  
 | 
# ÌØÊâÅж¨¸ù¾ÝʱЧʱ¼äÅж¨ÎïÆ·ÊÇ·ñ¿ÉÒÔʹÓà  
 | 
# ¹ýÆÚÎïÆ·²»ÄÜʹÓûò×°±¸µ«ÊÇ¿ÉÒÔ³öÊÛÐø·Ñ  
 | 
def CheckItemCanUseByExpireTime(curItem):  
 | 
#    curItemCreateTime = curItem.GetCreateTime()  
 | 
#    curItemExpireTime = curItem.GetExpireTime()  
 | 
#    curItemPastTime = GameWorld.GetPastSeconds(curItemCreateTime)  
 | 
#      
 | 
#    reduceType = curItem.GetEndureReduceType()  
 | 
#    if reduceType == ChConfig.Def_EquipReduceType_RTimeItem and \  
 | 
#    curItemPastTime >= curItemExpireTime:  
 | 
#        # ¹ýÆÚÁË  
 | 
#        return False  
 | 
#      
 | 
#    if reduceType == ChConfig.Def_EquipReduceType_Time:  
 | 
#        # ¿ªÊ¼×°±¸Ê±¼ä  
 | 
#        startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)  
 | 
#        if startTime == 0:  
 | 
#            return True  
 | 
#        if time.time() - startTime > curItemExpireTime:  
 | 
#            return False  
 | 
      
 | 
    isExpireItem, expireTime = GetItemRemainingTime(curItem)  
 | 
    if isExpireItem:  
 | 
        if expireTime <= 0:  
 | 
            return False  
 | 
    return True  
 | 
  
 | 
def GetItemRemainingTime(curItem):  
 | 
    ''' »ñÈ¡ÎïÆ·Ê£Óàʱ¼ä£¬Ãë  
 | 
    @return: ÊÇ·ñʱЧÎïÆ·, Ê£Óàʱ¼ä   
 | 
    '''  
 | 
      
 | 
    isExpireItem = False  
 | 
    reduceType = curItem.GetEndureReduceType()  
 | 
    remainingTime = 0  
 | 
      
 | 
    if reduceType in [ChConfig.Def_EquipReduceType_Time, ChConfig.Def_EquipReduceType_RTimeItem]:  
 | 
        isExpireItem = True  
 | 
        # ×°±¸ºó¿ªÊ¼¼ÆÊ±  
 | 
        curItemExpireTime = curItem.GetUserAttr(ShareDefine.Def_IudetExpireTime)  
 | 
        if not curItemExpireTime:  
 | 
            curItemExpireTime = curItem.GetExpireTime()  
 | 
              
 | 
        # ¿ªÊ¼×°±¸Ê±¼ä  
 | 
        startTime = curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)  
 | 
        if startTime == 0:  
 | 
            remainingTime = curItemExpireTime  
 | 
        else:  
 | 
            curItemPastTime = max(0, int(time.time()) - startTime)  
 | 
            remainingTime = max(0, curItemExpireTime - curItemPastTime)  
 | 
        return isExpireItem, remainingTime  
 | 
      
 | 
    return isExpireItem, remainingTime  
 | 
  
 | 
##¼ì²é¸ÃÎïÆ·ÊÇ·ñºÏ·¨£¬ÀàÐÍÑéÖ¤  
 | 
# @param curItem ÎïÆ·ÊµÀý  
 | 
# @param checkType ÎïÆ·ÀàÐÍ   
 | 
# @return ²¼¶ûÖµ£¨ÎïÆ·ÊÇ·ñºÏ·¨£©  
 | 
# @remarks ¼ì²é¸ÃÎïÆ·ÊÇ·ñºÏ·¨£¬ÀàÐÍÑéÖ¤  
 | 
def CheckItemByType(curItem, checkType):  
 | 
    #ÑéÖ¤²ÄÁÏ  
 | 
    if not CheckItemCanUse(curItem):  
 | 
        return False  
 | 
      
 | 
    #ÀàÐͲ»·ûºÏ  
 | 
    if curItem.GetType() != checkType:  
 | 
        return False  
 | 
      
 | 
    return True  
 | 
  
 | 
## ¼ì²é×°±¸ÊÇ·ñÓÐÏâǶ±¦Ê¯  
 | 
#  @param curItem ×°±¸¶ÔÏó  
 | 
#  @return True-ÓР  
 | 
def CheckHasStone(curItem):  
 | 
#    GetStoneCount          ×î´ó¿É¿ª¿×Êý  
 | 
#    GetMaxHoleCount        ÎïÆ·±íÅäÖõÄ×î´ó¿É¿ª¿×Êý£¬²»¿É³¬¹ý×î´ó¿É¿ª¿×Êý  
 | 
#    GetCanPlaceStoneCount  ÒÑ¿ª¿×Êý  
 | 
#    GetUseStoneCount       ÒÑÏâǶµÄ±¦Ê¯¿×Êý  
 | 
    #===========================================================================  
 | 
    # stoneCount = curItem.GetCanPlaceStoneCount()  
 | 
    # if stoneCount <= 0:  
 | 
    #    return False  
 | 
    #   
 | 
    # # Ò»¼þ×°±¸²»ÄÜÓÐÏâǶÏàͬIDµÄ¸ß¼¶±¦Ê¯  
 | 
    # for index in range(stoneCount):  
 | 
    #    if curItem.GetStone(index) > 0:  
 | 
    #        return True  
 | 
    #===========================================================================  
 | 
      
 | 
    return False  
 | 
  
 | 
##¼ì²éÖ¸¶¨Î»ÖÃÊÇ·ñÓÐÎïÆ·  
 | 
# @param equipIndex ×°±¸Î»  
 | 
# @return bool  
 | 
def CheckHasEquip(curPlayer, packIndex, equipIndex):  
 | 
    roleEquipPack = curPlayer.GetItemManager().GetPack(packIndex)  
 | 
    curEquip = roleEquipPack.GetAt(equipIndex)  
 | 
  
 | 
    if not curEquip or curEquip.IsEmpty():  
 | 
        return False  
 | 
      
 | 
    #ÓÐÎïÆ·´æÔÚ  
 | 
    return True  
 | 
  
 | 
  
 | 
## Í¨¹ýÎïÆ·ID, »ñµÃÎïÆ·µÄÏêϸЧ¹ûÐÅÏ¢  
 | 
#  @param itemID µ±Ç°ÎïÆ·  
 | 
#  @param effectIndex Ð§¹ûË÷Òý  
 | 
#  @return EffectID£¬EffectValue0£¬ EffectValue1  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetItemEffectByEffectID(curItem, effectID):  
 | 
    for i in range(curItem.GetEffectCount()):  
 | 
          
 | 
        effect = curItem.GetEffectByIndex(i)  
 | 
        if effect.GetEffectID() != effectID:  
 | 
            continue  
 | 
          
 | 
        return effect  
 | 
      
 | 
    return  
 | 
  
 | 
## »ñÈ¡ÎïÆ·Ê¹Óý׼¶  
 | 
#  @param curItem ÎïÆ·¶ÔÏó  
 | 
#  @return -1-ÕÒ²»µ½Ð§¹ûÀàÐÍ£¬ÎïÆ·ÅäÖÿÉÄÜÓÐÎó  
 | 
#  @remarks ¼¼ÄÜÎïÆ·Ð§¹û±ê¼ÇID, Ïàͬ±ê¼ÇµÄ¼¼ÄÜÖ»ÄÜ·ÅÈë(ÏâǶ/ʹÓÃ)Ò»¸ö£¬AÖµÌî±ê¼ÇID£¬Ä¬ÈÏ´Ó1¿ªÊ¼  
 | 
def GetItemUseClassLV(curItem):  
 | 
    effect = GetItemEffectByEffectID(curItem, ChConfig.Def_Item_Eff_UseClassLV)  
 | 
    if not effect:  
 | 
        return -1  
 | 
      
 | 
    return effect.GetEffectValue(0)  
 | 
  
 | 
def GetItemNoteDict(curItem, writeCount=1, beforeCount=None, afterCount=None):  
 | 
    ''' ÎïÆ·ÐÅÏ¢¼Ç¼   
 | 
    @param curItem: ÎïÆ·  
 | 
    '''  
 | 
    dataDict = {"ItemID":curItem.GetItemTypeID(), "ItemCount":writeCount,   
 | 
                "IsBind":curItem.GetIsBind(), "ItemGUID":curItem.GetGUID()}  
 | 
      
 | 
    if beforeCount != None:  
 | 
        dataDict["BeforeCount"] = beforeCount  
 | 
    if afterCount != None:  
 | 
        dataDict["AfterCount"] = afterCount  
 | 
          
 | 
    #if not CheckItemIsEquip(curItem):  
 | 
    #    return dataDict  
 | 
    if curItem.GetUserData() and curItem.GetUserData() != "{}":  
 | 
        dataDict.update({"UserData":curItem.GetUserData()})  
 | 
          
 | 
    return dataDict  
 | 
  
 | 
def DR_GetItem(curPlayer, packType, eventName, itemNoteDict, noteDict={}):  
 | 
    # ¼Ç¼µÃµ½ÎïÆ·  
 | 
    noteDict["PackType"] = packType  
 | 
      
 | 
    if eventName in ChConfig.ItemGiveTypeList:  
 | 
        operateType = eventName  
 | 
        if operateType in ChConfig.ItemGiveTypeDict:  
 | 
            eventName = ChConfig.ItemGiveTypeDict[operateType]  
 | 
    else:  
 | 
        operateType = ChConfig.ItemGive_Unknown  
 | 
          
 | 
    # ±¾µØÁ÷ÏòÖ»¼Ç¼ÓÐʼþÃû³ÆµÄ  
 | 
    if eventName:  
 | 
        DataRecordPack.DR_SetPlayerItem(curPlayer, eventName, itemNoteDict, noteDict)  
 | 
          
 | 
    # ¼ÇÂ¼Íæ¼Ò±³°ü»ñµÃÎïÆ·  
 | 
    if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:  
 | 
        EventReport.WriteEvent_item_record(curPlayer, 1, operateType, itemNoteDict, noteDict)  
 | 
          
 | 
    return  
 | 
  
 | 
def DR_DelItem(curPlayer, packType, eventName, itemNoteDict, noteDict={}):  
 | 
    # ¼Ç¼ɾ³ýÎïÆ·  
 | 
    noteDict["PackType"] = packType  
 | 
      
 | 
    if eventName in ChConfig.ItemDelTypeList:  
 | 
        operateType = eventName  
 | 
        if operateType in ChConfig.ItemDelTypeDict:  
 | 
            eventName = ChConfig.ItemDelTypeDict[operateType]  
 | 
    else:  
 | 
        operateType = ChConfig.ItemDel_Unknown  
 | 
          
 | 
    DataRecordPack.DR_DeleteItem(curPlayer, eventName, itemNoteDict, noteDict)  
 | 
      
 | 
    # ¼ÇÂ¼Íæ¼Ò±³°üÎïÆ·É¾³ý  
 | 
    if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:  
 | 
        EventReport.WriteEvent_item_record(curPlayer, 0, operateType, itemNoteDict, noteDict)  
 | 
          
 | 
    return  
 | 
  
 | 
def DR_EquipItemChange(curPlayer, curEquip, eventName, addDict={}):  
 | 
    # ¼Ç¼װ±¸ÎïÆ·ÊôÐÔ±ä¸ü  
 | 
    noteDict = GetItemNoteDict(curEquip, 1)  
 | 
    noteDict.update(addDict)  
 | 
    noteDict["packType"] = curEquip.GetItemPlaceType()  
 | 
    DataRecordPack.DR_EquipMachining(curPlayer, eventName, noteDict)  
 | 
    return  
 | 
  
 | 
#===============================================================================  
 | 
## ¼ì²éÊÇ·ñÊÇ×°±¸  
 | 
#  @param curItem   
 | 
#  @return None or True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def CheckItemIsEquip(curItem):  
 | 
    if not CheckItemCanUse(curItem):  
 | 
        return False  
 | 
          
 | 
    if curItem.GetType() not in ChConfig.Def_EquipItemType:  
 | 
        return False  
 | 
      
 | 
#    #²»¿ÉÐÞÀí  
 | 
#    if not curItem.GetCanRepair():  
 | 
#        return  
 | 
      
 | 
    #Ä;Ã×ֶβ»Âú×ã  
 | 
#    if not curItem.GetEndureReduceType() or not curItem.GetMaxEndure():  
 | 
#        return  
 | 
      
 | 
    return True  
 | 
  
 | 
def CheckNoteEquipGS(curItem):  
 | 
    if not CheckItemCanUse(curItem):  
 | 
        return False  
 | 
      
 | 
    if curItem.GetType() not in IpyGameDataPY.GetFuncEvalCfg("EquipGSTypeForSort", 1):  
 | 
        return False  
 | 
      
 | 
    return True  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  
 | 
#  @param findEffectID Ð§¹ûID  
 | 
#  @param curItemPack ±³°ü  
 | 
#  @param needCount Ö¸¶¨µÄÊýÁ¿  
 | 
#  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  
 | 
#  @return hasEnough, itemIndexList [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÓвÄÁÏÊÇ·ñ°ó¶¨, ²»×ãÊýÁ¿]  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetItem_FromPack_ByEff_Ex(findEffectID, curItemPack, needCount, isBind):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
    findItemIsBind = False  
 | 
      
 | 
    for i in range(curItemPack.GetCount()):  
 | 
        findItem = curItemPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemCanUse(findItem):  
 | 
            continue  
 | 
          
 | 
        #²»Ê¹Óð󶨵IJÄÁÏ  
 | 
        if not isBind and findItem.GetIsBind():  
 | 
            continue  
 | 
          
 | 
        #²»ÊÇÕâ¸öЧ¹ûµÄ  
 | 
        if findItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  
 | 
            continue  
 | 
          
 | 
        #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  
 | 
        if not findItemIsBind and findItem.GetIsBind():  
 | 
            findItemIsBind = True  
 | 
          
 | 
        itemCount = findItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCount > itemCount:  
 | 
            needCount -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            needCount = 0  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÓвÄÁÏÊÇ·ñ°ó¶¨, ²»×ãÊýÁ¿]  
 | 
    return hasEnough, itemIndexList, findItemIsBind, needCount  
 | 
#---------------------------------------------------------------------  
 | 
## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  
 | 
#  @param findEffectID Ð§¹ûID  
 | 
#  @param curItemPack ±³°ü  
 | 
#  @param needCount Ö¸¶¨µÄÊýÁ¿  
 | 
#  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  
 | 
#  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetItem_FromPack_ByEff(findEffectID, curItemPack, needCount, isBind):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
      
 | 
    for i in range(curItemPack.GetCount()):  
 | 
        curItem = curItemPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        #²»Ê¹Óð󶨵IJÄÁÏ  
 | 
        if not isBind and curItem.GetIsBind():  
 | 
            continue  
 | 
          
 | 
        #²»ÊÇÕâ¸öЧ¹ûµÄ  
 | 
        if curItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  
 | 
            continue  
 | 
          
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCount > itemCount:  
 | 
            needCount -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  
 | 
    return hasEnough, itemIndexList  
 | 
  
 | 
## Í¨¹ý±³°ü²éÕÒÖ¸¶¨ÎïÆ·IDµÄÖ¸¶¨Ð§¹ûIDµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  
 | 
#  @param findItemID ÎïÆ·ID  
 | 
#  @param findEffectID Ð§¹ûID  
 | 
#  @param curItemPack ±³°ü  
 | 
#  @param needCount Ö¸¶¨µÄÊýÁ¿  
 | 
#  @param isBind ÊÇ·ñʹÓÃ°ó¶¨µÄ  
 | 
#  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetItemFromPack_ByIDAndEff(findItemID, findEffectID, curItemPack, needCount, isBind):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
      
 | 
    for i in range(curItemPack.GetCount()):  
 | 
        curItem = curItemPack.GetAt(i)  
 | 
          
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != findItemID:  
 | 
            continue  
 | 
          
 | 
        #²»Ê¹Óð󶨵IJÄÁÏ  
 | 
        if not isBind and curItem.GetIsBind():  
 | 
            continue  
 | 
          
 | 
        #²»ÊÇÕâ¸öЧ¹ûµÄ  
 | 
        if curItem.GetEffectByIndex(0).GetEffectID() != findEffectID:  
 | 
            continue  
 | 
          
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCount > itemCount:  
 | 
            needCount -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  
 | 
    return hasEnough, itemIndexList  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  
 | 
# @param findItemID ²éÕÒµÄÎïÆ·ID  
 | 
# @param itemPack ÎïÆ·±³°ü  
 | 
# @param needCnt ÐèÒªÊýÁ¿  
 | 
# @param useItemMode °ó¶¨Ä£Ê½  
 | 
# @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý]  
 | 
# @remarks ´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  
 | 
def GetItem_FromPack_ByID(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
      
 | 
    for i in range(itemPack.GetCount()):  
 | 
        curItem = itemPack.GetAt(i)  
 | 
        #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != findItemID:  
 | 
            continue  
 | 
      
 | 
        #ÑéÖ¤ÎïÆ·ÊôÐÔ  
 | 
        if curItem.GetIsBind():  
 | 
            if useItemMode == UseStuffMode_NoBind:  
 | 
                continue  
 | 
        else:  
 | 
            if useItemMode == UseStuffMode_Bind:  
 | 
                continue  
 | 
  
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCnt > itemCount:  
 | 
            needCnt -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý]  
 | 
    return hasEnough, itemIndexList  
 | 
  
 | 
  
 | 
##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  
 | 
# @param findItemID ²éÕÒµÄÎïÆ·ID  
 | 
# @param itemPack ÎïÆ·±³°ü  
 | 
# @param needCnt ÐèÒªÊýÁ¿  
 | 
# @param useItemMode °ó¶¨Ä£Ê½  
 | 
# @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä]  
 | 
def GetItem_FromPack_ByID_Ex(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
    findItemIsBind = False  
 | 
      
 | 
    for i in range(itemPack.GetCount()):  
 | 
        curItem = itemPack.GetAt(i)  
 | 
        #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != findItemID:  
 | 
            continue  
 | 
      
 | 
        #ÑéÖ¤ÎïÆ·ÊôÐÔ  
 | 
        if curItem.GetIsBind():  
 | 
            if useItemMode == UseStuffMode_NoBind:  
 | 
                continue  
 | 
        else:  
 | 
            if useItemMode == UseStuffMode_Bind:  
 | 
                continue  
 | 
          
 | 
        #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  
 | 
        if not findItemIsBind and curItem.GetIsBind():  
 | 
            findItemIsBind = True  
 | 
              
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCnt > itemCount:  
 | 
            needCnt -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä]  
 | 
    return hasEnough, itemIndexList, findItemIsBind  
 | 
  
 | 
  
 | 
##´ÓÖ¸¶¨±³°üÖлñÈ¡ÎïÆ·Çåµ¥  
 | 
# @param findItemID ²éÕÒµÄÎïÆ·ID  
 | 
# @param itemPack ÎïÆ·±³°ü  
 | 
# @param needCnt ÐèÒªÊýÁ¿  
 | 
# @param useItemMode °ó¶¨Ä£Ê½  
 | 
# @return ÎïÆ·Çåµ¥ [ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä, ²»×ãµÄ¸öÊý]  
 | 
def GetItem_FromPack_ByID_ExEx(findItemID, itemPack, needCnt, useItemMode=UseStuffMode_All):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
    findItemIsBind = False  
 | 
      
 | 
    for i in range(itemPack.GetCount()):  
 | 
        curItem = itemPack.GetAt(i)  
 | 
        #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != findItemID:  
 | 
            continue  
 | 
      
 | 
        #ÑéÖ¤ÎïÆ·ÊôÐÔ  
 | 
        if curItem.GetIsBind():  
 | 
            if useItemMode == UseStuffMode_NoBind:  
 | 
                continue  
 | 
        else:  
 | 
            if useItemMode == UseStuffMode_Bind:  
 | 
                continue  
 | 
          
 | 
        #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  
 | 
        if not findItemIsBind and curItem.GetIsBind():  
 | 
            findItemIsBind = True  
 | 
              
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCnt > itemCount:  
 | 
            needCnt -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            needCnt = 0 # Èç¹û×ã¹»£¬ÔòÉèÖÃȱÉٵĸöÊýΪ0  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý, ËùÕҵIJÄÁÏÊÇ·ñÓа󶨵Ä, ²»×ãµÄ¸öÊý]  
 | 
    return hasEnough, itemIndexList, findItemIsBind, needCnt  
 | 
  
 | 
  
 | 
def GetPackItemBindStateIndexInfo(curPlayer, itemID, needCount=0):  
 | 
    ''' »ñÈ¡±³°üÏûºÄµÀ¾ß°ó¶¨¼°Î´°ó¶¨Ë÷ÒýÇé¿ö  
 | 
    @param needCount: ËùÐè¸öÊý, Ä¬Èϰó¶¨ÓÅÏÈ£¬µ±ÕÒµ½ÒѾ×ã¹»µÄ¸öÊýºó²»ÔÙ±éÀú£¬¼õÉÙÎÞÓñéÀú  
 | 
    @return: ¿ÉÏûºÄÎïÆ·Áбí[[°ó¶¨ÎïÆ·Ë÷Òý], [²»°ó¶¨ÎïÆ·Ë÷Òý]], °ó¶¨¸öÊý, Î´°ó¶¨¸öÊý  
 | 
    '''  
 | 
    consumeItemIndexList = [[], []] # ¿ÉÏûºÄÎïÆ·Áбí[[°ó¶¨ÎïÆ·Ë÷Òý], [²»°ó¶¨ÎïÆ·Ë÷Òý]]  
 | 
    bindCnt, unBindCnt = 0, 0  
 | 
      
 | 
    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  
 | 
    for i in range(0, curPack.GetCount()):  
 | 
        curItem = curPack.GetAt(i)  
 | 
        if not curItem:  
 | 
            continue  
 | 
          
 | 
        if curItem.GetItemTypeID() != itemID:  
 | 
            continue  
 | 
          
 | 
        itemCount = curItem.GetCount()  
 | 
  
 | 
        #²éÕÒµ½µÄÎïÆ·Îª°ó¶¨ÎïÆ·  
 | 
        if curItem.GetIsBind():  
 | 
            consumeItemIndexList[0].append(i)  
 | 
            bindCnt += itemCount  
 | 
            if needCount > 0 and bindCnt >= needCount:  
 | 
                break  
 | 
        else:  
 | 
            consumeItemIndexList[1].append(i)  
 | 
            unBindCnt += itemCount  
 | 
              
 | 
    return consumeItemIndexList, bindCnt, unBindCnt  
 | 
  
 | 
## ¿Û³ýÏûºÄ²ÄÁÏ, ÓÅÏȿ۳ý°ó¶¨µÄÎïÆ·, ÅäÖú¯ÊýʹÓàGetPackItemBindStateIndexInfo, DelCostItemByBind  
 | 
def DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, delEvent, saveDataDict={}):  
 | 
    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  
 | 
    bindIndexList, unBindIndexList = costItemIndexList  
 | 
    if bindCnt >= delCnt:  
 | 
        ReduceItem(curPlayer, curPack, bindIndexList, delCnt, True, delEvent, saveDataDict)  
 | 
    else:  
 | 
        ReduceItem(curPlayer, curPack, bindIndexList, bindCnt, True, delEvent, saveDataDict)  
 | 
        ReduceItem(curPlayer, curPack, unBindIndexList, delCnt - bindCnt, False, delEvent, saveDataDict)  
 | 
    return  
 | 
  
 | 
## ÅäºÏ GetItem_FromPack_ByEff, Ê¹ÓÃ, É¾³ýÎïÆ·  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItemPack ÎïÆ·±³°ü  
 | 
#  @param itemIndexList ÎïÆ·Ë÷ÒýÁÐ±í  
 | 
#  @param reduceCount É¾³ýÊýÁ¿  
 | 
#  @param makeItemBind ÎïÆ·°ó¶¨  
 | 
#  @return True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def ReduceItem(curPlayer, curItemPack, itemIndexList, reduceCount, makeItemBind, eventName="",   
 | 
               saveDataDict={}, needSysmsg=True):  
 | 
    itemTypeID = 0  
 | 
    totalUseCnt = reduceCount  
 | 
    if not eventName:  
 | 
        eventName = "ReduceItem"  
 | 
      
 | 
    for itemIndex in itemIndexList:  
 | 
        curItem = curItemPack.GetAt(itemIndex)  
 | 
          
 | 
        if not makeItemBind and curItem.GetIsBind():  
 | 
            makeItemBind = True  
 | 
              
 | 
        itemCount = curItem.GetCount()  
 | 
        itemTypeID = curItem.GetItemTypeID()  
 | 
          
 | 
        if reduceCount > itemCount:  
 | 
            if ItemControler.ItemNeedRecord(curItem):  
 | 
                itemNoteDict = GetItemNoteDict(curItem, itemCount, itemCount, 0)  
 | 
                DR_DelItem(curPlayer, IPY_GameWorld.rptItem, eventName, itemNoteDict, saveDataDict)  
 | 
                  
 | 
            ItemControler.SetItemCount(curItem, 0, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  
 | 
                                       curPlayer.GetPlayerName())  
 | 
            reduceCount -= itemCount  
 | 
        else:  
 | 
            if ItemControler.ItemNeedRecord(curItem):  
 | 
                itemNoteDict = GetItemNoteDict(curItem, reduceCount, itemCount, itemCount - reduceCount)  
 | 
                DR_DelItem(curPlayer, IPY_GameWorld.rptItem, eventName, itemNoteDict, saveDataDict)  
 | 
              
 | 
            ItemControler.SetItemCount(curItem, itemCount - reduceCount, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  
 | 
                                       curPlayer.GetPlayerName())  
 | 
            break  
 | 
      
 | 
    #ϵͳÌáʾ LostRes Ê§È¥ÎïÆ·  
 | 
    #if needSysmsg:  
 | 
    #    PlayerControl.NotifyCode(curPlayer, 'LostRes', [itemTypeID, totalUseCnt])  
 | 
    return makeItemBind  
 | 
  
 | 
def GetCostItemIndexList(costItemInfo, itemPack, bindFirst=True):  
 | 
    '''»ñµÃÐèÒªÏûºÄµÄ²ÄÁÏÎïÆ·ÐÅÏ¢, ÓÅÏȿ۳ý°ó¶¨ÎïÆ·  
 | 
    @param costItemInfo: ÐèÒªÎïÆ·ÊýÁ¿[(itemID,itemCnt), ...] »ò  {itemID:itemCnt, ...}  
 | 
    @param itemPack: ±³°ü  
 | 
    @param bindFirst: ÊÇ·ñ°ó¶¨ÓÅÏÈ, True-°ó¶¨ÓÅÏÈ£¬ False-·Ç°ó¶¨ÓÅÏÈ  
 | 
    @return: È±ÉÙµÄÎïÆ·¸öÊýÐÅÏ¢×Öµä{itemID:ȱÉÙ¸öÊý}, ¿Û³ýÎïÆ·ÐÅÏ¢×Öµä{itemID:[ɾ³ýË÷ÒýÁбí, É¾³ý¸öÊý], ...}  
 | 
    '''  
 | 
    lackItemDict = {}  
 | 
    delInfoDict = {}  
 | 
      
 | 
    costItemDict = {}  
 | 
    if not isinstance(costItemInfo, dict):  
 | 
        for needItemID, needItemCnt in costItemInfo:  
 | 
            costItemDict[needItemID] = needItemCnt  
 | 
    else:  
 | 
        costItemDict = costItemInfo  
 | 
          
 | 
    bindItemCntDict = {}  
 | 
    noBindItemCntDict = {}  
 | 
    bindItemIndexDict = {}  
 | 
    noBindItemIndexDict = {}  
 | 
      
 | 
    # ÕâÁ½ÖÖģʽ±ØÐë±éÀú±³°üÒ»±é  
 | 
    for i in xrange(itemPack.GetCount()):  
 | 
        curItem = itemPack.GetAt(i)  
 | 
        #¹ýÂ˲»·ûºÏÆäËûÌõ¼þµÄÎïÆ·  
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
        curItemID = curItem.GetItemTypeID()  
 | 
        if curItemID not in costItemDict:  
 | 
            continue  
 | 
          
 | 
        curItemCount = curItem.GetCount()  
 | 
        if curItem.GetIsBind():  
 | 
            indexDict = bindItemIndexDict  
 | 
            bindItemCntDict[curItemID] = bindItemCntDict.get(curItemID, 0) + curItemCount  
 | 
        else:  
 | 
            indexDict = noBindItemIndexDict  
 | 
            noBindItemCntDict[curItemID] = noBindItemCntDict.get(curItemID, 0) + curItemCount  
 | 
              
 | 
        if curItemID not in indexDict:  
 | 
            indexDict[curItemID] = []  
 | 
        indexList = indexDict[curItemID]  
 | 
        indexList.append(i)  
 | 
          
 | 
    # ±éÀúÍêºóÅжÏÊÇ·ñ×ã¹»  
 | 
    for needItemID, needItemCnt in costItemDict.items():  
 | 
        itemCntTotal = bindItemCntDict.get(needItemID, 0) + noBindItemCntDict.get(needItemID, 0)  
 | 
        lackCnt = max(0, needItemCnt - itemCntTotal)  
 | 
        # ²»¹»  
 | 
        if lackCnt:  
 | 
            lackItemDict[needItemID] = lackCnt  
 | 
              
 | 
        if itemCntTotal:  
 | 
            delCnt = needItemCnt - lackCnt  
 | 
            if bindFirst:  
 | 
                indexList = bindItemIndexDict.get(needItemID, []) + noBindItemIndexDict.get(needItemID, [])  
 | 
            else:  
 | 
                indexList = noBindItemIndexDict.get(needItemID, []) + bindItemIndexDict.get(needItemID, [])                  
 | 
            delInfoDict[needItemID] = [indexList, delCnt]  
 | 
          
 | 
    return lackItemDict, delInfoDict  
 | 
  
 | 
## »ñÈ¡×Ô¶¯¹ºÂò²ÄÁÏÐèÒªÏûºÄµÄ×êʯÊý  
 | 
def GetAutoBuyItemNeedGold(lackItemDict):  
 | 
    totalGold = 0  
 | 
    # ¼ÆËã×Ô¶¯¹ºÂòÏûºÄ  
 | 
    for itemID, lackCnt in lackItemDict.items():  
 | 
        if lackCnt <= 0:  
 | 
            continue  
 | 
          
 | 
        curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  
 | 
        if not curItem:  
 | 
            return 0  
 | 
             
 | 
        itemGold = GetShopItemPrice(curItem.GetItemTypeID(), IPY_GameWorld.TYPE_Price_Gold_Money)  
 | 
        if itemGold <= 0:  
 | 
            GameWorld.ErrLog("É̳DZíδÅäÖÃÎïÆ·×êʯÏûºÄ!itemID=%s" % itemID)  
 | 
            return 0  
 | 
          
 | 
        totalGold += (lackCnt * itemGold)  
 | 
          
 | 
    return totalGold  
 | 
  
 | 
def GetShopItemPrice(itemID, priceType):  
 | 
    ''' »ñÈ¡É̳ÇÎïÆ·¶ÔÓ¦¼Û¸ñ '''  
 | 
    # ÏµÍ³¹Ì¶¨É̵êÀàÐÍ£º ÏÉÓñ£¨2-³£ÓõÀ¾ß£¬3-³É³¤±äÇ¿£©£¬°óÓñ£¨4-°óÓñÉ̳ǣ©  
 | 
    priceTypeShopTypeDict = {IPY_GameWorld.TYPE_Price_Gold_Money:[2, 3],  
 | 
                             IPY_GameWorld.TYPE_Price_Gold_Paper:[4],  
 | 
                             }  
 | 
    ipyData = None  
 | 
    if priceType in priceTypeShopTypeDict:  
 | 
        for shopType in priceTypeShopTypeDict[priceType]:  
 | 
            ipyData = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType, "ItemID":itemID, "MoneyType":priceType}, isLogNone=False)  
 | 
            if ipyData:  
 | 
                break  
 | 
    else:  
 | 
        ipyData = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ItemID":itemID, "MoneyType":priceType}, isLogNone=False)  
 | 
    if not ipyData:  
 | 
        return 0  
 | 
    return ipyData.GetMoneyNum()  
 | 
  
 | 
def DelCostItem(curPlayer, itemPack, delInfoDict, delEvent="ReduceItem"):  
 | 
    ## ¿Û³ýÏûºÄ²ÄÁÏ, ÅäÖú¯ÊýʹÓàGetCostItemIndexList, GetAutoBuyItemNeedGold, DelCostItem  
 | 
    delItemHasBind = False  
 | 
    for indexList, delCnt in delInfoDict.values():  
 | 
        if not indexList:  
 | 
            continue  
 | 
        hasBindItem = ReduceItem(curPlayer, itemPack, indexList, delCnt, False, delEvent)  
 | 
        delItemHasBind = True if hasBindItem else delItemHasBind  
 | 
    return delItemHasBind  
 | 
#---------------------------------------------------------------------  
 | 
##ÈÎÎñϵͳµ÷ÓÃ, É¾³ýÖ¸¶¨±³°üÖеÄÎïÆ·  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
# @param delItemID É¾³ýÎïÆ·ID  
 | 
# @param delItemCount É¾³ýÎïÆ·ÊýÁ¿( Îª0È«²¿É¾³ý )  
 | 
# @param missionID ÈÎÎñID  
 | 
# @return ·µ»ØÖµÎÞÒâÒå  
 | 
# @remarks ÈÎÎñϵͳµ÷ÓÃ, É¾³ýÖ¸¶¨±³°üÖеÄÎïÆ·  
 | 
def DelMissionItem(curPlayer, packIndex, delItemID, delItemCount, missionID):  
 | 
    itemPack = curPlayer.GetItemManager().GetPack(packIndex)  
 | 
    #ÊÇ·ñÈ«²¿É¾³ý  
 | 
    delAllItem = False  
 | 
      
 | 
    if delItemCount <= 0:  
 | 
        delAllItem = True  
 | 
      
 | 
    for index in range(0, itemPack.GetCount()):  
 | 
        item = itemPack.GetAt(index)  
 | 
          
 | 
        if not CheckItemCanUse(item):  
 | 
            continue  
 | 
          
 | 
        itemTypeID = item.GetItemTypeID()  
 | 
        itemCount = item.GetCount()  
 | 
          
 | 
        if itemTypeID != delItemID:  
 | 
            continue  
 | 
          
 | 
        curBind = item.GetIsBind()  
 | 
          
 | 
        #È«²¿É¾³ý,»òɾ³ýµÄÊýÁ¿´óÓÚÎïÆ·µÄÊýÁ¿, Çå³ýÕâ¸öÎïÆ·  
 | 
        if delAllItem or delItemCount > itemCount:  
 | 
            item.Clear()  
 | 
            continue  
 | 
          
 | 
        #ÎïÆ·ÊýÁ¿´óÓÚɾ³ýµÄÊýÁ¿, º¯Êý·µ»Ø  
 | 
        ItemControler.SetItemCount(item, itemCount - delItemCount, curPlayer.GetPlayerID(), curPlayer.GetAccID(),  
 | 
                                   curPlayer.GetPlayerName())  
 | 
        return  
 | 
      
 | 
    return  
 | 
#---------------------------------------------------------------------  
 | 
## ÉèÖÃÎïÆ·°ó¶¨ÊôÐÔ// ChConfig.Def_BindType  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @param bindType °ó¶¨ÀàÐÍ  
 | 
#  @return None or True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def DoLogic_ItemBindType(curPlayer, curItem, bindType):  
 | 
    #¹Ì¶¨²»°ó¶¨  
 | 
    if bindType == ChConfig.Def_BindType_NoBind:  
 | 
        return  
 | 
      
 | 
    #²»´¦ÀíÒѾ°ó¶¨µÄÎïÆ·  
 | 
    if curItem.GetIsBind():  
 | 
        return  
 | 
    #²»ÊÇÕâ¸ö¹¦Äܵİó¶¨ÀàÐÍ  
 | 
    if curItem.GetBindType() != bindType:  
 | 
        return  
 | 
    if curItem.GetBindType() == ChConfig.Def_BindType_DoEquipBind:  
 | 
        pass  
 | 
                  
 | 
    ItemControler.SetItemIsBind(curItem, True)  
 | 
    return True  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @param switchItem ½»»»µÄÎïÆ·  
 | 
#  @param putInPackIndex ·ÅÈëµÄ±³°ü  
 | 
# @return ²¼¶ûÖµ  
 | 
# @remarks ¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  
 | 
def DoLogicSwitchItemEx(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex):  
 | 
      
 | 
    #---ÎïÆ·¼ì²é---  
 | 
    srcPack = curPlayer.GetItemManager().GetPack(srcBackpack)  
 | 
    if srcIndex < 0 or srcIndex >= srcPack.GetCount():  
 | 
        return  
 | 
    srcItem = srcPack.GetAt(srcIndex)  
 | 
    if not CheckItemCanUse(srcItem):  
 | 
        return  
 | 
      
 | 
    destPack = curPlayer.GetItemManager().GetPack(desBackPack)  
 | 
    if destIndex < 0 or destIndex >= destPack.GetCount():  
 | 
        return  
 | 
    destItem = destPack.GetAt(destIndex)  
 | 
    #Ä¿±ê¸ñ×ÓÖ»ÑéÖ¤Ëø¶¨, ¿ÉÒÔÔÊÐí¿Õλ  
 | 
    if destItem == None or destItem.GetIsLocked():  
 | 
        return  
 | 
  
 | 
    return DoLogicSwitchItem(curPlayer, srcItem, destItem, desBackPack)  
 | 
  
 | 
##¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @param switchItem ½»»»µÄÎïÆ·  
 | 
#  @param putInPackIndex ·ÅÈëµÄ±³°ü  
 | 
# @return ²¼¶ûÖµ  
 | 
# @remarks ¶ÔÍâ½Ó¿Ú, ½»»»ÎïÆ·  
 | 
def DoLogicSwitchItem(curPlayer, curItem, switchItem, packIndex):  
 | 
    #¿ÕÎïÆ·, ·ÅÈë  
 | 
    if curItem.IsEmpty():  
 | 
        return PutIn(curPlayer, curItem, switchItem, packIndex)  
 | 
  
 | 
    #·Ç¿ÕÎïÆ·½»»»  
 | 
    return SwitchItem(curPlayer, curItem, switchItem, packIndex)  
 | 
  
 | 
## ½»»»ÎïÆ·  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @param switchItem ½»»»µÄÎïÆ·  
 | 
#  @param putInPackIndex ·ÅÈëµÄ±³°ü  
 | 
#  @return True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def SwitchItem(curPlayer, curItem, switchItem, putInPackIndex):  
 | 
    ##ÎïÆ·°ó¶¨×Ö¶ÎÅж¨ -> ×°±¸°ó¶¨  
 | 
    if putInPackIndex == IPY_GameWorld.rptEquip:  
 | 
        DoLogic_ItemBindType(curPlayer, switchItem, ChConfig.Def_BindType_DoEquipBind)  
 | 
          
 | 
    # ×°±¸¼¼ÄÜÊé¡¢×øÆï×°±¸°ó¶¨  
 | 
    if putInPackIndex in [IPY_GameWorld.rptHorseEquip]:  
 | 
        DoLogic_ItemBindType(curPlayer, curItem, ChConfig.Def_BindType_DoEquipBind)  
 | 
      
 | 
    #½»»»×°±¸  
 | 
    curItem.Switch(switchItem)  
 | 
    return True  
 | 
  
 | 
## ·ÅÈëÎïÆ·   
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param emptyItem ¿ÕÎïÆ·  
 | 
#  @param switchItem ½»»»µÄÎïÆ·  
 | 
#  @param putInPackIndex ·ÅÈëµÄ±³°ü  
 | 
#  @return None or True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def PutIn(curPlayer, emptyItem, switchItem, putInPackIndex):  
 | 
    #Òì³£Ò»¶¨Òª¿ÕÎïÆ·  
 | 
    if not emptyItem.IsEmpty():  
 | 
        GameWorld.ErrLog('putInErr' , curPlayer.GetID())  
 | 
        return  
 | 
      
 | 
    ##ÎïÆ·°ó¶¨×Ö¶ÎÅж¨ -> ×°±¸°ó¶¨  
 | 
    if putInPackIndex == IPY_GameWorld.rptEquip:  
 | 
        DoLogic_ItemBindType(curPlayer, switchItem, ChConfig.Def_BindType_DoEquipBind)  
 | 
      
 | 
    # ×°±¸¼¼ÄÜÊé¡¢×øÆï×°±¸°ó¶¨  
 | 
    if putInPackIndex in [IPY_GameWorld.rptHorseEquip]:  
 | 
        DoLogic_ItemBindType(curPlayer, emptyItem, ChConfig.Def_BindType_DoEquipBind)  
 | 
  
 | 
    if switchItem.GetGameWorldItemType() == IPY_GameWorld.gwitRoleItem:  
 | 
        emptyItem.PutIn(switchItem)  
 | 
    elif switchItem.GetGameWorldItemType() == IPY_GameWorld.gwitSingleItem:  
 | 
        emptyItem.AssignItem(switchItem)  
 | 
      
 | 
    #½»»»×°±¸  
 | 
    #emptyItem.PutIn( switchItem )  
 | 
    return True  
 | 
  
 | 
## ·µ»ØÊÇ·ñÊÇ×°±¸  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetIsEquip(curItem):  
 | 
    return curItem.GetType() in ChConfig.Def_EquipItemType  
 | 
  
 | 
def GetIsDogzEquip(curItem):  
 | 
    ## ·µ»ØÊÇ·ñÉñÊÞ×°±¸  
 | 
    return curItem.GetType() in ChConfig.Def_DogzEquiipType  
 | 
  
 | 
## ·µ»ØÊÇ·ñÎäÆ÷  
 | 
#  @param curItem µ±Ç°ÎïÆ·  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetIsWeapon(curItem):  
 | 
    return curItem.GetType() in ChConfig.Def_WeaponItemType  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##±éÀúÊý¾Ý¿â²éÕÒºÏÊʵÄÎïÆ·, Í¨¹ý Ð§¹ûID + Ð§¹ûAֵȷ¶¨ÎïÆ·  
 | 
# @param itemType ÎïÆ·ÀàÐÍ  
 | 
# @param itemEffectID ÎïÆ·Ð§¹ûID  
 | 
# @param itemEffectValue ÎïÆ·Ð§¹ûÖµ  
 | 
# @return ÎïÆ·Êý¾Ý  
 | 
# @remarks ¿Í»§¶Ë·â°üÏìÓ¦  
 | 
# ±éÀúÊý¾Ý¿â²éÕÒºÏÊʵÄÎïÆ·, Í¨¹ý Ð§¹ûID + Ð§¹ûAֵȷ¶¨ÎïÆ·  
 | 
def FindItemFromDataByEffValue(itemType, itemEffectID, findEffectValue):  
 | 
    gameData = GameWorld.GetGameData()  
 | 
    #¹ýÂËÎïÆ·ÀàÐÍ  
 | 
    gameData.FilterItemByType(itemType)  
 | 
    #²éÕÒÊý¾Ý¿â  
 | 
    for i in range(0, gameData.GetFilterItemCount()):  
 | 
        curFindItem = gameData.GetFilterItem(i)  
 | 
#==================================================  
 | 
#        #¹Ì¶¨²»³öÏÖµÄÎïÆ·  
 | 
#        if not curFindItem.GetCanIdentifyAppear():  
 | 
#            continue  
 | 
#==================================================  
 | 
          
 | 
        curFindItemEffect = curFindItem.GetEffectByIndex(0)  
 | 
        curFindItemEffectID = curFindItemEffect.GetEffectID()  
 | 
        curFindItemEffectValue = curFindItemEffect.GetEffectValue(0)  
 | 
        #¶Ô±ÈЧ¹ûÖµ  
 | 
        if itemEffectID == curFindItemEffectID and curFindItemEffectValue == findEffectValue:  
 | 
            return curFindItem  
 | 
  
 | 
    return None  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
## Í¨¹ý±³°ü²éÕÒÖ¸¶¨Ð§¹ûIDºÍAÖµµÄÖ¸¶¨ÊýÁ¿ÎïÆ·  
 | 
#  @param effectID Ð§¹ûID  
 | 
#  @param effectA Ð§¹ûA  
 | 
#  @param curItemPack ±³°ü  
 | 
#  @param needCount Ö¸¶¨µÄÊýÁ¿  
 | 
#  @return hasEnough, itemIndexList [ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý,»¹Ðè¶àÉÙÊýÁ¿ ]  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def GetItemIndexListFromPackByEffA(effectID, effectA, curItemPack, needCount):  
 | 
    hasEnough = False  
 | 
    itemIndexList = []  
 | 
      
 | 
    for i in range(curItemPack.GetCount()):  
 | 
        curItem = curItemPack.GetAt(i)  
 | 
          
 | 
        #¼ì²éÎïÆ·  
 | 
        if not CheckItemCanUse(curItem):  
 | 
            continue  
 | 
          
 | 
        effect = curItem.GetEffectByIndex(0)  
 | 
          
 | 
        #²»ÊÇÕâ¸öЧ¹ûIDµÄ  
 | 
        if effect.GetEffectID() != effectID:  
 | 
            continue  
 | 
          
 | 
        #²»ÊÇÕâ¸öЧ¹ûAÖµµÄ  
 | 
        if effect.GetEffectValue(0) != effectA:  
 | 
            continue  
 | 
          
 | 
        itemCount = curItem.GetCount()  
 | 
        #²»¹»  
 | 
        if needCount > itemCount:  
 | 
            needCount -= itemCount  
 | 
            itemIndexList.append(i)  
 | 
        else:  
 | 
            needCount = 0 # Èç¹û×ã¹»£¬ÔòÉèÖÃȱÉٵĸöÊýΪ0  
 | 
            hasEnough = True  
 | 
            itemIndexList.append(i)  
 | 
            break  
 | 
      
 | 
    #·µ»ØÁбí[ ÊÇ·ñÓµÓÐ×ã¹»²ÄÁÏ, ²ÄÁÏÁÐ±í±³°üË÷Òý ]  
 | 
    return hasEnough, itemIndexList, needCount  
 | 
#---------------------------------------------------------------------  
 | 
##¿Û³ýÎïÆ·  
 | 
# @param curPlayer Íæ¼ÒʵÀý  
 | 
# @param curItem ÎïÆ·ÊµÀý  
 | 
# @param delCnt É¾³ýÊýÁ¿  
 | 
# @param needSysmsg ÊÇ·ñÐèҪϵͳÌáʾ  
 | 
# @param recordName ossÁ÷ÏòÃû  
 | 
# @param saveDataDict ¸½¼Ó´æ´¢ÐÅÏ¢  
 | 
# @param isForceDR ÊÇ·ñÇ¿ÖÆ¼Ç¼Á÷Ïò  
 | 
# @return ·µ»ØÖµÎÞÒâÒå  
 | 
# @remarks ¿Û³ýÎïÆ·  
 | 
def DelItem(curPlayer, curItem, delCnt, needSysmsg=True, recordName="", saveDataDict={}, isForceDR=False):  
 | 
    curItemTypeID = curItem.GetItemTypeID()  
 | 
    curItemCnt = curItem.GetCount()  
 | 
    curItemBind = curItem.GetIsBind()  
 | 
      
 | 
    if curItemCnt < delCnt:  
 | 
        GameWorld.ErrLog("DelItem, delCnt = %s, itemCnt = %s, itemTypeID = %s" % (delCnt, curItemCnt, curItemTypeID), curPlayer.GetID())  
 | 
        #raise Exception("DelItem, delCnt = %s, itemCnt = %s, itemTypeID = %s" % (delCnt, curItemCnt, curItemTypeID), curPlayer.GetID())  
 | 
        return  
 | 
      
 | 
    #===========================================================================  
 | 
    # if needSysmsg:  
 | 
    #    PlayerControl.NotifyCode(curPlayer, "LostRes", [curItemTypeID , delCnt])  
 | 
    #===========================================================================  
 | 
      
 | 
    if isForceDR or ItemControler.ItemNeedRecord(curItem):  
 | 
        itemNoteDict = GetItemNoteDict(curItem, delCnt, curItemCnt, curItemCnt - delCnt)  
 | 
        DR_DelItem(curPlayer, IPY_GameWorld.rptItem, recordName, itemNoteDict, saveDataDict)  
 | 
          
 | 
    #¿Û³ýÎïÆ·  
 | 
    ItemControler.SetItemCount(curItem, curItemCnt - delCnt,  
 | 
                               curPlayer.GetPlayerID(), curPlayer.GetAccID(),  
 | 
                               curPlayer.GetPlayerName())  
 | 
    return  
 | 
  
 | 
def DelVPackItem(curPlayer, packIndex, placeList, eventName=""):  
 | 
    ''' É¾³ýÐéÄâ±³°üÎïÆ· '''  
 | 
    if packIndex not in ShareDefine.Def_VPack_TypeList:  
 | 
        return  
 | 
    for place in placeList:  
 | 
        itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  
 | 
        if not itemKeyData:  
 | 
            continue  
 | 
          
 | 
        isNeedRecord = False  
 | 
        itemID = 0  
 | 
        itemName = ""  
 | 
        if packIndex == ShareDefine.rptRune:  
 | 
            itemID = ItemControler.GetRuneItemID(itemKeyData)  
 | 
            plusLV = ItemControler.GetRuneItemPlusLV(itemKeyData)  
 | 
            curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  
 | 
            itemName = str(itemID) if not curItemData else  curItemData.GetName()  
 | 
            itemName = "%s LV%s" % (itemName, plusLV + 1)  
 | 
            isNeedRecord = curItemData and ItemControler.IsRuneItemNeedRecord(curItemData, plusLV)  
 | 
        if packIndex == ShareDefine.rptGatherSoul:  
 | 
            itemID = ItemControler.GetGatherSoulItemID(itemKeyData)  
 | 
            plusLV = ItemControler.GetGatherSoulItemPlusLV(itemKeyData)  
 | 
            curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  
 | 
            itemName = str(itemID) if not curItemData else  curItemData.GetName()  
 | 
            itemName = "%s LV%s" % (itemName, plusLV + 1)  
 | 
            isNeedRecord = curItemData and ItemControler.IsGatherSoulItemNeedRecord(curItemData, plusLV)  
 | 
              
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_VPackItem % (packIndex, place), 0)  
 | 
        if isNeedRecord:  
 | 
            dataDict = {"ItemID":itemID, "ItemCount":1, "PlusLV":plusLV + 1}  
 | 
            DR_DelItem(curPlayer, packIndex, "VPack_%s" % packIndex if not eventName else eventName, dataDict)  
 | 
    ItemControler.Sync_VPackItem_Clear(curPlayer, packIndex, placeList)  
 | 
    return  
 | 
  
 | 
## »ñÈ¡ÎïÆ·×î¸ßÇ¿»¯ÐǼ¶  
 | 
#  @param itemType: ÎïÆ·ÀàÐÍ  
 | 
#  @return ×î´óÐǼ¶£¬0Ϊ²»¿ÉÇ¿»¯  
 | 
def GetItemMaxStarLV(curItem):  
 | 
    equipPlace = curItem.GetEquipPlace()  
 | 
    plusMaxTypeDict = IpyGameDataPY.GetFuncEvalCfg("StrengthenLevelLimit", 1)  
 | 
    if not plusMaxTypeDict:  
 | 
        GameWorld.ErrLog("GetItemMaxStarLVûÓÐÇ¿»¯ÀàÐÍÓ³Éä±í")  
 | 
        return 0  
 | 
      
 | 
    if equipPlace not in plusMaxTypeDict:  
 | 
        return 0  
 | 
    findType = plusMaxTypeDict[equipPlace]  
 | 
    #ÏÉÆ÷ÌØÊâÈ¡¹Ì¶¨Öµ  
 | 
    if equipPlace in [ShareDefine.retFairyCan, ShareDefine.retFairyCan2]:  
 | 
        rank = 0  
 | 
        itemColor = 0  
 | 
    else:  
 | 
        rank = GetItemClassLV(curItem)  
 | 
        itemColor = curItem.GetItemColor()  
 | 
    ipyData = IpyGameDataPY.GetIpyGameData("ItemPlusMax", findType, rank, itemColor)  
 | 
    if not ipyData:  
 | 
        GameWorld.ErrLog("ÕÒ²»µ½×°±¸Ç¿»¯µÈ¼¶ÉÏÏÞ±íÊý¾ÝÅäÖã¡ rank = %s, %s" % (rank , curItem.GetItemQuality()))  
 | 
        return  
 | 
      
 | 
    return ipyData.GetLevelMax()  
 | 
  
 | 
## »ñÈ¡ÎïÆ·½×¼¶  
 | 
def GetItemClassLV(curItem):  
 | 
    return curItem.GetLV()  
 | 
  
 | 
def GetWingLV(curItem):  
 | 
    ## »ñÈ¡³á°ò´úÊýµÈ¼¶  
 | 
    wingLVDict = IpyGameDataPY.GetFuncEvalCfg("WingLV", 1)  
 | 
    return wingLVDict.get(str(curItem.GetLV()), 0)  
 | 
  
 | 
## ×°±¸ÆÀ·Ö  
 | 
def GetEquipGearScore(curItem):  
 | 
    return curItem.GetGearScore()  
 | 
  
 | 
def SetEquipGearScore(curItem, value):  
 | 
    return curItem.SetGearScore(value)  
 | 
  
 | 
## Ã¿ÈÕ¿ÉʹÓôÎÊý  
 | 
def GetCanUseCountDaily(curItem): return curItem.GetMaxAddSkillCnt()  
 | 
## Ã¿ÖÜ¿ÉʹÓôÎÊý, Ô¤Áô£¬Ôݲ»ÊµÏÖ  
 | 
#def GetCanUseCountWeek(curItem): return curItem.GetMaxFitLV()  
 | 
  
 | 
## »ñÈ¡·¢ËÍÓʼþÎïÆ·×ÖµäÐÅÏ¢  
 | 
def GetMailItemDict(curItem):  
 | 
    if not curItem or curItem.IsEmpty():  
 | 
        return {}  
 | 
      
 | 
    if not CheckItemIsEquip(curItem):  
 | 
        return [curItem.GetItemTypeID(), curItem.GetCount(), curItem.GetIsBind()]  
 | 
      
 | 
    addItemDict = {}  
 | 
    addItemDict['ItemID'] = curItem.GetItemTypeID()  
 | 
    addItemDict['Count'] = curItem.GetCount()  
 | 
    addItemDict['IsBind'] = int(curItem.GetIsBind())  
 | 
    #addItemDict['EquipGS'] = GetEquipGearScore(curItem)  
 | 
    #addItemDict['ItemStarLV'] = curItem.GetItemStarLV()  
 | 
    #addItemDict['CurDurg'] = GameWorld.GetIntUpper(curItem.GetCurDurg(), ChConfig.Def_EndureRepairParameter)  
 | 
    #addItemDict['MaxDurg'] = GameWorld.GetIntUpper(curItem.GetMaxEndure(), ChConfig.Def_EndureRepairParameter)  
 | 
    #addItemDict['ItemProperty'] = curItem.GetItemProperty()  
 | 
    #addItemDict['SoulProperty'] = curItem.GetSoulProperty()  
 | 
    #addItemDict['CanPlaceStoneCount'] = curItem.GetCanPlaceStoneCount()  
 | 
    #addItemDict['Stone1'] = curItem.GetStone(0)  
 | 
    #addItemDict['Stone2'] = curItem.GetStone(1)  
 | 
    #addItemDict['Stone3'] = curItem.GetStone(2)  
 | 
    #addItemDict['Stone4'] = curItem.GetStone(3)  
 | 
    #addItemDict['Stone5'] = curItem.GetStone(4)  
 | 
    #addItemDict['Stone6'] = curItem.GetStone(5)  
 | 
    #addItemDict['Stone7'] = curItem.GetStone(6)  
 | 
    #addItemDict['Stone8'] = curItem.GetStone(7)  
 | 
    #addItemDict['Stone9'] = curItem.GetStone(8)  
 | 
    #addItemDict['RemainHour'] = curItem.GetRemainHour()  
 | 
    #addItemDict['IsRenZhu'] = curItem.GetCanRenZhu()  
 | 
    #addItemDict['EquipDefenseValue'] = curItem.GetEquipDefenseValue()  
 | 
    #addItemDict['EquipMinAtkValue'] = curItem.GetEquipMinAtkValue()  
 | 
    #addItemDict['EquipMaxAtkValue'] = curItem.GetEquipMaxAtkValue()  
 | 
    #addItemDict['FitLV'] = curItem.GetFitLV()  
 | 
    #addItemDict['Proficiency'] = curItem.GetProficiency()  
 | 
    addItemDict['IsSuite'] = int(curItem.GetIsSuite())  
 | 
    #addItemDict['BaseHP'] = curItem.GetBaseHP()  
 | 
    #addItemDict['BaseMagicDef'] = curItem.GetBaseMagicDef()  
 | 
    #addItemDict['MaxAddSkillCnt'] = curItem.GetMaxAddSkillCnt()  
 | 
    #addItemDict['EquipMagicDefValue'] = curItem.GetEquipMagicDefValue()  
 | 
    #addItemDict['EquipMinMagicAtkValue'] = curItem.GetEquipMinMagicAtkValue()  
 | 
    #addItemDict['EquipMaxMagicAtkValue'] = curItem.GetEquipMaxMagicAtkValue()  
 | 
    addItemDict['UserData'] = str(curItem.GetUserData())  
 | 
    return addItemDict  
 | 
  
 | 
def GetJsonItem(itemInfo):  
 | 
    '''»ñÈ¡ÎïÆ·ÐÅÏ¢¶ÔÓ¦µÄjsonÐÅÏ¢  
 | 
    @param itemInfo: Ö§³ÖÁбí [itemID, itemCount, isBind], Ö§³Ö¶¯Ì¬ÁÐ±í³¤¶È£¬Ë÷Òý´ú±íÊôÐԹ̶¨  
 | 
                        Ö§³ÖÎïÆ·ÊµÀý, Èç¹ûÊÇʾÀýʱ±ØÐëÔÚ¸øÍæ¼Ò֮ǰÏÈ»ñÈ¡³öÀ´£¬·ÀÖ¹¸øÍæ¼Òºó¸ÃÎïÆ·ÊµÀý±»Çå¿Õ  
 | 
                          
 | 
    @return: {"ItemID":101, "Count":10, "IsBind":1, "IsSuite":1, "UserData":"×Ô¶¨ÒåÊôÐÔ×Ö·û´®"}  
 | 
    '''  
 | 
    itemDict = {}  
 | 
    if isinstance(itemInfo, list) or isinstance(itemInfo, tuple):  
 | 
        infolen = len(itemInfo)  
 | 
        if infolen > 0:  
 | 
            itemDict["ItemID"] = itemInfo[0]  
 | 
        if infolen > 1 and itemInfo[1] > 1:  
 | 
            itemDict["Count"] = itemInfo[1]  
 | 
        if infolen > 2 and itemInfo[2]:  
 | 
            itemDict["IsBind"] = int(itemInfo[2])  
 | 
    elif isinstance(itemInfo, int):  
 | 
        itemDict["ItemID"] = itemInfo  
 | 
    else: #ÎïÆ·ÊµÀý  
 | 
        if not CheckItemCanUse(itemInfo):  
 | 
            # ÐèÒªÏÈ»ñÈ¡ÐÅÏ¢£¬ÔÙ¸øÎïÆ·£¬²»ÄÜ¿ÉÄܵ¼Ö¸øÎïÆ·ºó£¬ÔÀ´µÄÁÙʱÎïÆ·±»Çå¿Õ£¬µ¼ÖÂÎÞ·¨Õý³£»ñµÃÎïÆ·ÐÅÏ¢  
 | 
            GameWorld.ErrLog("ÎïÆ·Îª¿Õ!ÎÞ·¨»ñÈ¡JsonItemÐÅÏ¢!")  
 | 
            return {}  
 | 
        itemDict["ItemID"] = itemInfo.GetItemTypeID()  
 | 
        if itemInfo.GetCount() > 1:  
 | 
            itemDict["Count"] = itemInfo.GetCount()  
 | 
        if itemInfo.GetIsBind():  
 | 
            itemDict["IsBind"] = int(itemInfo.GetIsBind())  
 | 
        if itemInfo.GetIsSuite():  
 | 
            itemDict["IsSuite"] = int(itemInfo.GetIsSuite())  
 | 
        if itemInfo.GetUserData():  
 | 
            itemDict["UserData"] = itemInfo.GetUserData()  
 | 
    return itemDict  
 | 
  
 | 
## ½«ÎïÆ·ÁбíÖØ¸´ÎïÆ·¶ÑµþÆðÀ´·µ»ØÕûÀíºóµÄÁÐ±í  
 | 
#  @param itemlist  
 | 
#  @return ÕûÀíºóµÄÎïÆ·ÁÐ±í  
 | 
def GetSimpleItemList(itemlist):  
 | 
    sItemList = []  
 | 
    sItemDict = {}  
 | 
    for item in itemlist:  
 | 
        maxPackCount = item.GetPackCount()  
 | 
        if maxPackCount == 0:  
 | 
            return itemlist  
 | 
        itemCnt = item.GetCount()  
 | 
        if itemCnt > maxPackCount:  
 | 
            return itemlist  
 | 
        itemid = item.GetItemTypeID()  
 | 
        isBind = item.GetIsBind()  
 | 
        key = (itemid,isBind)  
 | 
        if key in sItemDict:  
 | 
            for sitem in sItemDict[key]:  
 | 
                if sitem.GetCount() >= maxPackCount:  
 | 
                    continue  
 | 
                totalCnt = item.GetCount()+ sitem.GetCount()  
 | 
                  
 | 
                if totalCnt > maxPackCount:  
 | 
                    ItemControler.SetItemCount(sitem, maxPackCount)  
 | 
                    ItemControler.SetItemCount(item, totalCnt - maxPackCount)  
 | 
                    sItemList.append(item)  
 | 
                    sItemDict[key].append(item)  
 | 
                    break  
 | 
                ItemControler.SetItemCount(sitem, totalCnt)  
 | 
                item.Clear()  
 | 
        else:  
 | 
            sItemList.append(item)  
 | 
            sItemDict[key] = [item]  
 | 
              
 | 
      
 | 
    return sItemList  
 | 
  
 | 
## =======================================================================================  
 | 
##¸ù¾Ý»î¶¯ÀàÐÍÅäÖÃËæ»ú×°±¸Æ·ÖÊ  
 | 
# @param itemType   
 | 
# @return Æ·ÖÊ  
 | 
def GetRandEquipQualityByTable(itemType, tableName):  
 | 
    qualityRandDict = ReadChConfig.GetEvalChConfig(tableName)  
 | 
    qualityRandList = qualityRandDict.get(itemType, [])  
 | 
    if qualityRandList == []:  
 | 
        qualityRandList = qualityRandDict[-1]  
 | 
          
 | 
    return GameWorld.GetResultByRandomList(qualityRandList, 0)  
 | 
  
 | 
## Ëæ»ú׿Խװ±¸£¬¸ù¾Ý¹æÔò´ÓÊý¾Ý¿âÖÐɸѡ³ö,µÈ¼¶Ö°Òµ  
 | 
#  @param equipType ×°±¸ÀàÐÍ  
 | 
#  @return ³é½±ÊÇ·ñ³É¹¦   
 | 
def RandGreateEquip(curPlayer, equipType, isBind, tableName, quality=1):  
 | 
    equipList = GameDataControl.GetItemDataListByType(equipType)  
 | 
    equipLVRandList, lvFormulaStr, lvRange, jobRand, luckyShotRand, greateNumRand, \  
 | 
    broadcastList, plusRand, addAttrRand = ReadChConfig.GetEvalChConfig(tableName)  
 | 
      
 | 
    playerLV = curPlayer.GetLV()  
 | 
    step = GameWorld.GetResultByRandomList(equipLVRandList, 0)  
 | 
    getLVMin = eval(lvFormulaStr)  
 | 
    getLVMax = getLVMin + lvRange  
 | 
    checkJob = GameWorld.CanHappen(jobRand)  
 | 
      
 | 
    randList = []  
 | 
    findItem = None  
 | 
      
 | 
    for item in equipList:  
 | 
        if item.GetUseLV() < getLVMin or item.GetUseLV() > getLVMax:  
 | 
            continue  
 | 
          
 | 
        if item.GetItemQuality() != quality:  
 | 
            continue  
 | 
          
 | 
        if checkJob:  
 | 
            if JobUseable(curPlayer, item):  
 | 
                findItem = item  
 | 
                break  
 | 
            continue  
 | 
          
 | 
        randList.append(item)  
 | 
      
 | 
    if randList:  
 | 
        findItem = random.choice(randList)  
 | 
      
 | 
    if findItem == None:  
 | 
        return None, False  
 | 
      
 | 
    return CreateGreateItem(findItem, luckyShotRand, greateNumRand, broadcastList,  
 | 
                     plusRand, addAttrRand, isBind)  
 | 
  
 | 
  
 | 
## Éú³É³é½±µÄ׿Խװ±¸  
 | 
#  @param ¸÷ÊôÐÔ  
 | 
#  @return Éú³ÉµÄÎïÆ·£¬ÊÇ·ñ¹ã²¥   
 | 
def CreateGreateItem(findItem, luckyShotRand, greateNumRand, broadcastList,  
 | 
                     plusRand, addAttrRand, isBind):  
 | 
    itemID = findItem.GetItemTypeID()  
 | 
    equipItem = CreateSingleItem(itemID)  
 | 
      
 | 
    tmpEquipData = ItemControler.SingleEquipTmpData()  
 | 
      
 | 
    tmpEquipData.starLV = random.randint(plusRand[0], plusRand[1])  
 | 
    tmpEquipData.holeCnt = 3  
 | 
    tmpEquipData.isBind = isBind  
 | 
    tmpEquipData.isSuite = 0  
 | 
      
 | 
    # ×°±¸¸½¼ÓÊôÐÔ  
 | 
    ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)  
 | 
      
 | 
    broadcast = False  
 | 
          
 | 
    return equipItem, broadcast  
 | 
  
 | 
  
 | 
## Ëæ»úÆÕͨװ±¸£¬¸ù¾Ý¹æÔò´ÓÊý¾Ý¿âÖÐɸѡ³ö,µÈ¼¶Ö°Òµ  
 | 
#  @param equipType ×°±¸ÀàÐÍ  
 | 
#  @return ³é½±ÊÇ·ñ³É¹¦   
 | 
def RandNormalEquip(curPlayer, equipType, isBind, tableName):  
 | 
    equipList = GameDataControl.GetItemDataListByType(equipType)  
 | 
    equipLVRandList, lvFormulaStr, lvRange, jobRand, luckyShotRand, \  
 | 
    plusRand, addAttrRand, skillRand = ReadChConfig.GetEvalChConfig(tableName)  
 | 
      
 | 
    playerLV = curPlayer.GetLV()  
 | 
    step = GameWorld.GetResultByRandomList(equipLVRandList, 0)  
 | 
    getLVMin = eval(lvFormulaStr)  
 | 
    getLVMax = getLVMin + lvRange  
 | 
    checkJob = GameWorld.CanHappen(jobRand)  
 | 
      
 | 
    randList = []  
 | 
    findItem = None  
 | 
      
 | 
    for item in equipList:  
 | 
        if item.GetUseLV() < getLVMin or item.GetUseLV() > getLVMax:  
 | 
            continue  
 | 
          
 | 
        if item.GetItemQuality() != 0:  
 | 
            continue  
 | 
          
 | 
        if checkJob:  
 | 
            if JobUseable(curPlayer, item):  
 | 
                findItem = item  
 | 
                break  
 | 
            continue  
 | 
          
 | 
        randList.append(item)  
 | 
      
 | 
    if randList:  
 | 
        findItem = random.choice(randList)  
 | 
      
 | 
    if findItem == None:  
 | 
        return None  
 | 
      
 | 
    return CreateNormalItem(findItem, luckyShotRand, plusRand, addAttrRand, isBind, skillRand)  
 | 
  
 | 
  
 | 
## Éú³É³é½±µÄ׿Խװ±¸  
 | 
#  @param ¸÷ÊôÐÔ  
 | 
#  @return Éú³ÉµÄÎïÆ·  
 | 
def CreateNormalItem(findItem, luckyShotRand, plusRand, addAttrRand, isBind, skillRand):  
 | 
    itemID = findItem.GetItemTypeID()  
 | 
    equipItem = CreateSingleItem(itemID)  
 | 
      
 | 
    tmpEquipData = ItemControler.SingleEquipTmpData()  
 | 
      
 | 
    tmpEquipData.starLV = random.randint(plusRand[0], plusRand[1])  
 | 
    tmpEquipData.holeCnt = 3  
 | 
    tmpEquipData.isBind = isBind  
 | 
    tmpEquipData.isSuite = 0  
 | 
      
 | 
    # ×°±¸¸½¼ÓÊôÐÔ  
 | 
    ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)  
 | 
      
 | 
    return equipItem  
 | 
  
 | 
## =======================================================================================  
 | 
  
 | 
def SyncMakeItemAnswer(curPlayer, makeType, isSuccess, makeItemID):  
 | 
    makeItemAnswer = ChPyNetSendPack.tagMCMakeItemAnswer()  
 | 
    makeItemAnswer.Clear()  
 | 
    makeItemAnswer.MakeType = makeType  
 | 
    makeItemAnswer.Result = isSuccess  
 | 
    makeItemAnswer.MakeItemID = makeItemID  
 | 
    NetPackCommon.SendFakePack(curPlayer, makeItemAnswer)  
 | 
    return  
 | 
  
 | 
  
 |