-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
151 lines (129 loc) · 3.77 KB
/
player.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import sys
import json
QB = 'QB'
RB = 'RB'
WR = 'WR'
TE = 'TE'
DST = 'DST'
FLEX = 'FLEX'
class Player:
def __init__(self, position, name, salary, opposition, avgpts, games):
# Common
self.position = position
self.name = name
self.opposition = opposition
self.salary = salary
self.avgpts = avgpts
self.oppositionObj = None
self.games = games
self.team = ""
# Offense
# Passing
self.passing_td = 0
self.pass_yd = 0
self.interception = 0
self.attempts = 0
# Rushing
self.rush_td = 0
self.rush_yd = 0
self.rushes = 0
# Recieving
self.recv_td = 0
self.recv_yd = 0
self.recv = 0
self.targets = 0
self.fumbles = 0
# Defense
self.sack = 0
self.def_interception = 0
self.fumb_recovery = 0
self.def_touchdowns = 0
self.points_allowed = 0
self.safety = 0
self.pass_yd_allowed = 0
self.rush_yd_allowed = 0
# Total pts projected
self.fantasy_points = 0
def getContribution(self):
score = self.fumbles * -1
if self.position == QB:
score += self.scoreQB()
elif self.position == RB:
score += self.scoreRB()
elif self.position == WR:
score += self.scoreWR()
elif self.position == TE:
score += self.scoreWR()
elif self.position == DST:
score += self.scoreDST()
else:
print('you fucked up')
sys.exit(1)
if self.games == 0:
score = 0
self.fantasy_points = score
return score
def scoreQB(self):
score = self.scorePassing()
score += self.scoreRushing()
return score
def scoreRB(self):
score = self.scoreReceiving()
score += self.scoreRushing()
return score
def scoreWR(self):
score = self.scoreReceiving()
return score
def scorePassing(self):
score = self.passing_td * 4
score += self.pass_yd * .04
score += self.interception * -1
if self.pass_yd > 300:
score += 3
return score
def scoreRushing(self):
score = self.rush_td * 6
score += self.rush_yd * .1
if self.rush_yd > 100:
score += 3
return score
def scoreReceiving(self):
score = self.recv_yd * .1
score += self.recv_td * 6
score += self.recv * 1
if self.recv_yd > 100:
score += 3
return score
def scoreDST(self):
score = self.sack * 1
score += self.def_interception * 2
score += self.fumb_recovery * 2
score += self.def_touchdowns * 6
score += self.safety * 2
if self.points_allowed == 0:
score += 10
elif self.points_allowed <= 6:
score += 7
elif self.points_allowed <= 13:
score += 4
elif self.points_allowed <= 20:
score += 1
elif self.points_allowed <= 27:
score += 0
elif self.points_allowed <= 34:
score += -1
else:
score += -4
return score
def __str__(self):
return "name = " + self.name + " position = " + self.position + " salary = " + str(self.salary) + " pts = " + str(self.fantasy_points) + " $/pt = " + str(self.salary / self.fantasy_points) + " team = " + self.team
def to_dict(self):
d = {}
d['name'] = self.name
d['position'] = self.position
d['salary'] = self.salary
d['points'] = self.fantasy_points
d['team'] = self.team
if self.oppositionObj:
d['opposition'] = self.oppositionObj.name
return d