Example #1
0
 public RightWrong()
 {
     foreach (Guess in List <Guess> )
     {
         If(WordToGuess.Contains(Guess))
         {
             Right.Add(Guess)
         }
Example #2
0
        public bool MakeGuess(char letter)
        {
            var isCorrect = WordToGuess.Contains(letter);

            if (!isCorrect)
            {
                const int liesLostDueToIncorrectGuess = 1;
                TriesLeft -= liesLostDueToIncorrectGuess;
            }

            return(isCorrect);
        }
 /// <summary>
 /// Check if the word contains a specific letter
 /// </summary>
 /// <param name="c">letter to check</param>
 private void CheckIfContainsChar(char c)
 {
     // Create a new list to erase old values each time
     charLocations = new List <int>();
     // If the word contains the character, then reveal it
     if (WordToGuess.Contains(c))
     {
         for (int i = 0; i < WordToGuess.Length; i++)
         {
             if (WordToGuess[i] == c)
             {
                 charLocations.Add(i);
             }
         }
     }
 }
Example #4
0
        void RunGameLoop()
        {
            HangmanConsoleWriter.PrintGuesses(Guesses);

            GenerateTiles();
            var guess = HangmanConsoleWriter.RequestInput();

            if (HangmanInputValidation.ValidateInput(guess))
            {
                var guessCharacter = guess[0];
                Guesses.Add(guessCharacter);

                if (!WordToGuess.Contains(guessCharacter))
                {
                    NumberOfWrongGuesses++;
                }
                else
                {
                    if (HaveWeWonYet())
                    {
                        GameIsOngoing = false;

                        HangmanConsoleWriter.WinnerOutput(WordToGuess);
                        return;
                    }
                }
            }
            else
            {
                HangmanConsoleWriter.InvalidGuess();
            }

            DrawHangman();

            CheckNumberOfWrongGuesses();
        }