Expectation: To have the do while loop end upon EGuessStatus Status = OK.
Reality: Pictures depict the stages of the debugger. On an entry that is the correct word length.
Breakpoints
- EGuessStatus Status = Invalid_Status.
- EGuessStatus Status = OK.
- EGuessStatus Status = Invalid_Status
Implications: No valid guess leaves the loop. there is no return.
Workarounds: The code works fine if return is put in case EGuessStatus::OK.
Thank you for your time!
FText GetValidGuess() //loop continually til user gets valid guess
{
EGuessStatus Status = EGuessStatus::Invald_Status; //Breakpoint 1 Status=Invalid_Status
FText Guess = "";
do
{
//Get guess from player
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry << ". Enter your guess:";
std::getline(std::cin, Guess);
EGuessStatus Status = BCGame.CheckGuessValidity(Guess);
switch (Status) // Break point 2 Status = OK
{
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " Letter word.\n";
break;
case EGuessStatus::Not_IsoGram:
std::cout << "Please enter an isogram.\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please use lowercase letters.\n";
break;
case EGuessStatus::OK:
std::cout << "valid guess";
break; //if return is here code works.
}
std::cout << std::endl;
}
while (Status != EGuessStatus::OK); // Break point 3 status reverts to Invalid_status and fails
return Guess;
}