-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchessUtil.py
38 lines (24 loc) · 1014 Bytes
/
chessUtil.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
import requests
from chessApi import *
chess_url = "https://api.chess.com/"
def getBoardResultsFromPlayer(match, n_team, player):
players = match['teams'][f'team{n_team}']['players']
for player_c in players:
if player_c['username'] == player:
board = getBoardfromLink(player_c['board'])
return float(board['board_scores'][player])
def getTeamNameFromMatch(match, n_team):
return match['teams'][f'team{n_team}']['name']
def getPlayersUsernamesFromTeam(team):
return [player['username'] for player in team['players']]
def getPlayersFromMatch(match):
players = {}
players[getTeamNameFromMatch(match, 1)] = getPlayersUsernamesFromTeam(match['teams']['team1'])
players[getTeamNameFromMatch(match, 2)] = getPlayersUsernamesFromTeam(match['teams']['team2'])
return players
def getResultsFromMatch(match):
return [match['teams']['team1']['score'], match['teams']['team2']['score']]
def main():
pass
if __name__ == '__main__':
main()