forked from ArkMowers/arknights-mower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_update.py
124 lines (103 loc) · 3.58 KB
/
data_update.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import json
import os
import fontforge
import requests
proxies = {'http': 'http://localhost:11223'}
datadir = 'arknights_mower/data/'
GitHubURL = 'https://raw.githubusercontent.com/Kengxxiao/ArknightsGameData/master/zh_CN/gamedata/'
def dump(data, filename):
with open(datadir + filename, 'w') as f:
json.dump(data, f, ensure_ascii=False, indent=4, default=str)
def requests_get(path):
return requests.get(GitHubURL + path, proxies=proxies).text
agent = []
character_table = json.loads(requests_get('excel/character_table.json'))
for x in character_table.values():
if x['displayNumber'] is not None:
agent.append(x['name'].strip())
dump(agent, 'agent.json')
agent_charset = set(''.join(agent))
Chinese, unChinese = [], []
for c in agent_charset:
if ord(c) < 256:
unChinese.append(c)
else:
Chinese.append(c)
with open('build/Chinese.txt', 'w') as f:
f.write(''.join(Chinese))
with open('build/unChinese.txt', 'w') as f:
f.write(''.join(unChinese))
command = 'java.exe -jar FontPruner/sfnttool.jar -c build/Chinese.txt build/unChinese.txt FontPruner/SourceHanSansSC-Bold.ttf build/SourceHanSansSC-Bold.ttf'
if os.system(command) is False:
raise Exception('build new font error!' + command)
ttf_file = 'build/SourceHanSansSC-Bold.ttf'
otf_file = 'arknights_mower/fonts/SourceHanSansSC-Bold.otf'
font = fontforge.open(ttf_file)
font.generate(otf_file)
font.close()
chapter = []
chapter_table = json.loads(requests_get('excel/chapter_table.json'))
for x in chapter_table.values():
chapter.append(x['chapterName2'])
dump(chapter, 'chapter.json')
level = {}
zone = {}
zone_table = json.loads(requests_get('excel/zone_table.json'))
chapterIndex = -1
for x in zone_table['zones'].values():
if x['type'] == 'MAINLINE':
if x['zoneIndex'] == 0:
chapterIndex += 1
zone[x['zoneID']] = {
'type': x['type'],
'name': x['zoneNameSecond'],
'chapterIndex': chapterIndex,
'zoneIndex': int(x['zoneID'].split('_')[1]),
}
elif x['type'] == 'WEEKLY':
zone[x['zoneID']] = {
'type': x['type'],
'name': x['zoneNameSecond'],
'chapterIndex': None,
'zoneIndex': None,
}
stage_table = json.loads(requests_get('excel/stage_table.json'))
for x in stage_table['stages'].values():
if (
x['zoneId'] in zone.keys()
and x['canBattleReplay']
and not x['levelId'].startswith('Activities')
):
level[x['code']] = {
'zone_id': x['zoneId'],
'ap_cost': x['apCost'],
'code': x['code'],
'name': x['name'],
}
retro_table = json.loads(requests_get('excel/retro_table.json'))
for x in retro_table['retroActList'].values():
if x['type'] == 1:
zone[x['retroId']] = {
'type': 'BRANCHLINE',
'name': x['name'],
'chapterIndex': None,
'zoneIndex': x['index'],
}
elif x['type'] == 0:
zone[x['retroId']] = {
'type': 'SIDESTORY',
'name': x['name'],
'chapterIndex': None,
'zoneIndex': x['index'],
}
zoneToRetro = retro_table['zoneToRetro']
for x in retro_table['stageList'].values():
if x['hardStagedId'] is None and x['canBattleReplay'] and x['zoneId'].endswith('1') and x['zoneId'] in zoneToRetro.keys():
level[x['code']] = {
'zone_id': zoneToRetro[x['zoneId']],
'ap_cost': x['apCost'],
'code': x['code'],
'name': x['name'],
}
dump(zone, 'zone.json')
dump(level, 'level.json')