コード例 #1
0
        private GameMetrics CalculateGameMetrics( bool isHome, NFLGame game, DateTime focusDate )
        {
            string teamRatings;
            string oppRatings;

            var gm = new GameMetrics();

            if ( isHome )
            {
                oppRatings = RatingsService.GetUnitRatingsFor( game.AwayNflTeam, focusDate );
                teamRatings = RatingsService.GetUnitRatingsFor( game.HomeNflTeam, focusDate );
                game.AwayNflTeam.Ratings = oppRatings;
                game.HomeNflTeam.Ratings = teamRatings;
            }
            else
            {
                teamRatings = RatingsService.GetUnitRatingsFor( game.AwayNflTeam, focusDate );
                oppRatings = RatingsService.GetUnitRatingsFor( game.HomeNflTeam, focusDate );
                game.HomeNflTeam.Ratings = oppRatings;
                game.AwayNflTeam.Ratings = teamRatings;
            }

            var score = 0;
            if ( string.IsNullOrEmpty( teamRatings ) || string.IsNullOrEmpty( oppRatings ))
                Utility.Announce( "Ratings not found - skipping score calculation" );
            else
            {
                var fg = isHome ? 2 : 1;
                if (game.IsDomeGame())
                    fg++;
                else
                {
                    if (game.IsBadWeather())
                        fg--;
                }

                //  Part 1 - Calculate Tdp
                var po = teamRatings.Substring( 0, 1 );
                var pd = oppRatings.Substring( 5, 1 );
                var tdp = TouchdownPasses( po, pd );
                var ydp = YardsPassing( po, pd );
                gm.TDp = tdp;
                gm.YDp = ydp;

                //  Part 2 - Adjust for protection
                var pp = teamRatings.Substring( 2, 1 );
                var pr = oppRatings.Substring( 3, 1 );
                var ppr = ProtectionAdjustment( pp, pr );

                tdp += ppr;
                if ( tdp < 0 ) tdp = 0;

                //  Part 3 - Calculate Tdr
                var ro = teamRatings.Substring( 1, 1 );
                var rd = oppRatings.Substring( 4, 1 );
                var tdr = TouchdownRuns( ro, rd );
                var ydr = YardsRushing( ro, rd );
                gm.TDp = tdp;
                gm.TDr = tdr;
                gm.YDr = ydr;

                var tdd = DefensiveScores(game.IsDivisionalGame(), isHome);

                var tds = SpecialTeamScores(game.IsMondayNight(), isHome);

                gm.TDd = tdd;
                gm.TDs = tds;
                gm.FG = fg;

                //TODO:  Short week adjustment
                //TODO:  Opponent had Route last game adjustment
                //TODO:  Revenge adjustment

                // Total up all the parts of a score
                score = ( tdp + tdr + tdd + tds )*7 + (fg * 3);

                DumpCalculations( isHome, game, tdr, pr, pp, ro, tds, tdd, rd, oppRatings,
                    teamRatings, ppr, tdp, score, pd, po, fg);

                if ( isHome )
                {
                    _homeTDp = tdp;
                    _homeTDr = tdr;
                    _homeFg = fg;
                    _homeTDd = tdd;
                    _homeTDs = tds;
                    _homeYDr = ydr;
                    _homeYDp = ydp;
                }
                else
                {
                    _awayTDp = tdp;
                    _awayTDr = tdr;
                    _awayFg = fg;
                    _awayTDd = tdd;
                    _awayTDs = tds;
                    _awayYDr = ydr;
                    _awayYDp = ydp;
                }
            }
            gm.Score = score;
            return gm;
        }
コード例 #2
0
ファイル: NFLTeam.cs プロジェクト: Quarterback16/GerardGui
        private int GuessFGs(NFLGame game)
        {
            int nFg = 1;
             string opponent = (TeamCode == game.HomeTeam) ? game.AwayTeam : game.HomeTeam;
             //  Also load in the FGs allowed by the defensive team
             ArrayList fgAllowedList = GetFGallowed(opponent);
             ArrayList totalFGlist = JoinLists(fgAllowedList, _fgResultList);

             int nStats = totalFGlist.Count;

             if (nStats > 0)
             {
            RandomNumber myRandom = new RandomNumber(); //  Generate a random number

            nFg = GuessFg(_fgResultList, nStats, myRandom);

            if (nFg > 0)
               if (game.IsBadWeather()) nFg--;

            if (game.IsDomeGame()) nFg++;

            //if ( game.HomeTeam == this.TeamCode ) nFG++;
             }

             return nFg;
        }
コード例 #3
0
        private static void DumpCalculations(bool isHome, NFLGame game, int tdr, string pr, string pp, string ro, int tds,
		                                     int tdd, string rd, string oppRatings, string teamRatings, int ppr, int tdp,
		                                     int score, string pd, string po, int fg)
        {
            var team = isHome ? game.HomeTeamName : game.AwayTeamName;
            Utility.Announce(string.Format("team {2} Ratings : {0}-{3} opponentRatings {1}-{4}",
                                                     teamRatings, oppRatings, team,
                                                     Utility.RatingPts(teamRatings),
                                                     Utility.RatingPts(oppRatings) ) );
            if (game.IsDomeGame())
                Utility.Announce("Adding FG for Dome game");
            if (game.IsBadWeather())
                Utility.Announce("Subtracting FG for bad weather");
            Utility.Announce(string.Format("PO-{1} v PD-{2}:TD passes: {0}", tdp-ppr, po, pd));
            Utility.Announce(string.Format("PP-{1} v PR-{2}:TD passes: {0}", ppr, pp, pr));
            Utility.Announce(string.Format("RO-{1} v RD-{2}:TD runs: {0}", tdr, ro, rd));
            Utility.Announce(string.Format("Field goals: {0}", fg ));
            Utility.Announce(string.Format("Defensive Scores: {0}", tdd));
            Utility.Announce(string.Format("Special Team Scores: {0}", tds));
            Utility.Announce(string.Format("Total Score: {0}", score));
        }