Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Gameplay.PlayoffSeries"/> class.
        /// </summary>
        /// <param name="seriesName">string</param>
        /// <param name="roadTeam">Team</param>
        /// <param name="homeTeam">Team</param>
        /// <param name="numGames">int</param>
        /// <param name="playFullSeries">bool</param>
        /// <param name="alternateVenues">bool</param>
        /// <param name="silentMode">If set to <c>true</c> silent mode.</param>
        /// <param name="isSeasonMode">If set to <c>true</c> is season mode.</param>
        /// <param name="interval">int</param>
        public Series(string seriesName, Team roadTeam, Team homeTeam, int numGames, bool playFullSeries = true, bool silentMode = false, bool alternateVenues = true, bool isSeasonMode = true, int interval = 1000)
        {
            if (numGames % 2 == 0)
            {
                throw new Exception("A playoff series must have an odd number of games.");
            }
            this.seriesName     = seriesName;
            this.roadTeam       = roadTeam;
            this.homeTeam       = homeTeam;
            this.numGames       = numGames;
            this.playFullSeries = playFullSeries;
            this.silentMode     = silentMode;
            this.isSeasonMode   = isSeasonMode;
            this.interval       = interval;

            if (alternateVenues)//playoff or world series, alternate venues
            {
                this.numberOfRoadTeamHomeGames = numGames / 2;
                this.numberOfHomeTeamHomeGames = (numGames / 2) + 1;


                for (int i = 0; i < this.numberOfHomeTeamHomeGames / 2; i++)
                {
                    venues.Add(VenueManager.GetVenue(homeTeam.RawName));
                    roadTeams.Add(roadTeam);
                    homeTeams.Add(homeTeam);
                }
                for (int i = 0; i < this.numberOfRoadTeamHomeGames; i++)
                {
                    venues.Add(VenueManager.GetVenue(roadTeam.RawName));
                    roadTeams.Add(homeTeam);
                    homeTeams.Add(roadTeam);
                }
                for (int i = 0; i < this.numberOfHomeTeamHomeGames / 2; i++)
                {
                    venues.Add(VenueManager.GetVenue(homeTeam.RawName));
                    roadTeams.Add(roadTeam);
                    homeTeams.Add(homeTeam);
                }
            }
            else//normal series, no alternation
            {
                for (int i = 0; i < numGames; i++)
                {
                    try //VenueManager will return a generically named stadium if nothing is found.
                    {
                        venues.Add(VenueManager.GetVenue(homeTeam.RawName));
                        roadTeams.Add(roadTeam);
                        homeTeams.Add(homeTeam);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Stadium for {homeTeam} not found.\n");
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
Beispiel #2
0
        public void TestCheckInningsPitched()
        {
            Db database = new Db(conn);

            bool passed = true;

            const int ITERATIONS = 3;


            Team roadTeam;
            Team homeTeam;

            for (int i = 0; i < ITERATIONS && passed; i++)
            {
                roadTeam = DatabaseTeamLoader.LoadTeam("New York", "Yankees", 1982, database);
                roadTeam.CapitalizeNames      = true;
                roadTeam.ShowExtendedToString = true;
                homeTeam = DatabaseTeamLoader.LoadTeam("Oakland", "Athletics", 1982, database);
                homeTeam.CapitalizeNames      = true;
                homeTeam.ShowExtendedToString = true;

                Game g = null;

                Venue venue = VenueManager.GetVenue(homeTeam.RawName);

                g = new Game(venue, roadTeam, homeTeam, Game.GenerateGameTime(), Convert.ToInt32(ConfigurationManager.GetConfigurationValue("CURRENT_NUM_INNINGS_REGULATION")), true);

                Logger logger = new Logger(String.Format($"{ConfigurationManager.GetConfigurationValue("GAME_FILE_DIRECTORY")}{g.Id}{ConfigurationManager.GetConfigurationValue("GAME_FILE_EXTENSION")}"));

                g.Announcer        = new Announcer(Guid.NewGuid().ToString(), ConfigurationManager.GetConfigurationValue("ANNOUNCER_NAME"), logger);//make sure announcer commentary gets logged
                g.Announcer.Silent = false;
                g.Announcer.AnnounceToConsole(ConfigurationManager.GetConfigurationValue("GAME_TITLE"));
                g.Execute();
                GameStatisticsDisplayer displayer = new GameStatisticsDisplayer(g.Scoreboard);
                Console.WriteLine(displayer.GetBoxScore());
                g.Announcer.AnnounceToConsole(new GameStatisticsDisplayer(g.Scoreboard).GetFullBoxScore());
                Console.WriteLine($"{g.Scoreboard.ToString()}");
                logger.WriteToFile();

                int totalHomeOuts = 0;
                int totalInnings  = g.Scoreboard.InningScores.Length;
                foreach (Player p in g.HomeTeam.Roster.StartingPitchers)
                {
                    totalHomeOuts += p.PitchingStatistics.TotalOuts;
                }
                foreach (Player p in g.HomeTeam.Roster.Bullpen)
                {
                    totalHomeOuts += p.PitchingStatistics.TotalOuts;
                }
                Console.WriteLine($"TotalHomeOuts: {totalHomeOuts} - TotalInnings: {totalInnings}");
                if (totalHomeOuts != (totalInnings * 3))
                {
                    passed = false;
                }
            }
            Assert.IsTrue(passed);
        }
Beispiel #3
0
        public void TestGetVenueManager()
        {
            Venue theVenue = VenueManager.GetVenue("Los Angeles Angels");

            Console.WriteLine(theVenue);
            Assert.IsTrue(VenueManager.VenueCount == 30);
            Assert.IsTrue(theVenue.Name.Equals("Angel Stadium"));
            Assert.IsTrue(theVenue.Capacity == 45517);
            Assert.IsTrue(theVenue.Location.Equals("Anaheim, California"));
            Console.WriteLine(theVenue);
        }
Beispiel #4
0
 public void TestGenericVenueInformation()
 {
     Assert.IsTrue(Venue.GenericVenue.Location == "Anytown, USA");
     Assert.IsTrue(Venue.GenericVenue.Capacity == 40000);
     Assert.IsTrue(VenueManager.GetVenue("Montreal Expos").Name == "Montreal Expos Stadium");
 }