Exemplo n.º 1
0
        public string RenderProjection(
            string header,
            IWeekMaster weekMaster,
            IAdpMaster adpMaster = null)
        {
            var html = new RenderStatsToHtml(WeekMaster)
            {
                RenderToCsv   = RenderToCsv,
                Season        = Season,
                Week          = Week,
                LongStats     = LongStats,
                WeeksToGoBack = WeeksToGoBack
            };

            if (header.EndsWith("Short"))
            {
                html.LongStats = false;
            }

            if (!string.IsNullOrEmpty(SubHeader))
            {
                html.SubHeader = SubHeader;
            }

            FileOut = html.RenderProjectedData(
                playerList: PlayerList,
                sHead: header,
                sortOrder: SortOrder,
                scorer: _mMyScorer,
                weekMaster: weekMaster,
                adpMaster: adpMaster);

            return(FileOut);
        }
Exemplo n.º 2
0
        public string RenderProjectedData(
            ArrayList playerList,
            string sHead,
            [Optional] string sortOrder,
            IRatePlayers scorer,
            IWeekMaster weekMaster,
            IAdpMaster adpMaster = null)
        {
            //  Output the list
            Utility.Announce("PlayerListing " + sHead);

            SimpleTableReport r = SetUpProjectionReport(
                sHead);

            var ds = LoadProjectedData(
                plyrList: playerList,
                scorer: scorer,
                weekMaster: weekMaster,
                adpMaster: adpMaster);

            var dt = ds.Tables[0];

            dt.DefaultView.Sort = LongStats
                           ? (string.IsNullOrEmpty(sortOrder)
                           ? "Points DESC" : sortOrder) : "Points DESC";

            r.LoadBody(dt);             //  just assigns the data table
            FileOut = $@"{
				Utility.OutputDirectory()
				}//{
				Season
				}//Projections//{
				sHead
				}.htm"                ;
            r.RenderAsHtml(
                fileName: FileOut,
                persist: true);

            if (RenderToCsv)
            {
                r.RenderAsCsv(
                    "Starters-" + sHead,
                    Logger);
            }
            return(FileOut);
        }
Exemplo n.º 3
0
        public PlayerCsv(
            IKeepTheTime timekeeper,
            IAdpMaster adpMaster) : base(timekeeper)
        {
            Name = "Players CSV";
            SetLastRunDate();
            AdpMaster = adpMaster;
            Lister    = new PlayerLister();
            Configs   = new List <StarterConfig>
            {
                new StarterConfig
                {
                    Category = Constants.K_QUARTERBACK_CAT,
                    Position = "QB"
                },
                new StarterConfig
                {
                    Category = Constants.K_RUNNINGBACK_CAT,
                    Position = "RB"
                },
#if !DEBUG2
                new StarterConfig
                {
                    Category = Constants.K_RECEIVER_CAT,
                    Position = "WR"
                },
                new StarterConfig
                {
                    Category = Constants.K_RECEIVER_CAT,
                    Position = "TE"
                },
                new StarterConfig
                {
                    Category = Constants.K_KICKER_CAT,
                    Position = "K"
                }
#endif
            };
        }
Exemplo n.º 4
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);
        }