Hey, I always get the letter ‘1’ as opposed to the length of the hidden word which in my case is “games”.
I have verified the code numerous times and here it is below.
void FBullCowGame::Reset()
{
constexpr int32 MAX_TRIES = 5;
const FString Hidden_Word = “water”;
MyMaxTries = MAX_TRIES;
MyHiddenWord = Hidden_Word;
MyCurrentTry = 1;
return;
}
bool FBullCowGame::IsGameWon()const
{
return false;
}
bool FBullCowGame::CheckGuessValidity(FString)const
{
return false;
}
//receives a valid guess, increament turn and returns the number of counts
FBullCowCount FBullCowGame::Submitguess(FString Guess)
{
//increament the turn number
MyCurrentTry++;
//setup the return variable
FBullCowCount BullCowCount;
//loop through all letters in the guess
int32 HiddenWordLength = MyHiddenWord.length();
for (int32 MHWChar = 0; MHWChar < HiddenWordLength; MHWChar++)
{
//compare the letters aggainst the hidden word
for (int32 GChar = 0; GChar < HiddenWordLength; GChar++)
{
//if they match then,
if (Guess[GChar]==MyHiddenWord[MHWChar])
{
if (MHWChar==GChar)//if they are in the same place against the hidden word
{
BullCowCount.Bulls++;
//increment bulls if they are in the same place
}
else
{
BullCowCount.Cows++;
//increment cows if they are there but not in the same place
}
}
}
}
return BullCowCount;
}
bool FBullCowGame::IsIsogram()
{
return false;Preformatted text