public string HandleLetterGuess(char guessedLetter, string wordToDisplay, out LetterStatus letterStatus) { if (triedLetters.Contains(guessedLetter)) { letterStatus = LetterStatus.Repeating; } else { triedLetters.Add(guessedLetter); if (wordToGuess.Contains(guessedLetter)) { letterStatus = LetterStatus.Correct; wordToDisplay = FillLetter(guessedLetter, wordToDisplay); } else { letterStatus = LetterStatus.Incorrect; this.WrongLettersCount++; } } return wordToDisplay; }
private void HandleLetterGuess(char guessedLetter, LetterStatus letterStatus) { switch (letterStatus) { case LetterStatus.Correct: if (!IsWordGuessed()) { this.renderer.PrintCorrectLetterMessage(this.letterHandler.GuessedLettersCount); } else { if (this.UsedHelp) { this.renderer.PrintCheatingMessage(this.letterHandler.WrongLettersCount); this.renderer.PrintWordToDisplayMessage(this.WordToDisplay); } else { this.renderer.PrintWinningMessage(this.letterHandler.WrongLettersCount); this.renderer.PrintWordToDisplayMessage(this.WordToDisplay); if (this.scoreManager.IsPlayerTop(this.letterHandler.WrongLettersCount)) { this.renderer.PrintGetNameForScoreboard(); string playerName = Console.ReadLine(); int playerMistakes = this.letterHandler.WrongLettersCount; Player player = new Player(playerName, playerMistakes); this.scoreManager.AddPlayerToScoreBoard(player); } this.renderer.PrintScoreboard(this.scoreManager.TopPlayers); } this.RestartGame(); } break; case LetterStatus.Incorrect: this.renderer.PrintIncorrectLetterMessage(guessedLetter); break; case LetterStatus.Repeating: this.renderer.PrintRepeatingLetterMessage(guessedLetter); break; default: break; } }