I’m pretty sure everything is correct here but for some reason, when the guess is incorrect, the lives value does not decrease so the value stays the same after each incorrect guess. No VScode errors or Unreal compilation issues.
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
int32 Lives = HiddenWord.Len();
if (bGameOver)
{
ClearScreen();
SetupGame();
}
else
{
if (Input == HiddenWord)
{
PrintLine(TEXT("You have won!"));
EndGame();
}
else
{
--Lives;
PrintLine(TEXT("Lost a life!"));
if (Lives > 0)
{
if (Input.Len() != HiddenWord.Len())
{
PrintLine(TEXT("Sorry, try again! \nYou have %i lives remaining."), Lives);
}
}
else
{
PrintLine(TEXT("You have no lives left!"));
EndGame();
}
}
}