| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerGatherSoul  | 
| #  | 
| # @todo:Íæ¼Ò¾Û»ê  | 
| # @author xdh  | 
| # @date 2018-12-10  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Íæ¼Ò¾Û»ê  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2018-12-10 12:00"""  | 
| #---------------------------------------------------------------------  | 
|   | 
| import GameWorld  | 
| import ShareDefine  | 
| import ChConfig  | 
| import ItemCommon  | 
| import ItemControler  | 
| import PlayerControl  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import IpyGameDataPY  | 
| import FormulaControl  | 
| import DataRecordPack  | 
| import PlayerSuccess  | 
|   | 
| g_GatherSoulLVExpDict = {}  #¾Ñ黺´æ  | 
| g_gatherSoulLVAttrDict = {}  #ÊôÐÔ»º´æ  | 
|   | 
|   | 
| ##µÇ¼´¦Àí  | 
| # @param curPlayer Íæ¼Ò  | 
| # @return None  | 
| def PlayerLogin(curPlayer):  | 
|     Sync_GatherSoulHoleInfo(curPlayer)  | 
|     return   | 
|   | 
|   | 
| ## »ñÈ¡¾Û»êipyÊý¾Ý  | 
| def GetGatherSoulIpyData(itemID):return IpyGameDataPY.GetIpyGameData("GatherSoul", itemID)  | 
|   | 
|   | 
| ## »ñÈ¡¾Û»êÉý¼¶ÐèÒª¾Ñé  | 
| def GetGatherSoulNeedExp(itemID, lv):  | 
|     global g_GatherSoulLVExpDict  | 
|     #£¨£¨Éý¼¶¾Ñé * Æ·ÖÊϵÊý£©* Éñ»êϵÊý£©*  ¶àÊôÐÔϵÊý  | 
|   | 
|     itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     if not itemData:  | 
|         return 0  | 
|     ipyData = GetGatherSoulIpyData(itemID)  | 
|     if not ipyData:  | 
|         return 0  | 
|     itemColor = itemData.GetItemColor()  | 
|     if lv == 0:  #³õʼ¾Ñé  | 
|         expDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 4, {})  | 
|         exp = expDict.get(itemColor, 0)  | 
|     else:  | 
|         if lv in g_GatherSoulLVExpDict:  | 
|             exp = g_GatherSoulLVExpDict[lv]  | 
|         else:  | 
|             level = lv + 1  #¹«Ê½´Ó1¿ªÊ¼  | 
|             exp = eval(IpyGameDataPY.GetFuncCompileCfg('GatherSoulLevelUp'))  | 
|             g_GatherSoulLVExpDict[lv] = exp  | 
|               | 
|         qualityPerDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 2, {}).get(str(itemData.GetType()), {})  | 
|         if str(itemColor) in qualityPerDict:  | 
|             exp *= float(qualityPerDict[str(itemColor)])  | 
|               | 
|         attrTypeCnt = len(ipyData.GetAttrType())  | 
|         specialPer = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 3, {}).get(attrTypeCnt, 1)  | 
|         exp *= float(specialPer)  | 
|           | 
|     soulGrade = ipyData.GetSoulGrade()  | 
|     exp *= float(IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 5, {}).get(soulGrade, 1))  | 
|     return int(exp)  | 
|   | 
|   | 
| ## »ñÈ¡¾Û»êÊôÐÔÊýÖµ  | 
| def GetGatherSoulAttrValue(itemID, lv):  | 
|     global g_gatherSoulLVAttrDict  | 
|     #£¨£¨³õʼÊôÐÔ + Éý¼¶ÊôÐÔ * Æ·ÖÊϵÊý£©* Éñ»êϵÊý £© * ¶àÊôÐÔϵÊý  | 
|   | 
|     itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     if not itemData:  | 
|         return {}  | 
|     ipyData = GetGatherSoulIpyData(itemID)  | 
|     if not ipyData:  | 
|         return {}  | 
|     level = lv + 1  #¹«Ê½´Ó1¿ªÊ¼  | 
|       | 
|     attrTypeList = ipyData.GetAttrType()  | 
|     attrTypeCnt = len(attrTypeList)  #ÊôÐÔÌõÊý  | 
|     soulGrade = ipyData.GetSoulGrade()  | 
|     itemColor = itemData.GetItemColor()  | 
|     attrDict = {}  | 
|     for attrType in attrTypeList:  | 
|         attrIpyData = IpyGameDataPY.GetIpyGameData('GatherSoulAttr', attrType)  | 
|         if not attrIpyData:  | 
|             GameWorld.ErrLog('    ¾Û»êÊôÐÔ±íδÅäÖøÃÊôÐÔ attrType=%s' % attrType)  | 
|             continue  | 
|         key = '%s_%s' % (attrType, level)  | 
|         if key in g_gatherSoulLVAttrDict:  | 
|             value = g_gatherSoulLVAttrDict[key]  | 
|         else:  | 
|             attrFormula = FormulaControl.GetCompileFormula('GatherSoulAttr%s' % attrType, attrIpyData.GetAttrInfo1())  | 
|             if not attrFormula:  | 
|                 continue  | 
|             value = eval(attrFormula)  | 
|             g_gatherSoulLVAttrDict[key] = value  | 
|         qualityPerDict = attrIpyData.GetAttrInfo2()  | 
|         if itemColor in qualityPerDict:  | 
|             value *= float(qualityPerDict[itemColor])  | 
|         extraValueDict = attrIpyData.GetAttrInfo4()  | 
|         value += extraValueDict.get(itemColor, 0)  | 
|         #½×¶ÎϵÊý  | 
|         value *= float(attrIpyData.GetAttrInfo5().get(soulGrade, 1))  | 
|         #ÊôÐÔÌõĿϵÊý  | 
|         specialPer = attrIpyData.GetAttrInfo3().get(attrTypeCnt, 1)  | 
|         value *= float(specialPer)  | 
|               | 
|         attrDict[int(attrType)] = int(value)  | 
|     return attrDict  | 
|   | 
|   | 
| def GetGatherSoulMaxLV(itemID):  | 
|     # »ñÈ¡¾Û»ê×î´óµÈ¼¶  | 
|     itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|     if not itemData:  | 
|         return 0  | 
|     GatherSoulMaxLVDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulMaxLevel', 1, {})  | 
|     itemColor = itemData.GetItemColor()  | 
|     GatherSoulMaxLV = GatherSoulMaxLVDict.get(itemColor, 0)  | 
|     return GatherSoulMaxLV  | 
|   | 
|   | 
| def SwitchGatherSoul(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex):  | 
|     # ÏâǶ/ÕªÏÂ¾Û»ê  | 
|     if not ((desBackPack == ShareDefine.rptGatherSoul and srcBackpack == ShareDefine.rptTempSwap) \  | 
|             or (srcBackpack == ShareDefine.rptGatherSoul and desBackPack == ShareDefine.rptTempSwap)):  | 
|         return False  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})  | 
|     maxGatherSoulHole = len(GatherSoulUnlockDict)  | 
|     # ´©  | 
|     if desBackPack == ShareDefine.rptTempSwap:  | 
|         desGatherSoulNum = destIndex  | 
|         if desGatherSoulNum < 0 or desGatherSoulNum >= maxGatherSoulHole:  | 
|             GameWorld.DebugLog("²»´æÔڸþۻê¿×! desGatherSoulNum=%s" % desGatherSoulNum, playerID)  | 
|             return True  | 
|           | 
|         if curPlayer.GetLV() < GatherSoulUnlockDict.get(desGatherSoulNum, 0):  | 
|             GameWorld.DebugLog("¸Ã¾Û»ê¿×δ½âËø! desGatherSoulNum=%s,needlv=%s" % (desGatherSoulNum, GatherSoulUnlockDict.get(desGatherSoulNum, 0)), playerID)  | 
|             return True  | 
|           | 
|         srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem   | 
|                                                      % (ShareDefine.rptGatherSoul, srcIndex))  # ¾Û»ê±³°üÖеÄÖµ  | 
|         if not srcGatherSoulData:  | 
|             GameWorld.DebugLog("¾Û»ê±³°ü¸ÃλÖÃûÓоۻê! srcIndex=%s" % srcIndex, playerID)  | 
|             return True  | 
|         srcGatherSoulItemID = ItemControler.GetGatherSoulItemID(srcGatherSoulData)  | 
|         srcItemData = GameWorld.GetGameData().GetItemByTypeID(srcGatherSoulItemID)  | 
|         if not srcItemData:  | 
|             return  | 
|         srcGatherSoulType = srcItemData.GetType()  | 
|         needItemType = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 2, {}).get(desGatherSoulNum, 0)  | 
|         if srcGatherSoulType != needItemType:  | 
|             GameWorld.DebugLog("¸Ã¾Û»ê¿×²»ÄÜÏâǶ¸Ã¾Û»êÀàÐÍ! desGatherSoulNum=%s£¬srcGatherSoulType=%s,needItemType=%s" % (desGatherSoulNum, srcGatherSoulType, needItemType), playerID)  | 
|             return  | 
|           | 
|         srcIpyData = GetGatherSoulIpyData(srcGatherSoulItemID)  | 
|         if not srcIpyData:  | 
|             GameWorld.Log("¸Ã¾Û»êûÓÐÅäÖÃÊôÐÔ! ÎÞ·¨ÏâǶ! itemID=%s" % srcGatherSoulItemID, playerID)  | 
|             return True  | 
|           | 
|         srcGatherSoulAttrTypeList = srcIpyData.GetAttrType()  | 
|         # ÅжÏÊÇ·ñÒÑÓÐÏâǶ¸ÃÊôÐÔÀàÐÍ  | 
|         for GatherSoulNum in xrange(maxGatherSoulHole):  | 
|             if GatherSoulNum == desGatherSoulNum:  # Ä¿±ê¿×²»ÅÐ¶Ï  | 
|                 continue  | 
|             GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % GatherSoulNum, 0)  | 
|             if not GatherSoulData:  | 
|                 continue  | 
|             GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|             ipyData = GetGatherSoulIpyData(GatherSoulItemID)  | 
|             if not ipyData:  | 
|                 continue  | 
|             attrTypeList = ipyData.GetAttrType()  | 
|             if set(srcGatherSoulAttrTypeList) & set(attrTypeList):  | 
|                 GameWorld.DebugLog("ÒÑÓÐÏâǶ¸ÃÊôÐÔÀàÐÍ! ÎÞ·¨ÏâǶ! GatherSoulHoleNum=%s,attrTypeList=%s,srcGatherSoulAttrTypeList=%s" % (GatherSoulNum, attrTypeList, srcGatherSoulAttrTypeList), playerID)  | 
|                 return True  | 
|          | 
|         desGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % desGatherSoulNum, 0)  # ¿×ÉϵÄÖµ  | 
|           | 
|         # ÉèÖþۻê¿×Êý¾Ý  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % desGatherSoulNum, srcGatherSoulData)  | 
|         # ÔÀ´µÄ¿×Êý¾Ý£¬Ôò·ÅÈë¾Û»ê±³°üÖÐ  | 
|         ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, srcIndex, desGatherSoulData)  | 
|   | 
|     else:  #ÍÑ  | 
|         srcGatherSoulNum = srcIndex  | 
|         srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % srcGatherSoulNum, 0)  | 
|         if not srcGatherSoulData:  | 
|             GameWorld.DebugLog("¸Ã¾Û»ê¿×ûÓÐÏâǶ¾Û»ê! srcGatherSoulNum=%s, srcGatherSoulData=%s" % (srcGatherSoulNum, srcGatherSoulData), curPlayer.GetPlayerID())  | 
|             return True  | 
|           | 
|         emptyIndex = ItemCommon.GetEmptyIndexInPack(curPlayer, ShareDefine.rptGatherSoul)  | 
|         if emptyIndex == -1:  | 
|             GameWorld.DebugLog("¾Û»ê±³°üÒÑÂú£¬ÎÞ·¨ÕªÏÂ! ", curPlayer.GetPlayerID())  | 
|             return True  | 
|         desGatherSoulData = 0  | 
|         # ÕªÏÂÉèÖÿ×Êý¾ÝΪ0  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % srcGatherSoulNum, 0)  | 
|         ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, emptyIndex, srcGatherSoulData)  | 
|     dataDict = {'desBackPack':desBackPack, 'srcGatherSoulData':srcGatherSoulData, 'desGatherSoulData':desGatherSoulData}  | 
|     DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_GatherSoul, dataDict)  | 
|     RefreshGatherSoulAttr(curPlayer)  | 
|     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|     Sync_GatherSoulHoleInfo(curPlayer)  | 
|     DoGatherSoulSuccessLogic(curPlayer)  | 
|     return True  | 
|   | 
|   | 
| #// A5 18 ¾Û»êÉý¼¶ #tagCMGatherSoulUp  | 
| #struct    tagCMGatherSoulUp  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        PlaceType;    // Î»ÖÃÀàÐÍ£»0-±³°ü£¬1-¿×  | 
| #    WORD        PlaceIndex;    // Î»ÖÃË÷Òý  | 
| #};  | 
| def OnGatherSoulUp(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     placeType = clientData.PlaceType  | 
|     placeIndex = clientData.PlaceIndex  | 
|     if placeType == 0:  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (ShareDefine.rptGatherSoul, placeIndex))  | 
|     elif placeType == 1:  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % (placeIndex), 0)  | 
|     else:  | 
|         return  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if not GatherSoulData:  | 
|         GameWorld.DebugLog("¸ÃλÖò»´æÔÚ¾Û»ê, ÎÞ·¨Éý¼¶! placeType=%s,placeIndex=%s" % (placeType, placeIndex), playerID)  | 
|         return  | 
|       | 
|     GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|     GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)  | 
|   | 
|     itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)  | 
|     if not itemData:  | 
|         return  | 
|       | 
|     GatherSoulMaxLV = GetGatherSoulMaxLV(GatherSoulItemID)  | 
|     if GatherSoulItemPlusLV + 1 >= GatherSoulMaxLV:  | 
|         GameWorld.DebugLog('¸Ã¾Û»êÒÑÂú¼¶£¬ÎÞ·¨Éý¼¶£¡GatherSoulMaxLV=%s' % GatherSoulMaxLV)  | 
|         return  | 
|       | 
|     plusCost = GetGatherSoulNeedExp(GatherSoulItemID, GatherSoulItemPlusLV + 1)  | 
|     plusCost = int(plusCost)  | 
|     if not plusCost:  | 
|         GameWorld.DebugLog("¸Ã¾Û»êÎÞ·¨Éý¼¶!  placeType=%s,placeIndex=%s,itemID=%s,plusLV=%s"   | 
|                            % (placeType, placeIndex, GatherSoulItemID, GatherSoulItemPlusLV), playerID)  | 
|         return  | 
|   | 
|     updGatherSoulData = ItemControler.GetGatherSoulItemKeyData(GatherSoulItemID, GatherSoulItemPlusLV + 1)  | 
|     if not PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, plusCost):  | 
|         curGatherSoulMoney = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust)  | 
|         GameWorld.DebugLog("¾Û»ê³¾µã²»×㣬ÎÞ·¨Éý¼¶!placeType=%s,placeIndex=%s,itemID=%s,plusLV=%s,plusCost=%s,curGatherSoulMoney=%s"   | 
|                            % (placeType, placeIndex, GatherSoulItemID, GatherSoulItemPlusLV, plusCost, curGatherSoulMoney), playerID)  | 
|         return  | 
|       | 
|     if placeType == 0:  | 
|         ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, placeIndex, updGatherSoulData)  | 
|     elif placeType == 1:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % (placeIndex), updGatherSoulData)  | 
|         RefreshGatherSoulAttr(curPlayer)  | 
|         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|         Sync_GatherSoulHoleInfo(curPlayer)  | 
|         DoGatherSoulSuccessLogic(curPlayer)  | 
|     GameWorld.DebugLog("¾Û»êÉý¼¶!placeType=%s,placeIndex=%s,GatherSoulData=%s,updGatherSoulData=%s"   | 
|                        % (placeType, placeIndex, GatherSoulData, updGatherSoulData), playerID)  | 
|     return  | 
|   | 
|   | 
| #// A5 19 ¾Û»ê·Ö½â #tagCMGatherSoulDecompose  | 
| #  | 
| #struct    tagCMGatherSoulDecompose  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        IsAuto;    // ÊÇ·ñ×Ô¶¯·Ö½â  | 
| #    BYTE        Count;    // Ö¸¶¨ÅúÁ¿·Ö½âÊý£¬×î´ó²»³¬¹ý50¸ö  | 
| #    WORD        PlaceIndexList[Count];    // ÅúÁ¿·Ö½âλÖÃË÷ÒýÁÐ±í  | 
| #};  | 
| def OnGatherSoulDecompose(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     isAuto = clientData.IsAuto  | 
|     placeList = clientData.PlaceIndexList  | 
|       | 
|     delPlaceDict = {}  | 
|     totalSoulDust = 0  | 
|     totalSoulSplinters = 0  | 
|     totalSoulCore = 0  | 
|     giveMaterialDict = {}  | 
|     needPackSpace = 0  | 
|     packIndex = ShareDefine.rptGatherSoul  | 
|       | 
|     for place in placeList:  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))  | 
|         if not GatherSoulData:  | 
|             continue  | 
|           | 
|         GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|         GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)  | 
|         itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)  | 
|         if not itemData:  | 
|             continue  | 
|         soulidList, soulSplinters, soulCore, soulDust = [], 0, 0, 0  | 
|         if itemData.GetType() == ChConfig.Def_ItemType_GatherSoulExp:  #¾«»ªÎïÆ·¶ÁЧ¹ûÖµ  | 
|             curEff = itemData.GetEffectByIndex(0)  | 
|             soulDust = curEff.GetEffectValue(0)  | 
|         else:  | 
|             #ÏȼÆËãÉý¼¶ÏûºÄµÄ²ÄÁÏ  | 
|             soulDust = 0  | 
|             for lv in xrange(1, GatherSoulItemPlusLV + 1):  | 
|                 soulDust += GetGatherSoulNeedExp(GatherSoulItemID, lv)  | 
|                       | 
|             #¶àÊôÐÔµÄÏȲð½â³Éµ¥ÊôÐÔµÄ¾Û»ê  | 
|             soulidList, soulSplinters, soulCore = __GetGatherSoulSplitMaterial(GatherSoulItemID)  | 
|             for itemID in soulidList:  | 
|                 giveMaterialDict[itemID] = giveMaterialDict.get(itemID, 0) + 1  | 
|                 needPackSpace += 1  | 
|             if not soulidList and not soulSplinters and not soulCore:  | 
|                 #²»Äܲð½âµÄÔòÒªËã0¼¶µÄ·Ö½â  | 
|                 soulDust += GetGatherSoulNeedExp(GatherSoulItemID, 0)  | 
|                   | 
|   | 
|         totalSoulSplinters += soulSplinters  | 
|         totalSoulCore += soulCore  | 
|         totalSoulDust += soulDust  | 
|         delPlaceDict[place] = [GatherSoulData, soulidList, int(soulDust), soulSplinters, soulCore]  | 
|           | 
|     if not delPlaceDict:  | 
|         return  | 
|     if delPlaceDict:  | 
|         ItemCommon.DelVPackItem(curPlayer, packIndex, delPlaceDict.keys(), ChConfig.ItemDel_GatherSoul)  | 
|     addDataDict = {"delPlaceDict":delPlaceDict, "isAuto":isAuto}  | 
|     if totalSoulDust:  | 
|         totalSoulDust = int(totalSoulDust)  | 
|         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, totalSoulDust,  | 
|                                 ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)  | 
|         PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulDust, ShareDefine.TYPE_Price_SoulDust])  | 
|     if totalSoulSplinters:  | 
|         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulSplinters, totalSoulSplinters,  | 
|                                 ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)  | 
|         PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulSplinters, ShareDefine.TYPE_Price_SoulSplinters])  | 
|     if totalSoulCore:  | 
|         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulCore, totalSoulCore,  | 
|                                 ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)  | 
|         PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulCore, ShareDefine.TYPE_Price_SoulCore])  | 
|           | 
|     if giveMaterialDict:  | 
|         emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptGatherSoul, needPackSpace)  | 
|         if emptySpace < needPackSpace:  | 
|             giveMaterialList = [[itemID, itemCnt, 0] for itemID, itemCnt in giveMaterialDict.items()]  | 
|             PlayerControl.SendMailByKey('JHBagFull1', [curPlayer.GetID()], giveMaterialList)  | 
|         else:  | 
|             for itemID, itemCnt in giveMaterialDict.items():  | 
|                 ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [ShareDefine.rptGatherSoul])  | 
|     GameWorld.DebugLog("¾Û»ê·Ö½â: isAuto=%s,PlaceIndexList=%s, delPlaceDict=%s, giveMaterialDict=%s" % (isAuto, placeList, delPlaceDict, giveMaterialDict))  | 
|     if not isAuto:  | 
|         curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitGatherSoulDecompose, 1)  | 
|     return  | 
|   | 
|   | 
| def __GetGatherSoulSplitMaterial(gathersoulID):  | 
|     ##²ð½â¶àÊôÐԾۻ꠷µ»Øµ¥ÊôÐÔ¾Û»êID,²ÄÁÏ  | 
|     soulidList, soulSplinters, soulCore= [], 0, 0  | 
|     compoundIpyData = IpyGameDataPY.GetIpyGameDataNotLog('GatherSoulCompound', gathersoulID)  | 
|     if compoundIpyData:  | 
|         materialList = compoundIpyData.GetNeedItem()  | 
|         soulSplinters += compoundIpyData.GetNeedSoulSplinters()  | 
|         soulCore += compoundIpyData.GetNeedSoulCore()  | 
|         for itemID in materialList:  | 
| #            soulIpyData = GetGatherSoulIpyData(itemID)  | 
| #            if soulIpyData and len(soulIpyData.GetAttrType()) > 1:  | 
| #                __GetGatherSoulSplitMaterial(itemID, soulidList, soulSplinters, soulCore)  | 
| #            else:  | 
|             soulidList.append(itemID)  | 
|     return soulidList, soulSplinters, soulCore  | 
|   | 
|   | 
| #// A5 1C ¾Û»êºÏ³É #tagCMGatherSoulCompound  | 
| #  | 
| #struct    tagCMGatherSoulCompound  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        Cnt;  | 
| #    BYTE        PackList[Cnt];    //ËùÔÚλÖà0-±³°ü 1-¿×  | 
| #    WORD        IndexList[Cnt];    //ÎïÆ·Ë÷Òý  | 
| #    DWORD        TagItemID;    //ºÏ³ÉÄ¿±êÎïÆ·ID  | 
| #};  | 
| def OnGatherSoulCompound(index, clientData, tick):  | 
|     ##¾Û»êºÏ³É  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     tagItemID = clientData.TagItemID  | 
|     packList = clientData.PackList  | 
|     indexList = clientData.IndexList  | 
|     GameWorld.DebugLog('    ¾Û»êºÏ³É tagItemID=%s' % tagItemID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('GatherSoulCompound', tagItemID)  | 
|     if not ipyData:  | 
|         return  | 
|     if curPlayer.GetLV() < ipyData.GetNeedLV():  | 
|         return  | 
|       | 
|     materialsIDList = []  | 
|     materialsLVDict = {}  | 
|     indexList1, dataList1 = [], []  #±³°üµÄ¾Û»êË÷Òý  | 
|     indexList2, dataList2 = [], []  #¿×Ë÷Òý  | 
|     for i, placeType in enumerate(packList):  | 
|         index = indexList[i]  | 
|         if placeType == 0:  | 
|             GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (ShareDefine.rptGatherSoul, index))  # ¾Û»ê±³°üÖеÄÖµ  | 
|             indexList1.append(index)  | 
|             dataList1.append(GatherSoulData)  | 
|         else:  | 
|             GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % (index), 0)  | 
|             indexList2.append(index)  | 
|             dataList2.append(GatherSoulData)  | 
|         if not GatherSoulData:  | 
|             continue  | 
|         GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|         GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)  | 
|         materialsIDList.append(GatherSoulItemID)   | 
|         materialsLVDict[GatherSoulItemID] = GatherSoulItemPlusLV  | 
|       | 
|     needItemIDList = ipyData.GetNeedItem()  | 
|     if sorted(materialsIDList) != sorted(needItemIDList):  | 
|         GameWorld.DebugLog('    ¾Û»êºÏ³É ²ÄÁϲ»¶Ô tagItemID=%s, materialsIDList=%s, needItemIDList=%s' % (tagItemID, materialsIDList, needItemIDList))  | 
|         return  | 
|       | 
|     if 0 not in packList:  | 
|         #Èç¹ûûÓб³°üµÄ²ÄÁÏÒªÅжϸñ×ÓÊý  | 
|         emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptGatherSoul, 1)  | 
|         if emptySpace < 1:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [ShareDefine.rptGatherSoul])  | 
|             GameWorld.DebugLog('    ¾Û»êºÏ³É ±³°ü¸ñ×ÓÊýÁ¿²»×ã1¸ö')  | 
|             return   | 
|           | 
|     costMoneyDict = {ShareDefine.TYPE_Price_SoulSplinters:ipyData.GetNeedSoulSplinters(),  | 
|                      ShareDefine.TYPE_Price_SoulCore:ipyData.GetNeedSoulCore(), }  | 
|     for moneyType, costMoney in costMoneyDict.items():  | 
|         if not PlayerControl.HaveMoney(curPlayer, moneyType, costMoney):  | 
|             GameWorld.DebugLog('¾Û»êºÏ³ÉÇ®²»¹» moneyType=%s, costMoney=%s'%(moneyType, costMoney))  | 
|             return  | 
|       | 
|     infoDict = {"TagItemID":tagItemID}  | 
|     for moneyType, costMoney in costMoneyDict.items():  | 
|         PlayerControl.PayMoney(curPlayer, moneyType, costMoney, ChConfig.Def_Cost_ItemProduce, infoDict)  | 
|        | 
|     totalPoint = 0  | 
|     for itemID in materialsIDList:  | 
|         decompose = 0  | 
|         GatherSoulItemPlusLV = materialsLVDict.get(itemID, 0)  | 
|         for lv in range(1, GatherSoulItemPlusLV + 1):  | 
|             decompose += GetGatherSoulNeedExp(itemID, lv)  | 
|         totalPoint += decompose  | 
|     totalPoint = int(totalPoint)  | 
|     tagItemLV = 0  | 
|   | 
|     GatherSoulMaxLV = GetGatherSoulMaxLV(tagItemID)  | 
|     for lv in xrange(1, GatherSoulMaxLV):  | 
|         needExp = GetGatherSoulNeedExp(tagItemID, lv)  | 
|         if totalPoint < needExp:  | 
|             break  | 
|         tagItemLV = lv  | 
|         totalPoint -= needExp  | 
|       | 
|     #ɾ³ý²ÄÁÏÎïÆ·  | 
|     if indexList1:  | 
|         ItemCommon.DelVPackItem(curPlayer, ShareDefine.rptGatherSoul, indexList1, ChConfig.ItemDel_GatherSoul)  | 
|     if indexList2:  | 
|         for index in indexList2:  | 
|             srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % index, 0)  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % index, 0)  | 
|             dataDict = {'doType':'GatherSoulCompound', 'srcGatherSoulData':srcGatherSoulData, 'desGatherSoulData':0}  | 
|             DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_GatherSoul, dataDict)  | 
|               | 
|         Sync_GatherSoulHoleInfo(curPlayer)  | 
|         RefreshGatherSoulAttr(curPlayer)  | 
|         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|     #·µ»¹¶àÓà»ê³¾  | 
|     totalPoint = int(totalPoint)  | 
|     if totalPoint > 0:  | 
|         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, totalPoint)  | 
|     #¸øÐÂÎïÆ·  | 
|     curItem = ItemControler.GetOutPutItemObj(tagItemID)  | 
|     curItem.SetUserAttr(ShareDefine.Def_IudetGatherSoulLV, tagItemLV)  | 
|     PlayerItemControler = ItemControler.PlayerItemControler(curPlayer)  | 
|     PlayerItemControler.PutInItem(ShareDefine.rptGatherSoul, curItem, event=[ChConfig.ItemGive_ItemCompound, False, {'indexList1':dataList1, 'indexList2':dataList2, 'soulDust':totalPoint}])  | 
|     GameWorld.DebugLog('    ¾Û»êºÏ³É ³É¹¦')  | 
|     curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitGatherSoulCompound, 1)  | 
|     return  | 
|   | 
|   | 
| def DoGatherSoulSuccessLogic(curPlayer):  | 
|     #¾Û»ê³É¾Í´¦Àí  | 
|     #Çåµô#ÏâǶXöXÆ·ÖʾۻêµÄ³É¾ÍÐÅÏ¢  | 
|     PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayGatherSoul)  | 
|     totalLV = 0  | 
|     GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})  | 
|     maxGatherSoulHole = len(GatherSoulUnlockDict)  | 
|     for holeNum in xrange(maxGatherSoulHole):  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % holeNum, 0)  | 
|         if not GatherSoulData:  | 
|             continue  | 
|         GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|         itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)  | 
|         if not itemData:  | 
|             continue  | 
| #        if itemData.GetType() == ChConfig.Def_ItemType_GatherSoulCore:  | 
| #            continue  | 
|         itemColor = itemData.GetItemColor()  | 
|         GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData) + 1 #¿Í»§¶Ë1¿ªÊ¼  | 
|         totalLV += GatherSoulItemPlusLV  | 
|         PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayGatherSoul, 1, [itemColor])  | 
|     PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GatherSoulLvUp, totalLV)  | 
|     return  | 
|   | 
| def RefreshGatherSoulAttr(curPlayer):  | 
|     allAttrList = [{} for _ in range(4)]  | 
|     GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})  | 
|     maxGatherSoulHole = len(GatherSoulUnlockDict)  | 
|     for holeNum in xrange(maxGatherSoulHole):  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % holeNum, 0)  | 
|         if not GatherSoulData:  | 
|             continue  | 
|         GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)  | 
|         GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)  | 
|           | 
|         attrDict = GetGatherSoulAttrValue(GatherSoulItemID, GatherSoulItemPlusLV)  | 
|           | 
|         if not attrDict:  | 
|             continue  | 
|         GameWorld.DebugLog('    Ë¢¾Û»êÊôÐÔ holeNum=%s, attrDict=%s' % (holeNum, attrDict))  | 
|         for attrID, attrValue in attrDict.items():  | 
|             PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)  | 
|           | 
|     # ±£´æ¼ÆËãÖµ  | 
|     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GatherSoul, allAttrList)  | 
|       | 
|     return  | 
|   | 
|   | 
| def Sync_GatherSoulHoleInfo(curPlayer):  | 
|     ##֪ͨ¾Û»ê¿×ÐÅÏ¢  | 
|     GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})  | 
|     maxGatherSoulHole = len(GatherSoulUnlockDict)  | 
|     GatherSoulInfoPack = ChPyNetSendPack.tagMCGatherSoulHoleInfo()  | 
|     GatherSoulInfoPack.Clear()  | 
|     GatherSoulInfoPack.GatherSoulDataList = []  | 
|     for GatherSoulNum in xrange(maxGatherSoulHole):  | 
|         GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % GatherSoulNum, 0)  | 
|         GatherSoulInfoPack.GatherSoulDataList.append(GatherSoulData)  | 
|     GatherSoulInfoPack.Count = len(GatherSoulInfoPack.GatherSoulDataList)  | 
|     NetPackCommon.SendFakePack(curPlayer, GatherSoulInfoPack)  | 
|     return  |