Please don’t look too hard at the lack of comments. And don’t think too hard about the weird way I went about doing this.
So my game was working with zero issues so far, but my HiddenWord is changing to an empty string somewhere in here and I can’t figure out where.
// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
PrintLine(TEXT("The HiddenWord is: %s"), *HiddenWord); //for debug only, delete
PrintLine(TEXT("Welcome To Bulls and Cows, The game that\nyou are somehow playing on a magical\nwooden board. Don't mind the Cowlords,\nthey're just watching you play. \nP.S. The Cowlords will be very angry if\nyou lose. Don't Make the Cowlords angry."));
PrintLine(TEXT("Press Tab to type to the board"));
PrintLine(TEXT("Press Enter to Begin"));
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
ClearScreen();
if (Input == HiddenWord)
{
PrintLine(TEXT("You Win!"));
EndGame();
}
else
{
if (Input.Len() != HiddenWord.Len() && Input != "")
{
PrintLine(TEXT("The word is %i letters."), HiddenWord.Len());
}
else if (Input == "")
{
InitGame();
}
else
{
PrintLine(TEXT("Wrong. You are a Failure.\nGAME OVER"));
EndGame();
}
}
}
void UBullCowCartridge::InitGame()
{
HiddenWord = TEXT("ccakke");
Lives = HiddenWord.Len() + 1;
bGameOver = false;
PrintLine(TEXT("There is a %i letter word you need to guess\nGuess."), HiddenWord.Len());
}
void UBullCowCartridge::EndGame()
{
bGameOver = true;
PrintLine(TEXT("Press enter to play again."));
}
/* judge input for isogram/correctness
subtract lives
give feedback
kill if no more lives
continue if more lives
give bulls and cows
*/