Skip to content

Instantly share code, notes, and snippets.

@waprin
Created August 12, 2018 23:27
Show Gist options
  • Save waprin/b392c213e3ae868fc212c6516d913e30 to your computer and use it in GitHub Desktop.
Save waprin/b392c213e3ae868fc212c6516d913e30 to your computer and use it in GitHub Desktop.
process the liquid matches
class Match:
def __init__(self, match, liquid_win):
self.match = match
self.liquid_win=liquid_win
self.liquid_picks = []
self.liquid_bans = []
self.opponent_picks = []
self.opponent_bans = []
names = {}
with open('heroes.json') as f:
data = json.load(f)
for h in data:
names[h['id']] = h['localized_name']
def process_match(match):
try:
liquid_dire = match['dire_team']['team_id'] == 2163
except:
liquid_dire = match['dire_team_id'] == 2163
if liquid_dire:
liquid_win = not match['radiant_win']
else:
liquid_win = match['radiant_win']
m = Match(match['match_id'], liquid_win)
for pb in match['picks_bans']:
if pb['team'] == liquid_dire and pb['is_pick']:
m.liquid_picks.append(names[pb['hero_id']])
if pb['team'] == liquid_dire and not pb['is_pick']:
m.liquid_bans.append(names[pb['hero_id']])
if pb['team'] != liquid_dire and pb['is_pick']:
m.opponent_picks.append(names[pb['hero_id']])
if pb['team'] != liquid_dire and not pb['is_pick']:
m.opponent_bans.append(names[pb['hero_id']])
return m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment