| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerAssist  | 
| #  | 
| # @todo:ÐÖúϵͳ  | 
| # @author hxp  | 
| # @date 2019-12-06  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ÐÖúϵͳ  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2019-12-06 21:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import PlayerFriend  | 
| import PyDataManager  | 
| import IpyGameDataPY  | 
| import NetPackCommon  | 
| import PyGameDataStruct  | 
| import PlayerFBHelpBattle  | 
| import ChPyNetSendPack  | 
| import PlayerControl  | 
| import PlayerFamily  | 
| import ShareDefine  | 
| import PlayerTeam  | 
| import GameWorld  | 
| import ChConfig  | 
|   | 
| import uuid  | 
|   | 
| # ÐÖúÀàÐÍ  | 
| (  | 
| AssistType_Unknown,  | 
| AssistType_Boss, # boss  | 
| AssistType_TeamFB, # ×é¶Ó¸±±¾  | 
| ) = range(3)  | 
|   | 
|   | 
| def OnPlayerLogin(curPlayer, isTJ=False):  | 
|     ## Íæ¼ÒÉÏÏß  | 
|     # @param isTJ: ÊÇ·ñÍÑ»úÉÏÏß  | 
|       | 
|     SyncCanGetAssistThanksGiftCount(curPlayer)  | 
|       | 
|     familyID = curPlayer.GetFamilyID()  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if not familyID:  | 
|         return  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID in assistMgr.playerNoSaveDBAssistDict:  | 
|         playerNoSaveList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|           | 
|         # ·ÇÍÑ»úÉÏÏß  | 
|         if not isTJ:  | 
|             GameWorld.DebugLog("Íæ¼ÒÉÏÏߣ¬»Ö¸´ÐÖú·¢²¼µ½ÏÉÃËÁбí!", playerID)  | 
|             if familyID not in assistMgr.familyAssistDict:  | 
|                 assistMgr.familyAssistDict[familyID] = []  | 
|             recoverList = []  | 
|             familyAssistList = assistMgr.familyAssistDict[familyID]  | 
|             for assistObj in playerNoSaveList:  | 
|                 familyAssistList.append(assistObj)  | 
|                 recoverList.append(assistObj)  | 
|                 GameWorld.DebugLog("    »Ö¸´: %s" % assistObj.GUID)  | 
|                   | 
|             if recoverList:  | 
|                 # Í¨Öª±¾ÃËÆäËûÍæ¼Ò  | 
|                 PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack(recoverList), [playerID])  | 
|                   | 
|         # ÍÑ»úÉÏÏß  | 
|         else:  | 
|             GameWorld.DebugLog("Íæ¼ÒÍÑ»úÉÏÏߣ¬Ç¿ÖÆÈ¡Ïû·¢²¼µÄ·Ç´æ¿âÐÖú!", playerID)  | 
|             for assistObj in playerNoSaveList:  | 
|                 OnCancelPlayerRequestAssist(assistObj, "TJGLogin", True)  | 
|                   | 
|     if not isTJ:  | 
|         SyncFamilyAssist(curPlayer)  | 
|           | 
|     # Ã»ÓÐÐÖúÖеÄÐÅÏ¢  | 
|     if playerID in assistMgr.playerAssistingDict:  | 
|         assistObj = assistMgr.playerAssistingDict[playerID]  | 
|         if not isTJ:  | 
|             tagPlayerID = assistObj.PlayerID  | 
|             GameWorld.DebugLog("·ÇÍÑ»úÉÏÏߣ¬¼ÌÐøÐÖú!tagPlayerID=%s" % tagPlayerID, playerID)  | 
|               | 
|             PlayerControl.SetAssistTagPlayerID(curPlayer, tagPlayerID)  | 
|             assistPack = ChPyNetSendPack.tagGCAssistingInfo()  | 
|             assistPack.AssistGUID = assistObj.GUID  | 
|             NetPackCommon.SendFakePack(curPlayer, assistPack)  | 
|               | 
|         # ÍÑ»úÉÏÏß  | 
|         else:  | 
|             OnCancelPlayerAssist(curPlayer, playerID, assistObj, "TJGLogin", True)  | 
|               | 
|     return  | 
|   | 
| def OnLeaveServer(curPlayer):  | 
|     ## Íæ¼ÒÀëÏß  | 
|     familyID = curPlayer.GetFamilyID()  | 
|     if not familyID:  | 
|         return  | 
|       | 
|     if PlayerControl.GetAssistTagPlayerID(curPlayer):  | 
|         PlayerControl.SetAssistTagPlayerID(curPlayer, 0)  | 
|           | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if familyID not in assistMgr.familyAssistDict:  | 
|         return  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if playerID not in assistMgr.playerNoSaveDBAssistDict:  | 
|         #GameWorld.DebugLog("Íæ¼ÒûÓз¢²¼¹ýÐÖú£¬ÀëÏß²»´¦Àí!", playerID)  | 
|         return  | 
|     playerNoSaveList = assistMgr.playerNoSaveDBAssistDict[playerID]      | 
|     familyAssistList = assistMgr.familyAssistDict[familyID]  | 
|     # ÔÝÊ±ÒÆ³ýÀëÏßÍæ¼Ò·¢²¼µÄ²»´æ¿âÐÖúÐÅÏ¢£¬²»ÔÙÈÃÆäËûÃËÓѼÌÐøÇ°ÍùÐÖú£¬ÒѾÔÚÐÖúµÄ²»Ó°Ïì  | 
|     for assistObj in playerNoSaveList:  | 
|         if assistObj not in familyAssistList:  | 
|             continue  | 
|         familyAssistList.remove(assistObj)  | 
|         SyncFamilyClearAssist(familyID, assistObj.GUID)  | 
|         GameWorld.DebugLog("Íæ¼ÒÏÂÏߣ¬ÔÝʱ´ÓÏÉÃËÐÖúÁбíÒÆ³ýÍæ¼Ò·¢²¼µÄÐÖú: %s" % assistObj.GUID)  | 
|           | 
|     return  | 
|   | 
| def OnPlayerLeaveFamily(familyID, leavePlayerID, leavePlayer):  | 
|     ## Íæ¼ÒÀ뿪ÏÉÃË  | 
|     ## @param leavePlayer: ¿ÉÄܲ»ÔÚÏßΪNone  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|       | 
|     # Íæ¼Ò·¢²¼µÄ  | 
|     if leavePlayerID in assistMgr.playerNoSaveDBAssistDict:  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[leavePlayerID]  | 
|         for assistObj in playerAssistList[::-1]:  | 
|             OnCancelPlayerRequestAssist(assistObj, "LeaveFamily", True)  | 
|               | 
|     # Íæ¼ÒÐÖúÖÐµÄ  | 
|     if leavePlayerID in assistMgr.playerAssistingDict:  | 
|         assistObj = assistMgr.playerAssistingDict[leavePlayerID]  | 
|         OnCancelPlayerAssist(leavePlayer, leavePlayerID, assistObj, "LeaveFamily", True)  | 
|           | 
|     return  | 
|   | 
| def OnPlayerTeamChange(curPlayer):  | 
|     ## Íæ¼Ò¶ÓÎé±ä¸ü  | 
|       | 
|     if curPlayer.GetTeamID():  | 
|         return  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID not in assistMgr.playerNoSaveDBAssistDict:  | 
|         return  | 
|     playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|       | 
|     for assistObj in playerAssistList[::-1]:  | 
|         gameMap = GameWorld.GetMap(assistObj.MapID)  | 
|         if gameMap and gameMap.GetMapFBType() == ChConfig.fbtTeam:  | 
|             OnCancelPlayerRequestAssist(assistObj, "LeaveTeam", True)  | 
|               | 
|     return  | 
|   | 
| def OnInitAssistData(dbData, isSaveDB):  | 
|     ## ¼ÓÔØÐÖúÊý¾Ý¶îÍâ´¦Àí  | 
|     setattr(dbData, "IsSaveDB", isSaveDB) # ÊÇ·ñ±£´æÊý¾Ý¿â£¬ÀëÏß¿ÉÐÖúµÄÐèÒª´æ¿â£¬ÈçÍÚ¿óÀà  | 
|     setattr(dbData, "ObjID", 0) # NPCʵÀýID  | 
|       | 
|     assistType = AssistType_Unknown  | 
|     if dbData.NPCID:  | 
|         assistType = AssistType_Boss  | 
|     else:  | 
|         assMapID = dbData.MapID  | 
|         gameMap = GameWorld.GetMap(assMapID)  | 
|         if gameMap and gameMap.GetMapFBType() == ChConfig.fbtTeam:  | 
|             assistType = AssistType_TeamFB  | 
|     setattr(dbData, "AssistType", assistType) # ÐÖúÀàÐÍ  | 
|     setattr(dbData, "AssistPlayerIDList", []) # ÐÖúÖеÄÍæ¼ÒIDÁÐ±í  | 
|     return  | 
|   | 
| def OnInitAssistThanksData(thanksMgr, dbData):  | 
|     ## ³õʼ»¯ÐÖú¸ÐлÊý¾Ý¶îÍâ´¦Àí  | 
|     setattr(dbData, "AssistPlayerDict", {})  | 
|     if dbData.AssistPlayer and dbData.AssistPlayer.startswith("{") and dbData.AssistPlayer.endswith("}"):  | 
|         dbData.AssistPlayerDict = eval(dbData.AssistPlayer)  | 
|           | 
|     thanksMgr.allAssistThanksList.append(dbData)  | 
|     # Î´¸ÐлµÄ  | 
|     if not dbData.ThanksState:  | 
|         playerID = dbData.PlayerID  | 
|         if playerID not in thanksMgr.playerThanksDict:  | 
|             thanksMgr.playerThanksDict[playerID] = []  | 
|         playerThanksList = thanksMgr.playerThanksDict[playerID]  | 
|         playerThanksList.append(dbData)  | 
|           | 
|     for assistPlayerID, assistPlayerInfo in dbData.AssistPlayerDict.items():  | 
|         if "IsGet" in assistPlayerInfo:  | 
|             # ÒѾ½ÓÊܸÐл½±ÀøµÄ²»ÔÙ´¦Àí  | 
|             continue  | 
|           | 
|         if assistPlayerID not in thanksMgr.assistPlayerThanksDict:  | 
|             thanksMgr.assistPlayerThanksDict[assistPlayerID] = []  | 
|         assistPlayerThanksList = thanksMgr.assistPlayerThanksDict[assistPlayerID]  | 
|         assistPlayerThanksList.append(dbData)  | 
|               | 
|     return  | 
|   | 
| def OnSaveAssistThanksData(dbData):  | 
|     ## ÐÖú¸Ðл±£´æÊý¾Ý¶îÍâ´¦Àí  | 
|     dbData.AssistPlayer = str(dbData.AssistPlayerDict)  | 
|     dbData.AssistPlayerLen = len(dbData.AssistPlayer)  | 
|     return  | 
|   | 
| #// B0 12 ¿ªÊ¼ÐÖúBoss #tagCGStartAssistBoss  | 
| #  | 
| #struct    tagCGStartAssistBoss  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    char        AssistGUID[40];    //ÐÖúGUID  | 
| #};  | 
| def OnStartAssistBoss(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     assistGUID = clientData.AssistGUID  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if assistGUID not in assistMgr.allAssistDict:  | 
|         GameWorld.DebugLog("²»´æÔÚ¸ÃÐÖú!assistGUID=%s" % assistGUID)  | 
|         return  | 
|     assistObj = assistMgr.allAssistDict[assistGUID]  | 
|     if assistObj.AssistType != AssistType_Boss:  | 
|         return  | 
|     if assistObj.PlayerID == curPlayer.GetPlayerID():  | 
|         GameWorld.DebugLog("²»ÄÜÐÖú×Ô¼º!")  | 
|         return  | 
|       | 
|     if assistObj.FamilyID != curPlayer.GetFamilyID():  | 
|         GameWorld.DebugLog("·ÇͬÃËÍæ¼Ò²»ÄÜÐÖú!")  | 
|         return  | 
|       | 
|     playerMapID = curPlayer.GetMapID()  | 
|     mapID = assistObj.MapID  | 
|     lineID = assistObj.LineID  | 
|     playerMap = GameWorld.GetMap(playerMapID)  | 
|     if not playerMap:  | 
|         return  | 
|     if playerMap.GetMapFBType() != ChConfig.fbtNull:  | 
|         if mapID == ChConfig.Def_FBMapID_SealDemon:  | 
|             playerLineID = PlayerControl.GetFBFuncLineID(curPlayer)  | 
|         else:  | 
|             playerLineID = curPlayer.GetFBID()  | 
|         if playerMapID != mapID or playerLineID != lineID:  | 
|             #¸±±¾ÖÐÎÞ·¨ÐÖú  | 
|             PlayerControl.NotifyCode(curPlayer, "AssistFBLimit")  | 
|             return  | 
|           | 
|     # É趨ÐÖú±ØÐëÀ뿪¶ÓÎé  | 
|     tagMap = GameWorld.GetMap(mapID)  | 
|     if not tagMap:  | 
|         return  | 
|     if tagMap.GetMapFBType() != ChConfig.fbtTeam:  | 
|         curTeam = curPlayer.GetTeam()  | 
|         if curTeam:  | 
|             PlayerTeam.DoPlayerLeaveTeam(curPlayer, curTeam, tick)  | 
|               | 
|     SetPlayerStartAssistBoss(curPlayer, assistObj)  | 
|     return  | 
|   | 
| #// B0 13 È¡ÏûÐÖúBoss #tagCGCancelAssistBoss  | 
| #  | 
| #struct    tagCGCancelAssistBoss  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    char        AssistGUID[40];    //ÐÖúGUID  | 
| #};  | 
| def OnCancelAssistBoss(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     assistGUID = clientData.AssistGUID  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID not in assistMgr.playerAssistingDict:  | 
|         GameWorld.DebugLog("ûÓÐÔÚÐÖúÖУ¬ÎÞÐèÈ¡Ïû!", playerID)  | 
|         return  | 
|     assistObj = assistMgr.playerAssistingDict[playerID]  | 
|     if assistGUID != assistObj.GUID:  | 
|         GameWorld.DebugLog("·ÇÕýÔÚÐÖúÖеÄGUID£¬²»ÄÜÈ¡Ïû!assistGUID=%s,assisting=%s" % (assistGUID, assistObj.GUID), playerID)  | 
|         return  | 
|     OnCancelPlayerAssist(curPlayer, curPlayer.GetPlayerID(), assistObj, "ClientCancel", True)  | 
|     return  | 
|   | 
| def SetPlayerStartAssistBoss(curPlayer, assistObj):  | 
|     ## Íæ¼Ò¿ªÊ¼ÐÖú boss  | 
|       | 
|     assistGUID = assistObj.GUID  | 
|     tagPlayerID = assistObj.PlayerID  | 
|     mapID = assistObj.MapID  | 
|     lineID = assistObj.LineID  | 
|     npcID = assistObj.NPCID  | 
|     objID = assistObj.ObjID  | 
|       | 
|     tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID)  | 
|     if not tagPlayer:  | 
|         GameWorld.DebugLog("Íæ¼ÒÒÑÀëÏߣ¬ÎÞ·¨ÐÖú!tagPlayerID=%s" % (tagPlayerID))  | 
|         return  | 
|       | 
|     if tagPlayer.GetMapID() != mapID:  | 
|         GameWorld.DebugLog("Ä¿±êÍæ¼ÒÒѲ»ÔÚÇëÇóÐÖúµÄµØÍ¼£¬ÎÞ·¨ÐÖú!tagPlayerID=%s" % (tagPlayerID))  | 
|         return  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     # ÉèÖÃÐÂÐÖú֮ǰÐèÒªÏÈÈ¡ÏûÕýÔÚ½øÐÐÖеÄÐÖú  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID in assistMgr.playerAssistingDict:  | 
|         assistingObj = assistMgr.playerAssistingDict[playerID]  | 
|         if assistGUID != assistingObj.GUID:  | 
|             OnCancelPlayerAssist(curPlayer, playerID, assistingObj, "StartNewAssistBoss", True)  | 
|     assistMgr.playerAssistingDict[playerID] = assistObj  | 
|       | 
|     #if playerID in assistObj.AssistPlayerIDList:  | 
|     #    GameWorld.DebugLog("ÒѾÔÚÐÖúÖÐ!", playerID)  | 
|     #    return  | 
|     if playerID not in assistObj.AssistPlayerIDList:  | 
|         assistObj.AssistPlayerIDList.append(playerID)  | 
|           | 
|     GameWorld.DebugLog("¿ªÊ¼ÐÖú: tagPlayerID=%s,mapID=%s,lineID=%s,npcID=%s,objID=%s" % (tagPlayerID, mapID, lineID, npcID, objID), playerID)  | 
|       | 
|     # ÉèÖÃÐÖú  | 
|     PlayerControl.SetAssistTagPlayerID(curPlayer, tagPlayerID)  | 
|       | 
|     # Í¨ÖªÄ¿±êÍæ¼Ò  | 
|     assistPlayerID = curPlayer.GetPlayerID()  | 
|     assistPlayerName = curPlayer.GetName()  | 
|     # xxx¿ªÊ¼ÐÖúÄã  | 
|     PlayerControl.NotifyCode(tagPlayer, "AssistStart", [assistPlayerName])  | 
|       | 
|     tagPlayerName = tagPlayer.GetName()  | 
|     tagTeamID = tagPlayer.GetTeamID()  | 
|     isFriend = PlayerFriend.IsFriend(assistPlayerID, tagPlayerID)  | 
|     assistData = [mapID, "Start", assistGUID, assistPlayerID, assistPlayerName, isFriend, tagPlayerID, tagPlayerName, tagTeamID, lineID, objID, npcID]  | 
|     GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_AssistBoss, assistData)  | 
|     return  | 
|   | 
| def OnAddAssistBossPlayerOK(queryData):  | 
|     ## Ìí¼ÓÐÖúBossµÄÍæ¼Ò³É¹¦£¬Í¨ÖªÐÖúÍæ¼Ò¿ÉÒÔǰÍù  | 
|     assistGUID, assistPlayerID = queryData  | 
|     assistPlayer = GameWorld.GetPlayerManager().FindPlayerByID(assistPlayerID)  | 
|     if not assistPlayer:  | 
|         return  | 
|       | 
|     assistPack = ChPyNetSendPack.tagGCAssistingInfo()  | 
|     assistPack.AssistGUID = assistGUID  | 
|     NetPackCommon.SendFakePack(assistPlayer, assistPack)  | 
|     return  | 
|   | 
| def MapServer_PlayerAssistLogic(curPlayer, msgList, tick):  | 
|     ## µØÍ¼Í¬²½µÄÐÖúÐÅÏ¢Âß¼´¦Àí  | 
|       | 
|     playerID = 0 if not curPlayer else curPlayer.GetPlayerID()  | 
|     familyID = 0 if not curPlayer else curPlayer.GetFamilyID()  | 
|     queryType, queryData = msgList  | 
|     #result = []  | 
|       | 
|     GameWorld.Log("ÊÕµ½µØÍ¼ÐÖúÐÅÏ¢: familyID=%s,queryType=%s,queryData=%s" % (familyID, queryType, queryData), playerID)  | 
|       | 
|     # ÇëÇóÐÖúboss  | 
|     if queryType == "RequestAssistBoss":  | 
|         __DoRequestAssistBoss(curPlayer, queryData)  | 
|         return  | 
|       | 
|     # Ìí¼ÓÐÖúBossµÄÍæ¼Ò³É¹¦  | 
|     elif queryType == "AddAssistBossPlayerOK":  | 
|         OnAddAssistBossPlayerOK(queryData)  | 
|         return  | 
|       | 
|     # È¡ÏûbossÐÖú·¢²¼  | 
|     elif queryType == "OnCancelBossRequestAssist":  | 
|         mapID, lineID, npcID, objID, reason = queryData  | 
|         assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|         if playerID in assistMgr.playerNoSaveDBAssistDict:  | 
|             playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|             for assistObj in playerAssistList:  | 
|                 if assistObj.MapID == mapID and assistObj.LineID == lineID and assistObj.NPCID == npcID and assistObj.ObjID == objID:  | 
|                     OnCancelPlayerRequestAssist(assistObj, reason, False)  | 
|                     break  | 
|         return  | 
|       | 
|     # È¡ÏûÐÖúBoss  | 
|     elif queryType == "OnCancelBossAssist":  | 
|         mapID, lineID, npcID, objID, reason = queryData  | 
|         assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|         if playerID in assistMgr.playerAssistingDict:  | 
|             assistObj = assistMgr.playerAssistingDict[playerID]  | 
|             if assistObj.MapID == mapID and assistObj.LineID == lineID and assistObj.NPCID == npcID and assistObj.ObjID == objID:  | 
|                 OnCancelPlayerAssist(curPlayer, playerID, assistObj, reason, False)  | 
|         return  | 
|       | 
|     # bossÐÖú½áÊø  | 
|     elif queryType == "OnBossAssistOver":  | 
|         __DoBossAssistOver(queryData)  | 
|         return  | 
|       | 
|     # ¸±±¾ÐÖú½áÊø  | 
|     elif queryType == "OnFBAssistOver":  | 
|         __DoFBAssistOver(queryData)  | 
|         return  | 
|       | 
|     ## -------------------------------------------------------------------------------------------  | 
|       | 
|     # ÇëÇóÐÖú×é¶Ó¸±±¾  | 
|     elif queryType == "RequestAssistTeamFB":  | 
|         __DoRequestAssistTeamFB(curPlayer, queryData)  | 
|         return  | 
|       | 
|     # ¿ªÊ¼ÐÖú×é¶Ó¸±±¾  | 
|     elif queryType == "OnStartAssistTeamFB":  | 
|         mapID, lineID, tagPlayerID = queryData  | 
|         GameWorld.DebugLog("    ¿ªÊ¼ÐÖú¸±±¾: mapID=%s,lineID=%s,tagPlayerID=%s" % (mapID, lineID, tagPlayerID), playerID)  | 
|         # ¸±±¾ÐÖúÔÝʱֻ´¦ÀíÉèÖÃÐÖúÄ¿±êID  | 
|         PlayerControl.SetAssistTagPlayerID(curPlayer, tagPlayerID)  | 
|         return  | 
|       | 
|     # È¡ÏûÐÖú×é¶Ó¸±±¾  | 
|     elif queryType == "OnCancelAssistTeamFB":  | 
|         mapID, lineID, reason = queryData  | 
|         GameWorld.DebugLog("    ¿ªÊ¼ÐÖú¸±±¾: mapID=%s,lineID=%s,reason=%s" % (mapID, lineID, reason), playerID)  | 
|         # ¸±±¾ÐÖúÔÝʱֻ´¦ÀíÉèÖÃÐÖúÄ¿±êID  | 
|         PlayerControl.SetAssistTagPlayerID(curPlayer, 0)  | 
|         return  | 
|       | 
|     #QueryPlayerResult_PlayerAssist(curPlayer, queryType, queryData, result)  | 
|     return  | 
|   | 
| def QueryPlayerResult_PlayerAssist(curPlayer, queryType, queryData, result=[]):  | 
|     if not curPlayer:  | 
|         return  | 
|     resultMsg = str([queryType, queryData, result])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "PlayerAssist", resultMsg, len(resultMsg))  | 
|     GameWorld.DebugLog("ÐÖúÐÅÏ¢·¢ËÍ MapServer: playerID=%s,queryType=%s,queryData=%s" % (curPlayer.GetPlayerID(), queryType, queryData))  | 
|     return  | 
|   | 
| def __DoRequestAssistBoss(curPlayer, queryData):  | 
|     ## ÇëÇóÐÖúBoss  | 
|       | 
|     familyID = curPlayer.GetFamilyID()  | 
|     if not familyID:  | 
|         return  | 
|     mapID, lineID, npcID, objID, npcLV = queryData  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     reqAssistObj = None  | 
|     addNewAssist = False  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID in assistMgr.playerNoSaveDBAssistDict:  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|         for assistObj in playerAssistList:  | 
|             if assistObj.AssistType != AssistType_Boss:  | 
|                 continue  | 
|             if npcID != assistObj.NPCID or lineID != assistObj.LineID or objID != assistObj.ObjID:  | 
|                 OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistBoss", True)  | 
|             else:  | 
|                 reqAssistObj = assistObj  | 
|             break  | 
|           | 
|     if not reqAssistObj:  | 
|         addNewAssist = True  | 
|         reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID, objID)  | 
|           | 
|     if not reqAssistObj:  | 
|         return  | 
|       | 
|     # Í¨Öª±¾ÏÉÃËÍæ¼Ò  | 
|     PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))  | 
|     # ÇóÖúÐÅÏ¢ÒÑ·¢ËÍ£¬ÇëµÈ´ýÃËÓÑÖ§Ô®  | 
|     PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")  | 
|       | 
|     # ¹ã²¥ÏÉÃËÇëÇó  | 
|     requestCount = 1  | 
|     if not addNewAssist:  | 
|         requestCount = min(curPlayer.GetDictByKey("AssistBossRequestCount") + 1, 999)  | 
|     curPlayer.SetDict("AssistBossRequestCount", requestCount)  | 
|     notifyNum = (requestCount - 1) % 3  | 
|     PlayerControl.FamilyNotify(familyID, "AssistBossRequest%s" % notifyNum, [curPlayer.GetName(), mapID, npcLV, npcID])  | 
|     return  | 
|   | 
| def __DoRequestAssistTeamFB(curPlayer, queryData):  | 
|     ## ÇëÇóÐÖú×é¶Ó¸±±¾  | 
|       | 
|     familyID = curPlayer.GetFamilyID()  | 
|     if not familyID:  | 
|         return  | 
|     mapID, lineID  = queryData  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     reqAssistObj = None  | 
|     addNewAssist = False  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if playerID in assistMgr.playerNoSaveDBAssistDict:  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|         for assistObj in playerAssistList:  | 
|             if assistObj.AssistType != AssistType_TeamFB:  | 
|                 continue  | 
|             if mapID != assistObj.MapID or lineID != assistObj.LineID:  | 
|                 OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistTeamFB", True)  | 
|             else:  | 
|                 reqAssistObj = assistObj  | 
|             break  | 
|           | 
|     if not reqAssistObj:  | 
|         addNewAssist = True  | 
|         reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID)  | 
|           | 
|     if not reqAssistObj:  | 
|         return  | 
|       | 
|     # Í¨Öª±¾ÏÉÃËÍæ¼Ò  | 
|     PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))  | 
|     # ÇóÖúÐÅÏ¢ÒÑ·¢ËÍ£¬ÇëµÈ´ýÃËÓÑÖ§Ô®  | 
|     PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")  | 
|     # ¹ã²¥ÏÉÃËÇëÇó  | 
|     requestCount = 1  | 
|     if not addNewAssist:  | 
|         requestCount = min(curPlayer.GetDictByKey("AssistFBRequestCount") + 1, 999)  | 
|     curPlayer.SetDict("AssistFBRequestCount", requestCount)  | 
|     notifyNum = (requestCount - 1) % 3  | 
|     PlayerControl.FamilyNotify(familyID, "AssistFBRequest%s" % notifyNum, [curPlayer.GetName(), mapID])  | 
|     return  | 
|   | 
| def __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID=0, objID=0, exData="", isSaveDB=0):  | 
|     ## Ìí¼ÓÐÂÐÖúÇëÇó  | 
|     assistGUID = str(uuid.uuid1())  | 
|     familyID = curPlayer.GetFamilyID()  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     assistObj = PyGameDataStruct.tagDBAssist()  | 
|     assistObj.GUID = assistGUID  | 
|     assistObj.FamilyID = familyID  | 
|     assistObj.PlayerID = playerID  | 
|     assistObj.PlayerName = curPlayer.GetName()  | 
|     assistObj.Job = curPlayer.GetJob()  | 
|     assistObj.LV = curPlayer.GetLV()  | 
|     assistObj.RealmLV = curPlayer.GetOfficialRank()  | 
|     assistObj.MapID = mapID  | 
|     assistObj.LineID = lineID  | 
|     assistObj.NPCID = npcID  | 
|     assistObj.ExData = exData  | 
|     assistObj.ExDataLen = len(exData)  | 
|       | 
|     # ÒÔÏÂÊÇ·ÇDB×Ö¶ÎÊôÐÔ  | 
|     OnInitAssistData(assistObj, isSaveDB)  | 
|     assistObj.ObjID = objID  | 
|       | 
|     #assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     assistMgr.allAssistDict[assistGUID] = assistObj  | 
|     if familyID not in assistMgr.familyAssistDict:  | 
|         assistMgr.familyAssistDict[familyID] = []  | 
|     familyAssistList = assistMgr.familyAssistDict[familyID]  | 
|     familyAssistList.append(assistObj)  | 
|       | 
|     if not isSaveDB:  | 
|         if playerID not in assistMgr.playerNoSaveDBAssistDict:  | 
|             assistMgr.playerNoSaveDBAssistDict[playerID] = []  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|         playerAssistList.append(assistObj)  | 
|           | 
|     GameWorld.DebugLog("    Ôö¼ÓÐÂÐÖúÇëÇó: familyID=%s,mapID=%s,lineID=%s,npcID=%s,objID=%s,exData=%s,assistGUID=%s"   | 
|                        % (familyID, mapID, lineID, npcID, objID, exData, assistGUID), playerID)  | 
|     return assistObj  | 
|   | 
| def GetAssistInfoListPack(familyAssistList):  | 
|     ## ÐÖúÁбí·â°üÊý¾Ý  | 
|     assistList = []  | 
|     for assistObj in familyAssistList:  | 
|         assistInfo = ChPyNetSendPack.tagGCAssistInfo()  | 
|         assistInfo.AssistGUID = assistObj.GUID  | 
|         assistInfo.PlayerID = assistObj.PlayerID  | 
|         assistInfo.PlayerName = assistObj.PlayerName  | 
|         assistInfo.Job = assistObj.Job  | 
|         assistInfo.LV = assistObj.LV  | 
|         assistInfo.RealmLV = assistObj.RealmLV  | 
|         assistInfo.MapID = assistObj.MapID  | 
|         assistInfo.LineID = assistObj.LineID  | 
|         assistInfo.NPCID = assistObj.NPCID  | 
|         assistInfo.ExData = assistObj.ExData  | 
|         assistInfo.ExDataLen = len(assistObj.ExData)  | 
|         assistList.append(assistInfo)  | 
|           | 
|     infoListPack = ChPyNetSendPack.tagGCAssistInfoList()  | 
|     infoListPack.AssistInfoList = assistList  | 
|     infoListPack.Count = len(assistList)  | 
|     return infoListPack  | 
|   | 
| def OnCancelPlayerRequestAssist(assistObj, reason, isGameServer):  | 
|     '''È¡ÏûÍæ¼ÒÐÖú - ·¢²¼·½  | 
|     MapServer ´¥·¢È¡Ïû  | 
|     1. ¹¥»÷ÁËÁíÒ»Ö»boss  | 
|     2. ÖØÐ·¢²¼ÁËÁíÒ»ÌõÐÖúboss/×é¶Ó¸±±¾  | 
|     3. ½øÈëÐÖú״̬£¬¼´±¾À´ÔÚ´òͬһֻboss£¬ºóÃæÖ±½Ó¸ÄΪÐÖú  | 
|     4. Í˳öÁË·¢²¼ÐÖúµØÍ¼  | 
|       | 
|     GameServer ´¥·¢È¡Ïû  | 
|     5. ±»Ìß/Í˳öÏÉÃË  | 
|     '''  | 
|       | 
|     assistGUID = assistObj.GUID  | 
|     playerID = assistObj.PlayerID  | 
|     familyID = assistObj.FamilyID  | 
|     assistType = assistObj.AssistType  | 
|     mapID = assistObj.MapID  | 
|     lineID = assistObj.LineID  | 
|     npcID = assistObj.NPCID  | 
|     objID = assistObj.ObjID  | 
|       | 
|     GameWorld.DebugLog("È¡Ïû·¢²¼µÄÐÖúÇëÇó: mapID=%s,lineID=%s,npcID=%s,objID=%s,reason=%s,isGameServer=%s, %s"   | 
|                        % (mapID, lineID, npcID, objID, reason, isGameServer, assistGUID))  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if assistGUID not in assistMgr.allAssistDict:  | 
|         return  | 
|     assistMgr.allAssistDict.pop(assistGUID)  | 
|       | 
|     if familyID in assistMgr.familyAssistDict:  | 
|         familyAssistList = assistMgr.familyAssistDict[familyID]  | 
|         if assistObj in familyAssistList:  | 
|             familyAssistList.remove(assistObj)  | 
|               | 
|     if playerID in assistMgr.playerNoSaveDBAssistDict:  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]  | 
|         if assistObj in playerAssistList:  | 
|             playerAssistList.remove(assistObj)  | 
|               | 
|     # È¡ÏûbossÐÖú  | 
|     if assistType == AssistType_Boss:  | 
|           | 
|         # Ç¿ÖÆÈ¡ÏûÕýÔÚÐÖúÖеÄÍæ¼Ò  | 
|         playerMgr = GameWorld.GetPlayerManager()  | 
|         for assPlayerID in assistObj.AssistPlayerIDList[::-1]:  | 
|             assistObj.AssistPlayerIDList.remove(assPlayerID)  | 
|             if assPlayerID in assistMgr.playerAssistingDict:  | 
|                 assistingObj = assistMgr.playerAssistingDict[assPlayerID]  | 
|                 if assistingObj.GUID == assistGUID:  | 
|                     assPlayer = playerMgr.FindPlayerByID(assPlayerID)  | 
|                     OnCancelPlayerAssist(assPlayer, assPlayerID, assistObj, reason, isGameServer, isNotify=False)  | 
|                       | 
|         # ·¢²¼·½È¡Ïû²»ÐèҪ֪ͨµØÍ¼£¬¶ÔµØÍ¼·¢²¼Íæ¼ÒûÓÐÓ°Ï죬¿É¼ÌÐø¹¥»÷boss  | 
|           | 
|     # È¡Ïû¸±±¾ÐÖú  | 
|     elif assistType == AssistType_TeamFB:  | 
|         # Ôݲ»ÐèÒª´¦Àí  | 
|         pass  | 
|       | 
|     # ·Å×îºó      | 
|     SyncFamilyClearAssist(familyID, assistGUID)  | 
|     return  | 
|   | 
| def OnCancelPlayerAssist(cancelPlayer, cancelPlayerID, assistObj, reason, isGameServer, isNotify=True):  | 
|     '''È¡ÏûÍæ¼ÒÐÖú - ÐÖú·½  | 
|     MapServer ´¥·¢È¡Ïû  | 
|     1. ¹¥»÷ÁËÁíÒ»Ö»boss  | 
|     2. Í˳öÁ˵±Ç°ÐÖúµÄÐÖúµØÍ¼  | 
|       | 
|     GameServer ´¥·¢È¡Ïû  | 
|     3. ÖØÐÂÐÖúÁËÁíÒ»ÌõÐÖúboss/×é¶Ó¸±±¾  | 
|     4. ±»Ìß/Í˳öÏÉÃË  | 
|     5. Ö÷¶¯µãÈ¡Ïû  | 
|       | 
|         ÆäËû£¬·¢²¼·½È¡Ïû·½Ê½  | 
|     6. ·¢²¼·½È¡ÏûÁË·¢²¼µÄÐÖú  | 
|     '''  | 
|       | 
|     assistGUID = assistObj.GUID  | 
|     tagPlayerID = assistObj.PlayerID  | 
|     mapID = assistObj.MapID  | 
|     lineID = assistObj.LineID  | 
|     npcID = assistObj.NPCID  | 
|     objID = assistObj.ObjID  | 
|       | 
|     GameWorld.DebugLog("È¡ÏûÐÖú: tagPlayerID=%s,mapID=%s,lineID=%s,npcID=%s,objID=%s,reason=%s,isGameServer=%s, %s"   | 
|                        % (tagPlayerID, mapID, lineID, npcID, objID, reason, isGameServer, assistGUID), cancelPlayerID)  | 
|       | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if cancelPlayerID in assistMgr.playerAssistingDict:  | 
|         assistMgr.playerAssistingDict.pop(cancelPlayerID)  | 
|           | 
|     if cancelPlayerID in assistObj.AssistPlayerIDList:  | 
|         assistObj.AssistPlayerIDList.remove(cancelPlayerID)  | 
|           | 
|     if cancelPlayer:  | 
|         isTagPlayerReason = reason.startswith("RequestPlayerCancel_")  | 
|         PlayerControl.SetAssistTagPlayerID(cancelPlayer, 0)  | 
|         overPack = ChPyNetSendPack.tagGCAssistOver()  | 
|         overPack.IsTagPlayerReason = isTagPlayerReason  | 
|         overPack.Reason = reason[len("RequestPlayerCancel_"):] if isTagPlayerReason else reason   | 
|         overPack.ReasonLen = len(overPack.Reason)  | 
|         overPack.AssistGUID = assistGUID  | 
|         NetPackCommon.SendFakePack(cancelPlayer, overPack)  | 
|           | 
|     # È¡ÏûbossÐÖú  | 
|     if assistObj.AssistType == AssistType_Boss:  | 
|           | 
|         # GameServerÈ¡ÏûµÄÐèҪ֪ͨÐÖúbossµØÍ¼£¬É¾³ýÐÖúÍæ¼Ò¼Ç¼  | 
|         if isGameServer:  | 
|             assistData = [mapID, "Cancel", cancelPlayerID, lineID, objID, npcID]  | 
|             GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_AssistBoss, assistData)  | 
|               | 
|         if isNotify and cancelPlayer:  | 
|             tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID)  | 
|             if tagPlayer:  | 
|                 # xxxÈ¡Ïû¶ÔÄãÐÖú  | 
|                 PlayerControl.NotifyCode(tagPlayer, "AssistCancel", [cancelPlayer.GetName()])  | 
|                   | 
|     # È¡Ïû¸±±¾ÐÖú  | 
|     elif assistObj.AssistType == AssistType_TeamFB:  | 
|         pass  | 
|       | 
|     return  | 
|   | 
| def __DoBossAssistOver(queryData):  | 
|     ## bossÐÖú½áÊø£¬Ò»°ãÊÇboss±»»÷ɱ »ò ±»ÏµÍ³  | 
|     mapID, lineID, npcID, objID, noAssistPlayerIDList, assistAwardItemID, assistAwardResult = queryData  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     for noAssistPlayerID in noAssistPlayerIDList:  | 
|         if noAssistPlayerID not in assistMgr.playerNoSaveDBAssistDict:  | 
|             continue  | 
|         playerAssistList = assistMgr.playerNoSaveDBAssistDict[noAssistPlayerID]  | 
|         for assistObj in playerAssistList:  | 
|             if assistObj.MapID == mapID and assistObj.LineID == lineID and assistObj.NPCID == npcID and assistObj.ObjID == objID:  | 
|                 OnCancelPlayerRequestAssist(assistObj, "BossAssistOver", False)  | 
|                 break  | 
|                   | 
|     if not assistAwardItemID or not assistAwardResult:  | 
|         return  | 
|       | 
|     # ÐÂÔö¸ÐлÊý¾Ý  | 
|     playerMgr = GameWorld.GetPlayerManager()  | 
|     for playerID, assistPlayerDict in assistAwardResult.items():  | 
|         curPlayer = playerMgr.FindPlayerByID(playerID)  | 
|         if not curPlayer:  | 
|             continue  | 
|         AddNewAssistThanks(curPlayer, assistAwardItemID, mapID, lineID, assistPlayerDict, npcID)  | 
|           | 
|     return  | 
|   | 
| def __DoFBAssistOver(queryData):  | 
|     ## ¸±±¾ÐÖú½áÊø  | 
|     mapID, lineID, noAssistPlayerID, assistAwardItemID, assistPlayerDict = queryData  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     if noAssistPlayerID not in assistMgr.playerNoSaveDBAssistDict:  | 
|         return  | 
|     playerAssistList = assistMgr.playerNoSaveDBAssistDict[noAssistPlayerID]  | 
|     for assistObj in playerAssistList:  | 
|         if assistObj.MapID == mapID and assistObj.LineID == lineID:  | 
|             OnCancelPlayerRequestAssist(assistObj, "FBAssistOver", False)  | 
|             break  | 
|           | 
|     if not assistAwardItemID or not assistPlayerDict:  | 
|         return  | 
|       | 
|     # ÐÂÔö¸ÐлÊý¾Ý  | 
|     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(noAssistPlayerID)  | 
|     if curPlayer:  | 
|         AddNewAssistThanks(curPlayer, assistAwardItemID, mapID, lineID, assistPlayerDict)  | 
|           | 
|     return  | 
|   | 
| def AddNewAssistThanks(curPlayer, itemID, mapID, lineID, assistPlayerDict, npcID=0, exData=""):  | 
|     ## Ìí¼ÓÐÖú¸ÐлÊý¾Ý  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     newThanks = PyGameDataStruct.tagDBAssistThanks()  | 
|     newThanks.GUID = str(uuid.uuid1())  | 
|     newThanks.ItemID = itemID  | 
|     newThanks.FamilyID = curPlayer.GetFamilyID()  | 
|     newThanks.PlayerID = playerID  | 
|     newThanks.PlayerName = curPlayer.GetName()  | 
|     newThanks.Job = curPlayer.GetJob()  | 
|     newThanks.LV = curPlayer.GetLV()  | 
|     newThanks.RealmLV = curPlayer.GetOfficialRank()  | 
|     newThanks.MapID = mapID  | 
|     newThanks.LineID = lineID  | 
|     newThanks.NPCID = npcID  | 
|     newThanks.ExData = exData  | 
|     newThanks.ExDataLen = len(exData)  | 
|     newThanks.DailyDateStr = GameWorld.GetDailyDateStr()  | 
|     newThanks.TimeStr = GameWorld.GetCurrentDataTimeStr()  | 
|     newThanks.AssistPlayer = str(assistPlayerDict)  | 
|     newThanks.AssistPlayerLen = len(newThanks.AssistPlayer)  | 
|       | 
|     assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()  | 
|     OnInitAssistThanksData(assistThanksMgr, newThanks)  | 
|       | 
|     GameWorld.DebugLog("Ôö¼ÓÐÖú¸Ðл: itemID=%s,mapID=%s,lineID=%s,npcID=%s,exData=%s" % (itemID, mapID, lineID, npcID, exData), playerID)  | 
|     return  | 
|   | 
| #// B0 14 Ê¹ÓÃÐÖú¸ÐлÀñºÐ #tagCGUseAssistThanksGift  | 
| #  | 
| #struct    tagCGUseAssistThanksGift  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        ItemID;  | 
| #    BYTE        IsPreview;    //ÊÇ·ñÔ¤ÀÀ£¬·ÇÔ¤ÀÀ¼´È·ÈÏʹÓà  | 
| #};  | 
| def OnUseAssistThanksGift(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     itemID = clientData.ItemID  | 
|     isPreview = clientData.IsPreview  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()  | 
|     if playerID not in assistThanksMgr.playerThanksDict:  | 
|         GameWorld.ErrLog("Íæ¼ÒûÓпÉʹÓõÄÐÖú¸ÐлÀñºÐ!", playerID)  | 
|         return  | 
|     useThanks = None  | 
|     playerThanksList = assistThanksMgr.playerThanksDict[playerID]  | 
|     for thanks in playerThanksList:  | 
|         if itemID == thanks.ItemID:  | 
|             useThanks = thanks  | 
|             break  | 
|     if not useThanks:  | 
|         GameWorld.ErrLog("Íæ¼ÒûÓиÃÐÖú¸ÐлÀñºÐ!itemID=%s" % (itemID), playerID)  | 
|         return  | 
|       | 
|     GameWorld.DebugLog("Íæ¼ÒʹÓÃÐÖú¸ÐлÀñºÐ!itemID=%s,isPreview=%s" % (itemID, isPreview), playerID)  | 
|     # Ô¤ÀÀ  | 
|     if isPreview:  | 
|         previewPack = ChPyNetSendPack.tagGCUseAssistThanksGiftPreview()  | 
|         previewPack.ItemID = useThanks.ItemID  | 
|         previewPack.MapID = useThanks.MapID  | 
|         previewPack.LineID = useThanks.LineID  | 
|         previewPack.NPCID = useThanks.NPCID  | 
|         previewPack.ExData = useThanks.ExData  | 
|         previewPack.ExDataLen = useThanks.ExDataLen  | 
|         previewPack.AssistPlayerList = []  | 
|         for assistPlayerID, assistPlayerInfoDict in useThanks.AssistPlayerDict.items():  | 
|             if "PlayerName" not in assistPlayerInfoDict:  | 
|                 continue  | 
|             assistPlayerInfo = ChPyNetSendPack.tagGCAssistPlayerInfo()  | 
|             assistPlayerInfo.PlayerID = assistPlayerID  | 
|             assistPlayerInfo.PlayerName = assistPlayerInfoDict["PlayerName"]  | 
|             assistPlayerInfo.Job = assistPlayerInfoDict["Job"]  | 
|             assistPlayerInfo.LV = assistPlayerInfoDict["LV"]  | 
|             assistPlayerInfo.RealmLV = assistPlayerInfoDict["RealmLV"]  | 
|             previewPack.AssistPlayerList.append(assistPlayerInfo)  | 
|         previewPack.AssistPlayerCount = len(previewPack.AssistPlayerList)  | 
|         NetPackCommon.SendFakePack(curPlayer, previewPack)  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("AssistThanksGift", itemID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     useThanks.ThanksState = 1 # ÉèÖÃΪÒѸÐл  | 
|     playerThanksList.remove(useThanks) # ÒƳýÒѸÐл  | 
|     queryData = [itemID]  | 
|     QueryPlayerResult_PlayerAssist(curPlayer, "UseAssistThanksGift", queryData)  | 
|       | 
|     # Í¨ÖªÐÖúÍæ¼Ò¿É½ÓÊյĸÐл¸öÊý  | 
|     playerMgr = GameWorld.GetPlayerManager()  | 
|     for assistPlayerID in useThanks.AssistPlayerDict.keys():  | 
|         assistPlayer = playerMgr.FindPlayerByID(assistPlayerID)  | 
|         if assistPlayer:  | 
|             SyncCanGetAssistThanksGiftCount(assistPlayer)  | 
|     return  | 
|   | 
| #// B0 15 ½ÓÊÕÐÖú¸ÐлÀñÎï #tagCGGetAssistThanksGift  | 
| #  | 
| #struct    tagCGGetAssistThanksGift  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        IsPreview;    //ÊÇ·ñÔ¤ÀÀ£¬·ÇÔ¤ÀÀ¼´È·ÈÏÁìÈ¡£¬ÎÞ¶îÍâ½±ÀøÈ·ÈÏʱҲÐèÒª»Ø¸´ÁìÈ¡°ü´ú±íÒѶÁ  | 
| #};  | 
| def OnGetAssistThanksGift(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     isPreview = clientData.IsPreview  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()  | 
|     if playerID not in assistThanksMgr.assistPlayerThanksDict:  | 
|         GameWorld.ErrLog("Íæ¼ÒûÓпɽÓÊÕ¸ÐлµÄÐÖú¸ÐлÀñºÐ!", playerID)  | 
|         return  | 
|     assistPlayerThanksList = assistThanksMgr.assistPlayerThanksDict[playerID]  | 
|     getThanks = None  | 
|     for thanks in assistPlayerThanksList:  | 
|         if thanks.ThanksState:  | 
|             getThanks = thanks  | 
|             break  | 
|     if not getThanks:  | 
|         GameWorld.ErrLog("ÕÒ²»µ½Íæ¼Ò¿É½ÓÊÕ¸ÐлµÄÐÖú¸ÐлÀñºÐ!", playerID)  | 
|         return  | 
|     itemID = getThanks.ItemID  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("AssistThanksGift", itemID)  | 
|     if not ipyData:  | 
|         return  | 
|     if playerID not in getThanks.AssistPlayerDict:  | 
|         return  | 
|     assistPlayerInfoDict = getThanks.AssistPlayerDict[playerID]  | 
|     todayGiftCount = assistPlayerInfoDict.get("TodayGiftCount", 0) # ¸ÃÀñºÐµ±ÈÕÒÑÁìÈ¡¶îÍâ½±Àø´ÎÊý  | 
|     isExtraAward = 1 if todayGiftCount < ipyData.GetAssistAwardCount() else 0  | 
|       | 
|     GameWorld.DebugLog("½ÓÊÕÐÖú¸ÐлÀñÎï: itemID=%s,isPreview=%s,isExtraAward=%s,DailyDateStr=%s"   | 
|                        % (itemID, isPreview, isExtraAward, getThanks.DailyDateStr), playerID)  | 
|       | 
|     # Ô¤ÀÀ  | 
|     if isPreview:  | 
|         previewPack = ChPyNetSendPack.tagGCGetAssistThanksGiftPreview()  | 
|         previewPack.ItemID = getThanks.ItemID  | 
|         previewPack.PlayerID = getThanks.PlayerID  | 
|         previewPack.PlayerName = getThanks.PlayerName  | 
|         previewPack.Job = getThanks.Job  | 
|         previewPack.LV = getThanks.LV  | 
|         previewPack.RealmLV = getThanks.RealmLV  | 
|         previewPack.MapID = getThanks.MapID  | 
|         previewPack.LineID = getThanks.LineID  | 
|         previewPack.NPCID = getThanks.NPCID  | 
|         previewPack.ExData = getThanks.ExData  | 
|         previewPack.ExDataLen = len(getThanks.ExData)  | 
|         previewPack.TimeStr = getThanks.TimeStr  | 
|         previewPack.ExtraAward = isExtraAward  | 
|         NetPackCommon.SendFakePack(curPlayer, previewPack)  | 
|         return  | 
|           | 
|     assistPlayerInfoDict["IsGet"] = 1  | 
|     isAllGet = True  | 
|     for playerDict in getThanks.AssistPlayerDict.values():  | 
|         if "IsGet" not in playerDict:  | 
|             isAllGet = False  | 
|             break  | 
|           | 
|     # ËùÓÐÈ˶¼½ÓÊÕ¸ÐлÁË£¬É¾³ý¸ÃÐÖú¸ÐлÊý¾Ý  | 
|     if isAllGet:  | 
|         GameWorld.DebugLog("    ËùÓÐÈ˶¼¸ÐлÁË£¬ÒƳý¸ÃÐÖú¸Ðл!", playerID)  | 
|         if getThanks in assistThanksMgr.allAssistThanksList:  | 
|             assistThanksMgr.allAssistThanksList.remove(getThanks)  | 
|               | 
|     assistPlayerThanksList.remove(getThanks) # ÒƳý  | 
|       | 
|     updateTodayGiftCount = todayGiftCount + 1  | 
|     # ¸üе±Ìì¸ÃÀñºÐIDÒÑÁìÈ¡´ÎÊý  | 
|     for thanks in assistPlayerThanksList:  | 
|         if getThanks.DailyDateStr != thanks.DailyDateStr or getThanks.ItemID != thanks.ItemID:  | 
|             continue  | 
|         if playerID not in thanks.AssistPlayerDict:  | 
|             continue  | 
|         assistPlayerInfoDict = thanks.AssistPlayerDict[playerID]  | 
|         assistPlayerInfoDict["TodayGiftCount"] = updateTodayGiftCount  | 
|           | 
|     SyncCanGetAssistThanksGiftCount(curPlayer, True)  | 
|       | 
|     isCurDailyDate = getThanks.DailyDateStr == GameWorld.GetDailyDateStr()  | 
|       | 
|     # Èç¹ûÊǾµÏñÐÖúµÄ£¬¸üнñÈÕ½ÓÊÕ¸ÐлÀñºÐ´ÎÊý  | 
|     if isCurDailyDate:  | 
|         if IpyGameDataPY.GetIpyGameDataNotLog("FBHelpBattle", getThanks.MapID, getThanks.LineID):  | 
|             PlayerFBHelpBattle.UpdateGetThanksGiftCountDict(curPlayer, itemID, updateTodayGiftCount)  | 
|               | 
|     # Í¨ÖªµØÍ¼  | 
|     queryData = [itemID, isExtraAward, isCurDailyDate, updateTodayGiftCount]  | 
|     QueryPlayerResult_PlayerAssist(curPlayer, "GetAssistThanksGift", queryData)  | 
|     return  | 
|   | 
| def SyncCanGetAssistThanksGiftCount(curPlayer, isForce=False):  | 
|     ## Í¨Öª¿É½ÓÊÕÐÖú¸ÐлÀñÎï¸öÊý  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     assistThanksMgr = PyDataManager.GetPlayerAssistThanksPyManager()  | 
|     if playerID not in assistThanksMgr.assistPlayerThanksDict:  | 
|         return  | 
|     assistPlayerThanksList = assistThanksMgr.assistPlayerThanksDict[playerID]  | 
|     canGetCount = 0  | 
|     for thanks in assistPlayerThanksList:  | 
|         if thanks.ThanksState:  | 
|             canGetCount += 1  | 
|               | 
|     if not canGetCount and not isForce:  | 
|         return  | 
|       | 
|     countPack = ChPyNetSendPack.tagGCCanGetAssistThanksGiftCount()  | 
|     countPack.CanGetCount = canGetCount  | 
|     NetPackCommon.SendFakePack(curPlayer, countPack)  | 
|     return  | 
|       | 
| def SyncFamilyAssist(curPlayer):  | 
|     ## Í¬²½µ±Ç°ÏÉÃËËùÓÐÐÖúÇëÇóÐÅÏ¢  | 
|     familyID = curPlayer.GetFamilyID()  | 
|     if not familyID:  | 
|         return  | 
|     assistMgr = PyDataManager.GetPlayerAssistPyManager()  | 
|     familyAssistList = assistMgr.familyAssistDict.get(familyID, [])  | 
|     if not familyAssistList:  | 
|         return  | 
|     NetPackCommon.SendFakePack(curPlayer, GetAssistInfoListPack(familyAssistList))  | 
|     return  | 
|   | 
| def SyncFamilyClearAssist(familyID, assistGUID):  | 
|     # ·â°ü֪ͨÏÉÃËÇå³ýÐÖú  | 
|     clearPack = ChPyNetSendPack.tagGCClearAssist()  | 
|     clearPack.AssistGUID = assistGUID  | 
|     PlayerFamily.SendFamilyFakePack(familyID, clearPack)  | 
|     return  | 
|   |