-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate_combo.py
executable file
·330 lines (284 loc) · 10.8 KB
/
generate_combo.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import requests
import time
import argparse
import json
import sys
from itertools import combinations
post_url = 'https://www.raidbots.com/sim'
get_url = 'https://www.raidbots.com/api/job/'
report_url = 'https://www.raidbots.com/simbot/report/'
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')
parser.add_argument('-d', '--dungeon', default=False, action='store_true')
parser.add_argument('-m', '--move', default=False, action='store_true')
parser.add_argument('-s', '--spread', default=False, action='store_true')
parser.add_argument('-r', '--raid', type=str, nargs='?', default='mythic', const='mythic', choices=['mythic', 'heroic', 'ptr'])
args = parser.parse_args()
targets = str(max(1, args.targets))
def is_H():
return args.raid == 'heroic'
def is_M():
return args.raid == 'mythic'
def is_PTR():
return args.raid == 'ptr'
def getJSON(url):
while(True):
try:
get = requests.get(url)
status = get.json()
except:
time.sleep(3)
continue
return status
profile_base = apl = dungeon = move = spread = ""
apl_txt = 'balance.txt'
if is_PTR():
profile_txt = 'sandbag_ptr_base.txt'
apl_txt = 'balance_ptr.txt'
elif is_H():
profile_txt = 'sandbag_h_base.txt'
else:
profile_txt = 'sandbag_base.txt'
with open(profile_txt, 'r') as fp:
profile_base = fp.read()
with open(apl_txt, 'r') as fp:
apl = fp.read()
with open('composite.txt', 'r') as fp:
dungeon = fp.read()
with open('move.txt', 'r') as fp:
move = fp.read()
with open('spread.txt', 'r') as fp:
spread = fp.read()
talents = [
['NB ', 'WOE', 'FON'],
['SOTF', 'SL ', 'INC '],
['TM', 'SD', 'SF'],
['SOL', 'FOE', 'NM ']
]
legendaries = {
'boat': 'feet=,id=172315,bonus_id=7107/6648/6649/6758/',
'dream': 'finger1=,id=178926,gems=16mastery,enchant=tenet_of_haste,bonus_id=7108/6716/7193/6648/6649/',
'oneth': 'back=,id=173242,bonus_id=6716/7087/6649/6648/',
'pulsar': 'finger1=,id=178926,gems=16mastery,enchant=tenet_of_haste,bonus_id=7088/6716/7193/6648/6649/',
#'lycaras':'waist=,id=172320,gems=16mastery,bonus_id=6716/7110/6649/6648/',
#'draught': 'neck=,id=178927,gems=16mastery,bonus_id=7086/6716/7193/6648/6649/',
#'eonar':'waist=,id=172320,gems=16mastery,bonus_id=7100/6716/7194/6648/6649/',
'circle': 'finger1=,id=178926,gems=16mastery,enchant=tenet_of_haste,bonus_id=7085/6716/7193/6648/6649/',
'covenant': {
'kyrian': 'waist=,id=172320,gems=16mastery,bonus_id=7477/6716/7194/6648/6649/',
'necrolord': 'waist=,id=172320,gems=16mastery,bonus_id=7472/6716/7194/6648/6649/',
'night_fae': 'waist=,id=172320,gems=16mastery,bonus_id=7571/6716/7194/6648/6649/',
'venthyr': 'waist=,id=172320,gems=16mastery,bonus_id=7474/6716/7194/6648/6649/'
}
}
def legendaries_suffix():
if is_H():
return '1559'
else:
return '1588'
conduits = [
'fury_of_the_skies:',
'umbral_intensity:',
'precise_alignment:',
'stellar_inspiration:'
]
cov_conduit = {
'kyrian': 'deep_allegiance:',
'necrolord': 'evolved_swarm:',
'night_fae': 'conflux_of_elements:',
'venthyr': 'endless_thirst:'
}
def conduit_suffix():
if is_H():
return '11'
else:
return '13'
covenants = {
'kyrian': {
'pelagos': {
'base': 'combat_meditation/better_together',
'add': 'newfound_resolve',
'trait': []
},
'kleia': {
'base': 'spear_of_the_archon',
'add': 'light_the_path',
'trait': ['pointed_courage']
},
'mikanikos': {
'base': 'brons_call_to_action/soulglow_spectrometer',
'add': 'effusive_anima_accelerator',
'trait': ['hammer_of_genesis']
}
},
'necrolord': {
'marileth': {
'base': 'volatile_solvent',
'add': 'kevins_oozeling',
'trait': ['plagueys_preemptive_strike']
},
'emeni': {
'base': 'lead_by_example',
'add': 'pustule_eruption',
'trait': ['gnashing_chompers']
},
'heirmir': {
'base': 'forgeborne_reveries/carvers_eye',
'add': 'mnemonic_equipment',
'trait': ['heirmirs_arsenal_marrowed_gemstone']
}
},
'night_fae': {
'niya': {
'base': 'grove_invigoration',
'add': 'bonded_hearts',
'trait': ['niyas_tools_burrs']
},
'dreamweaver': {
'base': 'field_of_blossoms',
'add': 'dream_delver',
'trait': ['social_butterfly']
},
'korayn': {
'base': 'wild_hunt_tactics',
'add': 'wild_hunt_strategem',
'trait': ['first_strike']
}
},
'venthyr': {
'nadjia': {
'base': 'thrill_seeker',
'add': 'fatal_flaw',
'trait': ['exacting_preparation', 'dauntless_duelist']
},
'theotar': {
'base': 'soothing_shade',
'add': 'party_favors',
'trait': ['refined_palate', 'wasteland_propriety']
},
'draven': {
'base': '',
'add': 'battlefield_presence',
'trait': ['built_for_war']
}
}
}
if args.dungeon:
target_str = dungeon
elif args.spread:
target_str = spread
else:
target_str = 'desired_targets=' + targets
if args.move:
target_str += '\n' + move
if args.dungeon:
stages = [1.2, 0.5, 0.2]
else:
stages = [1.0, 0.3, 0.1]
buffer = []
for cov, soulbinds in covenants.items():
cov_str = 'covenant=' + cov
for leg, leg_str in legendaries.items():
# split for covenant legis
if leg == 'covenant':
if is_M():
continue
leg_str = leg_str[cov]
leg_str += legendaries_suffix()
profile = profile_base
for soul, traits in soulbinds.items():
sets_list = []
name_str = 'name=' + '-'.join([cov, leg, soul])
soulbind_master = []
if traits['base']:
soulbind_master.append(traits['base'])
if traits['add']:
soulbind_master.append(traits['add'])
conduits_master = conduits.copy()
conduits_master.append(cov_conduit[cov])
conduits_master = [c + conduit_suffix() for c in conduits_master]
for t in traits['trait']:
conduits_master.append(t)
for combo in combinations(conduits_master, 3):
cond1, cond2, cond3 = combo
if all(set(traits['trait']) & set(subcombo) for subcombo in combinations([cond1, cond2, cond3], 2)):
continue
soulbind_list = soulbind_master.copy()
soulbind_list.append(cond1)
soulbind_list.append(cond2)
soulbind_list.append(cond3)
soulbind_str = 'soulbind=' + '/'.join(soulbind_list)
for t15, talent15 in enumerate(talents[0], 1):
for t40, talent40 in enumerate(talents[1], 1):
for t45, talent45 in enumerate(talents[2], 1):
for t50, talent50 in enumerate(talents[3], 1):
talent = str(t15) + '000' + str(t40) + str(t45) + str(t50)
talent_str = 'talents=' + talent
profile_name = '\"' + '-'.join([cond1, cond2, cond3, talent]) + '\"'
sets_list.append('profileset.' + profile_name + '=' + talent_str)
sets_list.append('profileset.' + profile_name + '+=' + soulbind_str)
sets_str = '\n'.join(sets_list)
simc = '\n'.join([profile, apl, leg_str, cov_str, name_str, target_str, sets_str])
payload = {'type': 'advanced', 'apiKey': args.apikey, 'simcVersion': 'nightly','smartStages': stages, 'advancedInput': simc}
while True:
time.sleep(3)
try:
post = requests.post(post_url, json=payload)
except:
continue
if post.status_code == 400:
sys.exit('Input Error. Return code {}'.format(post.status_code))
if post.status_code == 401:
sys.exit('Invalid API key. Return code {}'.format(post.status_code))
if post.status_code >= 500:
print('something went horribly wrong (or not). Return code {}'.format(post.status_code))
continue
if post.status_code == 429:
print('Rate limited. Return code {}'.format(post.status_code))
continue
if post.status_code == 200:
reply = post.json()
simID = reply['simId']
sim_url = report_url + simID
print(sim_url)
break
print('Unknown status code. Return code {}'.format(post.status_code))
continue
counter = 0
while True:
time.sleep(3)
status = getJSON(get_url + simID)
if ('message' in status and status['message'] == 'No job found') or ('job' not in status):
counter += 1
if counter >= 10:
sys.exit("The sim got lost after {} tries :( {}".format(counter, simID))
continue
if status['job']['state'] == 'complete':
results = getJSON(sim_url + '/data.json')
if 'error'in results:
sys.exit('Sim failed with error {}'.format(results['error']['type']))
if 'hasFullJson' in results['simbot'] and results['simbot']['hasFullJson']:
results = getJSON(sim_url + '/data.full.json')
break
cov_key, leg_key, soul_key = results['sim']['players'][0]['name'].split('-')
for actor in results['sim']['profilesets']['results']:
cond1_key, cond2_key, cond3_key, tal_key = actor['name'].split('-')
dps_key = actor['mean']
buffer.append({'cov': cov_key, 'leg': leg_key, 'soul': soul_key, 'cond1': cond1_key, 'cond2': cond2_key, 'cond3': cond3_key, 'tal': tal_key, 'dps': dps_key})
json_name = 'combo_'
if is_H():
json_name += 'h_'
elif is_PTR():
json_name += 'ptr_'
if args.dungeon:
json_name += 'd'
elif args.spread:
json_name += 's'
else:
json_name += targets
if args.move:
json_name += 'm'
with open(json_name + '.json', 'w') as fp:
fp.write(json.dumps(buffer).replace('},', '},\n'))