public void TestRatePlayerProjection()
 {
     var p = new NFLPlayer( "TAYLTY01" );
      var sut = new DbfPlayerGameMetricsDao();
      var pgms = sut.GetSeason("2016", "TAYLTY01");
      var totalPoints = 0.0M;
      foreach ( var pgm in pgms )
      {
     pgm.CalculateProjectedFantasyPoints( p );
     totalPoints += p.Points;
      }
      Assert.IsTrue(p.Points < 400M);
 }
Beispiel #2
0
        public DataSet LoadProjectedData(
            ArrayList plyrList,
            IRatePlayers scorer,
            IWeekMaster weekMaster,
            IAdpMaster adpMaster = null)
        {
            var ds = new DataSet();
            var dt = new DataTable();

            DefineReportColumns(dt);

            if (Season == null)
            {
                Season = Utility.CurrentSeason();
            }

            var dao = new DbfPlayerGameMetricsDao();

            foreach (NFLPlayer p in plyrList)
            {
                if (p.PlayerName.Equals("Mark Ingram"))
                {
                    Console.WriteLine("TestPlayer check");
                }

                var pgms = dao.GetSeason(Season, p.PlayerCode);

                var totPoints = 0M;
                foreach (PlayerGameMetrics pgm in pgms)
                {
                    var nWeek   = Int32.Parse(pgm.Week());
                    var theWeek = weekMaster.GetWeek(
                        season: Season,
                        week: nWeek);

                    //  We are only concerned with the first 4 weeks
                    //if (nWeek > 4)
                    //	continue;

                    // if there is no scorer it just reads the stats,
                    // this is what we want
                    if (scorer == null)
                    {
                        p.Points = pgm.CalculateProjectedFantasyPoints(p);
                    }
                    else
                    {
                        scorer.RatePlayer(p, theWeek);
                    }

                    if (p.TotStats == null)
                    {
                        p.TotStats = new PlayerStats();
                    }
                    p.TotStats.Tdp += pgm.ProjTDp;
                    p.TotStats.YDp += pgm.ProjYDp;
                    p.TotStats.Tdr += pgm.ProjTDr;
                    p.TotStats.Tdc += pgm.ProjTDc;
                    p.TotStats.YDr += pgm.ProjYDr;
                    p.TotStats.YDc += pgm.ProjYDc;
                    p.TotStats.Fg  += pgm.ProjFG;
                    totPoints      += p.Points;
                }

                if (totPoints > 0 || !SupressZeros)
                {
                    var dr = dt.NewRow();
                    dr["Name"]     = p.ProjectionLink(Season);
                    dr["Pos"]      = p.PlayerPos;
                    dr["Role"]     = p.RoleOut();
                    dr["RookieYr"] = p.RookieYear;
                    dr["CurrTeam"] = p.TeamCode;
                    if (ShowOpponent)
                    {
                        dr["Opponent"] = p.Opponent;
                        dr["Spread"]   = p.PlayerSpread;
                        dr["OppRate"]  = p.OppRate;
                    }
                    if (p.Owner == null)
                    {
                        p.LoadOwner();
                    }
                    dr["FT"]  = p.Owner;
                    dr["Age"] = p.PlayerAge();

                    if (LongStats)
                    {
                        dr["cat"]       = p.PlayerCat;
                        dr["scoremod"]  = p.ScoreModifier();
                        dr["seasons"]   = p.NoOfSeasons();
                        dr["newteam"]   = p.IsNewbie() ? "*" : string.Empty;
                        dr["CurSCORES"] = p.CurrScores;
                        dr["SCORES"]    = p.Scores;
                        dr["Avg"]       = p.ScoresPerYear();
                        dr["INJURY"]    = p.Injuries();
                        dr["Tdp"]       = p.TotStats.Tdp;
                        dr["YDp"]       = p.TotStats.YDp;
                        dr["Tdr"]       = p.TotStats.Tdr;
                        dr["TDc"]       = p.TotStats.Tdc;
                        dr["YDr"]       = p.TotStats.YDr;
                        dr["YDc"]       = p.TotStats.YDc;
                        dr["Fg"]        = p.TotStats.Fg;
                        dr["Health"]    = p.HealthRating();
                        dr["newbie"]    = 1.0M - p.NewbieModifier();
                        dr["adjProj"]   = AdjustedPoints(
                            p,
                            totPoints);
                        dr["AgeRate"] = p.AgeRating();
                    }

                    dr["Points"] = totPoints;
                    if (!LongStats)
                    {
                        dr["Points"] = (int)AdjustedPoints(
                            p,
                            totPoints);
                    }

                    dr["Adp"] = AsDraftRound(p.Adp);
                    if (adpMaster != null)
                    {
                        dr["Adp"] = adpMaster.GetAdp(
                            p.PlayerName);
                    }
                    dt.Rows.Add(dr);
                    //Logger.Trace($"{p.PlayerName:-20} {totPoints:0.0}");
                }
            }
            ds.Tables.Add(dt);
            return(ds);
        }
        public DataSet LoadProjectedData( ArrayList plyrList, IRatePlayers scorer, IWeekMaster weekMaster )
        {
            var ds = new DataSet();
             var dt = new DataTable();
             var cols = dt.Columns;
             cols.Add("Name", typeof (String));
             cols.Add("Pos", typeof (String));
             cols.Add("Role", typeof (String));
             cols.Add("RookieYr", typeof (String));
             cols.Add("Age", typeof (String));
             cols.Add("Currteam", typeof (String));
             if (ShowOpponent)
             {
            cols.Add("Opponent", typeof(String));
            cols.Add("Spread", typeof(String));
            cols.Add("OppRate", typeof(String));
             }
             cols.Add("FT", typeof (String));

             if (LongStats)
             {
            cols.Add("CurScores", typeof (Int32));
            cols.Add("Scores", typeof (Int32));
            cols.Add("Avg", typeof (Decimal));
            cols.Add("Injury", typeof (Int32));
            cols.Add("Tdp", typeof (Int32));
            cols.Add("YDp", typeof (Int32));
            cols.Add("Tdr", typeof (Int32));
            cols.Add("TDc", typeof (Int32));
            cols.Add("YDr", typeof (Int32));
            cols.Add("YDc", typeof (Int32));
            cols.Add("Fg", typeof (Int32));
            cols.Add( "Health", typeof( Decimal ) );
            cols.Add( "AdjProj", typeof( Int32 ) );
             }

             cols.Add("Points", typeof (Decimal));

             if (Season == null) Season = Utility.CurrentSeason();

             var dao = new DbfPlayerGameMetricsDao();

             foreach (NFLPlayer p in plyrList)
             {
            var pgms = dao.GetSeason(Season, p.PlayerCode);

            var totPoints = 0M;
            foreach (PlayerGameMetrics pgm in pgms)
            {
               var theWeek = weekMaster.GetWeek( Season, Int32.Parse( pgm.Week() ) );

               // if there is no scorer it just reads the stats, this is what we want
               if ( scorer == null )
                  p.Points = pgm.CalculateProjectedFantasyPoints(p);
               else
                  scorer.RatePlayer( p, theWeek );

               if ( p.TotStats == null) p.TotStats = new PlayerStats();
               p.TotStats.Tdp += pgm.ProjTDp;
               p.TotStats.YDp += pgm.ProjYDp;
               p.TotStats.Tdr += pgm.ProjTDr;
               p.TotStats.Tdc += pgm.ProjTDc;
               p.TotStats.YDr += pgm.ProjYDr;
               p.TotStats.YDc += pgm.ProjYDc;
               p.TotStats.Fg += pgm.ProjFG;
               totPoints += p.Points;
            }

            if (totPoints > 0 || !SupressZeros)
            {
               var dr = dt.NewRow();
               dr["Name"] = p.PlayerName;
               dr["Pos"] = p.PlayerPos;
               dr["Role"] = p.RoleOut();
               dr["RookieYr"] = p.RookieYear;
               dr["CurrTeam"] = p.TeamCode;
               if (ShowOpponent)
               {
                  dr["Opponent"] = p.Opponent;
                  dr["Spread"] = p.PlayerSpread;
                  dr["OppRate"] = p.OppRate;
               }
               if (p.Owner == null) p.LoadOwner();
               dr["FT"] =  p.Owner;
               dr["Age"] = p.PlayerAge();

               if (LongStats)
               {
                  dr["CurSCORES"] = p.CurrScores;
                  dr["SCORES"] = p.Scores;
                  dr["Avg"] = p.ScoresPerYear();
                  dr["INJURY"] = p.Injuries();
                  dr["Tdp"] = p.TotStats.Tdp;
                  dr["YDp"] = p.TotStats.YDp;
                  dr["Tdr"] = p.TotStats.Tdr;
                  dr["TDc"] = p.TotStats.Tdc;
                  dr["YDr"] = p.TotStats.YDr;
                  dr["YDc"] = p.TotStats.YDc;
                  dr["Fg"] = p.TotStats.Fg;
                  dr[ "Health" ] = p.HealthRating();
                  dr[ "AdjProj" ] = p.HealthRating()*totPoints;
               }

               dr["Points"] = totPoints;
               dt.Rows.Add(dr);
            }
             }
             ds.Tables.Add(dt);

             return ds;
        }
Beispiel #4
0
        public DataSet LoadProjectedData(
            ArrayList plyrList, IRatePlayers scorer, IWeekMaster weekMaster)
        {
            var ds   = new DataSet();
            var dt   = new DataTable();
            var cols = dt.Columns;

            cols.Add("Name", typeof(String));
            cols.Add("Pos", typeof(String));
            cols.Add("Role", typeof(String));
            cols.Add("RookieYr", typeof(String));
            cols.Add("Age", typeof(String));
            cols.Add("Currteam", typeof(String));
            if (ShowOpponent)
            {
                cols.Add("Opponent", typeof(String));
                cols.Add("Spread", typeof(String));
                cols.Add("OppRate", typeof(String));
            }
            cols.Add("FT", typeof(String));

            if (LongStats)
            {
                cols.Add("CurScores", typeof(Int32));
                cols.Add("Scores", typeof(Int32));
                cols.Add("Avg", typeof(Decimal));
                cols.Add("Injury", typeof(Int32));
                cols.Add("Tdp", typeof(Int32));
                cols.Add("YDp", typeof(Int32));
                cols.Add("Tdr", typeof(Int32));
                cols.Add("TDc", typeof(Int32));
                cols.Add("YDr", typeof(Int32));
                cols.Add("YDc", typeof(Int32));
                cols.Add("Fg", typeof(Int32));
                cols.Add("Health", typeof(Decimal));
                cols.Add("AdjProj", typeof(Int32));
            }

            cols.Add("Points", typeof(Decimal));
            cols.Add("PFP", typeof(Int32));
            cols.Add("Adp", typeof(Int32));

            if (Season == null)
            {
                Season = Utility.CurrentSeason();
            }

            var dao = new DbfPlayerGameMetricsDao();

            foreach (NFLPlayer p in plyrList)
            {
                var pgms = dao.GetSeason(Season, p.PlayerCode);

                var totPoints = 0M;
                foreach (PlayerGameMetrics pgm in pgms)
                {
                    var theWeek = weekMaster.GetWeek(Season, Int32.Parse(pgm.Week()));

                    // if there is no scorer it just reads the stats, this is what we want
                    if (scorer == null)
                    {
                        p.Points = pgm.CalculateProjectedFantasyPoints(p);
                    }
                    else
                    {
                        scorer.RatePlayer(p, theWeek);
                    }

                    if (p.TotStats == null)
                    {
                        p.TotStats = new PlayerStats();
                    }
                    p.TotStats.Tdp += pgm.ProjTDp;
                    p.TotStats.YDp += pgm.ProjYDp;
                    p.TotStats.Tdr += pgm.ProjTDr;
                    p.TotStats.Tdc += pgm.ProjTDc;
                    p.TotStats.YDr += pgm.ProjYDr;
                    p.TotStats.YDc += pgm.ProjYDc;
                    p.TotStats.Fg  += pgm.ProjFG;
                    totPoints      += p.Points;
                }

                if (totPoints > 0 || !SupressZeros)
                {
                    var dr = dt.NewRow();
                    dr["Name"]     = p.PlayerName;
                    dr["Pos"]      = p.PlayerPos;
                    dr["Role"]     = p.RoleOut();
                    dr["RookieYr"] = p.RookieYear;
                    dr["CurrTeam"] = p.TeamCode;
                    if (ShowOpponent)
                    {
                        dr["Opponent"] = p.Opponent;
                        dr["Spread"]   = p.PlayerSpread;
                        dr["OppRate"]  = p.OppRate;
                    }
                    if (p.Owner == null)
                    {
                        p.LoadOwner();
                    }
                    dr["FT"]  = p.Owner;
                    dr["Age"] = p.PlayerAge();

                    if (LongStats)
                    {
                        dr["CurSCORES"] = p.CurrScores;
                        dr["SCORES"]    = p.Scores;
                        dr["Avg"]       = p.ScoresPerYear();
                        dr["INJURY"]    = p.Injuries();
                        dr["Tdp"]       = p.TotStats.Tdp;
                        dr["YDp"]       = p.TotStats.YDp;
                        dr["Tdr"]       = p.TotStats.Tdr;
                        dr["TDc"]       = p.TotStats.Tdc;
                        dr["YDr"]       = p.TotStats.YDr;
                        dr["YDc"]       = p.TotStats.YDc;
                        dr["Fg"]        = p.TotStats.Fg;
                        dr["Health"]    = p.HealthRating();
                        dr["AdjProj"]   = p.HealthRating() * totPoints;
                    }

                    dr["Points"] = totPoints;
                    dr["PFP"]    = p.Rating;
                    dr["Adp"]    = p.Adp;
                    dt.Rows.Add(dr);
                    //Logger.Info( $"{p.PlayerName:-20} {totPoints:0.0}" );
                }
            }
            ds.Tables.Add(dt);

            return(ds);
        }
 public void TestGetPlayerProjections()
 {
     var sut = new DbfPlayerGameMetricsDao();
      var pgms = sut.GetSeason( "2014", "KAEPCO01" );
      Assert.IsTrue(pgms.Count > 0 );
 }