-
Notifications
You must be signed in to change notification settings - Fork 1
/
nfk_stats.py
79 lines (67 loc) · 2.59 KB
/
nfk_stats.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
import requests
def tdm_maps():
'''Функция показывает количество игр, сыгранных на ТДМ картах'''
url = 'https://stats.needforkill.ru/api.php?action=matches&skip=0&take=300'
response = requests.get(url)
matches = response.json()
maps_tdm = []
for match in matches:
if match['gameType'] == 'TDM':
maps_tdm.append(match['map'])
if len(maps_tdm) == 0:
return 'No games were found, asshole.'
maps_played_TDM = {}
for map in maps_tdm:
if map not in maps_played_TDM:
maps_played_TDM[map] = 1
else:
maps_played_TDM[map] += 1
maps_TDM_overall = []
for i in sorted(maps_played_TDM.items(),
key=lambda pair: (pair[1])):
maps_TDM_overall.append(i)
return maps_TDM_overall[::-1]
def ctf_maps():
'''Функция показывает количество игр, сыгранных на КТФ картах'''
url = 'https://stats.needforkill.ru/api.php?action=matches&skip=0&take=200'
response = requests.get(url)
matches = response.json()
maps_ctf = []
for match in matches:
if match['gameType'] == 'CTF':
maps_ctf.append(match['map'])
if len(maps_ctf) == 0:
return 'No games were found, asshole.'
maps_played_CTF = {}
for map in maps_ctf:
if map not in maps_played_CTF:
maps_played_CTF[map] = 1
else:
maps_played_CTF[map] += 1
maps_CTF_overall = []
for i in sorted(maps_played_CTF.items(),
key=lambda pair: (pair[1])):
maps_CTF_overall.append(i)
return maps_CTF_overall[::-1]
def duel_maps():
'''Функция показывает количество игр, сыгранных на 1в1 картах'''
url = 'https://stats.needforkill.ru/api.php?action=matches&skip=0&take=100'
response = requests.get(url)
matches = response.json()
maps_duel = []
for match in matches:
if match['gameType'] == 'DUEL':
maps_duel.append(match['map'])
if len(maps_duel) == 0:
return 'No games were found, asshole.'
maps_played_DUEL = {}
for map in maps_duel:
if map not in maps_played_DUEL:
maps_played_DUEL[map] = 1
else:
maps_played_DUEL[map] += 1
maps_DUEL_overall = []
for i in sorted(maps_played_DUEL.items(),
key=lambda pair: (pair[1])):
maps_DUEL_overall.append(i)
return maps_DUEL_overall[::-1]