hxp
4 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/python
# -*- coding: GBK -*-
#
# @todo: 
#
# @author: Alee
# @date 2017-12-29 ÏÂÎç02:02:23
# @version 1.0
#
# @note: ¹¹½¨¹¤¾ßÐèͬ²½´Ë±í
#
#---------------------------------------------------------------------
import CommFunc
import logging
# 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 = eval(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 fbID < mapData.TreasureID:
                continue
            
            maxMapID = mapData.MapID
        
        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
    if not __gChinMapDataReader:
        __gChinMapDataReader =  ChinMapDataMgr()
        __gChinMapDataReader.InitTable(PyBaseRoot + "Data\\tagChinMap.txt")
        
def GetChinMapData():
    global __gChinMapDataReader
    return __gChinMapDataReader