| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| # @todo:   | 
| #  | 
| # @author: Alee  | 
| # @date 2017-12-29 ÏÂÎç02:02:23  | 
| # @version 1.0  | 
| #  | 
| # @note: ¹¹½¨¹¤¾ßÐèͬ²½´Ë±í  | 
| #  | 
| #---------------------------------------------------------------------  | 
| import CommFunc  | 
| import logging  | 
| import ConfigurationReader.ConfigIniReader   | 
|   | 
|   | 
| # 1. ¹¹½¨±í  | 
|   | 
|           | 
| class ChinMapData():  | 
|     def __init__(self):  | 
|         #MapID    Name    Country    LV    ExistTime    MapFBType    AutoSize    Period    PeriodValue1    PeriodHour1      | 
|         #PeriodMinute1    PeriodValue2    PeriodHour2    PeriodMinute2    LocalReborn    SkillReborn    RebornMap      | 
|         #RebornMapX    RebornMapY    CanRide    CanOutPet    TreasureID  | 
|         self.MapID = 0  | 
|         self.LV = 0      | 
|         self.TreasureID = 0    | 
|         self.MapFBType = 0    | 
|   | 
|     def ReadFromList(self, curList):  | 
|         self.MapID = CommFunc.ToIntDef(curList[0])  | 
|         self.LV = CommFunc.ToIntDef(curList[3])  | 
|         self.MapFBType = CommFunc.ToIntDef(curList[5])  | 
|         self.TreasureID = CommFunc.ToIntDef(curList[21])  | 
|   | 
|           | 
|         return  | 
|       | 
|       | 
| class ChinMapDataMgr():  | 
|     def __init__(self):  | 
|         self.__Table = []  | 
|           | 
|     def InitTable(self, tablePath):  | 
|         fileIO = open(tablePath, "r")  | 
|         lines = fileIO.readlines()  | 
|           | 
|         linenum = 0  | 
|         for line in lines:  | 
|             linenum += 1  | 
|             # 1.×Ö¶ÎÃû   | 
|             if linenum <= 1:  | 
|                 continue  | 
|             classObj = ChinMapData()  | 
|             lineList = line.split('\t')  | 
|             classObj.ReadFromList(lineList)  | 
|   | 
|             self.__Table.append(classObj)  | 
|               | 
|     def FindMaxMapID(self, lv, fbID):  | 
|         maxMapID = self.__Table[0].MapID    # Ä¬ÈϵÚÒ»ÕŵØÍ¼  | 
|         for mapData in self.__Table:  | 
|   | 
|             # 10000¿ªÍ·ÎªÒ°Íâ¹Ò»úµØÍ¼  | 
|             if mapData.MapID/10000 != 1:  | 
|                 continue  | 
|               | 
|             if lv < mapData.LV:  | 
|                 continue  | 
|               | 
|             if mapData.TreasureID != 0 and fbID < mapData.TreasureID:  | 
|                 continue  | 
|               | 
|             maxMapID = max(mapData.MapID, maxMapID)  | 
|           | 
|         return maxMapID  | 
|           | 
|     def FindMapByID(self, mapID):  | 
|         for mapData in self.__Table:  | 
|             if mapData.MapID != mapID:  | 
|                 continue  | 
|               | 
|             return mapData  | 
|           | 
| __gChinMapDataReader = None  | 
|   | 
| def ReadChinMapData( PyBaseRoot):  | 
|     global __gChinMapDataReader  | 
|     config =  ConfigurationReader.ConfigIniReader.GetConfig()  | 
|     ServerDBConfigPath = config.GetServerDBConfigPath()    #Êý¾Ý¿â·¾¶  | 
|       | 
|     if not __gChinMapDataReader:  | 
|         __gChinMapDataReader =  ChinMapDataMgr()  | 
|         __gChinMapDataReader.InitTable(ServerDBConfigPath + r"\SysDB\tagChinMap.txt")  | 
|           | 
| def GetChinMapData():  | 
|     global __gChinMapDataReader  | 
|     return __gChinMapDataReader  |