void CheckNumberOfWrongGuesses() { if (NumberOfWrongGuesses >= 12) { GameIsOngoing = false; HangmanConsoleWriter.LoserOutput(WordToGuess); } }
protected override void StartGameCore() { HangmanConsoleWriter.WriteTitle(); GenerateWordToGuess(); while (GameIsOngoing) { RunGameLoop(); } TryRestartGame(); }
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(); }
void DrawHangman() { HangmanConsoleWriter.DrawHangman(NumberOfWrongGuesses); }