コード例 #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);
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #4
0
ファイル: GameUI.cs プロジェクト: lphamilton/azureRefactor
        /// <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);
        }
コード例 #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()));
        }
コード例 #6
0
 internal void DisplayBoardSimple(PhraseBoard board)
 {
     Console.WriteLine("\n" + board.GetBoardString() + "\n");
 }
コード例 #7
0
        // private const string HardCodedPhrase = "abc";


        public Game(ICategorizedPhrases catphrase)
        {
            this.catphrase = catphrase;
            phraseBoard    = new PhraseBoard(catphrase.GetPhrase(catphrase.category));
        }
コード例 #8
0
ファイル: GameUI.cs プロジェクト: denzalereese/azureRefactor
 /// <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());
 }
コード例 #9
0
ファイル: Game.cs プロジェクト: denzalereese/azureRefactor
 public Game()
 {
     phraseBoard = new PhraseBoard(HardCodedPhrase);
 }