Example #1
0
        // private const string HardCodedPhrase = "abc";


        public Game()
        {
            string Category = catPhrase.GetCatPhrase()[0];
            string Phrase   = catPhrase.GetCatPhrase()[1];

            Console.WriteLine("Your random category is going to be " + Category + "!");
            Console.WriteLine(Phrase);
            phraseBoard = new PhraseBoard(Phrase);
            //phraseBoard = new PhraseBoard(HardCodedPhrase);
        }
Example #2
0
        internal void DisplayBoard(PhraseBoard board)
        {
            var chars = board.GetBoardString();

            string topAndBottom = "+" + String.Join("+", chars.Select(c => (c == ' ')? "   ":"---").ToArray()) + "+";
            string middle       = "|" + String.Join("|", chars.Select(c => (c == '*') ? "   ":" " + c + " ").ToArray()) + "|";

            Console.WriteLine();
            Console.WriteLine(topAndBottom);
            Console.WriteLine(middle);
            Console.WriteLine(topAndBottom);
            Console.WriteLine();
        }
Example #3
0
        /// <summary>
        /// Prompts the player to guess a letter and returns the response as a char. If the input is invalid or a previously guessed letter, the player is prompted again.
        /// </summary>
        /// <param name="phraseBoard">The current PhraseBoard being guessed.</param>
        /// <returns>The letter the player has guessed.</returns>
        internal char GetSpinGuessLetter(PhraseBoard phraseBoard)
        {
            Console.Write("Guess a letter: ");
            string spinGuess = Console.ReadLine().ToLower();

            char spinGuessLetter = SingleLettersOnly(spinGuess);;

            //If the character has already been guessed, then it will prompt the user to type in one that has not.
            while (phraseBoard.HasGuessed(spinGuessLetter))
            {
                Console.Write($"{spinGuessLetter} has already been guessed. Guess again: ");
                spinGuess = Console.ReadLine().ToLower();

                spinGuessLetter = SingleLettersOnly(spinGuess);;
            }
            return(spinGuessLetter);
        }
Example #4
0
        /// <summary>
        /// Prompts the player to guess a letter and returns the response as a char. If the input is invalid or a previously guessed letter, the player is prompted again.
        /// </summary>
        /// <param name="phraseBoard">The current PhraseBoard being guessed.</param>
        /// <returns>The letter the player has guessed as a character</returns>
        public char GetSpinGuessLetter(PhraseBoard phraseBoard, Player player)
        {
            Console.Write("Guess a letter: ");
            string         spinGuess = Console.ReadLine().ToLower();
            HashSet <char> vowels    = new HashSet <char> {
                'a', 'e', 'i', 'o', 'u'
            };

            char spinGuessLetter = SingleLettersOnly(spinGuess);

            //If the character has already been guessed, then it will prompt the user to type in one that has not.
            while (phraseBoard.HasGuessed(spinGuessLetter))
            {
                Console.Write($"{spinGuessLetter} has already been guessed. Guess again: ");
                spinGuess = Console.ReadLine().ToLower();

                spinGuessLetter = SingleLettersOnly(spinGuess);
            }

            //If the character is a vowel, it will let user know the price and their total after purchasing
            //If they cannot afford a vowel, they will be told and given the option to guess a consonant

            if (vowels.Contains(spinGuessLetter))
            {
                Console.WriteLine("The price of a vowel is $600.");
                if (player.TurnScore >= 600)
                {
                    player.DeductCurrentScore(600);
                    Console.WriteLine("You've just bought the letter {0} and your total score is: ${1}", spinGuessLetter.ToString(), player.TurnScore);
                }
                else
                {
                    bool isConsonant = false;


                    while (!isConsonant)
                    {
                        Console.WriteLine("Looks like you're too broke to buy a vowel. Try guessing a consonant instead.");
                        spinGuessLetter = SingleLettersOnly(Console.ReadLine());
                        isConsonant     = !vowels.Contains(spinGuessLetter);
                    }
                }
            }

            return(spinGuessLetter);
        }
Example #5
0
        /// <summary>
        /// The current player takes their turn until they guess incorrectly, solve the puzzle, por spin Lose-A-Turn
        /// </summary>
        /// <param name="playerOne"></param>
        /// <param name="phraseBoard"></param>
        private void TakeTurn(Player playerOne, PhraseBoard phraseBoard)
        {
            bool turnOver;

            do
            {
                ui.DisplayPlayerScore(playerOne);
                ui.DisplayBoard(phraseBoard);

                if (ui.GetUserChoice() == 1)
                {
                    Spin(playerOne, out turnOver);
                }
                else
                {
                    Solve(playerOne, out turnOver);
                }
            } while (!(turnOver || phraseBoard.IsGameOver()));
        }
Example #6
0
 internal void DisplayBoardSimple(PhraseBoard board)
 {
     Console.WriteLine("\n" + board.GetBoardString() + "\n");
 }
Example #7
0
        // private const string HardCodedPhrase = "abc";


        public Game(ICategorizedPhrases catphrase)
        {
            this.catphrase = catphrase;
            phraseBoard    = new PhraseBoard(catphrase.GetPhrase(catphrase.category));
        }
Example #8
0
 /// <summary>
 ///  Displays the phrase board. Unsolved letters are displayed as asterisks.
 /// </summary>
 /// <param name="board">The PhraseBoard to be displayed.</param>
 internal void DisplayBoard(PhraseBoard board)
 {
     Console.WriteLine(board.GetBoardString());
 }
Example #9
0
 public Game()
 {
     phraseBoard = new PhraseBoard(HardCodedPhrase);
 }