forked from balance-simc/Balance-SimC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_apl.py
executable file
·76 lines (53 loc) · 1.84 KB
/
generate_apl.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
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('simcpath', type=str, help='path to SimC root (include \\simc)')
args = parser.parse_args()
simc_path = args.simcpath
cpp_path = os.path.join(simc_path, 'engine', 'class_modules', 'sc_druid.cpp')
apl_lists = {}
with open('balance.txt', 'r') as apl_file:
for line in apl_file:
if line.startswith('actions') == False:
continue
apl = 'default'
split_ = line.split('=', 1)
pref = split_[0].rstrip('+')
suf = split_[1].lstrip('/').rstrip('\n')
if suf == 'flask' or suf == 'food' or suf == 'augmentation' or suf == 'snapshot_stats':
continue
pref_apl_ = pref.split('.')
if len(pref_apl_) > 1:
apl = pref_apl_[1]
if apl not in apl_lists:
apl_lists[apl] = []
apl_lists[apl].append(suf)
marker_start = '### BALANCE_APL_START ###'
marker_end = '### BALANCE_APL_END ###'
cpp_old = open(cpp_path, 'r')
cpp_new = open(cpp_path + '__', 'w')
state = 0
for line in cpp_old:
if marker_end in line:
state = 0
if state == 0:
cpp_new.write(line)
if marker_start in line:
state = 2
if state == 2:
state = 1
for apl in apl_lists.keys():
apl_var = apl
if apl_var == 'default':
apl_var = 'def'
cpp_new.write(' action_priority_list_t* ' + apl_var + ' = get_action_priority_list( \"' + apl + '\" );\n')
for apl in apl_lists.keys():
apl_var = apl
if apl_var == 'default':
apl_var = 'def'
cpp_new.write('\n')
for action in apl_lists[apl]:
cpp_new.write(' ' + apl_var + '->add_action( \"' + action + '\" );\n')
cpp_new.close()
cpp_old.close()
os.replace(cpp_path + '__', cpp_path)