/// <summary>
        /// display the rules screen
        /// </summary>
        public void DisplayRulesScreen(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "The Rules";
            ConsoleUtil.DisplayReset();

            Console.WriteLine(ConsoleUtil.Center("This is tic-tac-toe with a twist."));
            Console.WriteLine(ConsoleUtil.Center("Instead of a 3x3 gameboard, we have a 4x4 gameboard."));
            Console.WriteLine();
            Console.WriteLine(ConsoleUtil.Center("You can win by getting four up, down, diagonal, and four corners."));
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();


            sb.Clear();
            Console.WriteLine(ConsoleUtil.Center("Press Enter to Continue, Press Esc to Quit"));
            Console.WriteLine();

            ConsoleKeyInfo info = Console.ReadKey();

            if (info.Key == ConsoleKey.Escape)
            {
                DisplayExitPrompt();
            }
            else if (info.Key == ConsoleKey.Enter)
            {
                DisplayMainMenu(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
        }
        /// <summary>
        /// display the welcome screen
        /// </summary>
        public void DisplayWelcomeScreen(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "The Tic-Tac-Toe Game";
            ConsoleUtil.DisplayReset();

            Console.WriteLine(ConsoleUtil.Center("Written by Jen Berigan and Alex Briggs"));
            Console.WriteLine(ConsoleUtil.Center("Northwestern Michigan College"));
            Console.WriteLine(ConsoleUtil.Center("Version: Sprint 2"));
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat(ConsoleUtil.Center("This application is designed to allow two players to play a game of tic-tac-toe. Though there's a bit of a twist...we have a 4x4 gameboard"));
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();
            Console.WriteLine();

            sb.Clear();
            Console.WriteLine(ConsoleUtil.Center("Press ESC key at anytime to exit."));
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();

            ConsoleKeyInfo info = Console.ReadKey();

            if (info.Key == ConsoleKey.Escape)
            {
                DisplayExitPrompt();
            }
            else if (info.Key == ConsoleKey.Enter)
            {
                DisplayMainMenu(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
        }
Exemple #3
0
        /// <summary>
        /// reset display to default size and colors including the header
        /// </summary>
        public static void DisplayReset()
        {
            Console.SetWindowSize(_windowWidth, _windowHeight);
            Console.Title = _windowTitle;

            Console.Clear();
            Console.ResetColor();

            Console.ForegroundColor = _headerForegroundColor;
            Console.BackgroundColor = _headerBackgroundColor;

            Console.WriteLine(ConsoleUtil.FillStringWithSpaces(_windowWidth));
            Console.WriteLine(ConsoleUtil.Center(_headerText));
            if (_subHeaderText != "")
            {
                Console.WriteLine(ConsoleUtil.Center(_subHeaderText));
            }
            else
            {
                Console.WriteLine(ConsoleUtil.FillStringWithSpaces(_windowWidth));
            }

            Console.ForegroundColor = _bodyForegroundColor;
            Console.BackgroundColor = _bodyBackgroundColor;

            Console.WriteLine();
        }
        /// <summary>
        /// display the MainMenu prompt
        /// </summary>
        public void DisplayMainMenu(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            Console.Clear();

            Console.CursorVisible = false;

            ConsoleUtil.HeaderText = "The Tic-Tac-Toe Game";
            ConsoleUtil.DisplayReset();


            Console.WriteLine(ConsoleUtil.Center("A. Play a New Round"));
            Console.WriteLine(ConsoleUtil.Center("B. View Rules"));
            Console.WriteLine(ConsoleUtil.Center("C. View Current Game Stats"));
            Console.WriteLine(ConsoleUtil.Center("D. View Historic Game Stats"));
            Console.WriteLine(ConsoleUtil.Center("E. Save Game Results"));
            Console.WriteLine(ConsoleUtil.Center("F. Quit"));
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine(ConsoleUtil.Center("Enter a letter to go to that screen"));
            ConsoleKeyInfo response = Console.ReadKey();

            Console.WriteLine();

            Console.CursorVisible = true;

            //while (true)
            //{

            //}
            if (response.Key == ConsoleKey.A)
            {
                Console.Clear();
                ChooseFirstPlayer(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (response.Key == ConsoleKey.B)
            {
                DisplayRulesScreen(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (response.Key == ConsoleKey.C)
            {
                DisplayCurrentGameStatus(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (response.Key == ConsoleKey.D)
            {
                DisplayHistoricGameStatus(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (response.Key == ConsoleKey.E)
            {
                DisplaySaveGameScreen();
            }
            else if (response.Key == ConsoleKey.F)
            {
                DisplayExitPrompt();
            }
        }
        /// <summary>
        /// display the maximum attempts reached screen
        /// </summary>
        public void DisplayMaxAttemptsReachedScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "Maximum Attempts Reached!";
            ConsoleUtil.DisplayReset();
            sb.Append(ConsoleUtil.Center(" It appears that you are having difficulty entering your choice." + Environment.NewLine));
            sb.Append(ConsoleUtil.Center("Please refer to the instructions and play again."));

            DisplayMessageBox(sb.ToString());
            DisplayContinuePromptCentered();
        }
        public void DisplayContinuePromptCentered()
        {
            Console.CursorVisible = false;

            Console.WriteLine();

            Console.WriteLine(ConsoleUtil.Center("Press any key to continue."));
            ConsoleKeyInfo response = Console.ReadKey();

            Console.WriteLine();

            Console.CursorVisible = true;
        }
        public void DisplayMessageBox(string message)
        {
            string leftMargin = new String(' ', ConsoleConfig.displayHorizontalMargin);
            string topBottom  = new String('*', ConsoleConfig.windowWidth - 2 * ConsoleConfig.displayHorizontalMargin);

            StringBuilder sb = new StringBuilder();

            Console.SetCursorPosition(0, MESSAGEBOX_VERTICAL_LOCATION);
            Console.WriteLine(leftMargin + topBottom);

            Console.WriteLine(ConsoleUtil.Center("Game Status"));

            ConsoleUtil.DisplayMessage(message);

            Console.WriteLine(Environment.NewLine + leftMargin + topBottom);
        }
        /// <summary>
        /// displays the who goes first method
        /// </summary>
        public void ChooseFirstPlayer(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            Console.CursorVisible = false;

            int playerFirstChoice;

            // asks the player who wants to go first
            ConsoleUtil.HeaderText = "Who Goes First?";
            ConsoleUtil.DisplayReset();

            Console.WriteLine(ConsoleUtil.Center("1. Player X"));
            Console.WriteLine(ConsoleUtil.Center("2. Player O"));
            Console.WriteLine(ConsoleUtil.Center("3. Let Us Decide"));
            playerFirstChoice = Convert.ToInt32(Console.ReadLine());


            // while (playerFirstChoice)
            // {
            if (playerFirstChoice == 1)
            {
                _gameboard.CurrentRoundState = Gameboard.GameboardState.PlayerXTurn;
                DisplayGameArea(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (playerFirstChoice == 2)
            {
                _gameboard.CurrentRoundState = Gameboard.GameboardState.PlayerOTurn;
                DisplayGameArea(roundsPlayed, playerXWins, playerOWins, catsGames);
            }
            else if (playerFirstChoice == 3)
            {
                Random rnd    = new Random();
                int    choice = rnd.Next(1, 3);
                if (choice == 1)
                {
                    _gameboard.CurrentRoundState = Gameboard.GameboardState.PlayerXTurn;
                    DisplayGameArea(roundsPlayed, playerXWins, playerOWins, catsGames);
                }
                else
                {
                    _gameboard.CurrentRoundState = Gameboard.GameboardState.PlayerOTurn;
                    DisplayGameArea(roundsPlayed, playerXWins, playerOWins, catsGames);
                }
            }
        }