void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
const FString WordListPath = FPaths::ProjectContentDir() / TEXT("Wordlists/HiddenWordList.txt");
FFileHelper::LoadFileToStringArray(Words, *WordListPath);
Words = GetValidWords(Words);
PrintLine(TEXT("The library consists of %i valid isograms"), Words.Num());
SetupGame();
}
I implemented the runtime HiddenWordList parser from earlier.
I saw no reason to maintain 2 wordlists so I replaced the full wordlist array from the library with the new ValidWords array.
TArray<FString> UBullCowCartridge::GetValidWords(TArray<FString> WordList) const
{
TArray<FString> ValidWords;
for (int32 Index = 0; Index < WordList.Num(); Index++)
{
if (WordList[Index].Len() >= 4 && WordList[Index].Len() <= 8 && IsIsogram(WordList[Index])) // Check for Isograms between 4 and 8 Characters long
{
ValidWords.Emplace(WordList[Index]);
}
}
return ValidWords;
}
And I got 452 valid words at runtime. Yay!