-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
30 lines (23 loc) · 877 Bytes
/
util.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
import json
from champion import Champion
def parse_mastery_response(mastery_response, field_name):
counter = 0
for champion in mastery_response:
counter += champion[field_name]
return counter
def parse_summoner_response(summoner_response, field_name):
return json.loads(summoner_response.content)[field_name]
def championBootstrap():
champions = []
#TODO: we should find a better way to include this resource
with open('./resources/champion.json') as champion_file:
body = json.load(champion_file)
for champ_name, championData in body["data"].items():
champion = Champion(championData)
champions.append((champion.id, champion))
# goofy check to make sure that we have a lot of champions loaded
if (len(champions) > 100):
print("Bootstrapped Champions Successfully")
else:
raise RuntimeError("Error bootstrapping champion data")
return champions