Here is my original code:
FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess)
{
//receives valid guess, increments turn, returns values
//increment turn number
MyCurrentTry++;
//setup a return variable
int32 WordLength = MyHiddenWord.length(); //assuming same length as guess
//loop through all letters in the hidden word
FBullCowCount BullCowCount;
for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++)
{
//compare letters against the hidden word
for (int32 GuessChar = 0; GuessChar < WordLength; GuessChar++)
{
if (Guess[GuessChar] == MyHiddenWord[MHWChar])
{
if (MHWChar == GuessChar)
{
BullCowCount.Bulls++;
}
else
{
BullCowCount.Cows++;
}
}
}
}
if (BullCowCount.Bulls = WordLength) <==
bGameWon = true;
else
bGameWon = false;
return BullCowCount;
}
I have marked the line in question with <==
So here’s an interesting question:
Why is it that when I use 1 equal sign, my console returns 5 bulls and 1 cow on an incorrect guess, and says that the player has won even though it’s incorrect, but putting a double equal sign makes it work normally?
If needed I can github my entire project, I was just lazy as it is late right now.
Thanks guys!