| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package PlayerFB  | 
| # @todo: Íæ¼Ò¸±±¾  | 
| #  | 
| # @author: hxp  | 
| # @date 2013-08-23  | 
| # @version 1.5  | 
| #  | 
| # @note  | 
| # @change: "2014-04-16 18:00" hxp Ôö¼Ó¼Ò×åboss¸±±¾½øÈëÅÐ¶Ï  | 
| # @change: "2015-01-09 10:30" hxp ¸ÄΪGetRouteServerIndex  | 
| # @change: "2015-03-20 15:00" hxp Ìõ¼þÅжÏÐÞ¸Ä  | 
| # @change: "2015-10-22 23:00" hxp Ôö¼Ó¿ç·þPK  | 
| # @change: "2017-01-04 12:00" hxp Ôö¼ÓÒì½çÈëÇÖ  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-01-04 12:00"""  | 
| #---------------------------------------------------------------------  | 
| import GameWorldBoss  | 
| import PlayerFamilyBoss  | 
| import GameWorldFamilyWar  | 
| import PlayerControl  | 
| import PyGameData  | 
| import IpyGameDataPY  | 
| import PlayerTeam  | 
| import GameWorld  | 
| import ChConfig  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| def GetFBLineIpyData(mapID, lineID, isDefaultLine=True):  | 
|     mapID = GetRecordMapID(mapID)  | 
|     fbLineIpyData = IpyGameDataPY.GetIpyGameDataNotLog("FBLine", mapID, lineID)  | 
|     if not fbLineIpyData and isDefaultLine:  | 
|         #GameWorld.DebugLog("ûÓÐÖ¸¶¨¹¦ÄÜÏß·µÄÔòĬÈÏÈ¡0£¬ÔÙûÓеϰ¾ÍÊDz»ÐèÒªµÄmapID=%s, lineID=%s" % (mapID, lineID))  | 
|         fbLineIpyData = IpyGameDataPY.GetIpyGameDataNotLog("FBLine", mapID, 0)  | 
|     return fbLineIpyData  | 
|   | 
| ## »ñÈ¡¼Ç¼ֵµÄmapID  | 
| #  @param mapID ËùÒª²éµÄmapID  | 
| #  @return  | 
| #  @remarks Ò»°ãÓÃÓÚ¼¸ÕŵØÍ¼¹«ÓÃÒ»·Ý´æ´¢¼Ç¼£¬Èç×é¶Ó¸±±¾½øÈë´ÎÊý£¬CDʱ¼äµÈÊý¾ÝÐè¹²Ïí  | 
| def GetRecordMapID(mapID):  | 
|     DataMapIDDict = IpyGameDataPY.GetConfigEx("DataMapIDDict")  | 
|     if not DataMapIDDict:  | 
|         dMapIDDict = {}  | 
|         ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|         for i in xrange(ipyDataMgr.GetFBLineCount()):  | 
|             ipyData = ipyDataMgr.GetFBLineByIndex(i)  | 
|             dMapID = ipyData.GetDataMapID()  | 
|             mID = ipyData.GetMapID()  | 
|             dMapIDList= dMapIDDict.get(dMapID, [])  | 
|             if mID not in dMapIDList:  | 
|                 dMapIDList.append(mID)  | 
|                 dMapIDDict[dMapID] = dMapIDList  | 
|               | 
|         for dMapID in dMapIDDict.keys():  | 
|             if len(dMapIDDict[dMapID]) == 1:  | 
|                 dMapIDDict.pop(dMapID)  | 
|         DataMapIDDict = IpyGameDataPY.SetConfigEx("DataMapIDDict", dMapIDDict)  | 
|         #GameWorld.Log("¼ÓÔØDataMapIDDict=%s" % DataMapIDDict)  | 
|           | 
|     for dataMapID, mapIDList in DataMapIDDict.items():  | 
|         if mapID in mapIDList:  | 
|             return dataMapID  | 
|     return mapID  | 
|   | 
| ## ÇëÇó½øÈ븱±¾·ÖÏß  | 
| #  @param curPlayer: ÇëÇóÍæ¼Ò  | 
| #  @param queryCallName: ÇëÇ󻨵÷Ãû  | 
| #  @param sendCMD: ÇëÇóµÄÃüÁî ¸ù¾ÝÇëÇóÀàÐͺÍÇëÇóÃüÁîÀ´¾ö¶¨×îÖÕ²Ù×÷  | 
| #  @return None  | 
| def EnterFBLine(curPlayer, queryCallName, sendCMD, tick):  | 
|     GameWorld.Log("EnterFBLine()...queryCallName=%s,sendCMD=%s" % (queryCallName, sendCMD), curPlayer.GetPlayerID())  | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     try:  | 
|         mapInfo = eval(sendCMD)  | 
|     except Exception, e:  | 
|         GameWorld.ErrLog("EnterFBLine() sendCMD=%s error" % sendCMD)  | 
|         return  | 
|       | 
|     if not mapInfo or len(mapInfo) < 2:  | 
|         GameWorld.ErrLog("EnterFBLine() sendCMD=%s error!" % sendCMD)  | 
|         return  | 
|       | 
|     #if mapInfo and len(mapInfo) == 2:  | 
|     tagMapID = mapInfo[0]  | 
|     tagLineID = mapInfo[1]  | 
|       | 
|     fbLineIpyData = GetFBLineIpyData(tagMapID, tagLineID)  | 
|     sceneMapID = tagMapID if not fbLineIpyData else fbLineIpyData.GetMapID()  | 
|     gameMap = GameWorld.GetMap(sceneMapID)  | 
|     if not gameMap:  | 
|         GameWorld.ErrLog("Ä¿±ê¸±±¾µØÍ¼²»´æÔÚ!tagMapID=%s,sceneMapID=%s" % (tagMapID, sceneMapID), curPlayer.GetPlayerID())  | 
|         return  | 
|       | 
|     # ×é¶Ó¸±±¾, ÓжÓÎéµÄÇé¿ö²ÅÑéÖ¤ÆäËû¶ÓÔ±¿É·ñ½øÈ룬·ñÔò´ú±íµ¥È˽øÈë  | 
|     if gameMap.GetMapFBType() == ChConfig.fbtTeam:  | 
|         PlayerTeam.OnEnterFBTeamAsk(curPlayer, PlayerTeam.TeamFBAskType_Enter, tagMapID, tagLineID, tick)  | 
|         return  | 
|       | 
|     #·âħ̳¸±±¾ÅжÏÀïÃæµÄBOSSÊÇ·ñµ½ÁËË¢ÐÂʱ¼ä  | 
|     if tagMapID in ChConfig.WorldBossFBMapIDList:  | 
|         bossID = mapInfo[2]  | 
|         if not GameWorldBoss.GetBossIsAliveOrCanReborn(bossID):  | 
|             return  | 
|           | 
|     elif tagMapID == ChConfig.Def_FBMapID_FamilyWar:  | 
|         if not GameWorldFamilyWar.CheckPlayerCanEnterFamilyWarFBMap(curPlayer):  | 
|             return  | 
|           | 
|     elif tagMapID == ChConfig.Def_FBMapID_FamilyBossMap:  | 
|         if not PlayerFamilyBoss.CheckIsFamilyBossFBOpen(curPlayer.GetFamilyID(), tagMapID):  | 
|             GameWorld.Log("EnterFBLine mapID=%s is familyBossFB, but is not open!" % tagMapID)  | 
|             return  | 
|     #ÊØÎÀÈ˻ʠÊÇ·ñÒÑ²Î¼Ó  | 
|     elif tagMapID == ChConfig.Def_FBMapID_FamilyInvade:  | 
|         if curPlayer.GetFamilyID() in PyGameData.g_swrhJoinRecord:  | 
|             PlayerControl.NotifyCode(curPlayer, "TheEmperor1")  | 
|             return  | 
|           | 
|     # MapServer_QueryPlayer(int srcPlayerID, int queryType, int queryID, int mapID, char *callName, char *cmd,WORD cmdLen, int RouteServerIndex)  | 
|     playerManager.MapServer_QueryPlayer(curPlayer.GetPlayerID(), ChConfig.queryType_EnterFB, 0, tagMapID,  | 
|                 queryCallName, sendCMD, len(sendCMD), curPlayer.GetRouteServerIndex())  | 
|     return  |