| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package PlayerFBHelpBattle  | 
| #  | 
| # @todo:¸±±¾Öúսϵͳ  | 
| # @author hxp  | 
| # @date 2018-11-24  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ¸±±¾Öúսϵͳ  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2018-11-24 22:30"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import PlayerFriend  | 
| import IpyGameDataPY  | 
| import PlayerViewCache  | 
| import IPY_GameServer  | 
| import PlayerControl  | 
| import ShareDefine  | 
| import PyGameData  | 
| import GameWorld  | 
| import ChConfig  | 
|   | 
| import random  | 
| import time  | 
|   | 
| MaxRobotID = 100 # ×î´ó»úÆ÷ÈËNPC¶¨ÒåID  | 
|   | 
| Def_RecType_CheckInPlayer = ShareDefine.Def_UniversalGameRecType_FBHelpBattleCheckInPlayer  | 
| Def_RecType_HelpRecord = ShareDefine.Def_UniversalGameRecType_FBHelpBattleRecord  | 
|   | 
| ## ÖúÕ½Íæ¼Ò¼òÒªÐÅÏ¢  | 
| class HelpBattlePlayer():  | 
|       | 
|     def __init__(self, playerID):  | 
|         self.playerID = playerID  | 
|         self.job = 0  | 
|         self.playerName = ""  | 
|         self.playerLV = 0  | 
|         self.realmLV = 0  | 
|         self.fightPower = 0  | 
|         self.familyID = 0  | 
|         self.vipLV = 0  | 
|         self.checkInCount = 0 # ÀۼƵǼǴÎÊý  | 
|         self.checkInTime = 0  | 
|         self.todayHelpCountDict = {} # ½ñÌìÒÑÖúÕ½´ÎÊý {(mapID, lineID):count, ...}, Í¨ÓôÎÊýʱlineIDĬÈÏΪ0  | 
|         self.todayXianyuanCoin = 0 # ½ñÈÕÒÑ»ñµÃÏÉÔµ±Ò  | 
|         return  | 
|   | 
| ## ÖúÕ½¼Ç¼ - Ä¿Ç°Ö»¼ÇÂ¼Î´Í¨ÖªÍæ¼ÒµÄÖúÕ½ÐÅÏ¢  | 
| class FBHelpBattleRecord():  | 
|       | 
|     def __init__(self):  | 
|         self.callPlayerID = 0 # ÕÙ»½ËûµÄÍæ¼ÒID  | 
|         self.callPlayerName = ""  | 
|         self.mapID = 0  | 
|         self.funcLineID = 0  | 
|         self.xianyuanCoinAdd = 0 # 0´ú±íµ½´ïÉÏÏÞ  | 
|         self.relation = 0 # µ±Ê±µÄ¹ØÏµ  | 
|         self.vipLV = 0 # µ±Ê±µÄVIPµÈ¼¶  | 
|         self.recordTime = 0 # ¼Ç¼µÄʱ¼ä  | 
|         return  | 
|   | 
| def OnServerStart():  | 
|     GameWorld.Log("¿ª·þ¼ÓÔØÖúÕ½Ïà¹ØÐÅÏ¢...")  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     checkInPlayerRecList = universalRecMgr.GetTypeList(Def_RecType_CheckInPlayer)  | 
|     for index in xrange(checkInPlayerRecList.Count()):  | 
|         recData = checkInPlayerRecList.At(index)  | 
|         playerID = recData.GetValue1()  | 
|         helpBattlePlayer = HelpBattlePlayer(playerID)  | 
|         helpBattlePlayer.checkInTime = recData.GetTime()  | 
|         helpBattlePlayer.fightPower = recData.GetValue2()  | 
|         helpBattlePlayer.familyID = recData.GetValue3()  | 
|         helpBattlePlayer.checkInCount = recData.GetValue4()  | 
|         value5 = recData.GetValue5()  | 
|         helpBattlePlayer.playerLV = value5 / 100000  | 
|         helpBattlePlayer.vipLV = int(str(value5)[-5:-3])  | 
|         helpBattlePlayer.realmLV = int(str(value5)[-3:-1])  | 
|         helpBattlePlayer.job = value5 % 10  | 
|         helpBattlePlayer.playerName = recData.GetStrValue1()  | 
|         helpBattlePlayer.todayXianyuanCoin = int(recData.GetStrValue2())  | 
|         helpCountDictStr = recData.GetStrValue3()  | 
|         if helpCountDictStr.startswith("{") and helpCountDictStr.endswith("}"):  | 
|             helpBattlePlayer.todayHelpCountDict = eval(helpCountDictStr)  | 
|         else:  | 
|             GameWorld.ErrLog("LoadCheckInPlayerError: helpCountDictStr=%s" % helpCountDictStr, playerID)  | 
|         PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID] = helpBattlePlayer  | 
|     GameWorld.Log("¼ÓÔØÖúÕ½µÇ¼ÇÍæ¼Ò¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))  | 
|       | 
|     helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)  | 
|     for index in xrange(helpRecordRecList.Count()):  | 
|         recData = helpRecordRecList.At(index)  | 
|         playerID = recData.GetValue1()  | 
|           | 
|         helpRecord = FBHelpBattleRecord()  | 
|         helpRecord.callPlayerID = int(recData.GetStrValue2())  | 
|         helpRecord.callPlayerName = recData.GetStrValue1()  | 
|         helpRecord.mapID = recData.GetValue2()  | 
|         helpRecord.funcLineID = recData.GetValue3()  | 
|         helpRecord.xianyuanCoinAdd = recData.GetValue4()  | 
|         helpRecord.relation = recData.GetValue5() % 10  | 
|         helpRecord.vipLV = recData.GetValue5() / 10  | 
|         helpRecord.recordTime = recData.GetTime()  | 
|           | 
|         unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(playerID, [])  | 
|         unNotifyRecordList.append(helpRecord)  | 
|         PyGameData.g_fbHelpBattleRecord[playerID] = unNotifyRecordList  | 
|           | 
|     GameWorld.Log("¼ÓÔØÍæ¼Òδͬ²½ÖúÕ½: %s" % len(PyGameData.g_fbHelpBattleRecord))  | 
|     for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():  | 
|         GameWorld.Log("¼ÓÔØÍæ¼Òδͬ²½ÖúÕ½¼Ç¼: %s" % (len(helpList)), playerID)  | 
|     return  | 
|   | 
| def OnServerClose():  | 
|     GameWorld.Log("¹Ø·þ±£´æÖúÕ½Ïà¹ØÐÅÏ¢...")  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     universalRecMgr.Delete(Def_RecType_CheckInPlayer)  | 
|     universalRecMgr.Delete(Def_RecType_HelpRecord)  | 
|       | 
|     GameWorld.Log("±£´æÖúÕ½µÇ¼ÇÍæ¼Ò¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleCheckInPlayerDict))  | 
|     checkInPlayerRecList = universalRecMgr.GetTypeList(Def_RecType_CheckInPlayer)  | 
|     for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():  | 
|         recData = checkInPlayerRecList.AddRec()  | 
|         recData.SetTime(checkInPlayer.checkInTime)  | 
|         recData.SetValue1(playerID)  | 
|         recData.SetValue2(checkInPlayer.fightPower)  | 
|         recData.SetValue3(checkInPlayer.familyID)  | 
|         recData.SetValue4(checkInPlayer.checkInCount)  | 
|         recData.SetValue5(int("%d%02d%02d%d" % (checkInPlayer.playerLV, checkInPlayer.vipLV, checkInPlayer.realmLV, checkInPlayer.job)))  | 
|         recData.SetStrValue1(checkInPlayer.playerName)  | 
|         recData.SetStrValue2(str(checkInPlayer.todayXianyuanCoin))  | 
|         recData.SetStrValue3(str(checkInPlayer.todayHelpCountDict).replace(" ", ""))  | 
|           | 
|     GameWorld.Log("±£´æÖúսδͬ²½¼Ç¼: %s" % len(PyGameData.g_fbHelpBattleRecord))  | 
|     helpRecordRecList = universalRecMgr.GetTypeList(Def_RecType_HelpRecord)  | 
|     for playerID, helpList in PyGameData.g_fbHelpBattleRecord.items():  | 
|         GameWorld.Log("Íæ¼Òδͬ²½ÖúÕ½¼Ç¼: %s" % (len(helpList)), playerID)  | 
|         for helpRecord in helpList:  | 
|             recData = helpRecordRecList.AddRec()  | 
|             recData.SetTime(helpRecord.recordTime)  | 
|             recData.SetValue1(playerID)  | 
|             recData.SetValue2(helpRecord.mapID)  | 
|             recData.SetValue3(helpRecord.funcLineID)  | 
|             recData.SetValue4(helpRecord.xianyuanCoinAdd)  | 
|             recData.SetValue5(helpRecord.vipLV*10+helpRecord.relation)  | 
|             recData.SetStrValue1(helpRecord.callPlayerName)  | 
|             recData.SetStrValue2(str(helpRecord.callPlayerID))  | 
|     return  | 
|   | 
| def HelpBattleOnDay():  | 
|     curTime = int(time.time())  | 
|     checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±  | 
|     # ÕâÀïÑÓ³¤30·ÖÖÓÇå³ý£¬·ÀÖ¹ÒѾ±»ÕÙ»½»¹Ã»½áËãµÄµ¼ÖÂÕÒ²»µ½µÇ¼ÇÐÅÏ¢  | 
|     checkInValidSeconds = checkInValidHours * 3600 + 30 * 60  | 
|       | 
|     # Ç峬ʱµÇ¼Ç£¬ÖØÖÃÐÅÏ¢  | 
|     for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():  | 
|         checkInTime = checkInPlayer.checkInTime  | 
|         if curTime - checkInTime > checkInValidSeconds:  | 
|             PyGameData.g_fbHelpBattleCheckInPlayerDict.pop(playerID)  | 
|             GameWorld.Log("Çå³ý³¬Ê±ÖúÕ½µÇ¼ÇÍæ¼Ò: curTime=%s,checkInTime=%s" % (curTime, checkInTime), playerID)  | 
|             continue  | 
|         checkInPlayer.todayHelpCountDict = {}  | 
|         checkInPlayer.todayXianyuanCoin = 0  | 
|     return  | 
|   | 
| def OnHelpPlayerLogin(curPlayer):  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if playerID not in PyGameData.g_fbHelpBattleRecord:  | 
|         return  | 
|     unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.pop(playerID)  | 
|     SendMapServer_FBHelpBattleRecord(curPlayer, unNotifyRecordList, True)  | 
|     return  | 
|   | 
| def OnMinuteProcess():  | 
|     ''' Ã¿·ÖÖÓ´¦Àí  | 
|             Ç°X´ÎµÇ¼Çºó£¬·Ö±ðÔڵǼǺóµÄµÚX·ÖÖÓÔùËÍÍæ¼Ò×ÚÃÅÊÔÁ¶Ò»²ãµÄÖúÕ½ÏÉÔµ±Ò£¬²¢Î±ÔìÒ»·ÝÖúÕ½¼Ç¼¡£  | 
|             ÖúÕ½¼ÇÂ¼Ëæ»ú´ÓÖúÕ½µÇ¼Ç¿âÀïËæ»úÌôÑ¡1Ãû³ý×Ô¼ºÍâµÄÍæ¼Ò£¬Èç¹ûûÓÐÍæ¼Ò£¬¸ÃÌØÊâÂß¼²»ÉúЧ  | 
|     '''  | 
|       | 
|     if not PyGameData.g_fbHelpBattleCheckInPlayerDict:  | 
|         return  | 
|     helpPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()  | 
|       | 
|     curTime = int(time.time())  | 
|       | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     newbieCheckInCount = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 2) # ÐÂÊÖǰX´ÎµÇ¼ÇÌØÊâÂß¼  | 
|     sysAutoCallHelpDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattleCheckIn", 3) # ÏµÍ³×Ô¶¯ÕÙ»½ÖúÕ½£¬Ä¬ÈϹ¦ÄÜÏß·0£¬ {µÇ¼Ç¶àÉÙ·ÖÖÓºó:[Ëæ»úµØÍ¼ID, ...], ...}  | 
|     for playerID, checkInPlayer in PyGameData.g_fbHelpBattleCheckInPlayerDict.items():  | 
|           | 
|         curPlayer = playerManager.FindPlayerByID(playerID)  | 
|           | 
|         if not curPlayer or PlayerControl.GetIsTJG(curPlayer):  | 
|             #GameWorld.DebugLog("    ÀëÏß»òÍÑ»ú²»´¦Àí, playerID=%s" % playerID)  | 
|             continue  | 
|           | 
|         checkInCount = checkInPlayer.checkInCount  | 
|         if checkInCount > newbieCheckInCount:  | 
|             #GameWorld.DebugLog("    ³¬¹ý¹æ¶¨µÄµÇ¼Ç´ÎÊý£¬²»´¦Àí, playerID=%s,checkInCount=%s > newbieCheckInCount=%s"   | 
|             #                   % (playerID, checkInCount, newbieCheckInCount))  | 
|             continue  | 
|           | 
|         checkInTime = checkInPlayer.checkInTime  | 
|         checkInMinutes = (curTime - checkInTime) / 60   | 
|         if checkInMinutes not in sysAutoCallHelpDict:  | 
|             #GameWorld.DebugLog("    Ç©µ½Ê±¼ä²»Âú×㣬²»´¦Àí, playerID=%s,checkInMinutes=%s not in %s"   | 
|             #                   % (playerID, checkInMinutes, sysAutoCallHelpDict))  | 
|             continue  | 
|           | 
|         randHelpMapList = sysAutoCallHelpDict[checkInMinutes]  | 
|         # Ëæ»úÒ»¸ö²»ÊÇ×Ô¼ºµÄµÇ¼ÇÍæ¼Ò  | 
|         for _ in xrange(20):  | 
|             randPlayerID = random.choice(helpPlayerIDList)  | 
|             if randPlayerID != playerID:  | 
|                 break  | 
|               | 
|         # Ö»ÓÐ×Ô¼º²»´¦Àí  | 
|         if randPlayerID == playerID:  | 
|             #GameWorld.DebugLog("    µÇ¼ÇÍæ¼ÒÖ»ÓÐ×Ô¼º£¬²»´¦Àí, playerID=%s" % (playerID))  | 
|             continue  | 
|           | 
|         randHelpMapID = random.choice(randHelpMapList)  | 
|         lineID = 0 # Ä¬ÈÏ0  | 
|           | 
|         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[randPlayerID]  | 
|         relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)  | 
|         calledPlayerID = playerID # ÒòΪÕâÀïÊÇϵͳģÄâÍæ¼Ò±»ÕÙ»½ÖúÕ½£¬ËùÒÔ±»ÕÙ»½Íæ¼Ò¾ÍÊǵ±Ç°±»´¦ÀíµÄÍæ¼ÒID  | 
|         GameWorld.DebugLog("    ÏµÍ³Ä£ÄâÕÙ»½ÐÂÊֵǼÇÍæ¼Ò: checkInMinutes=%s,playerID=%s,callPlayerID=%s" % (checkInMinutes, playerID, randPlayerID))  | 
|           | 
|         calledPlayerDict = {calledPlayerID:relation}  | 
|         msgList = ["Call", randHelpMapID, lineID, calledPlayerDict]  | 
|         __DoFBHelpBattleCall(randPlayerID, helpBattlePlayer.playerName, msgList)  | 
|           | 
|     return  | 
|   | 
| ## ÊÇ·ñÔÚÖúÕ½µÇ¼ÇÁбíÀï  | 
| def IsInHelpBattleCheckInList(playerID): return playerID in PyGameData.g_fbHelpBattleCheckInPlayerDict  | 
|   | 
| def MapServer_FBHelpBattle(curPlayer, msgList):  | 
|     ## µØÍ¼Íæ¼ÒÇëÇóÖúÕ½Ïà¹Ø²Ù×÷  | 
|     GameWorld.DebugLog("MapServer_FBHelpBattle %s" % str(msgList), curPlayer.GetPlayerID())  | 
|     if not msgList:  | 
|         return ""  | 
|       | 
|     cmd = msgList[0]  | 
|     result = []  | 
|       | 
|     # µÇ¼Ç  | 
|     if cmd == "CheckIn":  | 
|         result = __DoPlayerFBHelpBattleCheckIn(curPlayer, msgList)  | 
|           | 
|     # Ë¢ÐÂÖúÕ½ÁÐ±í      | 
|     elif cmd == "Refresh":  | 
|         result = __DoFBHelpBattleRefresh(curPlayer, msgList)  | 
|           | 
|     # ÕÙ»½  | 
|     elif cmd == "Call":  | 
|         result = __DoFBHelpBattleCall(curPlayer.GetPlayerID(), curPlayer.GetName(), msgList)  | 
|       | 
|     # É¨µ´ÕÙ»½  | 
|     elif cmd == "SweepCall":  | 
|         result = __DoFBHelpBattleSweepCall(curPlayer, msgList)  | 
|           | 
|     if result == None:  | 
|         return  | 
|       | 
|     return msgList + result  | 
|   | 
| def __DoPlayerFBHelpBattleCheckIn(curPlayer, msgList):  | 
|     ## Íæ¼ÒµÇ¼Ç  | 
|     checkInCount, fightPower = msgList[1:]  | 
|     curTime = int(time.time())  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     curCache = PlayerViewCache.FindViewCache(playerID)  | 
|     haveViewCache = 1 if curCache else 0  | 
|     todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer)  | 
|       | 
|     helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict.get(playerID)  | 
|     if not helpBattlePlayer:  | 
|         helpBattlePlayer = HelpBattlePlayer(playerID)  | 
|         PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID] = helpBattlePlayer  | 
|     helpBattlePlayer.playerName = curPlayer.GetName()  | 
|     helpBattlePlayer.playerLV = curPlayer.GetLV()  | 
|     helpBattlePlayer.job = curPlayer.GetJob()  | 
|     helpBattlePlayer.realmLV = curPlayer.GetOfficialRank()  | 
|     helpBattlePlayer.fightPower = fightPower  | 
|     helpBattlePlayer.familyID = curPlayer.GetFamilyID()  | 
|     helpBattlePlayer.vipLV = curPlayer.GetVIPLv()  | 
|     helpBattlePlayer.checkInCount = checkInCount + 1  | 
|     helpBattlePlayer.checkInTime = curTime  | 
|     helpBattlePlayer.todayXianyuanCoin = todayXianyuanCoin  | 
|       | 
|     isOK = 1 # Ä¬Èϳɹ¦  | 
|     GameWorld.Log("Íæ¼ÒÖúÕ½µÇ¼Ç: playerLV=%s,fightPower=%s,familyID=%s,vipLV=%s,todayXianyuanCoin=%s,checkInCount=%s,haveViewCache=%s"   | 
|                   % (curPlayer.GetLV(), fightPower, curPlayer.GetFamilyID(), curPlayer.GetVIPLv(), todayXianyuanCoin, checkInCount + 1, haveViewCache), playerID)  | 
|     return [isOK, haveViewCache]  | 
|   | 
| def UpdateCheckInPlayerInfo(playerID, fightPower, familyID, playerName):  | 
|     ## ¸üеǼǵÄÖúÕ½Íæ¼ÒµÈ¼¶Õ½Á¦  | 
|     if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:  | 
|         return  | 
|     helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]  | 
|     helpBattlePlayer.fightPower = fightPower  | 
|     helpBattlePlayer.familyID = familyID  | 
|     helpBattlePlayer.playerName = playerName  | 
|     GameWorld.DebugLog("¸üÐÂÖúÕ½Íæ¼ÒµÈ¼¶Õ½Á¦: fightPower=%s,familyID=%s" % (fightPower, familyID), playerID)  | 
|     return  | 
|   | 
| def UpdateCheckInPlayerInfoByRefresh(curPlayer, refreshType, value):  | 
|     ## ¸üеǼǵÄÖúÕ½Íæ¼ÒÏÉÃËID  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:  | 
|         return  | 
|     helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]  | 
|     if refreshType == IPY_GameServer.CDBPlayerRefresh_LV:  | 
|         helpBattlePlayer.playerLV = value  | 
|     elif refreshType == IPY_GameServer.CDBPlayerRefresh_ExAttr11:  | 
|         helpBattlePlayer.todayXianyuanCoin = value          | 
|     elif refreshType == IPY_GameServer.CDBPlayerRefresh_VIPLv:  | 
|         helpBattlePlayer.vipLV = value  | 
|     else:  | 
|         return  | 
|     GameWorld.DebugLog("¸üÐÂÖúÕ½Íæ¼ÒÐÅÏ¢: refreshType=%s,value=%s" % (refreshType, value), playerID)  | 
|     return  | 
|   | 
| def __DoFBHelpBattleRefresh(curPlayer, msgList):  | 
|     ## ÖúÕ½ÁбíˢР | 
|     mapID, funcLineID, isClientRefresh, costMoneyList, calledPlayerIDDict = msgList[1:]  | 
|       | 
|     helpBattlePlayerDict = {} # Í¬²½¸øµØÍ¼·þÎñÆ÷µÄ´ýÑ¡ÖúÕ½Íæ¼ÒÁбíÐÅÏ¢  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)  | 
|     if not ipyData:  | 
|         return [helpBattlePlayerDict]  | 
|       | 
|     fightPowerMin = ipyData.GetFightPowerMin()  | 
|     fightPowerMax = ipyData.GetFightPowerMax()  | 
|     limitLV = ipyData.GetLVLimit()  | 
|     dayFreeHelpCountInfo = ipyData.GetDayFreeHelpCount() # Ã¿ÈÕÃâ·ÑÖúÕ½´ÎÊý£¬[ÿÈÕÃâ·ÑÖúÕ½´ÎÊý, ÊÇ·ñËùÓвãͨÓÃ]  | 
|     dayFreeHelpCount = 0 # 0ΪÎÞÏÞÖÆ´ÎÊý  | 
|     helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0  | 
|     if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:  | 
|         dayFreeHelpCount, isAllLineCount = dayFreeHelpCountInfo  | 
|         if isAllLineCount:  | 
|             helpCountLineID = 0  | 
|     helpCountKey = (mapID, helpCountLineID)  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     GameWorld.Log("Ë¢ÐÂÖúÕ½Áбí: mapID=%s,funcLineID=%s,helpCountLineID=%s,isClientRefresh=%s,costMoneyList=%s,calledPlayerIDDict=%s"   | 
|                   % (mapID, funcLineID, helpCountLineID, isClientRefresh, costMoneyList, calledPlayerIDDict), playerID)  | 
|       | 
|     onlyFree = False  | 
|     goldCallCount = 0  | 
|     nowFreeRelationCount, nowRelationCount = 0, 0  | 
|     atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # ÖÁÉÙÃâ·ÑÉç½»ÈËÊý£¬ÎÞÉç½»ÔòºöÂÔ  | 
|     atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # ÖÁÉÙÉç½»ÈËÊý£¬ÎÞÉç½»ÔòºöÂÔ£¨ÈËÊý°üº¬Ãâ·ÑÉç½»ÈËÊý£©  | 
|     GameWorld.DebugLog("    atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))  | 
|       | 
|     #ÒѾÕÙ»½µÄ±£Áô  | 
|     for calledPlayerID, callInfo in calledPlayerIDDict.items():  | 
|         needGoldCall, job, relation = callInfo  | 
|         # Íæ¼Ò¾µÏñ  | 
|         if calledPlayerID in PyGameData.g_fbHelpBattleCheckInPlayerDict:  | 
|             helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[calledPlayerID]  | 
|             helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, job, relation)  | 
|             if needGoldCall:  | 
|                 goldCallCount += 1  | 
|             if relation:  | 
|                 nowRelationCount += 1  | 
|                 if not needGoldCall:  | 
|                     nowFreeRelationCount += 1  | 
|         # »úÆ÷ÈËNPC  | 
|         elif 1 <= calledPlayerID <= MaxRobotID:  | 
|             helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)  | 
|         else:  | 
|             GameWorld.ErrLog("ÒÑÕÙ»½µÄÖúÕ½Íæ¼ÒÕÒ²»µ½¾µÏñ»º´æ£¡ÀíÂÛÉϲ»´æÔÚ¸ÃÇé¿ö£¬¾µÏñ»º´æÊÍ·Å»á±ÈµÇ¼ÇÓÐЧʱ³¤¶à°ëСʱ£¡")  | 
|             continue  | 
|               | 
|     if helpBattlePlayerDict:  | 
|         GameWorld.Log("ÒÑÕÙ»½µÄÖúÕ½: %s" % str(helpBattlePlayerDict), playerID)  | 
|           | 
|     curTime = int(time.time())  | 
|     maxHelpPlayerSelectCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # ×î´ó¿ÉÒÔÑ¡ÔñÖúÕ½µÄÍæ¼Ò¸öÊý  | 
|     maxGoldHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 3) # ×î´ó¸¶·ÑÕÙ»½ÈËÊý  | 
|     checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±  | 
|     checkInValidSeconds = checkInValidHours * 3600  | 
|       | 
|     checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()  | 
|     random.shuffle(checkInPlayerIDList)  | 
|     GameWorld.Log("    µÇ¼ÇÖúÕ½ÈËÊý=%s" % (len(checkInPlayerIDList)), playerID)  | 
|       | 
|     # 1. ÖÁÉÙÉç½»¹ØÏµÈËÊý»¹²»×ãµÄ£¬ÏÈ´¦ÀíÖÁÉÙÉç½»¹ØÏµÈËÊý  | 
|     if nowRelationCount < atleastRelationCount:  | 
|         relationIDList = []  | 
|         friendIDList = PlayerFriend.GetFriendStruct(playerID).GetSocialIDList()  | 
|         relationIDList += friendIDList  | 
|         #GameWorld.DebugLog("    ºÃÓÑIDÁбí, friendIDList=%s" % friendIDList, playerID)  | 
|         curFamily = curPlayer.GetFamily()  | 
|         familyMemList = []  | 
|         if curFamily:  | 
|             for index in xrange(curFamily.GetCount()):  | 
|                 member = curFamily.GetAt(index)  | 
|                 memberID = member.GetPlayerID()  | 
|                 familyMemList.append(memberID)  | 
|                 if memberID != playerID and memberID not in relationIDList:  | 
|                     relationIDList.append(memberID)  | 
|         #GameWorld.DebugLog("    ÃËÓÑIDÁбí, familyMemList=%s" % familyMemList, playerID)  | 
|           | 
|         random.shuffle(relationIDList)  | 
|         #GameWorld.DebugLog("    ÓÐÉç½»µÄIDÁбí, relationIDList=%s" % relationIDList, playerID)  | 
|         tempRelationHelpPlayerList = []  | 
|         for relationID in relationIDList:  | 
|             if nowRelationCount >= atleastRelationCount:  | 
|                 break  | 
|             if relationID not in checkInPlayerIDList:  | 
|                 continue  | 
|             helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[relationID]  | 
|             canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,   | 
|                                                        checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)  | 
|             if not canHelp:  | 
|                 continue  | 
|               | 
|             # Ãâ·ÑÉç½»ÈËÊý²»×ãÇÒÃâ·Ñ   or  Ãâ·ÑÉç½»ÈËÊý¹»ÁËÇÒ×ÜÉç½»ÈËÊý»¹²»¹»  ; ¶¼Ö±½Ó¼ÓÈëÖúÕ½ÁÐ±í  | 
|             if (nowFreeRelationCount < atleastFreeRelationCount and not needGoldCall) \  | 
|                 or (nowFreeRelationCount >= atleastFreeRelationCount and nowRelationCount < atleastRelationCount):  | 
|                 goldCallCount, nowRelationCount, nowFreeRelationCount = \  | 
|                     __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)  | 
|             else:  | 
|                 lackRelationCount = atleastRelationCount - nowRelationCount  | 
|                 if len(tempRelationHelpPlayerList) < lackRelationCount:  | 
|                     tempRelationHelpPlayerList.append([helpBattlePlayer, needGoldCall])  | 
|                       | 
|         lackRelationCount = atleastRelationCount - nowRelationCount  | 
|         if lackRelationCount > 0:  | 
|             for helpBattlePlayer, needGoldCall in tempRelationHelpPlayerList[:lackRelationCount]:  | 
|                 goldCallCount, nowRelationCount, nowFreeRelationCount = \  | 
|                     __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)  | 
|       | 
|     # 2. ³£¹æÌí¼ÓÖúÕ½ÈËÊý          | 
|     for checkInPlayerID in checkInPlayerIDList:  | 
|         if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:  | 
|             GameWorld.DebugLog("    ³¬¹ý×î´ó¸öÊýÁ˲»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)  | 
|             break  | 
|         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]  | 
|         canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,   | 
|                                                    checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)  | 
|         if not canHelp:  | 
|             continue  | 
|           | 
|         goldCallCount, nowRelationCount, nowFreeRelationCount = \  | 
|             __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)  | 
|           | 
|     # 3. ²»×ãµÄ»úÆ÷ÈËNPC²¹×ã  | 
|     openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # ¿ª·ÅµÄÖ°Òµ  | 
|     lackCount = maxHelpPlayerSelectCount - len(helpBattlePlayerDict)  | 
|     robotID = 0 # »úÆ÷ÈËNPC¶¨ÒåID´Ó1¿ªÊ¼  | 
|     while lackCount > 0 and robotID < MaxRobotID:  | 
|         robotID += 1  | 
|         if robotID in helpBattlePlayerDict:  | 
|             continue  | 
|         lackCount -= 1  | 
|         randJob = random.choice(openJobList)  | 
|         helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)  | 
|       | 
|     GameWorld.Log("    helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)  | 
|     return [helpBattlePlayerDict]  | 
|   | 
| def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,   | 
|                        checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree=False, goldCallCount=0, maxGoldHelpPlayerCount=0):              | 
|     ## ³£¹æ¼ì²éÊÇ·ñÂú×ãÖúÕ½Ìõ¼þ  | 
|     if checkInPlayerID == playerID:  | 
|         GameWorld.DebugLog("    ×Ô¼º²»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)  | 
|         return False, False  | 
|     if checkInPlayerID in helpBattlePlayerDict:  | 
|         GameWorld.DebugLog("    ÒѾÔÚÖúÕ½ÀïµÄ²»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)  | 
|         return False, False  | 
|     checkInPlayerLV = helpBattlePlayer.playerLV  | 
|     checkInPlayerFightPower = helpBattlePlayer.fightPower  | 
|     checkInTime = helpBattlePlayer.checkInTime  | 
|     if checkInPlayerLV < limitLV:  | 
|         GameWorld.DebugLog("    µÈ¼¶²»×ã, checkInPlayerID=%s,checkInPlayerLV=%s < limitLV=%s" % (checkInPlayerID, checkInPlayerLV, limitLV))  | 
|         return False, False  | 
|     if fightPowerMin and checkInPlayerFightPower < fightPowerMin:  | 
|         GameWorld.DebugLog("    Õ½Á¦²»×ã, checkInPlayerID=%s,checkInPlayerFightPower=%s < fightPowerMin=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMin))  | 
|         return False, False  | 
|     if fightPowerMax and checkInPlayerFightPower > fightPowerMax:  | 
|         GameWorld.DebugLog("    Õ½Á¦³¬³ö, checkInPlayerID=%s,checkInPlayerFightPower=%s > fightPowerMax=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMax))  | 
|         return False, False  | 
|     passTime = curTime - checkInTime  | 
|     if passTime > checkInValidSeconds:  | 
|         GameWorld.DebugLog("    µÇ¼Ç³¬Ê±, checkInPlayerID=%s,checkInTime=%s,passTime=%s > checkInValidSeconds=%s" % (checkInPlayerID, checkInTime, passTime, checkInValidSeconds))  | 
|         return False, False  | 
|     todayHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0)  | 
|     needGoldCall = dayFreeHelpCount and todayHelpCount >= dayFreeHelpCount  | 
|     if needGoldCall:  | 
|         if onlyFree:  | 
|             GameWorld.DebugLog("    ²»ÊÇÃâ·Ñ, checkInPlayerID=%s,todayHelpCount=%s > dayFreeHelpCount=%s" % (checkInPlayerID, todayHelpCount, dayFreeHelpCount))  | 
|             return False, needGoldCall  | 
|         if goldCallCount >= maxGoldHelpPlayerCount:  | 
|             GameWorld.DebugLog("    ³¬¹ý×î´ó¸¶·ÑÕÙ»½ÈËÊý, checkInPlayerID=%s,goldCallCount=%s > maxGoldHelpPlayerCount=%s" % (checkInPlayerID, goldCallCount, maxGoldHelpPlayerCount))  | 
|             return False, needGoldCall  | 
|     return True, needGoldCall  | 
|   | 
| def __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount):  | 
|     ## Ìí¼ÓÖúÕ½Íæ¼Òµ½ÖúÕ½ÁÐ±í  | 
|     if needGoldCall:  | 
|         goldCallCount += 1  | 
|     relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)  | 
|     if relation:  | 
|         nowRelationCount += 1  | 
|         if not needGoldCall:  | 
|             nowFreeRelationCount += 1  | 
|     helpPlayerID = helpBattlePlayer.playerID  | 
|     helpBattlePlayerDict[helpPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)  | 
|     GameWorld.DebugLog("    ÖúÕ½ÁбíÌí¼ÓÍæ¼Ò: helpPlayerID=%s,needGoldCall=%s,relation=%s,goldCallCount=%s,nowRelationCount=%s,nowFreeRelationCount=%s"   | 
|                        % (helpPlayerID, needGoldCall, relation, goldCallCount, nowRelationCount, nowFreeRelationCount))  | 
|     return goldCallCount, nowRelationCount, nowFreeRelationCount  | 
|   | 
| def __GetHelpBattleRelation(curPlayer, helpBattlePlayer):  | 
|     ## »ñÈ¡ÖúÕ½Éç½»¹ØÏµ 0-ÎÞ£¬1-ºÃÓÑ£¬2-ÃËÓÑ  | 
|     if not helpBattlePlayer:  | 
|         return 0  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     tagPlayerID = helpBattlePlayer.playerID  | 
|     tagFamilyID = helpBattlePlayer.familyID  | 
|     relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # Éç½»¹ØÏµÓÅÏȼ¶  | 
|     for checkRelation in relationList:  | 
|         if checkRelation == 1:  | 
|             if PlayerFriend.IsFriend(playerID, tagPlayerID):  | 
|                 return checkRelation  | 
|         if checkRelation == 2:  | 
|             if tagFamilyID and curPlayer.GetFamilyID() == tagFamilyID:  | 
|                 return checkRelation  | 
|     return 0  | 
|   | 
| def __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, job, relation=0):  | 
|     ## »ñȡͬ²½¸øµØÍ¼µÄÖúÕ½Íæ¼Ò¼òÒªÐÅÏ¢  | 
|     helpPlayerDict = {"Job":job}  | 
|     if not helpBattlePlayer:  | 
|         return helpPlayerDict  | 
|     if needGoldCall:  | 
|         helpPlayerDict["NeedGoldCall"] = 1  | 
|     helpPlayerDict["Name"] = helpBattlePlayer.playerName  | 
|     helpPlayerDict["LV"] = helpBattlePlayer.playerLV  | 
|     #helpPlayerDict["Job"] = helpBattlePlayer.job  | 
|     helpPlayerDict["RealmLV"] = helpBattlePlayer.realmLV  | 
|     helpPlayerDict["FightPower"] = helpBattlePlayer.fightPower  | 
|     helpPlayerDict["Relation"] = relation  | 
|     return helpPlayerDict  | 
|   | 
| def __DoFBHelpBattleSweepCall(curPlayer, msgList):  | 
|     ''' É¨µ´ÖúÕ½ÁбíË¢ÐÂÇÒÖ±½ÓÕÙ»½  | 
|             Ëæ»úÑ¡ÔñÃâ·ÑµÄÍæ¼Ò¡¢¹ýÂËÏÉÔµ±ÒÒÑ´ïÉÏÏÞ»òÒç³öµÄÍæ¼Ò  | 
|     '''  | 
|     mapID, funcLineID = msgList[1:]  | 
|       | 
|     helpBattlePlayerDict = {} # Í¬²½¸øµØÍ¼·þÎñÆ÷µÄ´ýÑ¡ÖúÕ½Íæ¼ÒÁбíÐÅÏ¢  | 
|       | 
|     fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)  | 
|     fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)  | 
|     if not fbFuncIpyData or not fbHelpIpyData:  | 
|         return [helpBattlePlayerDict]  | 
|       | 
|     fightPowerMin = fbHelpIpyData.GetFightPowerMin()  | 
|     fightPowerMax = fbHelpIpyData.GetFightPowerMax()  | 
|     limitLV = fbHelpIpyData.GetLVLimit()  | 
|     dayFreeHelpCountInfo = fbHelpIpyData.GetDayFreeHelpCount() # Ã¿ÈÕÃâ·ÑÖúÕ½´ÎÊý£¬[ÿÈÕÃâ·ÑÖúÕ½´ÎÊý, ÊÇ·ñËùÓвãͨÓÃ]  | 
|     dayFreeHelpCount = 0 # 0ΪÎÞÏÞÖÆ´ÎÊý  | 
|     helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0  | 
|     if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:  | 
|         dayFreeHelpCount, isAllLineCount = dayFreeHelpCountInfo  | 
|         if isAllLineCount:  | 
|             helpCountLineID = 0  | 
|     helpCountKey = (mapID, helpCountLineID)  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     tagPlayerID = playerID  | 
|     tagPlayerName = curPlayer.GetName()  | 
|     GameWorld.Log("ɨµ´Ë¢ÐÂÖúÕ½Áбí: mapID=%s,funcLineID=%s,helpCountLineID=%s" % (mapID, funcLineID, helpCountLineID), playerID)  | 
|       | 
|     curTime = int(time.time())  | 
|     maxHelpPlayerCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # ×î´óÖúÕ½ÈËÊý  | 
|     checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # µÇ¼ÇÓÐЧʱ³¤£¬Ð¡Ê±  | 
|     checkInValidSeconds = checkInValidHours * 3600  | 
|       | 
|     xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # Ã¿ÈÕÏÉÔµ±ÒÉÏÏÞ  | 
|     baseHelpPoint = fbFuncIpyData.GetHelpPoint() # ÖúÕ½ - »ù´¡ÏÉÔµ±Ò  | 
|     relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # Éç½»¹ØÏµ¼Ó³É {"Éç½»¹ØÏµ":[¹ý¹Ø¼Ó³É, ÖúÕ½¼Ó³É], ...}   | 
|       | 
|     isSweep = True  | 
|     onlyFree = True  | 
|     checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()  | 
|     random.shuffle(checkInPlayerIDList) # Ë¢Ð´¿Ëæ»ú  | 
|     GameWorld.Log("    µÇ¼ÇÖúÕ½ÈËÊý=%s" % (len(checkInPlayerIDList)), playerID)  | 
|     for checkInPlayerID in checkInPlayerIDList:  | 
|         if len(helpBattlePlayerDict) >= maxHelpPlayerCount:  | 
|             GameWorld.DebugLog("    ³¬¹ý×î´ó¸öÊýÁ˲»´¦Àí, checkInPlayerID=%s" % checkInPlayerID)  | 
|             break  | 
|         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]  | 
|         canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,   | 
|                                                    checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)  | 
|         if not canHelp:  | 
|             continue  | 
|           | 
|         relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)  | 
|         if not __DoCallHelpPlayer(tagPlayerID, tagPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep,   | 
|                                   curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):  | 
|             continue  | 
|           | 
|         helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)  | 
|           | 
|     # ²»×ãµÄ»úÆ÷ÈËNPC²¹×ã  | 
|     openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # ¿ª·ÅµÄÖ°Òµ  | 
|     lackCount = maxHelpPlayerCount - len(helpBattlePlayerDict)  | 
|     robotID = 0 # »úÆ÷ÈËNPC¶¨ÒåID´Ó1¿ªÊ¼  | 
|     while lackCount > 0 and robotID < MaxRobotID:  | 
|         robotID += 1  | 
|         if robotID in helpBattlePlayerDict:  | 
|             continue  | 
|         lackCount -= 1  | 
|         randJob = random.choice(openJobList)  | 
|         helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)  | 
|       | 
|     GameWorld.Log("    helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)  | 
|     return [helpBattlePlayerDict]  | 
|   | 
| def __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep, curTime,   | 
|                        xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint):  | 
|       | 
|     calledPlayerID = helpBattlePlayer.playerID  | 
|     addCoinRate = 10000 # »ù´¡±¶ÂÊ  | 
|     playerXianyuanCoinUpper = xianyuanCoinUpper  | 
|     relationAddList = relationCoinAddDict.get(str(relation), [])  | 
|     relationAdd = relationAddList[1] if len(relationAddList) == 2 else 0  | 
|       | 
|     todayXianyuanCoin = helpBattlePlayer.todayXianyuanCoin # ½ñÈÕÒÑ»ñµÃÏÉÔµ±Ò  | 
|     vipLV = helpBattlePlayer.vipLV  | 
|     if vipLV:  | 
|         xianyuanCoinUpperAdd = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)  | 
|         xianyuanCoinAddPer = PlayerControl.GetPrivilegeValue(vipLV, ChConfig.VIPPrivilege_XianyuanCoinAddPer)  | 
|           | 
|         playerXianyuanCoinUpper += xianyuanCoinUpperAdd  | 
|         addCoinRate += xianyuanCoinAddPer  | 
|           | 
|     # ÏÉÔµ±Ò¹«Ê½=£¨Í¨¹ØÏÉÔµ±Ò»òÖúÕ½ÏÉÔµ±Ò+Éç½»¹ØÏµ¼Ó³É£©*VIP±¶Êý  | 
|     coinAdd = int((baseHelpPoint + relationAdd) * addCoinRate / 10000.0)  | 
|     canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)  | 
|       | 
|     # É¨µ´²»¿ÉÒç³ö  | 
|     if isSweep and coinAdd > canAddMax:  | 
|         GameWorld.DebugLog("    ½ñÈÕÏÉÔµ±ÒÒÑ´ïÉÏÏÞ, calledPlayerID=%s,coinAdd=%s > canAddMax=%s" % (calledPlayerID, coinAdd, canAddMax))  | 
|         return  | 
|     coinAddReal = min(coinAdd, canAddMax) # Êµ¼Ê¼ÓÏÉÔµ±Ò  | 
|       | 
|     todayMapHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1  | 
|     helpBattlePlayer.todayHelpCountDict[helpCountKey] = todayMapHelpCount  | 
|     GameWorld.DebugLog("    ÖúÕ½Ôö¼ÓÏÉÔµ±Ò: todayXianyuanCoin=%s,coinUpper=%s,canAddMax=%s,coinAdd=%s,coinAddReal=%s,todayMapHelpCount=%s"   | 
|                        % (todayXianyuanCoin, playerXianyuanCoinUpper, canAddMax, coinAdd, coinAddReal, todayMapHelpCount), calledPlayerID)  | 
|       | 
|     # GameServer Ö±½ÓÏÈ¼Ó  | 
|     helpBattlePlayer.todayXianyuanCoin += coinAddReal  | 
|       | 
|     helpRecord = FBHelpBattleRecord()  | 
|     helpRecord.callPlayerID = callPlayerID # ÕÙ»½ËûµÄÍæ¼ÒID  | 
|     helpRecord.callPlayerName = callPlayerName  | 
|     helpRecord.mapID = mapID  | 
|     helpRecord.funcLineID = funcLineID  | 
|     helpRecord.xianyuanCoinAdd = coinAddReal  | 
|     helpRecord.relation = relation  | 
|     helpRecord.vipLV = vipLV  | 
|     helpRecord.recordTime = curTime  | 
|       | 
|     calledPlayer = GameWorld.GetPlayerManager().FindPlayerByID(calledPlayerID)  | 
|     # ·ÇÍÑ»úÔÚÏßÖ±½Ó֪ͨµØÍ¼  | 
|     if calledPlayer and not PlayerControl.GetIsTJG(calledPlayer):  | 
|         SendMapServer_FBHelpBattleRecord(calledPlayer, [helpRecord])  | 
|     else:  | 
|         unNotifyRecordList = PyGameData.g_fbHelpBattleRecord.get(calledPlayerID, [])  | 
|         unNotifyRecordList.append(helpRecord)  | 
|         PyGameData.g_fbHelpBattleRecord[calledPlayerID] = unNotifyRecordList  | 
|     return True  | 
|   | 
| def __DoFBHelpBattleCall(callPlayerID, callPlayerName, msgList):  | 
|     ''' ÖúÕ½ÕÙ»½£¬²»¹Ü×îÖÕ¹ý¹ØÓë·ñ£¬±»ÕÙ»½·½¶¼Ö±½ÓËãÖúÕ½³É¹¦£¬ÕâÀï´¦Àí±»ÕÙ»½µÄ£¬Ö÷¶¯·½ÔÚµØÍ¼Ö±½Ó´¦Àí  | 
|     '''  | 
|     # calledPlayerDict = {} # {±»ÕÙ»½µÄÍæ¼ÒID:¹ØÏµ, ...}  | 
|     mapID, funcLineID, calledPlayerDict = msgList[1:]  | 
|     fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)  | 
|     fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)  | 
|     if not fbFuncIpyData or not fbHelpIpyData or not calledPlayerDict:  | 
|         return  | 
|       | 
|     helpCountLineID = funcLineID # ÖúÕ½´ÎÊýËùÊôlineID£¬µ±ËùÓвãͨÓÃʱ£¬Ä¬ÈÏΪ0  | 
|     dayFreeHelpCountInfo = fbHelpIpyData.GetDayFreeHelpCount()  | 
|     if dayFreeHelpCountInfo and len(dayFreeHelpCountInfo) == 2:  | 
|         isAllLineCount = dayFreeHelpCountInfo[1]  | 
|         if isAllLineCount:  | 
|             helpCountLineID = 0  | 
|     helpCountKey = (mapID, helpCountLineID)  | 
|       | 
|     curTime = int(time.time())  | 
|     xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # Ã¿ÈÕÏÉÔµ±ÒÉÏÏÞ  | 
|     baseHelpPoint = fbFuncIpyData.GetHelpPoint() # ÖúÕ½ - »ù´¡ÏÉÔµ±Ò  | 
|     relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # Éç½»¹ØÏµ¼Ó³É {"Éç½»¹ØÏµ":[¹ý¹Ø¼Ó³É, ÖúÕ½¼Ó³É], ...}   | 
|     GameWorld.DebugLog("ÕÙ»½ÖúÕ½: mapID=%s, funcLineID=%s, helpCountKey=%s, calledPlayerDict=%s" % (mapID, funcLineID, helpCountKey, calledPlayerDict), callPlayerID)  | 
|     isSweep = False  | 
|     for calledPlayerID, relation in calledPlayerDict.items():  | 
|         if calledPlayerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:  | 
|             continue  | 
|         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[calledPlayerID]  | 
|         __DoCallHelpPlayer(callPlayerID, callPlayerName, helpBattlePlayer, relation, mapID, funcLineID, helpCountKey, isSweep,   | 
|                            curTime, xianyuanCoinUpper, relationCoinAddDict, baseHelpPoint)  | 
|     return  | 
|   | 
| def SendMapServer_FBHelpBattleRecord(curPlayer, syncHelpRecordList, isLogin=False):  | 
|     if not syncHelpRecordList:  | 
|         return  | 
|       | 
|     helpRecordList = []  | 
|     for record in syncHelpRecordList:  | 
|         helpRecordList.append([record.callPlayerID, record.callPlayerName, record.mapID, record.funcLineID,   | 
|                                record.xianyuanCoinAdd, record.relation, record.vipLV, record.recordTime])  | 
|     addXianyuanCoinMsg = str(["HelpRecord", helpRecordList, isLogin])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, 'FBHelpBattle', addXianyuanCoinMsg, len(addXianyuanCoinMsg))  | 
|     GameWorld.DebugLog("    MapServer_QueryPlayerResult %s" % addXianyuanCoinMsg, curPlayer.GetPlayerID())  | 
|     return  | 
|   | 
|   |