Esempio n. 1
0
    public static bool Save(Venue venue, string gameID)
    {
        string filename = VenueManager.GetFilename(gameID) + "?tag=" + venue.id;

        ES2.Save(venue, filename);
        return(true);
    }
Esempio n. 2
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">string[]</param>
        public static void Main(string[] args)
        {
            //TODO: Implement DH logic
            //TODO: Implement double round robin
            //TODO: Refactor TeamGroupTree into Composite-Leaf pattern
            //TODO: Implement full season (162 games)

            ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
            StoredProcedureManager.Init(ConfigurationManager.GetConfigurationValue("STORED_PROCEDURES_DIRECTORY"));
            VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
            SABRMetricsManager.Init(ConfigurationManager.GetConfigurationValue("SABRMETRICS_DIRECTORY"), true);

            ConsoleMenu menu             = new ConsoleMenu(ConfigurationManager.GetConfigurationValue("TITLE"), true);
            MenuChoice  chooseTeam       = new MenuChoice(ViewTeamInformation.Display, "View Team", true);
            MenuChoice  chooseLeague     = new MenuChoice(ViewLeagueInformation.Display, "View League", true);
            MenuChoice  playRoundRobin   = new MenuChoice(PlayRoundRobin.SelectYear, "Play Round Robin!", true);
            MenuChoice  playSeries       = new MenuChoice(PlaySeries.SetUpSeries, "Play Series", true);
            MenuChoice  playWorldSeries  = new MenuChoice(PlayChampionshipSeries.SelectWorldSeries, "Replay Championship Series", true);
            MenuChoice  cleanGamesFolder = new MenuChoice(CleanGamesFolder.LoadCleanGamesFolder, "Clean Games Folder", true);
            MenuChoice  exit             = new MenuChoice(ProgramExit.Exit, "Exit", true);

            menu.AddItem(chooseTeam);
            menu.AddItem(chooseLeague);
            menu.AddItem(playRoundRobin);
            menu.AddItem(playSeries);
            menu.AddItem(playWorldSeries);
            menu.AddItem(cleanGamesFolder);
            menu.AddItem(exit);
            menu.Run();
        }
Esempio n. 3
0
 public void Init()
 {
     ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
     StoredProcedureManager.Init(@"./Data/StoredProcedures/");
     VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
     conn = Constants.SQLITE3_CONNECTION_STRING;
 }
Esempio n. 4
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);
                    }
                }
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
    public void DeleteSaved(SavedGame game)
    {
        GameManager.DeleteSaved(game.gameID);
        CompanyManager.DeleteSaved(game.gameID);
        WrestlerManager.DeleteSaved(game.gameID);
        VenueManager.DeleteSaved(game.gameID);

        games.Remove(game);
    }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public MainPage()
        {
            this.InitializeComponent();
            VenueManager m = map.VenueManager;

            m.UseDefaultVenueTooltip = false;
            m.VenueEntityTapped     += Venue_Tapped;

            mDispatcher = Dispatcher;
            Loaded     += MainPage_Loaded;
        }
Esempio n. 9
0
        public void Clear()
        {
            foreach (var v in EventManager.GetAll())
            {
                Context.Entry(v).State = EntityState.Deleted;
            }

            foreach (var v in VenueManager.GetAll())
            {
                Context.Entry(v).State = EntityState.Deleted;
            }

            Context.SaveChanges();
        }
    public static void DeleteSaved(string gameID)
    {
        string filename = VenueManager.GetFilename(gameID);

        if (ES2.Exists(filename))
        {
            ES2.Delete(filename);
        }

        if (VenueManager.Instance != null && SavedGameManager.Instance.IsGameLoaded() && gameID == SavedGameManager.Instance.CurrentGameID)
        {
            VenueManager.Instance.DestroyCurrentGameObjects();
        }
    }
Esempio n. 11
0
    public static bool DeleteSaved(string id, string gameID)
    {
        string filename = VenueManager.GetFilename(gameID) + "?tag=" + id;

        if (ES2.Exists(filename))
        {
            ES2.Delete(filename);
            return(true);
        }
        else
        {
            Debug.LogError(string.Format("Unable to delete venue at {0}: No such file found", filename));
            return(false);
        }
    }
Esempio n. 12
0
    public static bool Load(Venue venue, string id, string gameID)
    {
        string filename = VenueManager.GetFilename(gameID) + "?tag=" + id;

        if (ES2.Exists(filename))
        {
            ES2.Load <Venue>(filename, venue);
            venue.name = venue.venueName;
            return(true);
        }
        else
        {
            Debug.LogError(string.Format("Unable to load venue from {0}: No such file found", filename));
            return(false);
        }
    }
    public void Load(string gameID)
    {
        DestroyCurrentGameObjects();

        string filename = VenueManager.GetFilename(gameID);

        if (ES2.Exists(filename))
        {
            string[] tags = ES2.GetTags(filename);
            foreach (string tag in tags)
            {
                Venue venue = CreateEmptyVenue();
                Venue.Load(venue, tag, gameID);
                venues.Add(venue);
            }
        }
    }
    // Use this for initialization
    void Awake()
    {
        if (null == Instance)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
            if (!venuePrefab)
            {
                Debug.LogError("Unable to start Venue Manager: No venue prefab is set.");
            }

            venueGenerator.Initialize();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Esempio n. 15
0
        public void Init()
        {
            ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
            StoredProcedureManager.Init(@"./Data/StoredProcedures/");
            VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
            conn = Constants.SQLITE3_CONNECTION_STRING;

            database       = new Db(conn);
            americanLeague = DatabaseGroupLoader.LoadRoot("AL", year, database);
            americanLeague.ParentDirectoryPath = System.IO.Path.Combine($"{ConfigurationManager.GetConfigurationValue("GAME_FILE_DIRECTORY")}");
            nationalLeague = DatabaseGroupLoader.LoadRoot("NL", year, database);
            nationalLeague.ParentDirectoryPath = System.IO.Path.Combine($"{ConfigurationManager.GetConfigurationValue("GAME_FILE_DIRECTORY")}");

            try
            {
                americanLeague.Execute();
                nationalLeague.Execute();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 16
0
 public void Init()
 {
     ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
     StoredProcedureManager.Init(ConfigurationManager.GetConfigurationValue("STORED_PROCEDURES_DIRECTORY"));
     VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
 }
Esempio n. 17
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");
 }
Esempio n. 18
0
 public void Init()
 {
     ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
     VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
 }