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
        }
        private void WriteCountLine( DataTable dt, string stat )
        {
            var dr = dt.NewRow();
             dr[ "STAT" ] = stat;

             var tot = 0;
             foreach ( var week in NflSeason.RegularWeeks )
             {
            var weekNo = string.Format( "WK{0}", week.Week );
            var actuals = GetActuals( NflSeason.Year, week.Week );
            var nInWeek = 0;
            var predTab = actuals.Tables[ "sched" ];
            foreach ( DataRow row in predTab.Rows )
            {
               var g = new NFLGame( row );
            #if DEBUG
               Utility.Announce( g.ScoreOut() );
            #endif
               if ( g.TotalTds() == 0 || ForceRefresh )
                  g.RefreshTotals();

               g.TallyMetrics( string.Empty );

               switch ( stat )
               {
                  case "TDr":
                     nInWeek += g.HomeTDr + g.AwayTDr;
                     break;
                  case "TDp":
                     nInWeek += g.HomeTDp + g.AwayTDp;
                     break;
                  case "TDd":
                     nInWeek += g.HomeTDd + g.AwayTDd;
                     break;
                  case "TDs":
                     nInWeek += g.HomeTDs + g.AwayTDs;
                     break;
                  case "FG":
                     nInWeek += g.HomeFg + g.AwayFg;
                     break;
                  case "YDp":
                     nInWeek += g.HomeYDp + g.AwayYDp;
                     break;
                  case "YDr":
                     nInWeek += g.HomeYDr + g.AwayYDr;
                     break;

                  default:
                     break;
               }
            }
            if ( nInWeek > 0 )
            {
               tot += nInWeek;
               dr[ weekNo ] = string.Format( "{0}", nInWeek );
            }
            #if DEBUG
            //break;  //  dont iterate v not got time
            #endif
             }
             dr[ "TOT" ] = tot;
             dt.Rows.Add( dr );
        }
Exemple #3
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);
            }
        }