示例#1
0
        /// <summary>
        /// Display a Yes or No prompt with a message
        /// </summary>
        /// <param name="promptMessage">prompt message</param>
        /// <returns>bool where true = yes</returns>
        private bool DisplayGetYesNoPrompt(string promptMessage)
        {
            bool   yesNoChoice   = false;
            bool   validResponse = false;
            string userResponse;

            while (!validResponse)
            {
                ConsoleUtil.DisplayReset();

                ConsoleUtil.DisplayPromptMessage(promptMessage + "(yes/no)");
                userResponse = Console.ReadLine();

                if (userResponse.ToUpper() == "YES")
                {
                    validResponse = true;
                    yesNoChoice   = true;
                }
                else if (userResponse.ToUpper() == "NO")
                {
                    validResponse = true;
                    yesNoChoice   = false;
                }
                else
                {
                    ConsoleUtil.DisplayMessage(
                        "It appears that you have entered an incorrect response." +
                        " Please enter either \"yes\" or \"no\"."
                        );
                    DisplayContinuePrompt();
                }
            }

            return(yesNoChoice);
        }
        /// <summary>
        /// display the welcome screen
        /// </summary>
        public void DisplayWelcomeScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "3D Tic-tac-toe Game!";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Written by Cati Kujawski, Lianna Bowman & Thresa Schultz");
            ConsoleUtil.DisplayMessage("Northwestern Michigan College");
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat("This is a two player game playing 3D Tic Tac Toe. ");
            sb.AppendFormat("You may select from levels 1, 2 or 3 similar to different floors ");
            sb.AppendFormat("of a building. You have the ability to win utilizing all of the different levels.");
            sb.AppendFormat("After choosing a level, you choose a row, then a column.");
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat("Example of a win: player x gets top left corner on all");
            sb.AppendFormat("three levels");
            sb.AppendFormat("Example of a win: player O gets traditional 3 horizontally, diagonally or vertical.");
            ConsoleUtil.DisplayMessage(sb.ToString());

            DisplayContinuePrompt();
        }
示例#3
0
        /// <summary>
        /// display the welcome screen
        /// </summary>
        public void DisplayWelcomeScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = GAME_NAME + "!";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Programmed by Noah Osterhout, Jason Luckhardt, and Chris Coznowski.");
            ConsoleUtil.DisplayMessage("Wolf Group Technolgies");
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat("Welcome to " + GAME_NAME + "! This is Connect 4 but in the console ");
            sb.AppendFormat("for Windows. The standard rules for Connect 4 apply, and this is just a two player ");
            sb.AppendFormat("game with each player taking a turn. Good luck and have fun, but remeber, if you find a bug ");
            sb.AppendFormat("it's most likely a feature! ");
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat("You will be redirected to the main menu.");
            ConsoleUtil.DisplayMessage(sb.ToString());

            DisplayContinuePrompt();
        }
示例#4
0
        /// <summary>
        /// Display a Yes or No prompt with a message
        /// </summary>
        /// <param name="promptMessage">prompt message</param>
        /// <returns>bool where true = yes</returns>
        private bool DisplayGetYesNoPrompt(string promptMessage)
        {
            bool   yesNoChoice   = false;
            bool   validResponse = false;
            string userResponse;

            while (!validResponse)
            {
                ConsoleUtil.DisplayReset();

                ConsoleUtil.DisplayPromptMessage(promptMessage + "\r\n (yes/no): ");
                userResponse = Console.ReadLine();

                if (Regex.IsMatch(userResponse.ToLower(), "^y*$|^yes$"))
                {
                    validResponse = true;
                    yesNoChoice   = true;
                }
                else if (Regex.IsMatch(userResponse.ToLower(), "^n*$|^no$"))
                {
                    validResponse = true;
                    yesNoChoice   = false;
                }
                else
                {
                    ConsoleUtil.DisplayMessage(
                        "It appears that you have entered an incorrect response." +
                        " Please enter either \"yes\" or \"no\"."
                        );
                    DisplayContinuePrompt();
                }
            }

            return(yesNoChoice);
        }
示例#5
0
        public void DisplayCurrentGameStatus(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            ConsoleUtil.HeaderText = "Current Game Status";
            ConsoleUtil.DisplayReset();

            double playerXPercentageWins = (double)playerXWins / roundsPlayed;
            double playerOPercentageWins = (double)playerOWins / roundsPlayed;
            double percentageOfCatsGames = (double)catsGames / roundsPlayed;

            if (Player1.GamePiece == "X")
            {
                ConsoleUtil.DisplayMessage("Rounds Played: " + roundsPlayed);
                ConsoleUtil.DisplayMessage("Rounds for won for " + Player1.playerName + ": " + playerXWins + " - " + String.Format("{0:P2}", playerXPercentageWins));
                ConsoleUtil.DisplayMessage("Rounds for won for " + Player2.playerName + ": " + playerOWins + " - " + String.Format("{0:P2}", playerOPercentageWins));
                ConsoleUtil.DisplayMessage("Cat's Games: " + catsGames + " - " + String.Format("{0:P2}", percentageOfCatsGames));
            }
            else if (Player2.GamePiece == "X")
            {
                ConsoleUtil.DisplayMessage("Rounds Played: " + roundsPlayed);
                ConsoleUtil.DisplayMessage("Rounds for won for " + Player2.playerName + ": " + playerXWins + " - " + String.Format("{0:P2}", playerXPercentageWins));
                ConsoleUtil.DisplayMessage("Rounds for won for " + Player1.playerName + ": " + playerOWins + " - " + String.Format("{0:P2}", playerOPercentageWins));
                ConsoleUtil.DisplayMessage("Cat's Games: " + catsGames + " - " + String.Format("{0:P2}", percentageOfCatsGames));
            }
            else
            {
                ConsoleUtil.DisplayMessage("Rounds Played: " + roundsPlayed);
                ConsoleUtil.DisplayMessage("Rounds for won for X's: " + playerXWins + " - " + String.Format("{0:P2}", playerXPercentageWins));
                ConsoleUtil.DisplayMessage("Rounds for won for O's: " + playerOWins + " - " + String.Format("{0:P2}", playerOPercentageWins));
                ConsoleUtil.DisplayMessage("Cat's Games: " + catsGames + " - " + String.Format("{0:P2}", percentageOfCatsGames));
            }

            DisplayContinuePrompt();
        }
示例#6
0
        /// <summary>
        /// displays previous game stats
        /// </summary>
        public void DisplayPreviousGameStats(List <Scoreboard> historicScores)
        {
            string[] scoresArray = new string[historicScores.Count];
            int      i           = 0;

            ConsoleUtil.HeaderText = GAME_NAME + " | Previous Game Stats";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("The below stats are the stats for the previous game of " + GAME_NAME + ".");
            ConsoleUtil.DisplayMessage("");

            ConsoleUtil.DisplayMessage("Game Time".PadRight(23) + "Player 1".PadRight(15) + "Score".PadRight(10) + "Player 2".PadRight(15) + "Score".PadRight(10));
            foreach (Scoreboard score in historicScores)
            {
                ConsoleUtil.DisplayMessage(new String('=', ConsoleConfig.windowWidth - 2 * ConsoleConfig.displayHorizontalMargin));
                ConsoleUtil.DisplayMessage(score.gameTime.ToString().PadRight(23) + score.playerNames[0].PadRight(15) +
                                           score.playerScores[0].ToString().PadRight(10) +
                                           score.playerNames[1].PadRight(15) +
                                           score.playerScores[1].ToString().PadRight(10));
            }

            Console.WriteLine();


            //ConsoleUtil.Wrap();
            //TODO: Display previous game stats here

            Console.WriteLine();

            DisplayContinuePrompt();
        }
示例#7
0
        /// <summary>
        /// displays who goes first and returns a 0 or 1 for X and O
        /// </summary>
        public Gameboard.GameboardState  DisplayWhosOnFirst()
        {
            bool   validChoice = false;
            string userResponse;

            Gameboard.GameboardState readyPlayerOne = 0;

            Random random = new Random();

            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = GAME_NAME + " | Who Goes First";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Choose who will go first, X or O");
            Console.WriteLine();

            ConsoleUtil.DisplayMessage("Please enter either an X or an O for first player.");
            ConsoleUtil.DisplayMessage("If you want the game to decide press any other key!");
            userResponse = Console.ReadLine();

            while (!validChoice)
            {
                if (userResponse == "x" | userResponse == "X")
                {
                    readyPlayerOne = Gameboard.GameboardState.PlayerXTurn;
                    validChoice    = true;
                }
                else if (userResponse == "o" | userResponse == "O")
                {
                    readyPlayerOne = Gameboard.GameboardState.PlayerOTurn;
                    validChoice    = true;
                }
                else
                {
                    if (random.Next(0, 2) == 0)
                    {
                        readyPlayerOne = Gameboard.GameboardState.PlayerXTurn;
                        validChoice    = true;
                    }
                    else
                    {
                        readyPlayerOne = Gameboard.GameboardState.PlayerOTurn;
                        validChoice    = true;
                    }
                }
            }

            if (readyPlayerOne == Gameboard.GameboardState.PlayerXTurn)
            {
                Console.WriteLine("First player is X");
            }
            else
            {
                Console.WriteLine("First player is O");
            }

            DisplayContinuePrompt();
            return(readyPlayerOne);
        }
示例#8
0
        public bool DisplayNewRoundPrompt()
        {
            ConsoleUtil.HeaderText = "Continue or Quit";
            ConsoleUtil.DisplayReset();

            return(DisplayGetYesNoPrompt("Would you like to play another round?"));
        }
示例#9
0
        /// <summary>
        /// display the welcome screen
        /// </summary>
        public void DisplayWelcomeScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "The Tic-tac-toe Game";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Written by John Velis");
            ConsoleUtil.DisplayMessage("Northwestern Michigan College");
            Console.WriteLine();

            sb.Clear();

            sb.AppendFormat("This application is designed to allow two players to play ");
            sb.AppendFormat("a game of tic-tac-toe. The rules are the standard rules for the ");
            sb.AppendFormat("game with each player taking a turn.");
            ConsoleUtil.DisplayMessage(sb.ToString());
            Console.WriteLine();

            sb.Clear();
            sb.AppendFormat("Your first task will be to set up your account details.");
            ConsoleUtil.DisplayMessage(sb.ToString());

            DisplayContinuePrompt();
        }
        /// <summary>
        /// display game area
        /// </summary>
        public void DisplayGameArea(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            ConsoleUtil.HeaderText = "Current Game Board";
            ConsoleUtil.DisplayReset();

            DisplayGameboard();
            DisplayGameStatus(roundsPlayed, playerXWins, playerOWins, catsGames);
        }
示例#11
0
        /// <summary>
        /// Displays the rules of 3x3x3 Tic-Tac-Toe
        /// </summary>
        private void DisplayViewRules()
        {
            ConsoleUtil.HeaderText = "Game Rules";
            ConsoleUtil.DisplayReset();

            DisplayMessageBox("The rules of the game are to get 3 in a row in any way you can. Each player goes back and forth taking their turn until someone wins or its a Cat's game. Any way you can get 3 in a row (that's not crossing the face of the cube) is considered a win.");
            DisplayContinuePrompt();
        }
        public void DisplayGameArea()
        {
            ConsoleUtil.HeaderText = "Current Game Board";
            ConsoleUtil.DisplayReset();

            DisplayGameboard();
            DisplayGameStatus();
        }
示例#13
0
        /// <summary>
        /// display a closing screen when the user quits the application
        /// </summary>
        public void DisplayClosingScreen()
        {
            ConsoleUtil.HeaderText = GAME_NAME + " | Quit Game";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Thank you for playing " + GAME_NAME + "!.");

            DisplayContinuePrompt();
        }
        /// <summary>
        /// display a closing screen when the user quits the application.
        /// </summary>
        public void DisplayClosingScreen()
        {
            ConsoleUtil.HeaderText = "Knots & Crosses";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Thank you for using Knots & Crosses.");

            DisplayContinuePrompt();
        }
示例#15
0
        /// <summary>
        /// display a closing screen when the user quits the application
        /// </summary>
        public void DisplayClosingScreen()
        {
            ConsoleUtil.HeaderText = "The Tic-tac-toe Game";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Thank you for using The Tic-tac-toe Game.");

            DisplayContinuePrompt();
        }
        /// <summary>
        /// display the session timed out screen
        /// </summary>
        public void DisplayTimedOutScreen()
        {
            ConsoleUtil.HeaderText = "Session Timed Out!";
            ConsoleUtil.DisplayReset();

            DisplayMessageBox("It appears your session has timed out.");

            DisplayContinuePrompt();
        }
        //prompt player to choose quit or main menu//
        public void OpeningScreenPrompt()
        {
            Console.CursorVisible = true;


            bool validResponse = false;



            while (!validResponse)
            {
                Console.WriteLine();

                ConsoleUtil.DisplayMessage("     Please choose from the options below: (Type in the number and press enter)");
                Console.WriteLine();
                Console.SetCursorPosition(10, 16);
                ConsoleUtil.DisplayMessage("     1. Main Menu" + Environment.NewLine + "2. Quit");

                int choice;

                Console.SetCursorPosition(13, 18);
                string response = Console.ReadLine();


                if (Int32.TryParse(response, out choice))
                {
                    if (choice == 1)
                    {
                        validResponse = true;
                    }
                    else if (choice == 2)
                    {
                        DisplayExitPrompt();
                        validResponse = true;
                    }
                    else
                    {
                        Console.WriteLine("Please choose from the numbers listed.");
                        validResponse = false;
                        ConsoleUtil.DisplayPromptMessage("Press any key to try again.");
                        Console.ReadKey();
                        ConsoleUtil.DisplayReset();
                    }
                }
                else
                {
                    Console.WriteLine();
                    ConsoleUtil.DisplayMessage("That is not a valid response. ");
                    ConsoleUtil.DisplayPromptMessage("Press any key to try again.");
                    Console.ReadKey();
                    validResponse = false;

                    ConsoleUtil.DisplayReset();
                }
            }
        }
示例#18
0
        /// <summary>
        /// Display a closing screen when the user quits the application
        /// </summary>
        public void DisplayClosingScreen()
        {
            ConsoleUtil.HeaderText = "The Tic-tac-toe Game";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Thank you for playimg Tic-tac-toe 3D by Bird Brain International.");
            ConsoleUtil.DisplayMessage("Visit www.birdbrain.com for upcoming games.\n\n");

            DisplayContinuePrompt();
        }
示例#19
0
        public void DisplayGameArea()
        {
            ConsoleUtil.HeaderText    = "Current Game Board";
            ConsoleUtil.SubHeaderText = "[F1: SAVE] [F2: LOAD] [ECS: EXIT ROUND]";
            ConsoleUtil.DisplayReset();
            ConsoleUtil.SubHeaderText = "";

            DisplayGameboard();
            DisplayGameStatus();
        }
        /// <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();
        }
示例#22
0
        public void SelectFirstPlayer(int index, string[] playerOptions)
        {
            ConsoleUtil.HeaderText = "Starting Player";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("Select which player starts:");
            Console.WriteLine();

            DisplayFirstPlayerOptions(index, playerOptions);

            Console.CursorVisible = false;
        }
示例#23
0
        /// <summary>
        /// displays no game stats
        /// </summary>
        public void DisplayNoGameStats()
        {
            ConsoleUtil.HeaderText = GAME_NAME + " | Previous Game Stats";
            ConsoleUtil.DisplayReset();

            Console.WriteLine();

            ConsoleUtil.DisplayMessage("Oops it looks like there aren't any scores yet!");

            Console.WriteLine();

            DisplayContinuePrompt();
        }
        /// <summary>
        /// display the Exit prompt on a clean screen
        /// </summary>
        public void DisplayExitPrompt()
        {
            ConsoleUtil.DisplayReset();

            Console.CursorVisible = false;

            Console.WriteLine();
            ConsoleUtil.DisplayMessage("Thank you for playing the game. Press any key to Exit.");

            Console.ReadKey();

            System.Environment.Exit(1);
        }
示例#25
0
        /// <summary>
        /// Informs the player that there game was saved.
        /// </summary>
        public void DisplayGameSavedScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "Game Save";
            ConsoleUtil.DisplayReset();

            sb.Append(" Your game was saved!");

            DisplayMessageBox(sb.ToString());

            DisplayContinuePrompt();
        }
        /// <summary>
        /// Inform the player that their position choice is not available
        /// </summary>
        public void DisplayGamePositionChoiceNotAvailableScreen()
        {
            StringBuilder sb = new StringBuilder();

            ConsoleUtil.HeaderText = "Position Choice Unavailable";
            ConsoleUtil.DisplayReset();

            sb.Append(" It appears that you have chosen a position that is already");
            sb.Append(" taken. Please try again.");

            DisplayMessageBox(sb.ToString());

            DisplayContinuePrompt();
        }
示例#27
0
        /// <summary>
        /// displays current game stats
        /// </summary>
        public void DisplaySaveGameScreen()
        {
            ConsoleUtil.HeaderText = GAME_NAME + " | Save Game";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("We are saving your game.  Please do not turn off " + GAME_NAME + ".");

            Console.WriteLine();

            //TODO: Save game for user

            Console.WriteLine();

            DisplayContinuePrompt();
        }
示例#28
0
        /// <summary>
        /// Displays the game board, sidebar menu, and game status in the console.
        /// </summary>
        public void DisplayGameArea()
        {
            //Reset the console.
            ConsoleUtil.HeaderText = "Current Game Board";
            ConsoleUtil.DisplayReset();

            //Display the menu
            DisplaySidebarMenu();

            //Display the game board.
            DisplayGameboard();

            //Display the current status of the game at the bottom of the screen.
            DisplayGameStatus();
        }
示例#29
0
        /// <summary>
        /// display main menu screen
        /// </summary>
        public int DisplayMainMenuScreen()
        {
            bool validResponse = false;
            int  usersChoice = 0, i = 0;

            while (!validResponse)
            {
                StringBuilder sb = new StringBuilder();

                ConsoleUtil.HeaderText = GAME_NAME + " | Main Menu";
                ConsoleUtil.DisplayReset();

                ConsoleUtil.DisplayMessage("Welcome to the Main Menu!");
                ConsoleUtil.DisplayMessage("Please choose a menu option to continue");

                Console.WriteLine();
                foreach (string option in MAIN_MENU)
                {
                    ConsoleUtil.DisplayMessage("(" + (++i) + ") " + option + " \n ");
                }
                Console.WriteLine();


                Console.Write("Please enter the menu option: ".PadLeft(33));

                Console.CursorVisible = true;

                string userResponse = Console.ReadLine();
                var    isNumeric    = int.TryParse(userResponse, out usersChoice);
                usersChoice--;

                Console.WriteLine();
                if (usersChoice > -1 && usersChoice < MAIN_MENU.Length)
                {
                    ConsoleUtil.DisplayMessage("You selected " + MAIN_MENU[usersChoice] + ". ");
                    validResponse = true;
                }
                else
                {
                    ConsoleUtil.DisplayMessage("It looks like you entered a wrong menu choice, please try again");
                    validResponse = false;
                }
                Console.ReadKey();
                i = 0;
            }

            return(usersChoice);
        }
        public void DisplayCurrentGameStatus(int roundsPlayed, int playerXWins, int playerOWins, int catsGames)
        {
            ConsoleUtil.HeaderText = "Current Game Status";
            ConsoleUtil.DisplayReset();

            double playerXPercentageWins = (double)playerXWins / roundsPlayed;
            double playerOPercentageWins = (double)playerOWins / roundsPlayed;
            double percentageOfCatsGames = (double)catsGames / roundsPlayed;

            ConsoleUtil.DisplayMessage("Rounds Played: " + roundsPlayed);
            ConsoleUtil.DisplayMessage("Rounds for Player X: " + playerXWins + " - " + String.Format("{0:P2}", playerXPercentageWins));
            ConsoleUtil.DisplayMessage("Rounds for Player O: " + playerOWins + " - " + String.Format("{0:P2}", playerOPercentageWins));
            ConsoleUtil.DisplayMessage("Cat's Games: " + catsGames + " - " + String.Format("{0:P2}", percentageOfCatsGames));

            DisplayContinuePrompt();
        }