Sharing my code snippet here.
void UBullCowCartridge::ProcessGuess(FString Guess)
{
if (Guess == HiddenWord)
{
PrintLine(TEXT("You have Won!"));
EndGame();
return;
}
else
{
if (Guess.Len() != HiddenWord.Len())
{
PrintLine(TEXT("Sorry, try again. %i lives remaining"),Lives);
PrintLine(TEXT("The hidden word is %i letter long"),HiddenWord.Len());
return;
}
// else if (!IsIsogram)
// {
// /* code */
// PrintLine(TEXT("No repeating letters, guess again"));
// return
// }
else
{
PrintLine(TEXT("You have lost 1 life"));
--Lives;
if (Lives <= 0)
{
ClearScreen();
PrintLine(TEXT("You have no life left"));
PrintLine(TEXT("The hiddenword is: %s."), *HiddenWord);
EndGame();
}
else
{
PrintLine(TEXT("Guess again, you have %i lives left"),Lives);
}
}
}
}