Oh yes! why am I such an idiot. Okay so I have modified the code a bit. I have overcome the problem of infinite loop of lives getting decremented. but a new issue has turned up. the condition for lives==0 is not getting executed.
void UBullCowCartridge::ProcessGuess(FString Input)
{
if(Input== Hiddenword)
{
PrintLine(TEXT("You Have Won !!"));
EndGame();
return;
}
/*if(!Isogram())
{
PrintLine(TEXT("There are no repeating letters"));
}*/
PrintLine(TEXT("Lost a life"));
PrintLine(TEXT("Guess again. You have %i lives remaining"),lives);
if(Hiddenword.Len()!=Input.Len())
{
//PrintLine(TEXT("Guess again. You have %i lives remaining"),lives);
PrintLine(TEXT("Hiddenword has %i letters"),Hiddenword.Len());
lives--;
}
if(lives==0)
{
PrintLine(TEXT("GAME OVER!!!"));
PrintLine(TEXT("The hidden word was %s"),*Hiddenword);
PrintLine(TEXT("\nPress Enter to continue playing"));
EndGame();
}
return;
}
Please help.
EDIT: Also I just now realised this code won’t work if the input is wrong but the word length is same as hiddenword.