I’m in the lesson “Out of the Frying Pan”. Right now I haven’t been able to advance because I have this issue
my code is this:
HiddenWordList.h
#pragma once
#include "CoreMinimal.h"
const TArray<FString> Words =
{
TEXT("a"),
TEXT("ability"),
TEXT("able"),
TEXT("about"),
TEXT("above"),
TEXT("accept"),
TEXT("according"),
TEXT("account"),
TEXT("across"),
TEXT("act"),
TEXT("action"),
TEXT("activity"),
TEXT("actually"),
TEXT("add"),
TEXT("address"),
TEXT("administration"),
TEXT("admit"),
TEXT("adult"),
TEXT("affect"),
TEXT("after"),
TEXT("again"),
TEXT("against"),
TEXT("age"),
TEXT("agency"),
TEXT("agent"),
TEXT("ago"),
TEXT("agree"),
TEXT("agreement"),
TEXT("ahead"),
TEXT("air"),
TEXT("all"),
TEXT("allow"),
TEXT("almost"),
TEXT("alone"),
TEXT("along"),
TEXT("already"),
TEXT("also"),
TEXT("although"),
TEXT("always"),
TEXT("American"),
TEXT("among"),
TEXT("amount"),
TEXT("analysis"),
TEXT("and"),
TEXT("animal"),
TEXT("another"),
TEXT("answer"),
TEXT("any"),
TEXT("anyone"),
TEXT("anything"),
TEXT("appear"),
TEXT("apply"),
TEXT("approach"),
TEXT("area"),
TEXT("argue"),
TEXT("arm"),
TEXT("around"),
TEXT("arrive"),
TEXT("art"),
TEXT("article"),
TEXT("artist"),
TEXT("as"),
TEXT("ask"),
TEXT("assume"),
TEXT("at"),
TEXT("attack"),
TEXT("attention"),
TEXT("attorney"),
TEXT("audience"),
TEXT("author"),
TEXT("authority"),
TEXT("available"),
TEXT("avoid"),
TEXT("away"),
TEXT("baby"),
TEXT("back"),
TEXT("bad"),
TEXT("bag"),
TEXT("ball"),
TEXT("bank"),
TEXT("bar"),
TEXT("base"),
TEXT("be"),
TEXT("beat"),
TEXT("beautiful"),
TEXT("because"),
TEXT("become"),
TEXT("bed"),
TEXT("before"),
TEXT("begin"),
TEXT("behavior"),
TEXT("behind"),
TEXT("believe"),
TEXT("benefit"),
TEXT("best"),
TEXT("better"),
TEXT("between"),
TEXT("beyond"),
TEXT("big"),
TEXT("bill"),
TEXT("billion"),
TEXT("bit"),
TEXT("black"),
TEXT("blood"),
TEXT("blue"),
TEXT("board"),
TEXT("body"),
TEXT("book"),
TEXT("born"),
TEXT("both"),
TEXT("box"),
TEXT("boy"),
TEXT("break"),
TEXT("bring"),
TEXT("brother"),
TEXT("budget"),
TEXT("build"),
TEXT("building"),
TEXT("business"),
TEXT("but"),
TEXT("buy"),
TEXT("by"),
TEXT("call"),
TEXT("camera"),
TEXT("campaign"),
TEXT("can"),
TEXT("cancer"),
TEXT("candidate"),
TEXT("capital"),
TEXT("car"),
TEXT("card"),
TEXT("care"),
TEXT("career"),
TEXT("carry"),
TEXT("case"),
TEXT("catch"),
TEXT("cause"),
TEXT("cell"),
TEXT("center"),
TEXT("central"),
TEXT("century"),
TEXT("certain"),
TEXT("certainly"),
TEXT("chair"),
TEXT("challenge"),
TEXT("chance"),
TEXT("change"),
TEXT("character"),
TEXT("charge"),
TEXT("check"),
TEXT("child"),
TEXT("choice"),
TEXT("choose"),
TEXT("church"),
TEXT("citizen"),
TEXT("city"),
TEXT("civil"),
TEXT("claim"),
TEXT("class"),
TEXT("clear"),
TEXT("clearly"),
TEXT("close"),
TEXT("coach"),
TEXT("cold"),
TEXT("collection"),
TEXT("college"),
TEXT("color"),
TEXT("come"),
TEXT("commercial"),
TEXT("common"),
TEXT("community"),
TEXT("company"),
TEXT("compare"),
TEXT("computer"),
TEXT("concern"),
TEXT("condition"),
TEXT("conference"),
TEXT("Congress"),
TEXT("consider"),
TEXT("consumer"),
TEXT("contain"),
TEXT("continue"),
TEXT("control"),
TEXT("cost"),
TEXT("could"),
TEXT("country"),
TEXT("couple"),
TEXT("course"),
TEXT("court"),
TEXT("cover"),
TEXT("create"),
TEXT("crime"),
TEXT("cultural"),
TEXT("culture"),
TEXT("cup"),
TEXT("current"),
TEXT("customer"),
TEXT("cut"),
TEXT("dark"),
TEXT("data"),
TEXT("daughter"),
TEXT("day"),
TEXT("dead"),
TEXT("deal"),
TEXT("death"),
TEXT("debate"),
TEXT("decade"),
TEXT("decide"),
TEXT("decision"),
TEXT("deep"),
TEXT("defense"),
TEXT("degree"),
TEXT("Democrat"),
TEXT("democratic"),
TEXT("describe"),
TEXT("design"),
TEXT("despite"),
TEXT("detail"),
TEXT("determine"),
TEXT("develop"),
TEXT("development"),
TEXT("die"),
TEXT("difference"),
TEXT("different"),
TEXT("difficult"),
TEXT("dinner"),
TEXT("direction"),
TEXT("director"),
TEXT("discover"),
TEXT("discuss"),
TEXT("discussion"),
TEXT("disease"),
TEXT("do"),
TEXT("doctor"),
TEXT("dog"),
TEXT("door"),
TEXT("down"),
TEXT("draw"),
TEXT("dream"),
TEXT("drive"),
TEXT("drop"),
TEXT("drug"),
TEXT("during"),
TEXT("each"),
TEXT("early"),
TEXT("east"),
TEXT("easy"),
TEXT("eat"),
TEXT("economic"),
TEXT("economy"),
TEXT("edge"),
TEXT("education"),
TEXT("effect"),
TEXT("effort"),
TEXT("eight"),
TEXT("either"),
TEXT("election"),
TEXT("else"),
TEXT("employee"),
TEXT("end"),
TEXT("energy"),
TEXT("enjoy"),
TEXT("enough"),
TEXT("enter"),
TEXT("entire"),
TEXT("environment"),
TEXT("environmental"),
TEXT("especially"),
TEXT("establish"),
TEXT("even"),
TEXT("evening"),
TEXT("event"),
TEXT("ever"),
TEXT("every"),
TEXT("everybody"),
TEXT("everyone"),
TEXT("everything"),
TEXT("evidence"),
TEXT("exactly"),
TEXT("example"),
TEXT("executive"),
TEXT("exist"),
TEXT("expect"),
TEXT("experience"),
TEXT("expert"),
TEXT("explain"),
TEXT("eye"),
TEXT("face"),
TEXT("fact"),
TEXT("factor"),
TEXT("fail"),
TEXT("fall"),
TEXT("family"),
TEXT("far"),
TEXT("fast"),
TEXT("father"),
TEXT("fear"),
TEXT("federal"),
TEXT("feel"),
TEXT("feeling"),
TEXT("few"),
TEXT("field"),
TEXT("fight"),
TEXT("figure"),
TEXT("fill"),
TEXT("film"),
TEXT("final"),
TEXT("finally"),
TEXT("financial"),
TEXT("find"),
TEXT("fine"),
TEXT("finger"),
TEXT("finish"),
TEXT("fire"),
TEXT("firm"),
TEXT("first"),
TEXT("fish"),
TEXT("five"),
TEXT("floor"),
TEXT("fly"),
TEXT("focus"),
TEXT("follow"),
TEXT("food"),
TEXT("foot"),
TEXT("for"),
TEXT("force"),
TEXT("foreign"),
TEXT("forget"),
TEXT("form"),
TEXT("former"),
TEXT("forward"),
TEXT("four"),
TEXT("free"),
TEXT("friend"),
TEXT("from"),
TEXT("front"),
TEXT("full"),
TEXT("fund"),
TEXT("future"),
TEXT("game"),
TEXT("garden"),
TEXT("gas"),
TEXT("general"),
TEXT("generation"),
TEXT("get"),
TEXT("girl"),
TEXT("give"),
TEXT("glass"),
TEXT("go"),
TEXT("goal"),
TEXT("good"),
TEXT("government"),
TEXT("great"),
TEXT("green"),
TEXT("ground"),
TEXT("group"),
TEXT("grow"),
TEXT("growth"),
TEXT("guess"),
TEXT("gun"),
TEXT("guy"),
TEXT("hair"),
TEXT("half"),
TEXT("hand"),
TEXT("hang"),
TEXT("happen"),
TEXT("happy"),
TEXT("hard"),
TEXT("have"),
TEXT("he"),
TEXT("head"),
TEXT("health"),
TEXT("hear"),
TEXT("heart"),
TEXT("heat"),
TEXT("heavy"),
TEXT("help"),
TEXT("her"),
TEXT("here"),
TEXT("herself"),
TEXT("high"),
TEXT("him"),
TEXT("himself"),
TEXT("his"),
TEXT("history"),
TEXT("hit"),
TEXT("hold"),
TEXT("home"),
TEXT("hope"),
TEXT("hospital"),
TEXT("hot"),
TEXT("hotel"),
TEXT("hour"),
TEXT("house"),
TEXT("how"),
TEXT("however"),
TEXT("huge"),
TEXT("human"),
TEXT("hundred"),
TEXT("husband"),
TEXT("I"),
TEXT("idea"),
TEXT("identify"),
TEXT("if"),
TEXT("image"),
TEXT("imagine"),
TEXT("impact"),
TEXT("important"),
TEXT("improve"),
TEXT("in"),
TEXT("include"),
TEXT("including"),
TEXT("increase"),
TEXT("indeed"),
TEXT("indicate"),
TEXT("individual"),
TEXT("industry"),
TEXT("information"),
TEXT("inside"),
TEXT("instead"),
TEXT("institution"),
TEXT("interest"),
TEXT("interesting"),
TEXT("international"),
TEXT("interview"),
TEXT("into"),
TEXT("investment"),
TEXT("involve"),
TEXT("issue"),
TEXT("it"),
TEXT("item"),
TEXT("its"),
TEXT("itself"),
TEXT("job"),
TEXT("join"),
TEXT("just"),
TEXT("keep"),
TEXT("key"),
TEXT("kid"),
TEXT("kill"),
TEXT("kind"),
TEXT("kitchen"),
TEXT("know"),
TEXT("knowledge"),
TEXT("land"),
TEXT("language"),
TEXT("large"),
TEXT("last"),
TEXT("late"),
TEXT("later"),
TEXT("laugh"),
TEXT("law"),
TEXT("lawyer"),
TEXT("lay"),
TEXT("lead"),
TEXT("leader"),
TEXT("learn"),
TEXT("least"),
TEXT("leave"),
TEXT("left"),
TEXT("leg"),
TEXT("legal"),
TEXT("less"),
TEXT("let"),
TEXT("letter"),
TEXT("level"),
TEXT("lie"),
TEXT("life"),
TEXT("light"),
TEXT("like"),
TEXT("likely"),
TEXT("line"),
TEXT("list"),
TEXT("listen"),
TEXT("little"),
TEXT("live"),
TEXT("local"),
TEXT("long"),
TEXT("look"),
TEXT("lose"),
TEXT("loss"),
TEXT("lot"),
TEXT("love"),
TEXT("low"),
TEXT("machine"),
TEXT("magazine"),
TEXT("main"),
TEXT("maintain"),
TEXT("major"),
TEXT("majority"),
TEXT("make"),
TEXT("man"),
TEXT("manage"),
TEXT("management"),
TEXT("manager"),
TEXT("many"),
TEXT("market"),
TEXT("marriage"),
TEXT("material"),
TEXT("matter"),
TEXT("may"),
TEXT("maybe"),
TEXT("me"),
TEXT("mean"),
TEXT("measure"),
TEXT("media"),
TEXT("medical"),
TEXT("meet"),
TEXT("meeting"),
TEXT("member"),
TEXT("memory"),
TEXT("mention"),
TEXT("message"),
TEXT("method"),
TEXT("middle"),
TEXT("might"),
TEXT("military"),
TEXT("million"),
TEXT("mind"),
TEXT("minute"),
TEXT("miss"),
TEXT("mission"),
TEXT("model"),
TEXT("modern"),
TEXT("moment"),
TEXT("money"),
TEXT("month"),
TEXT("more"),
TEXT("morning"),
TEXT("most"),
TEXT("mother"),
TEXT("mouth"),
TEXT("move"),
TEXT("movement"),
TEXT("movie"),
TEXT("Mr"),
TEXT("Mrs"),
TEXT("much"),
TEXT("music"),
TEXT("must"),
TEXT("my"),
TEXT("myself"),
TEXT("name"),
TEXT("nation"),
TEXT("national"),
TEXT("natural"),
TEXT("nature"),
TEXT("near"),
TEXT("nearly"),
TEXT("necessary"),
TEXT("need"),
TEXT("network"),
TEXT("never"),
TEXT("new"),
TEXT("news"),
TEXT("newspaper"),
TEXT("next"),
TEXT("nice"),
TEXT("night"),
TEXT("no"),
TEXT("none"),
TEXT("nor"),
TEXT("north"),
TEXT("not"),
TEXT("note"),
TEXT("nothing"),
TEXT("notice"),
TEXT("now"),
TEXT("n')"),
TEXT("number"),
TEXT("occur"),
TEXT("of"),
TEXT("off"),
TEXT("offer"),
TEXT("office"),
TEXT("officer"),
TEXT("official"),
TEXT("often"),
TEXT("oh"),
TEXT("oil"),
TEXT("ok"),
TEXT("old"),
TEXT("on"),
TEXT("once"),
TEXT("one"),
TEXT("only"),
TEXT("onto"),
TEXT("open"),
TEXT("operation"),
TEXT("opportunity"),
TEXT("option"),
TEXT("or"),
TEXT("order"),
TEXT("organization"),
TEXT("other"),
TEXT("others"),
TEXT("our"),
TEXT("out"),
TEXT("outside"),
TEXT("over"),
TEXT("own"),
TEXT("owner"),
TEXT("page"),
TEXT("pain"),
TEXT("painting"),
TEXT("paper"),
TEXT("parent"),
TEXT("part"),
TEXT("participant"),
TEXT("particular"),
TEXT("particularly"),
TEXT("partner"),
TEXT("party"),
TEXT("pass"),
TEXT("past"),
TEXT("patient"),
TEXT("pattern"),
TEXT("pay"),
TEXT("peace"),
TEXT("people"),
TEXT("per"),
TEXT("perform"),
TEXT("performance"),
TEXT("perhaps"),
TEXT("period"),
TEXT("person"),
TEXT("personal"),
TEXT("phone"),
TEXT("physical"),
TEXT("pick"),
TEXT("picture"),
TEXT("piece"),
TEXT("place"),
TEXT("plan"),
TEXT("plant"),
TEXT("play"),
TEXT("player"),
TEXT("PM"),
TEXT("point"),
TEXT("police"),
TEXT("policy"),
TEXT("political"),
TEXT("politics"),
TEXT("poor"),
TEXT("popular"),
TEXT("population"),
TEXT("position"),
TEXT("positive"),
TEXT("possible"),
TEXT("power"),
TEXT("practice"),
TEXT("prepare"),
TEXT("present"),
TEXT("president"),
TEXT("pressure"),
TEXT("pretty"),
TEXT("prevent"),
TEXT("price"),
TEXT("private"),
TEXT("probably"),
TEXT("problem"),
TEXT("process"),
TEXT("produce"),
TEXT("product"),
TEXT("production"),
TEXT("professional"),
TEXT("professor"),
TEXT("program"),
TEXT("project"),
TEXT("property"),
TEXT("protect"),
TEXT("prove"),
TEXT("provide"),
TEXT("public"),
TEXT("pull"),
TEXT("purpose"),
TEXT("push"),
TEXT("put"),
TEXT("quality"),
TEXT("question"),
TEXT("quickly"),
TEXT("quite"),
TEXT("race"),
TEXT("radio"),
TEXT("raise"),
TEXT("range"),
TEXT("rate"),
TEXT("rather"),
TEXT("reach"),
TEXT("read"),
TEXT("ready"),
TEXT("real"),
TEXT("reality"),
TEXT("realize"),
TEXT("really"),
TEXT("reason"),
TEXT("receive"),
TEXT("recent"),
TEXT("recently"),
TEXT("recognize"),
TEXT("record"),
TEXT("red"),
TEXT("reduce"),
TEXT("reflect"),
TEXT("region"),
TEXT("relate"),
TEXT("relationship"),
TEXT("religious"),
TEXT("remain"),
TEXT("remember"),
TEXT("remove"),
TEXT("report"),
TEXT("represent"),
TEXT("Republican"),
TEXT("require"),
TEXT("research"),
TEXT("resource"),
TEXT("respond"),
TEXT("response"),
TEXT("responsibility"),
TEXT("rest"),
TEXT("result"),
TEXT("return"),
TEXT("reveal"),
TEXT("rich"),
TEXT("right"),
TEXT("rise"),
TEXT("risk"),
TEXT("road"),
TEXT("rock"),
TEXT("role"),
TEXT("room"),
TEXT("rule"),
TEXT("run"),
TEXT("safe"),
TEXT("same"),
TEXT("save"),
TEXT("say"),
TEXT("scene"),
TEXT("school"),
TEXT("science"),
TEXT("scientist"),
TEXT("score"),
TEXT("sea"),
TEXT("season"),
TEXT("seat"),
TEXT("second"),
TEXT("section"),
TEXT("security"),
TEXT("see"),
TEXT("seek"),
TEXT("seem"),
TEXT("sell"),
TEXT("send"),
TEXT("senior"),
TEXT("sense"),
TEXT("series"),
TEXT("serious"),
TEXT("serve"),
TEXT("service"),
TEXT("set"),
TEXT("seven"),
TEXT("several"),
TEXT("sex"),
TEXT("sexual"),
TEXT("shake"),
TEXT("share"),
TEXT("she"),
TEXT("shoot"),
TEXT("short"),
TEXT("shot"),
TEXT("should"),
TEXT("shoulder"),
TEXT("show"),
TEXT("side"),
TEXT("sign"),
TEXT("significant"),
TEXT("similar"),
TEXT("simple"),
TEXT("simply"),
TEXT("since"),
TEXT("sing"),
TEXT("single"),
TEXT("sister"),
TEXT("sit"),
TEXT("site"),
TEXT("situation"),
TEXT("six"),
TEXT("size"),
TEXT("skill"),
TEXT("skin"),
TEXT("small"),
TEXT("smile"),
TEXT("so"),
TEXT("social"),
TEXT("society"),
TEXT("soldier"),
TEXT("some"),
TEXT("somebody"),
TEXT("someone"),
TEXT("something"),
TEXT("sometimes"),
TEXT("son"),
TEXT("song"),
TEXT("soon"),
TEXT("sort"),
TEXT("sound"),
TEXT("source"),
TEXT("south"),
TEXT("southern"),
TEXT("space"),
TEXT("speak"),
TEXT("special"),
TEXT("specific"),
TEXT("speech"),
TEXT("spend"),
TEXT("sport"),
TEXT("spring"),
TEXT("staff"),
TEXT("stage"),
TEXT("stand"),
TEXT("standard"),
TEXT("star"),
TEXT("start"),
TEXT("state"),
TEXT("statement"),
TEXT("station"),
TEXT("stay"),
TEXT("step"),
TEXT("still"),
TEXT("stock"),
TEXT("stop"),
TEXT("store"),
TEXT("story"),
TEXT("strategy"),
TEXT("street"),
TEXT("strong"),
TEXT("structure"),
TEXT("student"),
TEXT("study"),
TEXT("stuff"),
TEXT("style"),
TEXT("subject"),
TEXT("success"),
TEXT("successful"),
TEXT("such"),
TEXT("suddenly"),
TEXT("suffer"),
TEXT("suggest"),
TEXT("summer"),
TEXT("support"),
TEXT("sure"),
TEXT("surface"),
TEXT("system"),
TEXT("table"),
TEXT("take"),
TEXT("talk"),
TEXT("task"),
TEXT("tax"),
TEXT("teach"),
TEXT("teacher"),
TEXT("team"),
TEXT("technology"),
TEXT("television"),
TEXT("tell"),
TEXT("ten"),
TEXT("tend"),
TEXT("term"),
TEXT("test"),
TEXT("than"),
TEXT("thank"),
TEXT("that"),
TEXT("the"),
TEXT("their"),
TEXT("them"),
TEXT("themselves"),
TEXT("then"),
TEXT("theory"),
TEXT("there"),
TEXT("these"),
TEXT("they"),
TEXT("thing"),
TEXT("think"),
TEXT("third"),
TEXT("this"),
TEXT("those"),
TEXT("though"),
TEXT("thought"),
TEXT("thousand"),
TEXT("threat"),
TEXT("three"),
TEXT("through"),
TEXT("throughout"),
TEXT("throw"),
TEXT("thus"),
TEXT("time"),
TEXT("to"),
TEXT("today"),
TEXT("together"),
TEXT("tonight"),
TEXT("too"),
TEXT("top"),
TEXT("total"),
TEXT("tough"),
TEXT("toward"),
TEXT("town"),
TEXT("trade"),
TEXT("traditional"),
TEXT("training"),
TEXT("travel"),
TEXT("treat"),
TEXT("treatment"),
TEXT("tree"),
TEXT("trial"),
TEXT("trip"),
TEXT("trouble"),
TEXT("true"),
TEXT("truth"),
TEXT("try"),
TEXT("turn"),
TEXT("TV"),
TEXT("two"),
TEXT("type"),
TEXT("under"),
TEXT("understand"),
TEXT("unit"),
TEXT("until"),
TEXT("up"),
TEXT("upon"),
TEXT("us"),
TEXT("use"),
TEXT("usually"),
TEXT("value"),
TEXT("various"),
TEXT("very"),
TEXT("victim"),
TEXT("view"),
TEXT("violence"),
TEXT("visit"),
TEXT("voice"),
TEXT("vote"),
TEXT("wait"),
TEXT("walk"),
TEXT("wall"),
TEXT("want"),
TEXT("war"),
TEXT("watch"),
TEXT("water"),
TEXT("way"),
TEXT("we"),
TEXT("weapon"),
TEXT("wear"),
TEXT("week"),
TEXT("weight"),
TEXT("well"),
TEXT("west"),
TEXT("western"),
TEXT("what"),
TEXT("whatever"),
TEXT("when"),
TEXT("where"),
TEXT("whether"),
TEXT("which"),
TEXT("while"),
TEXT("white"),
TEXT("who"),
TEXT("whole"),
TEXT("whom"),
TEXT("whose"),
TEXT("why"),
TEXT("wide"),
TEXT("wife"),
TEXT("will"),
TEXT("win"),
TEXT("wind"),
TEXT("window"),
TEXT("wish"),
TEXT("with"),
TEXT("within"),
TEXT("without"),
TEXT("woman"),
TEXT("wonder"),
TEXT("word"),
TEXT("work"),
TEXT("worker"),
TEXT("world"),
TEXT("worry"),
TEXT("would"),
TEXT("write"),
TEXT("writer"),
TEXT("wrong"),
TEXT("yard"),
TEXT("yeah"),
TEXT("year"),
TEXT("yes"),
TEXT("yet"),
TEXT("you"),
TEXT("young"),
TEXT("your"),
TEXT("yourself")
};
BullCowCartridge.h
#pragma once
#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class BULLCOWGAME_API UBullCowCartridge : public UCartridge
{
GENERATED_BODY()
public:
virtual void BeginPlay() override;
virtual void OnInput(const FString& Input) override;
void SetupGame();
void EndGame();
void ProcessGuess(const FString& Guess);
bool IsIsogram(const FString& Word) const;
TArray<FString> GetValidWords(const TArray<FString>& WorldList) const;
//TArray<FString> WordList;
// Your declarations go below!
private:
FString HiddenWord;
int32 Lives;
bool bGameOver;
TArray<FString> Isograms;
};
BullCowCartridge.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
#include "HiddenWordList.h"
// #include "Misc/FileHelper.h"
// #include "Misc/Paths.h"
// #include "Math/UnrealMathUtility.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
// const FString WordListPath = FPaths::ProjectContentDir() / TEXT("WordLists/HiddenWordList.txt");
// FFileHelper::LoadFileToStringArray(WordList, *WordListPath);
Isograms = GetValidWords(Words);
SetupGame();
}
void UBullCowCartridge::OnInput(const FString& PlayerInput) // When the player hits enter
{
if(bGameOver){
ClearScreen();
SetupGame();
}
else //Checking PlayGuess
{
ProcessGuess(PlayerInput);
}
}
void UBullCowCartridge::SetupGame()
{
//Welcoming The Player
PrintLine(TEXT("Welcome to Bull Cow!"));
HiddenWord = Isograms[FMath::RandRange(0, Isograms.Num() - 1)];
Lives = HiddenWord.Len();//Set Lives
bGameOver = false;
PrintLine(TEXT("Guess the %i letter word!"), HiddenWord.Len());
PrintLine(TEXT("You have %i lives."), Lives);
PrintLine(TEXT("Type in your guess and \npress enter to continue... "));//Prompt Player For Guess
PrintLine(TEXT("The HiddenWord is: %s."), *HiddenWord); //Debug Line
}
void UBullCowCartridge::EndGame()
{
bGameOver = true;
PrintLine(TEXT("\nPress enter to play again. "));
}
void UBullCowCartridge::ProcessGuess(const FString& Guess){
if(Guess == HiddenWord){
PrintLine(TEXT("You have won!"));
EndGame();
return;
}
if (Guess.Len() != HiddenWord.Len())
{
PrintLine(TEXT("The hidden word is %i letters long."), HiddenWord.Len());
PrintLine(TEXT("Sorry, try guessing again! \nYou have %i lives remaining"), Lives);
return;
}
//Check if Isogram
if (!IsIsogram(Guess))
{
PrintLine(TEXT("No repeating letters, guess again"));
return;
}
//Remove Life
PrintLine(TEXT("Lost a life"));
--Lives;
if(Lives <= 0)
{
ClearScreen();
PrintLine(TEXT("You have no lives left"));
PrintLine(TEXT("The hidden word was: %s"), *HiddenWord);
EndGame();
return;
}
//Show the player Bulls and Cows
PrintLine(TEXT("Guess again, you have %i lives left"), Lives);
}
bool UBullCowCartridge::IsIsogram(const FString& Word) const
{
for (int32 Index = 0; Index < Word.Len(); Index++)
{
for (int32 Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
{
if (Word[Index] == Word[Comparison])
{
return false;
}
}
}
return true;
}
TArray<FString> UBullCowCartridge::GetValidWords(const TArray<FString>& WordList) const{
TArray<FString> ValidWords;
for (FString Word : WordList)
{
if (Word.Len() >=4 && Word.Len() <=8 && IsIsogram(Word))
{
ValidWords.Emplace(Word);
}
}
return ValidWords;
}
I review a lot of times this code but I don’t know very well why I have this issue