-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2468EPAMatches.py
More file actions
72 lines (69 loc) · 3.75 KB
/
Copy path2468EPAMatches.py
File metadata and controls
72 lines (69 loc) · 3.75 KB
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
from __future__ import print_function
import time
import tbaapiv3client
from tbaapiv3client.rest import ApiException
from pprint import pprint
import statbotics
# Defining the host is optional and defaults to https://www.thebluealliance.com/api/v3
# See configuration.py for a list of all supported configuration parameters.
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKey
configuration = tbaapiv3client.Configuration(
host = "https://www.thebluealliance.com/api/v3",
api_key = {
'X-TBA-Auth-Key': 'zpJtTjpTewSyKqYYnjTlzzmq6NzVpc4CrWZzwRrZQvsAoTE3BMnFxekqQkAj1d07'
}
)
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-TBA-Auth-Key'] = 'Bearer'
# Enter a context with an instance of the API client
with tbaapiv3client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance2 = tbaapiv3client.MatchApi(api_client)
api_instance = tbaapiv3client.EventApi(api_client)
team_key = 'frc2468' # str | TBA Team Key, eg `frc254` # str | TBA Event Key, eg `2016nytr`
listOfYears = [2022, 2023, 2024]
if_modified_since = 'if_modified_since_example'
sb = statbotics.Statbotics()
# str | Value of the `Last-Modified` header in the most recently cached response by the client. (optional)
list_of_matches_should_not_have_won = []
try:
for year in listOfYears:
api_response = api_instance.get_team_events_by_year(team_key,year,if_modified_since=if_modified_since)
listOfEvents = []
for val in api_response:
listOfEvents.append(val)
for event in listOfEvents:
api_response1 = api_instance.get_team_event_matches_keys(team_key, event.key,if_modified_since=if_modified_since)
for value in api_response1:
alliance = sb.get_team_match(2468,value)['alliance']
match_info = sb.get_match(value)
AllianceTeamsStation = [alliance+'_1', alliance+'_2', alliance+'_3']
EnemyAlliance = ''
if alliance == 'blue':
EnemyAlliance = 'red'
else:
EnemyAlliance = 'blue'
EnemyTeamsStation = [EnemyAlliance+'_1', EnemyAlliance+'_2', EnemyAlliance+'_3']
EnemyTeams = [match_info[EnemyTeamsStation[0]], match_info[EnemyTeamsStation[1]], match_info[EnemyTeamsStation[2]]]
AllianceTeams = [match_info[AllianceTeamsStation[0]], match_info[AllianceTeamsStation[1]], match_info[AllianceTeamsStation[2]]]
#print(AllianceTeams, " Alliance")
#print(EnemyTeams, "Enemy")
AllianceEPA = 0
EnemyEPA = 0
for team in AllianceTeams:
AllianceEPA += sb.get_team_year(team, year)['epa_end']
for team in EnemyTeams:
EnemyEPA += sb.get_team_year(team, year)['epa_end']
EPADifference = AllianceEPA - EnemyEPA
#print(EPADifference)
if EPADifference >= 0:
print("We won when we shouldn't have on in match: ", value)
list_of_matches_should_not_have_won.append(value)
except ApiException as e:
print("Exception when calling EventApi->get_team_event_matches: %s\n" % e)
for match in list_of_matches_should_not_have_won:
pprint("We won with a lower avg final Alliance EPA in: "+match+", ")