Playtest results: don't accept guesses containing non-letter characters!

So I asked my flatmate to test my game for me, and asked him to try and break it. He immediately entered “123456”, which was accepted as a valid guess! I think I might have brought this on myself by implementing the check for lowercase only slightly differently than in the lessons?

Anyway, a bit of searching revealed the existence of C++'s handy “isalpha(char)” function, which I made use of to code another helper function called CheckGuessIsAlpha(FString Guess). Code is as follows:

bool FBullCowGame::CheckGuessIsAlpha(FString Guess) const {
	if (Guess.length() > 0) {
		for (auto c : Guess) {
			if (!isalpha(c)) {
				return false;
			}
		}
		return true;
	}
	else {
		return false;
	}
}

CheckGuessValidity(FString Guess) calls it like so:

// <snip>
else if (!CheckGuessIsAlpha(Guess)) {
		return EGuessValidity::Contains_Non_Alpha;
	}
// <snip>

Hope it’s useful to someone! I’ll leave you to figure out the function prototype and EGuessValidity enumeration value, as well as an appropriate message to the player :wink:

I guess you used isupper in your IsLowercase function. Because this catches non alpha characters.

if (!islower(letter))

Ah yep, that would be what I did wrong! Thanks, good to know