Beispiel #1
0
        void CheckNumberOfWrongGuesses()
        {
            if (NumberOfWrongGuesses >= 12)
            {
                GameIsOngoing = false;

                HangmanConsoleWriter.LoserOutput(WordToGuess);
            }
        }
Beispiel #2
0
        protected override void StartGameCore()
        {
            HangmanConsoleWriter.WriteTitle();
            GenerateWordToGuess();

            while (GameIsOngoing)
            {
                RunGameLoop();
            }

            TryRestartGame();
        }
Beispiel #3
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();
        }
Beispiel #4
0
 void DrawHangman()
 {
     HangmanConsoleWriter.DrawHangman(NumberOfWrongGuesses);
 }