示例#1
0
        private void RecordKickingStats(string baseUri, string week, XElement element)
        {
            var    values = element.Elements().ToList();
            string rawXPM = values[2].Value;
            string rawXPA = values[3].Value;
            string rawFGM = values[4].Value;
            string rawFGA = values[5].Value;

            if (string.IsNullOrWhiteSpace(rawXPM) && string.IsNullOrWhiteSpace(rawXPA) &&
                string.IsNullOrWhiteSpace(rawFGM) && string.IsNullOrWhiteSpace(rawFGA))
            {
                // punters and kickers are in the same table, if no values are present, then
                // this is a punter.
                return;
            }

            NFLPlayer player = ExtractPlayerInfo(element, baseUri);

            AssignTeam(player, element);

            Game game = new Game();

            game.Week = int.Parse(week);
            //game2.Opponent = this.context.GetTeam(values[1].Value);

            Kicking k = game.Kicking = new Kicking();

            k.FGM = string.IsNullOrWhiteSpace(rawFGM) ? 0 : int.Parse(rawFGM);
            k.FGA = string.IsNullOrWhiteSpace(rawFGA) ? 0 : int.Parse(rawFGA);

            k.XPM = string.IsNullOrWhiteSpace(rawXPM) ? 0 : int.Parse(rawXPM);
            k.XPA = string.IsNullOrWhiteSpace(rawXPA) ? 0 : int.Parse(rawXPA);

            player.GameLog.Add(game);
        }
示例#2
0
        /// <summary />
        public static int TotalBonuses(this NFLPlayer player)
        {
            int bonuses = 0;

            foreach (Game game in player.GameLog)
            {
                Passing p = game.Passing;
                if (p != null)
                {
                    bonuses += CountBonuses(p.YDS, 300, 100);
                }

                Rushing r = game.Rushing;
                if (r != null)
                {
                    bonuses += CountBonuses(r.YDS, 100, 50);
                }

                Receiving c = game.Receiving;
                if (c != null)
                {
                    bonuses += CountBonuses(c.YDS, 100, 50);
                }

                Kicking k = game.Kicking;
                if (k != null)
                {
                    // unable to determine bonuses for kicking yet
                }

                Defense dst = game.Defense;
                if (dst != null)
                {
                    // unable to determine bonuses for defense yet
                }
            }

            return(bonuses);
        }
示例#3
0
        /// <summary />
        public static int GetFanastyPoints(this Game game)
        {
            int points = 0;

            Passing p = game.Passing;

            if (p != null)
            {
                points += p.YDS;
                points += 50 * CountBonuses(p.YDS, 300, 100);
                points -= p.INT * 50;

                // estimate 10 yards per passing TD on average
                points += p.TD * 10;
            }

            Rushing r = game.Rushing;

            if (r != null)
            {
                points += r.YDS;
                points += 50 * CountBonuses(r.YDS, 100, 50);

                // estimate 3 yards per rushing TD on average
                points += r.TD * 3;
            }

            Receiving c = game.Receiving;

            if (c != null)
            {
                points += c.YDS;
                points += 50 * CountBonuses(c.YDS, 100, 50);

                // estimate 10 yards per receiving TD on average
                points += c.TD * 10;
            }

            Fumbles f = game.Fumbles;

            if (f != null)
            {
                points -= f.FUM * 25;
            }

            Kicking k = game.Kicking;

            if (k != null)
            {
                // calculate the points for all field goals awarding
                // points per yard of a field goal and subtracting the
                // points of a missed fieldgoal.

                // In 2016, the average kick was from 37.7 yards away; the average
                // successful kick was from 36.2 yards out - while the average miss was from 46.2 yards away.

                points += k.FGM * 38;
                points -= (k.FGA - k.FGM) * 46;

                // calculate 20 points for each extra point made and
                // subtract 20 points for each point missed
                points += k.XPM * 33;
                points -= (k.XPA - k.XPM) * 33;
            }

            Defense defense = game.Defense;

            if (defense != null)
            {
                //calculate points for interceptions
                points += defense.INT * 50;
                points += defense.YDS_INT;
                if (defense.TD_INT > 0)
                {
                    // if we have a touchdown, one point per yard avaraged
                    points += (defense.YDS_INT / defense.TD_INT) * defense.TD_INT;
                }

                // calculate points for fumble recoveries
                points += defense.FUM * 25;
                if (defense.TD_FUM > 0)
                {
                    // if we have a touchdown, one point per yard averaged
                    points += (defense.YDS_FUM / defense.TD_FUM) * defense.TD_FUM;
                }

                // calculate points for sacks
                points += defense.SACK * 10;
            }

            return(points);
        }