Last active
November 20, 2016 00:43
-
-
Save houbysoft/ad9704cf1bdb951c8d37e02c5176ead5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import nflgame | |
def fantasy_points(p, site='draftkings', player_type='offensive'): | |
assert player_type == 'offensive' | |
assert site == 'draftkings' | |
score = 0.0 | |
# Passing TD +4PTs | |
score += 4.00 * value_or_zero(p, 'passing_tds') | |
# +0.04PT per passing yard | |
score += 0.04 * value_or_zero(p, 'passing_yds') | |
# TODO: 300+ yard passing game +3PTs | |
# Interception -1PT | |
score -= 1.00 * value_or_zero(p, 'passing_ints') | |
# +0.1PT per rushing yard | |
score += 0.10 * value_or_zero(p, 'rushing_yds') | |
# Rushing TD +6 PTs | |
score += 6.00 * value_or_zero(p, 'rushing_tds') | |
# TODO: 100+ yard rushing game +3PTs | |
# +0.1PT per receiving yard | |
score += 0.10 * value_or_zero(p, 'receiving_yds') | |
# +1PT per reception | |
score += 1.00 * value_or_zero(p, 'receiving_rec') | |
# Receiving TD | |
score += 6.00 * value_or_zero(p, 'receiving_tds') | |
# TODO 100+ yard receiving game +3 PTs | |
# punt/kickoff return/FG return for TD +6 PTs | |
score += 6.00 * (value_or_zero(p, 'puntret_tds') + value_or_zero(p, 'kickret_tds')) | |
# Fumble lost | |
score -= 1.00 * value_or_zero(p, 'fumbles_lost') | |
# 2 Point conversion (pass, run, or catch) +2 PTs | |
score += 2.00 * (value_or_zero(p, 'passing_twoptm') + value_or_zero(p, 'rushing_twoptm') + value_or_zero(p, 'receiving_twoptm')) | |
# Offensive Fumble Recovery TD +6 PTs | |
score += 6.00 * value_or_zero(p, 'fumbles_trcv') | |
return score | |
def value_or_zero(p, k): | |
if k in p.stats: | |
return p.stats[k] | |
else: | |
return 0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment