-
Notifications
You must be signed in to change notification settings - Fork 0
/
heroTimes.py
137 lines (94 loc) · 4.14 KB
/
heroTimes.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
import requests
from operator import itemgetter
import timeConvert, heroList
dpsTimes = []
tankTimes = []
supportTimes = []
response = requests.get('https://ow-api.com/v1/stats/pc/us/SkeeCoops-1827/complete')
profile = response.json()
#GETTING TOP HEROES OF THE USER
def getTopHeroes():
return profile['competitiveStats']['topHeroes']
#DPS ------------------------------------------------------------------------------------------------------------------------------------------------------
def getTopDPS():
heroTimeSeconds = []
for i in heroList.dpsList:
try:
if(len(profile['competitiveStats']['topHeroes'][i]['timePlayed']) > 5 ):
dpsTimes.append(profile['competitiveStats']['topHeroes'][i]['timePlayed'])
else:
dpsTimes.append("00:" + profile['competitiveStats']['topHeroes'][i]['timePlayed'])
except KeyError:
dpsTimes.append("00:00:00")
#Making the hero time in seconds list here:
for i in range(0, len(dpsTimes)):
heroTimeSeconds.append(int(timeConvert.totalSeconds(dpsTimes[i])))
#Making a list of lists
heroNameAndSeconds = list(zip(heroList.dpsList, heroTimeSeconds))
#new list called output that is sorted by the time list.
output = sorted(heroNameAndSeconds, key= itemgetter(1), reverse=True)
#2D ARRAY HAS BECOME SORTED
return output
def getTopTanks():
heroTimeSeconds = []
for i in heroList.tankList:
try:
if(len(profile['competitiveStats']['topHeroes'][i]['timePlayed']) > 5 ):
tankTimes.append(profile['competitiveStats']['topHeroes'][i]['timePlayed'])
else:
tankTimes.append("00:" + profile['competitiveStats']['topHeroes'][i]['timePlayed'])
except KeyError:
tankTimes.append("00:00:00")
#Making the hero time in seconds list here:
for i in range(0, len(tankTimes)):
heroTimeSeconds.append(int(timeConvert.totalSeconds(tankTimes[i])))
#Making a list of lists
heroNameAndSeconds = list(zip(heroList.tankList, heroTimeSeconds))
#new list called output that is sorted by the time list.
output = sorted(heroNameAndSeconds, key= itemgetter(1), reverse=True)
#2D ARRAY HAS BECOME SORTED
return output
def getTopSupports():
heroTimeSeconds = []
for i in heroList.supportList:
try:
if(len(profile['competitiveStats']['topHeroes'][i]['timePlayed']) > 5 ):
supportTimes.append(profile['competitiveStats']['topHeroes'][i]['timePlayed'])
else:
supportTimes.append("00:" + profile['competitiveStats']['topHeroes'][i]['timePlayed'])
except KeyError:
supportTimes.append("00:00:00")
#Making the hero time in seconds list here:
for i in range(0, len(supportTimes)):
heroTimeSeconds.append(int(timeConvert.totalSeconds(supportTimes[i])))
#Making a list of lists
heroNameAndSeconds = list(zip(heroList.supportList, heroTimeSeconds))
#new list called output that is sorted by the time list.
output = sorted(heroNameAndSeconds, key= itemgetter(1), reverse=True)
#2D ARRAY HAS BECOME SORTED
return output
def getTop3DPS():
sortedDPS = getTopDPS()
#for i in range(0, 2):
# top3DPS.append(str(i+1) +") "+ str(sortedDPS[i][0].capitalize()))
top3DPSMsg = ""
for i in range(0, 3):
top3DPSMsg = top3DPSMsg + str(i+1) + ") "+ str(sortedDPS[i][0].capitalize()) + "\n"
return top3DPSMsg
def getTop3Tanks():
sortedTanks = getTopTanks()
#for i in range(0, 2):
# top3Tanks.append(sortedTanks[i])
top3TankMsg = ""
for i in range(0, 3):
top3TankMsg = top3TankMsg + str(i+1) + ") "+ str(sortedTanks[i][0].capitalize()) + "\n"
return top3TankMsg
#returns a string with the top 3 in the role with the new lines in
def getTop3Support():
sortedSupports = getTopSupports()
#for i in range(0, 2):
# top3Support.append(sortedSupport[i])
top3SupportsMsg = ""
for i in range(0, 3):
top3SupportsMsg = top3SupportsMsg + str(i+1) + ") "+ str(sortedSupports[i][0].capitalize()) + "\n"
return top3SupportsMsg