public static GameResult.Result Play(string word, char[] gameWord, char playerInput) { if (word.Contains(playerInput.ToString())) { for (int y = 0; y < word.Length; y++) { if (word[y] == playerInput) { gameWord[y] = playerInput; GameResult.CompletedWord = new string(gameWord); gameResult = GameResult.Result.correctInput; } } if (GameResult.CompletedWord.Equals(word)) { gameResult = GameResult.Result.win; GameOver = true; } } else { wrongInputCount++; gameResult = GameResult.Result.wrongInput; if (wrongInputCount == errorLimit) { gameResult = GameResult.Result.lost; GameOver = true; } } return(gameResult); }
public static void GameRoundResult(GameResult.Result result, string completedWord = "", char playerInput = ' ') { switch (result) { case GameResult.Result.correctInput: Console.WriteLine($"\nYou entered correct letter: [ {playerInput} ] - Game completed word: [ {completedWord} ] \n\nEnter a new letter: "); break; case GameResult.Result.win: Console.WriteLine($"\nGame completed: [ {completedWord} ]: \n\n YOU'VE WON THE GAME"); break; case GameResult.Result.lost: Console.WriteLine($"\nYou have entered a wrong letter: [ { playerInput } ] and used up your joker.\n\n YOU LOST THE GAME"); break; case GameResult.Result.wrongInput: Console.WriteLine($"\nYou have entered a wrong letter: [ { playerInput } ] you have Few more chance....\n\n Enter a new letter: "); break; } }