-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayList.py
74 lines (62 loc) · 2.4 KB
/
PlayList.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
# Skout - Flagfootball Scouting Analysis Tool
# Copyright (C) 2021 Xaver Klemenschits
# See LICENSE.txt for details
from Route import Route, RouteList
class PlayList:
def __init__(self):
self.routes = []
self.formations = []
self.downs = []
self.sides = []
self.clipNumbers = []
self.progression = []
self.intRec = []
self.distance = []
self.notes = []
def setTeamNames(self, home, away):
self.homeTeam = home
self.awayTeam = away
def setDate(self, date):
self.date = date
def setScore(self, home, away):
self.homeScore = home
self.awayScore = away
def addPlays(self, dict):
for play in dict:
routes = []
for i in range(4):
routes.append(Route(play['routes'][i]))
self.routes.append(RouteList(routes))
self.formations.append(play['formation'])
self.downs.append(play['down'])
self.sides.append(play['strongside'])
# optional fields
self.clipNumbers.append(play.get('clipnumber', ''))
self.progression.append(play.get('yardsTotal', ''))
self.intRec.append(play.get('intendedReceiver', '').upper())
self.distance.append(play.get('distance', ''))
self.notes.append(play.get('notes', ''))
def printAllPlays(self):
for i in range(len(self.routes)):
print("Routes: {}, formation: {}, down: {}, strongside: {}".format(
self.routes[i], self.formations[i], self.downs[i], self.sides[i]))
def swapEntry(self, i, j, swappable):
swappable[i], swappable[j] = swappable[j], swappable[i]
def swapEntries(self, i, j):
self.swapEntry(i, j, self.routes)
self.swapEntry(i, j, self.formations)
self.swapEntry(i, j, self.downs)
self.swapEntry(i, j, self.sides)
self.swapEntry(i, j, self.clipNumbers)
self.swapEntry(i, j, self.progression)
self.swapEntry(i, j, self.intRec)
self.swapEntry(i, j, self.distance)
self.swapEntry(i, j, self.notes)
def sort(self):
n = len(self.routes)
# traverse from front
for i in range(n-1):
# last elements are already in place
for j in range(n-i-1):
if(self.routes[j] < self.routes[j+1]):
self.swapEntries(j, j+1)