Example #1
0
 public void AddGame(NFLGame g)
 {
     if (!_gameHt.ContainsKey(g.GameKey()))
     {
         _gameHt.Add(g.GameKey(), g);
         IsDirty = true;
     }
 }
Example #2
0
        public PlayerGameMetricsCollection(NFLGame game)
        {
            GameKey = game.GameKey();
            var pgms = game.PlayerGameMetrics;

            if (pgms == null)
            {
                pgms = new List <PlayerGameMetrics>();
            }
            Pgms = pgms;
        }
        public 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
            Announce($"Game {g.GameKey()} projection for {playerTeamCode} {playerCategory} {playerRole} is {projection}");
#endif
            return(projection);
        }
Example #4
0
        private static void WriteGameNode(XmlWriter writer, NFLGame g)
        {
            var winner = g.WinningTeamCode();

            if (winner.Equals("HO"))
            {
                winner = "TT";
            }

            if ((g.HomeScore + g.AwayScore == 0) && (g.GameDate < DateTime.Now))
            {
                Utility.Announce(String.Format("0-0 tie {0} {1} @ {2}", g.GameKey(), g.AwayTeamName, g.HomeTeamName));
            }

            writer.WriteStartElement("game");
            writer.WriteAttributeString("winner", winner);
            writer.WriteAttributeString("type", g.GameType());
            decimal spread = g.Spread;

            if (spread == 0.0M)
            {
                writer.WriteAttributeString("off-the-board", "true");
            }
            else if (spread == 0.5M)
            {
                spread = 0.0M;
            }

            if (g.WentIntoOvertime())
            {
                writer.WriteAttributeString("overtime", "true");
            }

            WriteElement(writer, "date", g.GameDate.ToString("yyyy-MM-dd"));
            WriteElement(writer, "week-number", g.WeekNo.ToString());

            WriteTeams(writer, g);
            WriteElement(writer, "spread", spread.ToString());
            writer.WriteEndElement();
        }
        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));
            }
        }