Example #1
0
 public NflTeam GetAwayTeam()
 {
     AwayNflTeam = Masters.Tm.GetTeam(Season, AwayTeam);
      AwayNflTeam.SetRecord(Season, skipPostseason: false);
      return AwayNflTeam;
 }
Example #2
0
 public NflTeam GetHomeTeam()
 {
     HomeNflTeam = Masters.Tm.GetTeam(Season, HomeTeam);
      HomeNflTeam.SetRecord(Season, skipPostseason: false);
      return HomeNflTeam;
 }
Example #3
0
        /// <summary>
        ///   Returns a number representing how strong the teams opponents
        ///   are based on the oppnents results last year.
        /// </summary>
        /// <returns>a clip number W-L clip of opponents</returns>
        public double StrengthOfSchedule()
        {
            var oppWins = 0;
             var oppLosses = 0;

             if (SoS != 0.000D) return SoS;

             //  set my record last year

             SetRecord(Utility.LastSeason(), skipPostseason: false);
             var myClip = Utility.Clip( Wins, Losses, Ties );
            #if DEBUG
             Utility.Announce( string.Format( "---{0}----------------------------------------------------------------------------------", TeamCode ) );
             Utility.Announce( string.Format( "set {1} record last year {0} {2}-{3}-{4} {5:0.##0}",
            Utility.LastSeason(), this, Wins, Losses, Ties, Utility.Clip( Wins, Losses, Ties  ) ) );
            #endif
             //  Calculate it
             foreach (NFLGame g in GameList)
             {
            #if DEBUG
            string res;
            #endif
            var opp = (g.HomeTeam == TeamCode) ? g.AwayTeam : g.HomeTeam;
            var ha = (g.HomeTeam == TeamCode) ? "v" : "@";
            var opponent = new NflTeam(opp);
            opponent.SetRecord(Utility.LastSeason(), skipPostseason: false);
            oppWins += opponent.Wins;
            oppLosses += opponent.Losses;
            var oppClip = Utility.Clip( opponent.Wins, opponent.Losses, opponent.Ties );

            //  Calculate expected result based on this teams clip
            if (myClip > oppClip)
            {
               ExpWins++;
            #if DEBUG
               res = "WIN";
            #endif
            }
            else
            {
               if (myClip == oppClip)
               {
                  if (ha == "v")
                  {
                     ExpWins++;
            #if DEBUG
                     res = "WIN";
            #endif
                  }
                  else
                  {
                     ExpLosses++;
            #if DEBUG
                     res = "LOSS";
            #endif
                  }
               }
               else
               {
                  ExpLosses++;
            #if DEBUG
                  res = "LOSS";
            #endif
               }
            }

            #if DEBUG
            Utility.Announce(string.Format("    Wk {0}  {7}{1} {2,2}-{3,2} {4,3}-{5,3} {6}",
               g.Week, opponent.Name, opponent.Wins, opponent.Losses, oppWins,
               oppLosses, res,
               ha));
            #endif
             }
             SoS = (double)oppWins / (oppWins + oppLosses);
            #if DEBUG
             Utility.Announce(
            string.Format("{0} ({5,2}-{6,2} {4:0.##0}) Strength of schedule {1:0.##0} exp record {2,2}-{3,2}",
               Name.Trim(), SoS, ExpWins, ExpLosses, myClip, Wins, Losses));
            #endif

             return SoS;
        }