| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Event.EventSrc.Operate_EquipStone  | 
| #  | 
| # @todo:×°±¸±¦Ê¯  | 
| # @author hxp  | 
| # @date 2017-07-29  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ×°±¸±¦Ê¯  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2017-07-29 12:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import GameWorld  | 
| import ItemCommon  | 
| import PlayerControl  | 
| import IPY_GameWorld  | 
| import ItemControler  | 
| import IpyGameDataPY  | 
| import ChConfig  | 
| import ChEquip  | 
| import OpenServerCampaign  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import DataRecordPack  | 
| import PlayerSuccess  | 
| import ShareDefine  | 
|   | 
|   | 
|   | 
| def OnLogin(curPlayer):  | 
|     ###µÇ¼·¢°üͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢  | 
|     Sycn_StoneHoleInfo(curPlayer)  | 
|     return  | 
|   | 
| def GetAllStoneEquipIndexList():  | 
|     ###µÃµ½ËùÓпÉÏâǶ±¦Ê¯×°±¸Î»ÁÐ±í  | 
|       | 
|     #»ñµÃ±¦Ê¯ÀàÐÍÊýÁ¿  | 
|     GemTypeCount = IpyGameDataPY.GetFuncCfg("GemTypeCount")  | 
|     #»ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î»  | 
|     stoneCanPlaceList = []        | 
|     for stoneTypeIndex in xrange(1, GemTypeCount + 1):  | 
|         #Ñ»·±¦Ê¯ÀàÐͶÔÓ¦µÄ×°±¸Î»  | 
|         stoneCanPlaceList += IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneTypeIndex, 1)  | 
|       | 
|     return stoneCanPlaceList  | 
|   | 
| def GetAllEquipPlaceHoleIndex():  | 
|     ### µÃµ½×°±¸Î»ËùÓп×λ  | 
|     gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)  | 
|     maxEquipHoleCnt = len(gemOpenClassLVList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý  | 
|        | 
|     gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)  | 
|     maxHoleVipCnt = len(gemOpenVipList)# ×î´óVip¿ª·Å¿×Êý  | 
|       | 
|     return range(maxEquipHoleCnt) + range(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxHoleVipCnt)  | 
|   | 
| def GetEquipIndexStoneIDList(curPlayer, equipIndex):  | 
|     ### ×°±¸Î»¿×λ±¦Ê¯IDÁÐ±í  | 
|       | 
|     holeIndexList = GetAllEquipPlaceHoleIndex()  | 
|     holeStoneIDList = []  | 
|     for holeIndex in holeIndexList:  | 
|         stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex) [0]  | 
|         holeStoneIDList.append(stoneID)  | 
|     return holeStoneIDList  | 
|   | 
| def GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex):  | 
|     '''»ñµÃ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢  | 
|     @return: stoneID, stoneIsBind  | 
|     '''  | 
|     #»ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢  | 
|     stoneInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex))   | 
|     #»ñȡװ±¸Î»¿×λÉϱ¦Ê¯ID  | 
|     stoneID = stoneInfo / ChConfig.Def_Stone_SaveStoneInfoXNumber  | 
|     #»ñȡװ±¸Î»¿×λÉϱ¦Ê¯ÊÇ·ñ°ó¶¨×´Ì¬  | 
|     stoneIsBind = stoneInfo % ChConfig.Def_Stone_SaveStoneInfoXNumber     | 
|     return stoneID, stoneIsBind  | 
|   | 
| def SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind):  | 
|     ### ±£´æ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex),  | 
|                                        changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind)   | 
|     return  | 
|   | 
|   | 
| #//A3 04 ±¦Ê¯ÏâǶ»òÌæ»» #tagCMEquipEnchase  | 
| #struct    tagCMEquipEnchase  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        EquipIndex;        //×°±¸Î»Ë÷Òý  | 
| #    BYTE        StoneIndex;        //±¦Ê¯ËùÔÚÍæ¼ÒÎïÆ·±³°üË÷Òý  | 
| #    BYTE        HoleIndex;        //Ñ¡ÔñµÄ¿×Ë÷Òý  | 
| #};  | 
| def OnEquipEnchase(playerIndex, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ  | 
|     equipIndex = clientData.EquipIndex  | 
|     stoneIndex = clientData.StoneIndex  | 
|     holeIndex = clientData.HoleIndex  | 
|       | 
|     GameWorld.DebugLog("±¦Ê¯ÏâǶ: equipIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipIndex, stoneIndex, holeIndex), playerID)  | 
|       | 
|     #»ñµÃ×°±¸Î»×°±¸ÊµÀý  | 
|     equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     curEquip = equipPack.GetAt(equipIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curEquip):  | 
|         GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)  | 
|         return  | 
|    | 
|     #»ñµÃ±¦Ê¯ÊµÀý  | 
|     itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|     curStone = itemPack.GetAt(stoneIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curStone):  | 
|         GameWorld.Log("Ä¿±ê±¦Ê¯Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)  | 
|         return  | 
|       | 
|     stoneItemID = curStone.GetItemTypeID()  | 
|     isBind = curStone.GetIsBind()  | 
|     curStoneEff = curStone.GetEffectByIndex(0)  | 
|     curEffID = curStoneEff.GetEffectID()  | 
|     if curEffID != ChConfig.Def_Effect_EquipStone:  | 
|         GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨ÏâǶ£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s != %s"   | 
|                       % (stoneIndex, stoneItemID, curEffID, ChConfig.Def_Effect_EquipStone), playerID)  | 
|         return  | 
|       | 
|     stoneEffType = curStoneEff.GetEffectValue(0)  | 
|     stoneCanPlaceList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneEffType, 1)  | 
|       | 
|     if equipIndex not in stoneCanPlaceList:  | 
|         GameWorld.Log("¸Ã±¦Ê¯²»¿ÉÏâǶÔÚ¸Ã×°±¸Î»£¡stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPlace=%s"   | 
|                       % (stoneItemID, stoneEffType, stoneCanPlaceList, equipIndex), playerID)  | 
|         return  | 
|       | 
|     equipClassLV = ItemCommon.GetItemClassLV(curEquip)  | 
|     if not __CheckStoneHoleCanUse(curPlayer, equipClassLV, holeIndex):  | 
|         return  | 
|       | 
|     # ¿Û³ý±¦Ê¯  | 
|     ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"EquipPlace":equipIndex, "HoleIndex":holeIndex})  | 
|       | 
|     isBind = 1 if isBind else 0  | 
|       | 
|     # ±ä¸ü±¦Ê¯¿×±¦Ê¯ÐÅÏ¢  | 
|     __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, stoneItemID, isBind, "EquipStone", True)  | 
|       | 
| #    #ÏâǶ³É¹¦  | 
| #    if not curEquip.GetIsBind():  | 
| #        ItemControler.SetItemIsBind(curEquip, True)  | 
|       | 
|     # Ë¢ÐÂÊôÐÔ  | 
|     RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, True)  | 
|       | 
|     #ͬ²½¿Í»§¶Ë  | 
|     Sycn_StoneHoleInfo(curPlayer, [equipIndex])  | 
|     #³É¾Í  | 
|     __DoStoneSuccess(curPlayer)  | 
|     return  | 
|   | 
| def __DoStoneSuccess(curPlayer):  | 
|     PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone1)  | 
|     PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone2)  | 
|     totalStoneLV = 0  | 
|     holeIndexList = GetAllEquipPlaceHoleIndex()  | 
|     gameData = GameWorld.GetGameData()  | 
|     packType = IPY_GameWorld.rptEquip  | 
|     playerEquip = curPlayer.GetItemManager().GetPack(packType)  | 
|     for equipIndex in xrange(playerEquip.GetCount()):  | 
|         if equipIndex not in ShareDefine.RoleEquipType :  | 
|             continue  | 
|         for holeIndex in holeIndexList:  | 
|               | 
|             curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]  | 
|             if curGemID == 0:  | 
|                 continue  | 
|             curGem = gameData.GetItemByTypeID(curGemID)  | 
|             if not curGem:  | 
|                 continue      | 
|       | 
|             gemEffect = curGem.GetEffectByIndex(0)  | 
|             gemType, gemLV = gemEffect.GetEffectValue(0), gemEffect.GetEffectValue(1)  | 
|             if gemType == 1:#ÉúÃü±¦Ê¯  | 
|                 PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone1, 1, [gemLV])  | 
|             elif gemType == 2:#»ÙÃð±¦Ê¯  | 
|                 PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone2, 1, [gemLV])  | 
|                   | 
|             totalStoneLV += gemLV  | 
|               | 
|     # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶  | 
|     OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)  | 
|     PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_StoneTotalLV, totalStoneLV)  | 
|     return  | 
|   | 
| #//A3 05 ±¦Ê¯ÕªÈ¡ #tagCMEquipStonePick  | 
| #struct    tagCMEquipStonePick  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        EquipIndex;        //×°±¸Î»ÔÚ±³°üÖÐË÷Òý  | 
| #    BYTE        HoleIndex;        //×°±¸Î»µÄ¿×Ë÷Òý  | 
| #};  | 
| def OnEquipStonePick(playerIndex, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ  | 
|     equipIndex = clientData.EquipIndex  | 
|     holeIndex = clientData.HoleIndex  | 
|     GameWorld.DebugLog("±¦Ê¯Õª³ý: equipIndex=%s,holeIndex=%s" % (equipIndex, holeIndex), playerID)  | 
|       | 
|     #»ñµÃ×°±¸Î»×°±¸ÊµÀý  | 
|     equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     curEquip = equipPack.GetAt(equipIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curEquip):  | 
|         GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)  | 
|         return  | 
|       | 
|     #ÑéÖ¤±³°ü¿Õ¼ä  | 
|     if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem, True):  | 
|         return  | 
|       | 
|     # ÑéÖ¤±¦Ê¯  | 
|     stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]  | 
|       | 
|     if not stoneID:  | 
|         GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")  | 
|         return  | 
|       | 
|     __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, 0, 0, "StonePick", True)  | 
|       | 
|     # Ë¢ÐÂÊôÐÔ  | 
|     RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)  | 
|       | 
|     #ͬ²½¿Í»§¶Ë  | 
|     Sycn_StoneHoleInfo(curPlayer, [equipIndex])  | 
|       | 
|     totalStoneLV = 0  | 
|     holeIndexList = GetAllEquipPlaceHoleIndex()  | 
|     gameData = GameWorld.GetGameData()  | 
|     playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     for equipIndex in xrange(playerEquip.GetCount()):  | 
|         if equipIndex not in ShareDefine.RoleEquipType :  | 
|             continue  | 
|         for holeIndex in holeIndexList:  | 
|             curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]  | 
|             if curGemID == 0:  | 
|                 continue  | 
|             curGem = gameData.GetItemByTypeID(curGemID)  | 
|             if not curGem:  | 
|                 continue  | 
|             gemLV = curGem.GetEffectByIndex(0).GetEffectValue(1)  | 
|             totalStoneLV += gemLV  | 
|               | 
|     # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶  | 
|     OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)  | 
|     return  | 
|   | 
|   | 
| #// A3 06 ±¦Ê¯Éý¼¶ #tagCMEquipStoneUpgrade  | 
| #struct    tagCMEquipStoneUpgrade  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        EquipIndex;        //×°±¸Î»ÔÚ×°±¸±³°üÖеÄË÷Òý  | 
| #    BYTE        HoleIndex;        //×°±¸Î»Öб¦Ê¯¿×Ë÷Òý  | 
| #    BYTE        UpWay;        //Éý¼¶·½Ê½ 0:ÏÉÓñ 1:±¦Ê¯  | 
| #};  | 
| def OnEquipStoneUpgrade(playerIndex, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ  | 
|     equipIndex = clientData.EquipIndex  | 
|     holeIndex = clientData.HoleIndex  | 
|     upWay = clientData.UpWay  | 
|     GameWorld.DebugLog("±¦Ê¯Éý¼¶: equipPlace=%s,holeIndex=%s" % (equipIndex, holeIndex), playerID)  | 
|       | 
|     #»ñµÃ×°±¸Î»×°±¸ÊµÀý  | 
|     equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     curEquip = equipPack.GetAt(equipIndex)  | 
|       | 
|     if not ItemCommon.CheckItemCanUse(curEquip):  | 
|         GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)  | 
|         return  | 
|           | 
|     #Éý¼¶±¦Ê¯ID  | 
|     stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)  | 
|     if stoneID == 0:  | 
|         GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")        | 
|         return        | 
|     stoneItemData = GameWorld.GetGameData().GetItemByTypeID(stoneID)   | 
|     stoneItemID = stoneItemData.GetItemTypeID()  | 
|     curStoneEff = stoneItemData.GetEffectByIndex(0)  | 
|     curEffID = curStoneEff.GetEffectID()  | 
|     if curEffID != ChConfig.Def_Effect_EquipStone:  | 
|         GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨Éý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s"   | 
|                       % (holeIndex, stoneItemID, curEffID), playerID)  | 
|         return   | 
|     stoneEffType = curStoneEff.GetEffectValue(0)  | 
|     level = curStoneEff.GetEffectValue(1)  | 
|     upgradeStoneID = curStoneEff.GetEffectValue(2)  | 
|       | 
|     stoneTypeItemIDDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 1)  | 
|     GameWorld.DebugLog("stoneEffType=%s,stoneTypeItemIDDict=%s,level=%s,upgradeStoneID=%s"   | 
|                        % (stoneEffType, stoneTypeItemIDDict, level, upgradeStoneID))  | 
|     if stoneEffType not in stoneTypeItemIDDict:  | 
|         return  | 
|     stoneTypeItemID = stoneTypeItemIDDict[stoneEffType]  | 
|       | 
|     if not upgradeStoneID:  | 
|         GameWorld.Log("¸Ã±¦Ê¯ÒÑÊÇ×î´ó¼¶,²»ÄÜÉý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s,upgradeStoneID=%s"  | 
|                       % (holeIndex, stoneItemID, curEffID, upgradeStoneID), playerID)  | 
|         return  | 
|     needCount = IpyGameDataPY.GetFuncCfg("GemUpCostFormula", 2) # ºÏ³ÉÏÂÒ»¼¶ËùÐ豦ʯ¸öÊý  | 
|     if not needCount:  | 
|         return  | 
|     if upWay == 0: #ÏÉÓñ  | 
|         unitPrice = ItemCommon.GetShopItemPrice(stoneTypeItemID, IPY_GameWorld.TYPE_Price_Gold_Money)  | 
|         if not unitPrice:  | 
|             return  | 
|         costCount = pow(needCount, level - 1) * (needCount - 1)  | 
|         costGold = costCount * unitPrice  | 
|         if costGold <= 0:  | 
|             return  | 
|         infoDict = {"StoneItemID":stoneItemID, "CurStoneIDLV":level, "UpgradeStoneID":upgradeStoneID, "CostCount":costCount, "UnitPrice":unitPrice}  | 
|         if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_EquipStone, infoDict):  | 
|             GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % costGold)  | 
|             return  | 
|     else:  | 
|         #ͬ¼¶±¦Ê¯  | 
|         costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, stoneItemID)  | 
|         if bindCnt + unBindCnt < needCount-1:  | 
|             GameWorld.DebugLog("ͬ¼¶±¦Ê¯²»×ã %s!" % (needCount-1))  | 
|             return  | 
|         if stoneIsBind:  | 
|             costIndexList = (costItemIndexList[0]+costItemIndexList[1])[:2]  | 
|         else:  | 
|             costIndexList = (costItemIndexList[1]+costItemIndexList[0])[:2]  | 
|         itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|         hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, costIndexList, needCount-1, False, ChConfig.ItemDel_StoneUpgrade,   | 
|                                         {"EquipPlace":equipIndex, "HoleIndex":holeIndex})  | 
|         if hasBind:  | 
|             stoneIsBind = True  | 
|           | 
|       | 
|     __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, upgradeStoneID, stoneIsBind, "StoneUpgrade", False)  | 
|       | 
|     # Ë¢ÐÂÊôÐÔ  | 
|     RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)  | 
|       | 
|     #ͬ²½¿Í»§¶Ë  | 
|     Sycn_StoneHoleInfo(curPlayer, [equipIndex])  | 
|       | 
|     __DoStoneSuccess(curPlayer)  | 
|     return  | 
|   | 
| def __CheckStoneHoleCanUse(curPlayer, equipClassLV, holeIndex):  | 
|     ##ÑéÖ¤¿×ºÏ·¨ÐÔ  | 
|       | 
|     holeIndexList = GetAllEquipPlaceHoleIndex()  | 
|     if holeIndex not in holeIndexList:  | 
|         GameWorld.Log("ÏâǶ¿×Ë÷Òý´íÎó!holeIndex=%s, holeIndexList=%s" % (holeIndex, holeIndexList))  | 
|         return False  | 
|       | 
|     openCommHoleCnt = 0 # ÒѾ¿ª·Å×°±¸³£¹æ¿×Êý  | 
|     gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)  | 
|     for holeCnt, openClassLV in enumerate(gemOpenClassLVList, 1):  | 
|         if equipClassLV >= openClassLV:  | 
|             openCommHoleCnt = holeCnt  | 
|               | 
|     # VIP¿×  | 
|     if holeIndex >= ChConfig.Def_Stone_VipHole:  | 
|           | 
|         if openCommHoleCnt <= 0:  | 
|             GameWorld.Log("×°±¸Î´¿ªÆôÈÎºÎÆÕͨ±¦Ê¯¿×£¬ÎÞ·¨¿ªÆôVIP¿×λ! equipClassLV=%s,openCommHoleCnt=%s" % (equipClassLV, openCommHoleCnt))  | 
|             return False  | 
|         gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)  | 
|           | 
|         openVIPHoleCnt = 0 # ÒѾ¿ª·Å×°±¸VIP¿×Êý  | 
|         curVipLV = curPlayer.GetVIPLv()  | 
|         for holeCnt, vipLv in enumerate(gemOpenVipList, 1):        | 
|             if curVipLV >= vipLv:         | 
|                 openVIPHoleCnt = holeCnt  | 
|                   | 
|         if holeIndex >= openVIPHoleCnt + ChConfig.Def_Stone_VipHole:  | 
|             GameWorld.Log("×°±¸VIP±¦Ê¯¿×먦·Å!curVipLV=%s,holeIndex=%s,openVIPHoleCnt=%s"   | 
|                           % (curVipLV, holeIndex, openVIPHoleCnt), curPlayer.GetPlayerID())  | 
|             return False  | 
|           | 
|         #²»ÏÞÖÆÊÇ·ñ¹ýÆÚ  | 
|         #if not PlayerVip.GetCurVIPTime(curPlayer):  | 
|         #    GameWorld.Log("VIPÒѹýÆÚ£¬ÎÞ·¨Ê¹ÓÃVIP±¦Ê¯¿×£¡", curPlayer.GetPlayerID())  | 
|         #    return False  | 
|           | 
|     # ³£¹æ¿×  | 
|     elif holeIndex >= openCommHoleCnt:  | 
|         GameWorld.Log("¸Ã×°±¸±¦Ê¯¿×Ϊ¿ª·Å£¡equipClassLV=%s,holeIndex=%s,openCommHoleCnt=%s"   | 
|                       % (equipClassLV, holeIndex, openCommHoleCnt), curPlayer.GetPlayerID())  | 
|         return False  | 
|       | 
|     return True  | 
|   | 
| def __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff):  | 
|     ## ±ä¸üÍæ¼Ò×°±¸¿×±¦Ê¯  | 
|       | 
|     #»ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢  | 
|     stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)  | 
|     #±£´æ×°±¸Î»¿×λÉϱ¦Ê¯IDºÍ°ó¶¨×´Ì¬  | 
|     SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind)  | 
|       | 
|     if isPickoff and stoneID:  | 
|         itemCount = 1  | 
|         # Õª³ýµÄ±¦Ê¯¶¼°ó¶¨  | 
|         if ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):  | 
|             ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, True if stoneIsBind else False,  | 
|                                          [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],   | 
|                                          event=[ChConfig.ItemGive_StonePickoff, False, {"EquipPlace":equipIndex, "HoleIndex":holeIndex}])  | 
|         else:  | 
|             PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], [[stoneID, 1, stoneIsBind]])  | 
|               | 
|     DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {"holeIndex":holeIndex, "stoneID":stoneID})      | 
|     return  | 
|   | 
|   | 
| def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify):  | 
|     ## ±¦Ê¯Ë¢ÐÂÊôÐÔ  | 
|     # ×°±¸µÈ¼¶¸Ä±ä£¬ÅжÏÊÇ·ñÎªÍæ¼ÒÉíÉϵÄ×°±¸£¬Èç¹ûÊǵĻ°Ë¢ÐÂÍæ¼ÒÊôÐÔ  | 
|     if packType in [IPY_GameWorld.rptEquip, IPY_GameWorld.rptHorseEquip]:  | 
|         #ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ  | 
|         if isNeedNotify:  | 
|             curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Stone)  | 
|         ChEquip.RefreshPlayerEquipAttribute(curPlayer)  | 
|           | 
|         #Ë¢ÐÂËùÓÐÊôÐÔ  | 
|         playControl = PlayerControl.PlayerControl(curPlayer)  | 
|         playControl.RefreshPlayerAttrState()  | 
|           | 
|     return  | 
|   | 
|   | 
| def DoMoveEquipStone(curPlayer, equipIndex):   | 
|     ###Ìæ»»×°±¸Ê±±¦Ê¯×ªÒÆ  | 
|     equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|     curEquip = equipPack.GetAt(equipIndex)  | 
|     if not ItemCommon.CheckItemCanUse(curEquip):  | 
|         return  | 
|       | 
|     #»ñµÃ×°±¸½×¼¶¿×ÐÅÏ¢  | 
|     gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)  | 
|     maxEquipHoleCnt = len(gemOpenClassLVList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý  | 
|       | 
|     openEquipHoleCnt = 0 # ÒѾ¿ª·Å¿×Êý  | 
|     equipClassLV = ItemCommon.GetItemClassLV(curEquip)  | 
|     for holeCnt, openClassLV in enumerate(gemOpenClassLVList, 1):  | 
|         if equipClassLV >= openClassLV:  | 
|             openEquipHoleCnt = holeCnt  | 
|               | 
|     #ÐèÒª²ðж±¦Ê¯µÄ¿×ÁÐ±í  | 
|     pickoffHoleList = []  | 
|       | 
|     #ÅжÏ×°±¸½×¼¶±¦Ê¯ÊÇ·ñ²ðж  | 
|     for holeIndex in xrange(maxEquipHoleCnt):        | 
|         if holeIndex < openEquipHoleCnt:  | 
|             continue  | 
|         curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]  | 
|         if curGemID == 0:  | 
|             continue         | 
|         pickoffHoleList.append([equipIndex, holeIndex])  | 
|           | 
|     #ûÓпªÆôÆÕͨװ±¸¿×£¬ÐèÕª³ýVIP¿×  | 
|     if not openEquipHoleCnt:  | 
|         #»ñµÃVIPµÈ¼¶¿×ÐÅÏ¢  | 
|         gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)  | 
|         maxVipHoleCnt = len(gemOpenVipList)# ×î´óVIP¿ª·Å¿×Êý  | 
|         #ÅжÏVIPµÈ¼¶¿×ÐÅÏ¢  | 
|         for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt):   | 
|             curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]  | 
|             if curGemID == 0:                               | 
|                 continue  | 
|             pickoffHoleList.append([equipIndex, holeIndex])  | 
|               | 
|     # ÍÑ×°±¸µÄÍâ²ãË¢ÊôÐÔ, ÕâÀﲻˢ  | 
|     __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, "EquipChange", False)  | 
|     return  | 
|   | 
| def OnVIPTimeOut(curPlayer):  | 
|     ## VIPµ½ÆÚ´¦Àí  | 
|     #¹ýÆÚÒ»ÑùÓÐЧ£¬ÆÁ±Î¸ÃÂß¼  | 
|     #===============================================================================================  | 
|     # #»ñµÃvipµÈ¼¶¿×ÐÅÏ¢  | 
|     # gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)  | 
|     # maxVipHoleCnt = len(gemOpenVipList)# ×î´óVip¿ª·Å¿×Êý  | 
|     #   | 
|     # #»ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î»  | 
|     # stoneCanPlaceList = GetAllStoneEquipIndexList()  | 
|     # #ÐèÒª²ðж±¦Ê¯µÄ¿×ÁÐ±í  | 
|     # pickoffHoleList = []  | 
|     # for equipIndex in stoneCanPlaceList:  | 
|     #    for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt):  | 
|     #        stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)  | 
|     #        if not stoneInfo[0]:  | 
|     #            continue  | 
|     #        pickoffHoleList.append([equipIndex, holeIndex])  | 
|     #          | 
|     # __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, "VIPChange", True)  | 
|     #===============================================================================================  | 
|     return    | 
|   | 
| def __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, eventName, isRefreshAttr):  | 
|     ## ÏµÍ³Õª³ý±¦Ê¯  | 
|       | 
|     if not pickoffHoleList:  | 
|         return  | 
|       | 
|     GameWorld.DebugLog("ϵͳժ³ý±¦Ê¯: %s,pickoffHoleList=%s" % (eventName, pickoffHoleList), curPlayer.GetPlayerID())  | 
|       | 
|     equipIndexList = []  | 
|     stoneCount = len(pickoffHoleList)  | 
|     packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, stoneCount)  | 
|     if packSpace >= stoneCount:  | 
|         for equipIndex, holeIndex in pickoffHoleList:  | 
|             __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, 0, 0, eventName, True)  | 
|             if equipIndex not in equipIndexList:  | 
|                 equipIndexList.append(equipIndex)  | 
|     else:  | 
|         #ÓʼþÎïÆ·ÐÅÏ¢ÁÐ±í  | 
|         mailItemInfoList = []  | 
|         for equipIndex, holeIndex in pickoffHoleList:  | 
|             stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)  | 
|             mailItemInfoList.append([stoneInfo[0], 1, stoneInfo[1]])  | 
|             SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, 0, 0)  | 
|             DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {"holeIndex":holeIndex, "stoneID":stoneInfo[0]})  | 
|             if equipIndex not in equipIndexList:  | 
|                 equipIndexList.append(equipIndex)  | 
|         PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList)  | 
|           | 
|     if isRefreshAttr:  | 
|         RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)  | 
|       | 
|     if equipIndexList:  | 
|         Sycn_StoneHoleInfo(curPlayer, equipIndexList)  | 
|     return  | 
|   | 
| def Sycn_StoneHoleInfo(curPlayer, equipIndexList=[]):  | 
|     ###ͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢  | 
|     #×°±¸Î»ËùÓп×λ  | 
|     holeIndexList = GetAllEquipPlaceHoleIndex()  | 
|     maxHoleCount = len(holeIndexList)  | 
|     if not equipIndexList:  | 
|         equipIndexList = GetAllStoneEquipIndexList()  | 
|       | 
|     sendPack = ChPyNetSendPack.tagMCStoneInfo()  | 
|     sendPack.InfoList = []  | 
|     for equipIndex in equipIndexList:  | 
|         stoneMsg = ChPyNetSendPack.tagMCStoneMsg()  | 
|         stoneMsg.EquipPlace = equipIndex  | 
|         stoneMsg.MaxStoneCount = maxHoleCount   | 
|         stoneMsg.StoneInfo = GetEquipIndexStoneIDList(curPlayer, equipIndex)  | 
|         holeStoneBindList = []  | 
|         for holeIndex in holeIndexList:  | 
|             isBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[1]  | 
|             holeStoneBindList.append(isBind)  | 
|         stoneMsg.StoneBind = holeStoneBindList  | 
|         sendPack.InfoList.append(stoneMsg)  | 
|     sendPack.EquipCount = len(sendPack.InfoList)    | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   |