-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_by_talent.py
78 lines (61 loc) · 2.57 KB
/
generate_by_talent.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
import requests
import time
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('apikey', type=str, help='raidbots apikey')
#parser.add_argument('-t', '--targets', type=int, nargs='?', default=1, const=1, help='set desired sim targets')
args = parser.parse_args()
apikey = args.apikey
#with open('apikey', 'r') as fp: apikey = fp.read()
#targets = str(args.targets)
post_url = 'https://mimiron.raidbots.com/sim'
get_url = 'https://mimiron.raidbots.com/api/job/'
report_url = 'https://mimiron.raidbots.com/simbot/report/'
clean_url = 'https://www.raidbots.com/reports/'
profile = apl = combo = sets = ""
jso = {}
with open('sandbag.txt', 'r') as fp:
profile = fp.read()
with open('balance.txt', 'r') as fp:
apl = fp.read()
with open('leg_x_cov.txt', 'r') as fp:
combo = fp.read()
sets = open('talent_profiles.txt', 'r')
betabot = open('by_talent.html', 'w')
betabot.write('<html><script>function newlink(e) {if (e.target.tagName === \'A\') {parent.setTitle(e.target.textContent.substring(0, 15));}} document.addEventListener(\'click\', newlink, false);</script><style>body {margin-left:0; margin-right:0} a {color:#FF7D0A; text-decoration:none; font-family:monospace; font-size:large;}</style><body><div style=\"columns:5;\"><div style=\"display:inline-block;\">\n')
for line in sets:
if line == '\n':
html = '</div><div style=\"display: inline-block;\">\n'
betabot.write(html)
continue
splits = line.split('=', 1)
talent = splits[-1]
name = splits[0].split('.')[-1]
simc = profile + '\ntarget_error=0.1\n' + talent + '\n' + apl + '\n' + 'name=' + name + '\n\n' + combo
post = requests.post(post_url, json={'type': 'advanced', 'apiKey': apikey, 'advancedInput': simc})
reply = post.json()
simID = reply['simId']
sim_url = report_url + simID
print(sim_url)
time.sleep(5)
while True:
get = requests.get(get_url + simID)
status = get.json()
time.sleep(5)
if (status['job']['state'] == 'complete'):
break
data = requests.get(sim_url + '/data.json')
result = data.json()
dps_list = []
for actor in result['sim']['players']:
dps_list.append(actor['collected_data']['dps']['mean'])
dps_max = max(dps_list)
name = name.strip('\"')
html = '<div><a href=\"' + clean_url + simID + '/index.html\">' + name + ' ' + f'{dps_max:.2f}' + '</a></div>\n'
betabot.write(html)
jso[name] = simID
betabot.write('</div></div></body></html>\n')
betabot.close()
sets.close()
with open('jso.js', 'w') as fp:
fp.write('var jso =' + str(jso) + ';')