public static int GameProjection(NFLGame g, string playerTeamCode, string playerCategory, string playerRole)
        {
            var projection = 0;
              if (playerRole != Constants.K_ROLE_STARTER) return projection;

            //  is a starter
              switch (playerCategory)
              {
              case Constants.K_QUARTERBACK_CAT:
                  projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdp : g.ProjectedAwayTdp;
                  break;
              case Constants.K_RUNNINGBACK_CAT:
                  projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdr : g.ProjectedAwayTdr;
                  break;
              case Constants.K_RECEIVER_CAT:
                  projection = g.IsHome(playerTeamCode) ? g.ProjectedHomeTdp/2 : g.ProjectedAwayTdp/2;
                  break;
              case Constants.K_KICKER_CAT:
                  projection = g.IsHome( playerTeamCode ) ? g.ProjectedHomeFg : g.ProjectedAwayFg;
                  break;
              }
            #if DEBUG
              Utility.Announce(string.Format("Game {0} projection for {1} {2} {3} is {4}",
              g.GameKey(), playerTeamCode, playerCategory, playerRole, projection ) );
            #endif
              return projection;
        }
Esempio n. 2
0
 /// <summary>
 /// Segment I (Weeks 1-4)
 /// Pointer Two: (p 63, 73)
 ///   Home Dog After Home Loss as Favourite.
 ///   When a team loses as a favourite at home and is the home dog next week, 
 ///   look to bet on the underdog 
 /// </summary>
 public static bool HomeDogBounce( NflTeam team, NFLGame nextGame )
 {
     bool bounce = false;
      NFLGame lastGame = team.PreviousGame( nextGame.GameDate );
      if ( lastGame.IsFavourite( team ) )
     if ( lastGame.Lost( team ) )
     {
        if ( nextGame.IsDog( team ) )
           if ( nextGame.IsHome( team.TeamCode ) )
              bounce = true;
     }
      return bounce;
 }
Esempio n. 3
0
        private void LoadTeam( NflTeam team, string teamCode, bool skipPostseason )
        {
            var ep = new EpMetric();
            var metricsHt = new Hashtable();

               DataSet dg;
             dg = skipPostseason ? _tflWs.GetAllRegularSeasonGames( teamCode, Season )
            : _tflWs.GetAllGames( teamCode, Season );
            var games = dg.Tables[ "sched" ];
            foreach ( DataRow drg in games.Rows )
            {
                var g = new NFLGame( drg );
            //last 2 yrs				if (!g.IsRecent()) continue;
               if (skipPostseason && g.IsPlayoff()) continue;

                if ( ! g.MetricsCalculated )  g.TallyMetrics(String.Empty);
                var hashCode = string.Format( "{0}{1}{2}", teamCode, g.Season, g.Week );
                if ( g.IsHome( teamCode ) )
                {
                    ep.HomeTeam = teamCode;
                    ep.OffTDp = g.HomeTDp;
                    ep.OffTDr = g.HomeTDr;
                    ep.OffSakAllowed = g.HomeSaKa;
                    ep.DefTDp = g.AwayTDp;
                    ep.DefTDr = g.AwayTDr;
                    ep.DefSak = g.AwaySaKa;
                    ep.HomePasses = g.HomePasses;
                    ep.HomeRuns = g.HomeRuns;
                }
                else
                {
                    ep.AwayTeam = g.AwayTeam;
                    ep.OffTDp = g.AwayTDp;
                    ep.OffTDr = g.AwayTDr;
                    ep.OffSakAllowed = g.AwaySaKa;
                    ep.DefTDp = g.HomeTDp;
                    ep.DefTDr = g.HomeTDr;
                    ep.DefSak = g.HomeSaKa;
                    ep.AwayPasses = g.AwayPasses;
                    ep.AwayRuns = g.AwayRuns;
                }

                if ( DoBreakdowns ) AddBreakdown( teamCode, ep, g );

                if (ep.Total() <= 0) continue;

                ep.WeekSeed = Utility.WeekSeed( g.Season, g.Week );
                if ( ! metricsHt.ContainsKey( hashCode ) )
                    metricsHt.Add( hashCode, ep );
            }
            team.SetMetrics( metricsHt );
            #if DEBUG
            Utility.PrintIndexAndKeysAndValues( metricsHt );
            #endif
        }
Esempio n. 4
0
        //  rank points are used to sort players
        public decimal RankPoints( NFLPlayer player, NFLGame game, NflTeam opponent )
        {
            decimal points = 0;

             #region  short cut

             if (RankMaster.Contains(player.PlayerCode))
             {
            var rankedPlayer = (NFLPlayer) RankMaster[player.PlayerCode];
            return rankedPlayer.Points;
             }
             #endregion

             #region  Get the average output for the last 3 games

             //  Always start with the Average points in their last 3 games, if 0 and QB use 14
             if (game != null)
             {
            if (player.PlayerRole.Equals(Constants.K_ROLE_STARTER))
            {
               var avgPoints = AveragePoints(player);

               //  Rookies and injured players may not have played in the last 3 games
               if ( player.PlayerCat.Equals( "1" ) )
               {
                  if (avgPoints.Equals( 0.0M )) avgPoints = 14.0M;  // avergage for a QB
               }
               if ( player.PlayerCat.Equals( "2" ) )
               {
                  if ( avgPoints.Equals( 0.0M ) ) avgPoints = 8.0M;  // avergage for a RB
               }
               if ( player.PlayerCat.Equals( "3" ) )
               {
                  if ( avgPoints.Equals( 0.0M ) ) avgPoints = 6.0M;  // avergage for a RB
               }
               else if ( player.PlayerCat.Equals( "4" ))
               {
                  if (avgPoints.Equals( 0.0M )) avgPoints = 6.0M;  // avergage day for a PK
               }
               points += avgPoints;
            }
             }

             #endregion

             #region  Consider the likely result

             decimal spreadModifier = 1;  //  no modification

             if ( IncludeSpread )
             {
            if (game != null) spreadModifier = PlayerSpread( game.GetSpread(), game.IsHome( player.CurrTeam.TeamCode ) ) / 1;

            points *= spreadModifier;
             }

             #endregion

             #region  factor in the quality of the opponent

             if ( IncludeRatingModifier )
             {
            if ( opponent != null )
            {
               var oppRating = player.OpponentRating( opponent.Ratings );
               var ratingModifier = RatingModifier( oppRating );
               points *= ratingModifier;
            }
             }

             #endregion

             player.Points = points;
             RankMaster.Add(player.PlayerCode, player); //  save points for later

            #if DEBUG
             //  verbose audit trail of the calculations
             //Utility.Announce( string.Format(
             //   "{0,-16} has {1,4:#0.#} r pts- spr {2,4:#0.#} avgFP last 3 {3,4:##.#} rating mod {4,4:#0.#} {5}",
             //   player.PlayerNameShort, points, spreadModifier, avgPoints, ratingModifier, oppRating ) );
            #endif
             return points;
        }
Esempio n. 5
0
        private static void ProcessGame(UnitMatrix u, NFLGame g)
        {
            var weekOffset = Int32.Parse(g.Week) - 1;
            Utility.Announce(string.Format("Game {0}", g.GameCodeOut()));
            if ((weekOffset < 0) || (weekOffset > 20))
                Utility.Announce(string.Format("Game {0} has week {1}", g.GameCodeOut(), g.Week));
            else
            {
                if (!g.MetricsCalculated) g.TallyMetrics(String.Empty);

                decimal metric = (g.IsHome(u.Team.TeamCode) ? g.HomeTDp : g.AwayTDp);
                GetEp("PO", u.PoExp, g, u, weekOffset, metric);

                metric = (g.IsHome(u.Team.TeamCode) ? g.HomeTDr : g.AwayTDr);
                GetEp("RO", u.RoExp, g, u, weekOffset, metric);

                metric = (g.IsHome(u.Team.TeamCode) ? g.HomeSaKa : g.AwaySaKa);
                GetEp("PP", u.PpExp, g, u, weekOffset, metric);

                metric = (g.IsHome(u.Team.TeamCode) ? g.AwaySaKa : g.HomeSaKa);
                GetEp("PR", u.PrExp, g, u, weekOffset, metric);

                metric = (g.IsHome(u.Team.TeamCode) ? g.AwayTDr : g.HomeTDr);
                GetEp("RD", u.RdExp, g, u, weekOffset, metric);

                metric = (g.IsHome(u.Team.TeamCode) ? g.AwaySaKa : g.HomeSaKa);
                GetEp("PD", u.PdExp, g, u, weekOffset, metric);
            }
        }