forked from moeheart/jx3bla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReplayBase.py
56 lines (45 loc) · 1.87 KB
/
ReplayBase.py
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
# Created by moeheart at 10/11/2020
# 复盘相关方法的基类库。
from tools.Functions import *
from tools.LoadData import *
from tools.Names import *
class StatGeneratorBase():
filename = ""
rawdata = {}
bossname = ""
battleTime = 0
def parseFile(self, path):
if path == "":
name = self.filename
else:
name = "%s/%s" % (path, self.filename)
print("读取文件:%s" % name)
f = open(name, "r", encoding='gbk')
s = f.read()
if self.window is not None:
bossname = getNickToBoss(self.filename.split('_')[1])
self.window.setNotice({"t1": "正在读取[%s]..."%bossname, "c1": "#000000"})
luatableAnalyser = LuaTableAnalyser(self.window)
res = luatableAnalyser.analyse(s)
self.rawdata = res
luatableAnalyser2 = LuaTableAnalyserToDict(self.window)
res2 = luatableAnalyser2.analyse(s)
self.formatData = res2
if '9' not in self.rawdata:
if len(self.rawdata['']) == 17:
for i in range(1, 17):
self.rawdata[str(i)] = [self.rawdata[''][i - 1]]
else:
raise Exception("数据不完整,无法生成,请确认是否生成了正确的茗伊战斗复盘记录。")
self.bossname = getNickToBoss(self.filename.split('_')[1])
self.battleTime = int(self.filename.split('_')[2].split('.')[0])
def __init__(self, filename, path="", rawdata={}, window = None):
self.window = window
if rawdata == {}:
self.filename = filename
self.parseFile(path)
else:
self.filename = filename
self.rawdata = rawdata
self.bossname = getNickToBoss(self.filename.split('_')[1])
self.battleTime = int(self.filename.split('_')[2].split('.')[0])