private void DumpCalculations(bool isHome, NFLGame game, int tdr, string pr, string pp, string ro, int tds, int tdd, string rd, string oppRatings, string teamRatings, int ppr, int tdp, int score, string pd, string po, int fg) { var team = isHome ? game.HomeTeamName : game.AwayTeamName; Announce(string.Format("team {2} Ratings : {0}-{3} opponentRatings {1}-{4}", teamRatings, oppRatings, team, Utility.RatingPts(teamRatings), Utility.RatingPts(oppRatings))); if (game.IsDomeGame()) { Announce("Adding FG for Dome game"); } if (game.IsBadWeather()) { Announce("Subtracting FG for bad weather"); } Announce(string.Format("PO-{1} v PD-{2}:TD passes: {0}", tdp - ppr, po, pd)); Announce(string.Format("PP-{1} v PR-{2}:TD passes: {0}", ppr, pp, pr)); Announce(string.Format("RO-{1} v RD-{2}:TD runs: {0}", tdr, ro, rd)); Announce(string.Format("Field goals: {0}", fg)); Announce(string.Format("Defensive Scores: {0}", tdd)); Announce(string.Format("Special Team Scores: {0}", tds)); Announce(string.Format("Total Score: {0}", score)); }
private string DomeBit( NFLGame g, NFLPlayer p) { var bit = " "; if (p.IsKicker()) { if (g.IsDomeGame()) { bit = "+"; } else if (g.IsBadWeather()) { bit = "-"; } } else { if (p.ScoredLastTwo(TimeKeeper)) { bit = "*"; } else if (p.ScoredLastGame(TimeKeeper)) { bit = "+"; } } return(bit); }
private string DomeBit(NFLGame g, NFLPlayer p) { var bit = " "; if (p.IsKicker()) { if (g.IsDomeGame()) { bit = "+"; } else if (g.IsBadWeather()) { bit = "-"; } } return(bit); }
public Int32 PredictFGs(NFLPlayer plyr, string season, int week) { // Predict the number of FGs this player will kick int fg = 0; // starters only if (plyr.IsStarter()) { // who does he play for NflTeam kickersTeam = plyr.CurrTeam; // who are the opponents NflTeam opponent = kickersTeam.OpponentFor(season, week); if (opponent != null) { // not on a bye fg += 1; if (opponent.IsGoodDefence()) { fg += 1; } } // What is the Game NFLGame game = kickersTeam.GameFor(season, week); if (game != null) { if (game.IsHome(kickersTeam.TeamCode)) { fg += 1; } if (game.IsDomeGame()) { fg += 1; } if (game.IsBadWeather()) { fg -= 1; } } } return(fg); }
private string DomeBit( NFLGame g, NFLPlayer p ) { var bit = " "; if (p.IsKicker() ) { if ( g.IsDomeGame() ) bit = "+"; } return bit; }
private GameMetrics CalculateGameMetrics( bool isHome, NFLGame game, DateTime focusDate) { string teamRatings; string oppRatings; var gm = new GameMetrics(); if (isHome) { oppRatings = RatingsService.GetUnitRatingsFor( game.AwayNflTeam, focusDate); teamRatings = RatingsService.GetUnitRatingsFor( game.HomeNflTeam, focusDate); // pump up the defence ratings if its divisional game if (game.IsDivisionalGame()) { teamRatings = PumpIt( teamRatings); } game.AwayNflTeam.Ratings = oppRatings; game.HomeNflTeam.Ratings = teamRatings; } else { teamRatings = RatingsService.GetUnitRatingsFor( game.AwayNflTeam, focusDate); oppRatings = RatingsService.GetUnitRatingsFor( game.HomeNflTeam, focusDate); // pump up the defence ratings if its divisional game if (game.IsDivisionalGame()) { oppRatings = PumpIt( oppRatings); } game.HomeNflTeam.Ratings = oppRatings; game.AwayNflTeam.Ratings = teamRatings; } var score = 0; if (string.IsNullOrEmpty(teamRatings) || string.IsNullOrEmpty(oppRatings)) { Announce("Ratings not found - skipping score calculation"); } else { // Part 0 - Calculate field goals var fg = isHome ? 2 : 1; if (game.IsDomeGame()) { fg++; } else { if (game.IsBadWeather()) { fg--; } } // Part 1 - Calculate Tdp var po = teamRatings.Substring(0, 1); var pd = oppRatings.Substring(5, 1); var tdp = TouchdownPasses(po, pd); var ydp = YardsPassing(po, pd); gm.TDp = tdp; gm.YDp = ydp; // Part 2 - Adjust for protection var pp = teamRatings.Substring(2, 1); var pr = oppRatings.Substring(3, 1); var ppr = ProtectionAdjustment(pp, pr); tdp += ppr; if (tdp < 0) { tdp = 0; } // Part 3 - Calculate Tdr var ro = teamRatings.Substring(1, 1); var rd = oppRatings.Substring(4, 1); var tdr = TouchdownRuns(ro, rd); var ydr = YardsRushing(ro, rd); gm.TDp = tdp; gm.TDr = tdr; gm.YDr = ydr; var tdd = DefensiveScores( game.IsDivisionalGame(), isHome); var tds = SpecialTeamScores( game.IsMondayNight(), isHome); gm.TDd = tdd; gm.TDs = tds; gm.FG = fg; //TODO: Short week adjustment //TODO: Opponent had Route last game adjustment //TODO: Revenge adjustment // Total up all the parts of a score score = (tdp + tdr + tdd + tds) * 7 + (fg * 3); DumpCalculations( isHome, game, tdr, pr, pp, ro, tds, tdd, rd, oppRatings, teamRatings, ppr, tdp, score, pd, po, fg); if (isHome) { _homeTDp = tdp; _homeTDr = tdr; _homeFg = fg; _homeTDd = tdd; _homeTDs = tds; _homeYDr = ydr; _homeYDp = ydp; } else { _awayTDp = tdp; _awayTDr = tdr; _awayFg = fg; _awayTDd = tdd; _awayTDs = tds; _awayYDr = ydr; _awayYDp = ydp; } } gm.Score = score; return(gm); }