#!/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 PlayerWeekParty import ShareDefine import EventShell import PyGameData g_stoneCanPlaceList = [] # ¿ÉÏâǶµÄλÖà # def OnLogin(curPlayer): # ###µÇ¼·¢°üͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢ # Sycn_StoneHoleInfo(curPlayer) # return def GetAllStoneEquipIndexList(): ###µÃµ½ËùÓпÉÏâǶ±¦Ê¯×°±¸Î»Áбí global g_stoneCanPlaceList if g_stoneCanPlaceList: return g_stoneCanPlaceList # »ñµÃ±¦Ê¯ÀàÐÍÊýÁ¿ GemTypeCount = IpyGameDataPY.GetFuncCfg("GemTypeCount") # »ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î» g_stoneCanPlaceList = [] for stoneTypeIndex in xrange(1, GemTypeCount + 1): # Ñ­»·±¦Ê¯ÀàÐͶÔÓ¦µÄ×°±¸Î» placeList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneTypeIndex, 1) for place in placeList: ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'EquipPlace': place}, True) if not ipyDataList: continue for ipyData in ipyDataList: gridIndex = ipyData.GetGridIndex() if gridIndex not in g_stoneCanPlaceList: g_stoneCanPlaceList.append(gridIndex) return g_stoneCanPlaceList def GetAllEquipPlaceHoleIndex(): ### µÃµ½×°±¸Î»ËùÓп×λ gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1) maxEquipHoleCnt = len(gemOpenNeedStarList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý 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ºÍ°ó¶¨ÐÅÏ¢ befStoneID, befIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex) if befStoneID == changeStoneID and befIsBind == isBind: return isBind = 0 # ÏÖ°ó¶¨ÎÞÓã¬Ä¬ÈÏ´æ0 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex), changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind) # ͬ²½¸üб¦Ê¯×ܵȼ¶ gameData = GameWorld.GetGameData() befStoneLV = 0 if befStoneID: befGem = gameData.GetItemByTypeID(befStoneID) befStoneLV = 0 if not befGem else befGem.GetEffectByIndex(0).GetEffectValue(1) aftStoneLV = 0 if changeStoneID: aftGem = gameData.GetItemByTypeID(changeStoneID) aftStoneLV = 0 if not aftGem else aftGem.GetEffectByIndex(0).GetEffectValue(1) befTotalStoneLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV) updTotalStoneLV = max(0, befTotalStoneLV + aftStoneLV - befStoneLV) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalStoneLV, updTotalStoneLV) GameWorld.DebugLog( "ÉèÖñ¦Ê¯µÈ¼¶: equipIndex=%s,holeIndex=%s,befStoneLV=%s,aftStoneLV=%s,befTotalStoneLV=%s,updTotalStoneLV=%s" % (equipIndex, holeIndex, befStoneLV, aftStoneLV, befTotalStoneLV, updTotalStoneLV)) return def GetPackTypeByEquipPlace(equipPlace): ##Ŀǰ֧³ÖÏâǶÆÕͨװ±¸ equipPackType = IPY_GameWorld.rptEquip stonePackType = IPY_GameWorld.rptItem placeIndex = equipPlace return equipPackType, stonePackType, placeIndex # //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() # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ equipPackIndex = clientData.EquipIndex stoneIndex = clientData.StoneIndex holeIndex = clientData.HoleIndex GameWorld.DebugLog("±¦Ê¯ÏâǶ: equipPackIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipPackIndex, stoneIndex, holeIndex), playerID) equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex) # »ñµÃ×°±¸Î»×°±¸ÊµÀý equipPack = curPlayer.GetItemManager().GetPack(equipPackType) curEquip = equipPack.GetAt(placeIndex) if not ItemCommon.CheckItemCanUse(curEquip): GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID) return # »ñµÃ±¦Ê¯ÊµÀý itemPack = curPlayer.GetItemManager().GetPack(stonePackType) 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) ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex}) if not ipyData: return classLV = ipyData.GetClassLV() if ipyData.GetEquipPlace() not in stoneCanPlaceList: GameWorld.Log("¸Ã±¦Ê¯²»¿ÉÏâǶÔÚ¸Ã×°±¸Î»£¡stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPackIndex=%s" % (stoneItemID, stoneEffType, stoneCanPlaceList, equipPackIndex), playerID) return equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, placeIndex, curEquip) if not __CheckStoneHoleCanUse(curPlayer, equipStar, holeIndex, equipPackType): return # ¿Û³ý±¦Ê¯ ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex}) isBind = 1 if isBind else 0 # ±ä¸ü±¦Ê¯¿×±¦Ê¯ÐÅÏ¢ __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, stoneItemID, isBind, "EquipStone", True) # #ÏâǶ³É¹¦ # if not curEquip.GetIsBind(): # ItemControler.SetItemIsBind(curEquip, True) # Ë¢ÐÂÊôÐÔ RefreshAttrByStoneAction(curPlayer, equipPackType, True, classLV) # ͬ²½¿Í»§¶Ë Sycn_StoneHoleInfo(curPlayer, [equipPackIndex]) # ³É¾Í DoStoneSuccess(curPlayer, classLV) EventShell.EventRespons_InlayStone(curPlayer) return def DoStoneSuccess(curPlayer, classLV): #PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone1) #PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone2) totalStoneLV = 0 classStoneLV = 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 ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipIndex}) if ipyData and ipyData.GetClassLV() == classLV: classStoneLV += gemLV # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶ #GameWorld.DebugLog("classLV=%s,classStoneLV=%s,totalStoneLV=%s" % (classLV, classStoneLV, totalStoneLV)) OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV) PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_StoneTotalLV, totalStoneLV) PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_EquipStoneClass, classStoneLV, [classLV]) PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True) 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() # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ equipPackIndex = clientData.EquipIndex holeIndex = clientData.HoleIndex GameWorld.DebugLog("±¦Ê¯Õª³ý: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID) equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex) # »ñµÃ×°±¸Î»×°±¸ÊµÀý equipPack = curPlayer.GetItemManager().GetPack(equipPackType) curEquip = equipPack.GetAt(placeIndex) if not ItemCommon.CheckItemCanUse(curEquip): GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID) return # ÑéÖ¤±³°ü¿Õ¼ä if not ItemCommon.CheckPackHasSpace(curPlayer, stonePackType, True): return # ÑéÖ¤±¦Ê¯ stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0] if not stoneID: GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!") return ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex}) if not ipyData: return classLV = ipyData.GetClassLV() __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, 0, 0, "StonePick", True) # Ë¢ÐÂÊôÐÔ RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV) # ͬ²½¿Í»§¶Ë Sycn_StoneHoleInfo(curPlayer, [equipPackIndex]) totalStoneLV = GetTotalStoneLV(curPlayer) # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶ OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV) PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True) return def GetTotalStoneLV(curPlayer): ##±¦Ê¯×ܵȼ¶ return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV) def GetStoneCntByLV(curPlayer, stoneLV): ##Ö¸¶¨µÈ¼¶µÄ±¦Ê¯ÊýÁ¿ cnt = 0 holeIndexList = GetAllEquipPlaceHoleIndex() equipIndexList = GetAllStoneEquipIndexList() gameData = GameWorld.GetGameData() for equipIndex in equipIndexList: 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) if gemLV >= stoneLV: cnt += 1 return cnt # // 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() # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ equipPackIndex = clientData.EquipIndex holeIndex = clientData.HoleIndex #upWay = clientData.UpWay GameWorld.DebugLog("±¦Ê¯Éý¼¶: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID) equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex) # »ñµÃ×°±¸Î»×°±¸ÊµÀý equipPack = curPlayer.GetItemManager().GetPack(equipPackType) curEquip = equipPack.GetAt(placeIndex) if not ItemCommon.CheckItemCanUse(curEquip): GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID) return # Éý¼¶±¦Ê¯ID stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, 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) stoneLevel = curStoneEff.GetEffectValue(1) upgradeStoneID = curStoneEff.GetEffectValue(2) upgradeStoneLV = stoneLevel + 1 GameWorld.DebugLog("stoneEffType=%s,stoneLevel=%s,upgradeStoneID=%s,upgradeStoneLV=%s" % (stoneEffType, stoneLevel, upgradeStoneID, upgradeStoneLV)) if not upgradeStoneID: GameWorld.Log("¸Ã±¦Ê¯ÒÑÊÇ×î´ó¼¶,²»ÄÜÉý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s,upgradeStoneID=%s" % (holeIndex, stoneItemID, curEffID, upgradeStoneID), playerID) return upNeedCount = IpyGameDataPY.GetFuncCfg("GemUpCostFormula", 2) # ºÏ³ÉÏÂÒ»¼¶ËùÐ豦ʯ¸öÊý if not upNeedCount: return ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex}) if not ipyData: return classLV = ipyData.GetClassLV() extraItemInfoDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 3, {}) # ¶îÍâ²ÄÁÏ itemPack = curPlayer.GetItemManager().GetPack(stonePackType) delItemListDict = {} # ʵ¼Ê¿Û³ýÓà exItemNeedCountDict = {} # ËùÐè¶îÍâ²ÄÁÏ×ÜÊý delItemCountDict, buyItemCountDict = {}, {} # ͳ¼ÆÓà delExItemCountDict, buyExItemCountDict = {}, {} # ͳ¼ÆÓà # ÓÅÏÈÏûºÄ¸ß¼¶±¦Ê¯£¬´ÓÉý¼¶Ä¿±êµÈ¼¶¿ªÊ¼ÏòϱéÀúµ½2¼¶ tagLVStoneLackCount = 1 # ¿ÉÀí½âΪ×îÖÕÒªºÏ³É1¸öÉý¼¶Ä¿±êµÈ¼¶±¦Ê¯ for tagLevel in xrange(upgradeStoneLV, 1, -1): needStoneLV = tagLevel - 1 key = (stoneEffType, needStoneLV) if key not in PyGameData.g_stoneLevelIDDict: GameWorld.ErrLog("ÕÒ²»µ½±¦Ê¯ÀàÐ͵ȼ¶ÎïÆ·ID! stoneEffType=%s, needStoneLV=%s" % (stoneEffType, needStoneLV)) return needStoneID = PyGameData.g_stoneLevelIDDict[key] needStoneCount = tagLVStoneLackCount * upNeedCount # ÉÏÒ»¸öµÈ¼¶±¦Ê¯È±ÉÙÊý * Éý¼¶±¦Ê¯ÊýÄ¿ if needStoneID == stoneID: needStoneCount = upNeedCount - 1 # ÒÑÏâǶ±¦Ê¯×ÔÉí¿É×öΪ1¸ö²ÄÁÏ GameWorld.DebugLog(" tagLevel=%s,tagLVStoneLackCount=%s,needStoneID=%s,needStoneCount=%s" % (tagLevel, tagLVStoneLackCount, needStoneID, needStoneCount)) # ¶îÍâ²ÄÁÏͳ¼Æ£¬Ê¹ÓúϳÉÄ¿±êµÈ¼¶ËùÐèÊý¾Ý£»¶îÍâ²ÄÁÏÎÞ·¨Í¨¹ýµü´úÉý¼¶µÃµ½£¬Ö±½ÓÏÈͳ¼ÆÊýÁ¿£¬ºóÃæÔÚÑéÖ¤¿Û³ýÊý¼°²»×ãÊý extraItemInfo = extraItemInfoDict.get(str(tagLevel)) if extraItemInfo: extraItemID, extraItemCnt = extraItemInfo extraItemNeedCount = extraItemCnt * tagLVStoneLackCount exItemNeedCountDict[extraItemID] = exItemNeedCountDict.get(extraItemID, 0) + extraItemNeedCount # ¶îÍâ²ÄÁÏID¿ÉÄÜÖØ¸´£¬×öÀÛ¼Ó GameWorld.DebugLog(" ¶îÍâ²ÄÁÏ: extraItemID=%s,extraItemNeedCount=%s, %s" % (extraItemID, extraItemNeedCount, exItemNeedCountDict)) # µÈ¼¶±¦Ê¯Í³¼Æ£¬Ã¿¼¶±¦Ê¯IDÒ»¶¨²»Ò»Ñù£¬ËùÒÔ²»ÐèҪͳ¼ÆÒѾ­¼ÆÈëÐèÒª¿Û³ýµÄ hasEnough, indexList, findItemIsBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(needStoneID, itemPack, needStoneCount) delCount = needStoneCount - lackCnt GameWorld.DebugLog(" ±¦Ê¯²ÄÁÏ: needStoneID=%s,delCount=%s,lackCnt=%s" % (needStoneID, delCount, lackCnt)) if delCount > 0: delItemListDict[needStoneID] = [indexList, delCount] delItemCountDict[needStoneID] = delCount if lackCnt > 0: # ËùÐèΪ1¼¶±¦Ê¯»¹È±£¬Ö±½ÓÉ̳ǹºÂò if needStoneLV == 1: buyItemCountDict[needStoneID] = lackCnt break else: tagLVStoneLackCount = lackCnt # ¸üÐÂÏÂÒ»µÈ¼¶±¦Ê¯È±ÉÙ¸öÊý else: # »ù´¡±¦Ê¯²ÄÁϲ»È±ÁËÖ±½ÓÍ˳ö break # ¹ºÂòÏûºÄͳ¼Æ costGold = 0 for buyItemID, buyCount in buyItemCountDict.items(): unitPrice = ItemCommon.GetShopItemPrice(buyItemID, IPY_GameWorld.TYPE_Price_Gold_Money) if not unitPrice: return costGold += unitPrice * buyCount GameWorld.DebugLog(" ¹ºÂò²»×㱦ʯ: buyItemID=%s,buyCount=%s,unitPrice=%s,costGold=%s" % (buyItemID, buyCount, unitPrice, costGold)) for extraItemID, exNeedCount in exItemNeedCountDict.items(): exHasEnough, exIndexList, findItemIsBind, exLackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(extraItemID, itemPack, exNeedCount) exDelCount = exNeedCount - exLackCnt if exDelCount > 0: delItemListDict[extraItemID] = [exIndexList, exDelCount] delExItemCountDict[extraItemID] = exDelCount if exLackCnt > 0: unitPrice = ItemCommon.GetShopItemPrice(extraItemID, IPY_GameWorld.TYPE_Price_Gold_Money) if not unitPrice: return costGold += unitPrice * exLackCnt buyExItemCountDict[extraItemID] = exLackCnt GameWorld.DebugLog(" ¹ºÂò¶îÍâ²ÄÁÏ: extraItemID=%s,exNeedCount=%s,exDelCount=%s,exLackCnt=%s,unitPrice=%s,costGold=%s" % (extraItemID, exNeedCount, exDelCount, exLackCnt, unitPrice, costGold)) infoDict = {"EquipPackIndex": equipPackIndex, "HoleIndex": holeIndex, "ClassLV":classLV, "StoneItemID": stoneItemID, "CurStoneIDLV": stoneLevel, "UpgradeStoneID": upgradeStoneID, "BuyItemCountDict": buyItemCountDict, "DelItemCountDict": delItemCountDict, "BuyExItemCountDict": buyExItemCountDict, "DelExItemCountDict": delExItemCountDict, } GameWorld.DebugLog("delItemCountDict=%s,buyItemCountDict=%s" % (delItemCountDict, buyItemCountDict)) GameWorld.DebugLog("delExItemCountDict=%s,buyExItemCountDict=%s" % (delExItemCountDict, buyExItemCountDict)) if costGold and not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_EquipStone, infoDict): GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % costGold) return for delItemIndexList, delCnt in delItemListDict.values(): ItemCommon.ReduceItem(curPlayer, itemPack, delItemIndexList, delCnt, False, ChConfig.ItemDel_StoneUpgrade, infoDict) __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, upgradeStoneID, False, "StoneUpgrade", False) # Ë¢ÐÂÊôÐÔ RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV) # ͬ²½¿Í»§¶Ë Sycn_StoneHoleInfo(curPlayer, [equipPackIndex]) DoStoneSuccess(curPlayer, classLV) return def __CheckStoneHoleCanUse(curPlayer, equipStar, holeIndex, equipPackType): ##ÑéÖ¤¿×ºÏ·¨ÐÔ holeIndexList = GetAllEquipPlaceHoleIndex() if holeIndex not in holeIndexList: GameWorld.Log("ÏâǶ¿×Ë÷Òý´íÎó!holeIndex=%s, holeIndexList=%s" % (holeIndex, holeIndexList)) return False openCommHoleCnt = 0 # ÒѾ­¿ª·Å×°±¸³£¹æ¿×Êý gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1) for holeCnt, openStar in enumerate(gemOpenNeedStarList, 1): if equipStar >= openStar: openCommHoleCnt = holeCnt # VIP¿× if holeIndex >= ChConfig.Def_Stone_VipHole: if openCommHoleCnt <= 0: GameWorld.Log("×°±¸Î´¿ªÆôÈÎºÎÆÕͨ±¦Ê¯¿×£¬ÎÞ·¨¿ªÆôVIP¿×λ! equipStar=%s,openCommHoleCnt=%s" % (equipStar, 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("¸Ã×°±¸±¦Ê¯¿×Ϊ¿ª·Å£¡equipStar=%s,holeIndex=%s,openCommHoleCnt=%s" % (equipStar, holeIndex, openCommHoleCnt), curPlayer.GetPlayerID()) return False return True def __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff): ## ±ä¸üÍæ¼Ò×°±¸¿×±¦Ê¯ # »ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢ stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex) # ±£´æ×°±¸Î»¿×λÉϱ¦Ê¯IDºÍ°ó¶¨×´Ì¬ SetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind) if isPickoff and stoneID: equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex) itemCount = 1 # Õª³ýµÄ±¦Ê¯¶¼°ó¶¨ if ItemCommon.CheckPackHasSpace(curPlayer, stonePackType): ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, 0, [stonePackType], event=[ChConfig.ItemGive_StonePickoff, False, {"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex}]) else: PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], [[stoneID, 1, stoneIsBind]]) DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'equipPackIndex': equipPackIndex, "holeIndex": holeIndex, "stoneID": stoneID, 'changeStoneID': changeStoneID}) EventShell.EventRespons_StoneChange(curPlayer) return def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify, classLV): ## ±¦Ê¯Ë¢ÐÂÊôÐÔ # ×°±¸µÈ¼¶¸Ä±ä£¬ÅжÏÊÇ·ñÎªÍæ¼ÒÉíÉϵÄ×°±¸£¬Èç¹ûÊǵĻ°Ë¢ÐÂÍæ¼ÒÊôÐÔ if packType in [IPY_GameWorld.rptEquip]: # ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ if isNeedNotify: curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Stone) ChEquip.RefreshPlayerEquipAttribute(curPlayer, classLV) # Ë¢ÐÂËùÓÐÊôÐÔ playControl = PlayerControl.PlayerControl(curPlayer) playControl.RefreshPlayerAttrState() return def DoMoveEquipStone(curPlayer, equipPackIndex): ###Ìæ»»×°±¸Ê±±¦Ê¯×ªÒÆ equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex) equipPack = curPlayer.GetItemManager().GetPack(equipPackType) curEquip = equipPack.GetAt(placeIndex) if not ItemCommon.CheckItemCanUse(curEquip): return # »ñµÃ×°±¸ÐǼ¶¿×ÐÅÏ¢ gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1) maxEquipHoleCnt = len(gemOpenNeedStarList) # ×î´ó×°±¸ÐǼ¶¿ª·Å¿×Êý openEquipHoleCnt = 0 # ÒѾ­¿ª·Å¿×Êý partStar = ChEquip.GetEquipPartStarByRank(curPlayer, equipPackIndex, curEquip) for holeCnt, openStar in enumerate(gemOpenNeedStarList, 1): if partStar >= openStar: openEquipHoleCnt = holeCnt # ÐèÒª²ðж±¦Ê¯µÄ¿×Áбí pickoffHoleList = [] # ÅжÏ×°±¸½×¼¶±¦Ê¯ÊÇ·ñ²ðж for holeIndex in xrange(maxEquipHoleCnt): if holeIndex < openEquipHoleCnt: continue curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0] if curGemID == 0: continue pickoffHoleList.append([equipPackIndex, 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, equipPackIndex, holeIndex)[0] if curGemID == 0: continue pickoffHoleList.append([equipPackIndex, holeIndex]) # ÍÑ×°±¸µÄÍâ²ãË¢ÊôÐÔ, ÕâÀﲻˢ __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, "EquipChange", False) return def OnVIPTimeOut(curPlayer): ## VIPµ½ÆÚ´¦Àí # ¹ýÆÚÒ»ÑùÓÐЧ£¬ÆÁ±Î¸ÃÂß¼­ return def __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, eventName, isRefreshAttr): ## ϵͳժ³ý±¦Ê¯ if not pickoffHoleList: return GameWorld.DebugLog("ϵͳժ³ý±¦Ê¯: %s,pickoffHoleList=%s" % (eventName, pickoffHoleList), curPlayer.GetPlayerID()) equipIndexList = [] stoneCount = len(pickoffHoleList) packSpace = ItemCommon.GetItemPackSpace(curPlayer, stonePackType, 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, {'changeStoneID': 0, 'equipIndex': equipIndex, "holeIndex": holeIndex, "stoneID": stoneInfo[0]}) if equipIndex not in equipIndexList: equipIndexList.append(equipIndex) PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList) # ĿǰֻÓÐÍÑ×°±¸»á´¥·¢£¬ÔÝʱÆÁ±Î£¬ÓÉÍÑ×°±¸´¥·¢Ë¢ÊôÐÔ # if isRefreshAttr: # RefreshAttrByStoneAction(curPlayer, equipPackType, 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