예제 #1
0
 /// <summary>
 /// Renders the object as a simple HTML report.
 /// </summary>
 public override void RenderAsHtml()
 {
     Name = "Strength of Schedule";
     var ds = Utility.TflWs.TeamsDs(Season);
     var dt = ds.Tables["Team"];
     _teamList = new ArrayList();
     foreach (DataRow dr in dt.Rows)
     {
         var t = new NflTeam(dr["TEAMID"].ToString(), Season,
                             Int32.Parse(dr["WINS"].ToString()),
                             dr["TEAMNAME"].ToString());
         t.StrengthOfSchedule();
         _teamList.Add(t);
     }
     var str = new SimpleTableReport(Name) {ColumnHeadings = true, DoRowNumbers = true};
     str.AddColumn(new ReportColumn("Team", KFieldTeam, "{0,-20}"));
     str.AddColumn(new ReportColumn("SoS", KFieldSos, "{0}"));
     str.AddColumn(new ReportColumn("Exp W", KFieldExpWins, "{0}"));
     str.AddColumn(new ReportColumn("Exp L", KFieldExpLosses, "{0}"));
     str.AddColumn(new ReportColumn("Prev W", KFieldWins, "{0}"));
     str.AddColumn(new ReportColumn("Prev L", KFieldLosses, "{0}"));
     str.AddColumn(new ReportColumn("Var", KFieldVariance, "{0}"));
     str.LoadBody(BuildTable());
     str.RenderAsHtml( OutputFilename(), true );
 }
예제 #2
0
 public void TestDepthChartExecution()
 {
     const string teamCode = "NE";
      var t = new NflTeam(teamCode);
      var sut = new DepthChartReport("2015", teamCode);
      sut.Execute();
      var isError = false;
      if (sut.HasIntegrityError())
      {
     isError = true;
     sut.DumpErrors();
     Utility.Announce(string.Format("   Need to fix Depth Chart {0}", t.Name));
      }
      t.LoadRushUnit();
      if (t.RushUnit.HasIntegrityError())
      {
     isError = true;
     t.RushUnit.DumpUnit();
     Utility.Announce(string.Format("   Need to fix  Rushing Unit {0}", t.Name));
      }
      t.LoadPassUnit();
      if (t.PassUnit.HasIntegrityError())
      {
     isError = true;
     t.PassUnit.DumpUnit();
     Utility.Announce(string.Format("   Need to fix  Passing Unit {0}", t.Name));
      }
      Assert.IsFalse(isError);
 }
예제 #3
0
 public void TestUnitReportNiners()
 {
     //  Fake historian garantees job will run always
      var sut = new NflTeam( "SF" );
      var r = sut.PoReport();
      Assert.IsTrue( r.Length > 0 );
 }
        public Int32 PredictSacks( NflTeam team, string season, int week )
        {
            //  Predict the number of Sacks the team will make
             int sacks = 0;
             //  who are the opponents
             NflTeam opponent = team.OpponentFor( season, week );
             if (opponent != null)
             {
            //  not on a bye
            sacks += 1;
            int prSacks = ConvertRating( team.PrRating() );
            int ppSacks = ConvertRating( opponent.PpRating() );
            sacks += ( prSacks - ppSacks );
             }

             //  What is the Game
             NFLGame game = team.GameFor(season, week);
             if (game != null)
             {
            if (game.IsHome(team.TeamCode)) sacks += 1;
            if (game.IsBadWeather()) sacks += 1;
             }

             if (sacks < 0) sacks = 0;

             return sacks;
        }
예제 #5
0
 public EventReport( string teamCode, string statCode, DataLibrarian tflWS)
 {
     Team = new NflTeam( teamCode );
     Team.LoadGames( teamCode, Utility.LastSeason() );
     this.tflWS = tflWS;
     StatCode = statCode;
 }
예제 #6
0
 public void TestGetShortYardageBack()
 {
     var sut = new NflTeam("AF");
      sut.LoadRushUnit();
      var sh = sut.RushUnit.GetShortYardageBack("2013", "12", "AF");
      Assert.AreEqual("JACKST02",sh);
 }
예제 #7
0
 public void TestLoad()
 {
     var team = new NflTeam( "PS" );
      var ru = team.LoadPassUnit();
      Console.WriteLine( "   >>> Pass unit loaded {0} receivers; Ace receiver {1}",
     team.PassUnit.Receivers.Count, team.PassUnit.AceReceiver );
      Assert.IsTrue( team.PassUnit.Receivers.Count < 50 );
 }
예제 #8
0
 public void TestLoad()
 {
     var team = new NflTeam("PS");
      var ru = team.LoadRushUnit();
      Console.WriteLine( "   >>> Rush unit loaded {0} rushers; Ace back {1}",
     team.RushUnit.Runners.Count, team.RushUnit.AceBack );
      Assert.IsTrue( team.RushUnit.Runners.Count < 50 );
 }
예제 #9
0
 public void TestRatingsRetrieval2()
 {
     var team = new NflTeam("SF");
     var currRatings = team.Ratings;
     const string expectedValue = "EACCBD";
     Assert.IsTrue(currRatings.Equals(expectedValue),
         string.Format("SF team rating should be {1} not {0}", currRatings, expectedValue));
 }
 public void TestDefensivePatsyBBReport()
 {
     var team = new NflTeam( "BB" );
      var tl = new TeamLister(team) {Heading = "Defence Friendly Offences"};
       ICalculate ttbCalculator = new DefensiveScoringCalculator( new NFLWeek( 2013, 1 ), -17 );
      var fileOut = tl.RenderTeamToBeat( ttbCalculator );
      Assert.IsTrue( File.Exists( fileOut ), string.Format( "Cannot find {0}", fileOut ) );
 }
예제 #11
0
 public void TestLoadPreviousSeasonGmes()
 {
     var team = new NflTeam("SF");
     team.LoadPreviousRegularSeasonGames(team.TeamCode, "2014", new DateTime(2014, 9, 7));
     Assert.IsTrue(team.GameList.Count.Equals(16));
     var game1 = (NFLGame) team.GameList[15];
     Assert.IsTrue(game1.Season.Equals("2013"));
 }
 public DefensiveScoringCalculator( NFLWeek startWeek, int offset )
 {
     StartWeek = startWeek;
     if (startWeek.WeekNo < 2 )
         StartWeek = startWeek.PreviousWeek(startWeek, loadgames: false, regularSeasonGamesOnly: true);
     Offset = offset;
     Team = new NflTeam("SF");
 }
예제 #13
0
 public void TestRatingsRetrieval()
 {
     var team = new NflTeam( "SF" );
     var rr = new UnitRatingsService();
     var currRatings = rr.GetUnitRatingsFor( team, new DateTime( 2014, 9, 7 ) );  //  first Sunday of the 2014 season
     const string expectedValue = "EACCBD";
     Assert.IsTrue( currRatings.Equals( expectedValue ),
         string.Format( "SF team rating should be {1} not {0}", currRatings, expectedValue ) );
 }
예제 #14
0
        public void TestAnalisePassingYardage()
        {
            var sut = new NflTeam("SL");
             sut.LoadPassUnit();
             Assert.IsTrue(sut.PassUnit.Quarterbacks.Count > 0);
             Utility.Announce(string.Format("Loaded {0} QBs", sut.PassUnit.Quarterbacks.Count));

             sut.PassUnit.AnalyseQuarterbacks("2014", "04");
        }
예제 #15
0
 public void TestNewRatingsRetrievalDB()
 {
     var team = new NflTeam( "DB" );
     var sut = new UnitRatingsService();
     var currRatings = sut.GetUnitRatingsFor( team, new DateTime( 2015, 11, 1 ) );  //  Date must be a Sunday
     const string expectedValue = "CECBAA";
     Assert.IsTrue( currRatings.Equals( expectedValue ),
         string.Format( "{0} team rating should be {2} not {1}", team.TeamCode, currRatings, expectedValue ) );
 }
예제 #16
0
 public void TestDefensiveScoringCalculator()
 {
     var week = new NFLWeek( seasonIn: "2016", weekIn: "13" );
      var team = new NflTeam( "KC" );
      var game = new NFLGame( gameKey: "2016:13-B" );  // KC @ AF
      var sut = new DefensiveScoringCalculator( week, offset:0 );
      sut.Calculate( team: team, game: game );
      Assert.AreEqual( expected: 11.0M, actual: team.FantasyPoints );
 }
예제 #17
0
 public void PpSnippet(NflTeam t)
 {
     FileOut = string.Format("{0}\\Prot\\PP-{1}.htm", RootPath(t.Season), t.TeamCode);
      var h = new HtmlFile(FileOut,
              string.Format(" {2} Pass Protection Unit as of {0}  Week {1}",
                             DateTime.Now.ToString("dd MMM yy"), Utility.CurrentWeek(), t.NameOut()));
      h.AddToBody(HeaderPp(t));
      h.AddToBody(t.PpReport());
      h.Render();
 }
 public void TestPatriotsDefenseCalcs()
 {
     var week = new NFLWeek( 2010, 17 );
      ICalculate myCalculator = new DefensiveScoringCalculator( week, -1 );
      var team = new NflTeam( "NE" );
      team.CalculateDefensiveScoring( myCalculator, doOpponent: false );
      Assert.AreEqual( 17, myCalculator.Team.FantasyPoints );
      Assert.AreEqual( 1, myCalculator.Team.TotInterceptions );
      Assert.AreEqual( 5, myCalculator.Team.TotSacks );
 }
예제 #19
0
 public void TestDoubleLoad()
 {
     var team = new NflTeam( "PS" );
      var pu = team.LoadPassUnit();
      Console.WriteLine( "   >>> Pass unit loaded {0} receivers; Ace receiver {1}",
     team.PassUnit.Receivers.Count, team.PassUnit.AceReceiver );
      var count1 = pu.Count;
      var pu2 = team.LoadPassUnit();
      var count2 = pu2.Count;
      Assert.IsTrue( count1 == count2 );
 }
예제 #20
0
 public NFLSchedule( string season, NflTeam team )
 {
     #if DEBUG
     Utility.Announce( string.Format( "NFLSchedule:Loading {0} Schedule for {1}", season, team.Name ) );
     #endif
     Team = team;
     _season = season;
     //  load schedule
     GameList = new ArrayList();
     Load();
 }
예제 #21
0
 public void TestDoubleLoad()
 {
     var team = new NflTeam( "PS" );
      var ru = team.LoadRushUnit();
      Console.WriteLine( "   >>> Rush unit loaded {0} rushers; Ace back {1}",
     team.RushUnit.Runners.Count, team.RushUnit.AceBack );
      var count1 = ru.Count;
      var ru2 = team.LoadRushUnit();
      var count2 = ru2.Count;
      Assert.IsTrue( count1 == count2 );
 }
예제 #22
0
        public void TestAnaliseReceptionYardage()
        {
            var sut = new NflTeam("JJ");
             sut.LoadPassUnit();
             Assert.IsTrue(sut.PassUnit.Receivers.Count > 0);
             Utility.Announce(string.Format("Loaded {0} receivers", sut.PassUnit.Receivers.Count));

             sut.PassUnit.DumpUnit();
             sut.PassUnit.AnalyseWideouts("2014", "07");
            //         sut.PassUnit.AnalyseTightends("2014", "04");
        }
예제 #23
0
        public int RateTeam( NflTeam team )
        {
            //  Defensive team ratings
            team.ProjectNextWeek();
            //  Sacks are worth 3 points each
            int sackPoints = team.ProjectedSacks*3;
            //  Interceptions are worth 6 points each
            int intPoints = team.ProjectedSteals * 6;
            team.Points = sackPoints + intPoints;

            return team.Points;
        }
예제 #24
0
        private void LoadTeams()
        {
            var ds = Utility.TflWs.TeamsDs( Season );
             DataTable dt = ds.Tables[ "Team" ];
             TeamList = new Dictionary<string, NflTeam>();

             foreach ( DataRow dr in dt.Rows )
             {
            var t = new NflTeam( dr[ "TEAMID" ].ToString(), Season,
                                     Int32.Parse( dr[ "WINS" ].ToString() ),
                                     dr[ "TEAMNAME" ].ToString() );
            t.MetricsHt = new Hashtable();
            TeamList.Add( t.TeamCode, t );
             }
        }
        public NibbleTeamRating GetNibbleRatingFor( NflTeam team, DateTime when )
        {
            //  otherwise retrieve ratings they way they were at when
            if ( CacheIsDirty( when ) )
            {
                RankTeams( when );
                CacheHit = false;
            }
            else
                CacheHit = true;

            var ratings = RatingsFor( team.TeamCode );

            return ratings;
        }
예제 #26
0
 public UnitLister( string unitCode )
 {
     mUnitList = new ArrayList();
     mFormat = "weekly";
     UnitFactory uf = new UnitFactory();
      DataSet ds = Utility.TflWs.GetTeams( Utility.CurrentSeason() );
      DataTable dt = ds.Tables[ 0 ];
      foreach ( DataRow dr in dt.Rows )
      {
     NflTeam t = new NflTeam( dr["TEAMID"].ToString() );
        TeamUnit myUnit = uf.CreateUnit( unitCode );
     myUnit.Team = t;
     mUnitList.Add( myUnit );
      }
 }
        public void Calculate( NflTeam team, NFLGame game )
        {
            Team = team;
            _game = game;

            var opponentCode = DetermineOpponent();

            Team.FantasyPoints = 0;
            Team.DefensiveScores = 0;
            Team.TotInterceptions = 0;
            Team.TotSacks = 0;
            Team.PtsAgin = 0;

            CalculateDefensiveScores();  //  will increment _team.FantasyPoints

            CountStats();

            Team.FantasyPoints += Team.TotSacks;
            #if DEBUG
             Utility.Announce( string.Format( "  Defense got {0} sacks for {0} FP",
            Team.TotSacks  ) );
            #endif
             Team.FantasyPoints += Team.TotInterceptions * 2;
            #if DEBUG
             Utility.Announce( string.Format( "  Defense got {0} intercepts for {1} FP",
            Team.TotInterceptions, Team.TotInterceptions * 2 ) );
            #endif

             CountYardage( opponentCode );

            Team.PtsAgin = CountPointsAllowed();
            var defFantasyPts =  PointsForAllowing( Team.PtsAgin );
            Team.FantasyPoints += defFantasyPts;

            #if DEBUG
            Utility.Announce( string.Format( "  Defense gave up {0} real points for {1} FP",
            Team.PtsAgin, defFantasyPts ));
            #endif

            #if DEBUG
             Utility.Announce( string.Format( "  FP total {0}", Team.FantasyPoints ) );
            #endif
             Team.Games++;
        }
예제 #28
0
 /// <summary>
 /// Segment II (weeks 5-8)
 /// Pointer Twelve: (p 74)
 ///   Big Scoring Teams
 ///     As in the first 4 games, I look to bet against a favourite that scored a total of
 ///     30 or more points in each of the last two weeks in winning efforts.
 /// </summary>
 /// <param name="team"></param>
 /// <param name="upcomingGame"></param>
 /// <returns></returns>
 public static bool BigScoringTeam( NflTeam team, NFLGame upcomingGame )
 {
     bool isBigScorer = false;
      if ( upcomingGame.IsFavourite( team ) )
      {
     NFLGame prevGame = team.PreviousGame( upcomingGame.GameDate );
     if ( prevGame.Won( team ) )
        if ( prevGame.ScoreFor( team ) >= KBigScore )
        {
           NFLGame prevPrevGame = team.PreviousGame( prevGame.GameDate );
           if ( prevGame.Won( team ) )
           {
              if ( prevPrevGame.ScoreFor( team ) >= KBigScore )
                 isBigScorer = true;
           }
        }
      }
      return isBigScorer;
 }
예제 #29
0
        public string GetUnitRatingsFor( NflTeam team, DateTime when )
        {
            //if ( IsCurrent( team, when ) )
            //	return team.Ratings;

            if ( CacheIsDirty( when ) )
            {
                RankTeams( when );
                CacheHit = false;
            }
            else
            {
                CacheHit = true;
            }

            var ratings = RatingsFor( team.TeamCode );
            var strRatings = ratings.ToString();

            //strRatings = team.AdjustedRatings( strRatings );  //TODO: we dont adjust if season has started - implement check

            return strRatings;
        }
        public int PredictSteals( NflTeam team, string season, int week )
        {
            //  Predict the number of Interceptions the team will make
             int ints = 0;
             //  who are the opponents
             NflTeam opponent = team.OpponentFor(season, week);
             if (opponent != null)
             {
            //  not on a bye
            int pdInts = ConvertRating(team.PrRating());
            int poInts = ConvertRating(opponent.PpRating());
            ints += (pdInts - poInts) - 1; //  will range from 3 to -5
             }

             //  What is the Game
             NFLGame game = team.GameFor(season, week);
             if ( game != null )
            if ( game.IsHome( team.TeamCode ) ) ints += 1;

             if (ints < 0) ints = 0;

             return ints;
        }