Quit functionality - Is this messy?

My code adds a quit system, but I don’t like how the check for quit spans multiple levels of code, and I’m not sure I’m supposed to be setting and getting the flag all at once. Is this bad practice, and how might I fix it?

void TheGame()
{
    // Introduce the player.
    PrintIntroduction();

    do
    {
        Game.ResetGame();

        // Play the game.
        GuessingLoop();

        if (bPlayerQuit)
            return;
        else
            Game.GameRecap();

    } while (Game.GetKeepPlayingYN());
}

/// /// /// /// /// /// /// /// /// /// /// /// /// 


void GuessingLoop()
{
    // Loop the guessing function.
    for (int32 iGuessTotal = Game.GetCurrentGuess(); iGuessTotal <= Game.GetMaximumGuesses(); iGuessTotal++)
    {
        Guess = GetValidInput();
        
        if (Game.PlayerWonGame() == true || PlayerQuit(Guess))
            return;
        else
            FBullCowCount BullCowCount = Game.SubmitValidGuess(Guess); 

    }   
}

bool PlayerQuit(FText Guess)
{
    FString Quitters[5] = { "Quit", "quit", "Exit", "exit", "qqq" };

    //if (Guess == "Quit" || Guess == "quit" || Guess == "exit" || Guess == "Exit" || Guess == "qqq")
    for (const FString &Quit : Quitters)
        if (Guess == Quit)
            bPlayerQuit = true;
            
    return bPlayerQuit;
}

FText GetValidInput()
{
    EGuessValidity GuessValidity = EGuessValidity::Invalid;
    FText _Guess = "";
    
    do
    {
        std::cout << "Type your guess here >>> "; std::getline(std::cin, _Guess);

        if (PlayerQuit(_Guess))
            return _Guess;

        GuessValidity = Game.CheckGuessValidity(_Guess);
        
        std::cout << std::endl;
        switch (GuessValidity)
        {
            case EGuessValidity::Wrong_Length:
                std::cout << "Wrong length! Please enter a " << Game.GetHiddenWordLength() << " letter word.";
                PrintDblEndl(); break;
            case EGuessValidity::Not_Alpha:
                std::cout << "Your entry had unknown characters. Please type only letters!";
                PrintDblEndl(); break;
            case EGuessValidity::Not_Isogram:
                std::cout << "Your guess had repeating letters! Try again.";
                PrintDblEndl(); break;
            default:
                break;
        } 

    } while (GuessValidity != EGuessValidity::Valid);

    return _Guess;
}

Privacy & Terms