public void StorePrediction(string method, NFLGame game, NFLResult result)
        {
            //  Validate prediction
            if ( !result.IsValid() )
                Utility.Announce( "Invalid prediction - " + game.GameName() );

            //  See if we have this prediction already
            var ds = Utility.TflWs.GetPrediction(method, game.Season, game.Week, game.GameCode);

            if (ds.Tables[0].Rows.Count == 1)
                //  if yes just update
                Utility.TflWs.UpdatePrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
             					result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                    );
            else
                //  otherwise insert
                Utility.TflWs.InsertPrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
             					result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                  );
        }
        public void StorePrediction(string method, NFLGame game, NFLResult result)
        {
            //  Validate prediction
            if (!result.IsValid())
            {
                Utility.Announce("Invalid prediction - " + game.GameName());
            }

            //  See if we have this prediction already
            var ds = Utility.TflWs.GetPrediction(method, game.Season, game.Week, game.GameCode);

            if (ds.Tables[0].Rows.Count == 1)
            {
                //  if yes just update
                Utility.TflWs.UpdatePrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
                    result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                    );
            }
            else
            {
                //  otherwise insert
                Utility.TflWs.InsertPrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
                    result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                    );
            }
        }
示例#3
0
        private void RateGame(NFLGame g)
        {
            if (g.Played())
            {
                Utility.Announce(string.Format("Rating game {0}", g.GameName()));
                //  workout the Average Score
                //AverageScore = Season.AverageScoreAfterWeek( g.WeekNo );
                AverageScore = 21;                  //  this is pretty much fixed

                //  workout adjustments to the previous ratings
                NibbleGameRating startingGameRating;
                if (g.Week.Equals("01"))
                {
                    startingGameRating = new NibbleGameRating(
                        ho: 0,
                        hd: 0,
                        ao: 0,
                        ad: 0);
                }
                else
                {
                    // Get previous rating
                    startingGameRating = GetRating(g);
                }

                var projHome = (int)(AverageScore + ((startingGameRating.HomeOff + startingGameRating.AwayDef) / 2));
                projHome += 3;                  // home field advantage
                var projAway = (int)(AverageScore + ((startingGameRating.AwayOff + startingGameRating.HomeDef) / 2));

                var adjustment = new NibbleGameRating(0, 0, 0, 0);
                var ff         = FudgeFactor(g.Week);
                adjustment.HomeOff = (MaximumScore(g.HomeScore) - projHome) / ff;
                adjustment.HomeDef = (MaximumScore(g.AwayScore) - projAway) / ff;
                adjustment.AwayOff = (MaximumScore(g.AwayScore) - projAway) / ff;
                adjustment.AwayDef = (MaximumScore(g.HomeScore) - projHome) / ff;

                Utility.Announce(string.Format("    Projected score {0} {1:00} v {2} {3:00}",
                                               g.HomeTeam, projHome, g.AwayTeam, projAway));
                Utility.Announce(string.Format("    Actual    score {0} {1:00} v {2} {3:00}",
                                               g.HomeTeam, g.HomeScore, g.AwayTeam, g.AwayScore));
                Utility.Announce(string.Format("    Adjustments  H {0} {1} - {2}",
                                               g.HomeTeam, adjustment.HomeOff, adjustment.HomeDef));
                Utility.Announce(string.Format("    Adjustments  A {0} {1} - {2}",
                                               g.AwayTeam, adjustment.AwayOff, adjustment.AwayDef));

                AdjustRatings(
                    startingGameRating: startingGameRating,
                    adjustment: adjustment,
                    homeTeam: g.HomeTeam,
                    awayTeam: g.AwayTeam,
                    week: g.Week);
            }
        }
示例#4
0
        private void AddBreakdown(string teamCode, EpMetric ep, NFLGame g)
        {
            var scorers = string.Empty;

            if (ep.OffTDr > 0)
            {
                scorers = g.ScorersOff(Constants.K_SCORE_TD_RUN, teamCode);
            }

            Breakdowns.AddLine(string.Format("{0}-Tdr", teamCode),
                               string.Format("{0}  {1:#0} {2}",
                                             g.GameName(), ep.OffTDr, scorers));

            if (ep.OffTDp > 0)
            {
                scorers = g.ScorersOff(Constants.K_SCORE_TD_PASS, teamCode);
            }

            Breakdowns.AddLine(string.Format("{0}-Tdp", teamCode),
                               string.Format("{0}  {1:#0} {2}",
                                             g.GameName(), ep.OffTDp, scorers));
        }
        public string RecordMetrics(NFLPlayer player, NFLGame game)
        {
            var gameKey = game.GameKey();
            var pgm     = Dao.Get(player.PlayerCode, gameKey);

            if (pgm.GameKey != null)
            {
                pgm.TDp = player.CurrentGameMetrics.TDp;
                pgm.TDr = player.CurrentGameMetrics.TDr;
                pgm.TDc = player.CurrentGameMetrics.TDc;
                pgm.YDp = player.CurrentGameMetrics.YDp;
                pgm.YDr = player.CurrentGameMetrics.YDr;
                pgm.YDc = player.CurrentGameMetrics.YDc;
                pgm.FG  = player.CurrentGameMetrics.FG;
                pgm.Pat = player.CurrentGameMetrics.Pat;

                Dao.Save(pgm);
                return(string.Format("Game:{0} Player:{1} metrics:{2}", game.GameName(), player.PlayerName, pgm));
            }
            else
            {
                return(string.Format("Failed to find pgm for {0}:{1}", game.GameName(), player.PlayerName));
            }
        }
        public void StorePrediction(string method, NFLGame game, NFLResult result)
        {
            //  Validate prediction
            if (!result.IsValid())
            {
                Utility.Announce("Invalid prediction - " + game.GameName());
            }

            //  See if we have this prediction already
            var ds = Utility.TflWs.GetPrediction(method, game.Season, game.Week, game.GameCode);

            if (ds.Tables[0].Rows.Count == 1)
            {
                //  if yes just update
                Utility.TflWs.UpdatePrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
                    result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                    );
            }
            else
            {
                //  otherwise insert
                Utility.TflWs.InsertPrediction(
                    method, game.Season, game.Week, game.GameCode, result.HomeScore, result.AwayScore,
                    result.HomeTDp, result.HomeTDr, result.HomeTDd, result.HomeTDs, result.HomeFg,
                    result.AwayTDp, result.AwayTDr, result.AwayTDd, result.AwayTDs, result.AwayFg,
                    result.HomeYDp, result.HomeYDr, result.AwayYDp, result.AwayYDr
                    );
            }

            //TODO:  this stuffs up the scores if using the Miller predictions
            //// also update Game projections (used by Starters())
            //Utility.TflWs.StoreResult(game.Season, game.Week, game.GameCode, result.AwayScore, result.HomeScore, result.HomeTDp,
            //                          result.AwayTDp, result.HomeTDr, result.AwayTDr, result.HomeFg, result.AwayFg,
            //                          result.AwayTDd, result.HomeTDd, result.AwayTDs, result.HomeTDs);
        }