Parameters and Args

Working like a dream. Since the code is done before Mike’s It’s a little different. Quit and Reset is working sweet too.

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"

void UBullCowCartridge::BeginPlay() // When the game 
{
    Super::BeginPlay();
	
	IntiateGame();

	/*	
		Welcome Message Instructions

		Intiate game (lives Levels hidden word)

		While (guess)
			
			Get input
			If (play)
				Display Win
				Level ++
			else	
				Display Bulls and Cows
				if(Life > 0)
					Life --
				else
					if(PlayAgain)
						Intiate new game
					else
						break
		Quit
				
	*/
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
	ClearScreen();
	ProcessInput(Input);
}

void UBullCowCartridge::DisplayWelcomeMessage()
{
	PrintLine(TEXT("Velcro's Bulls and Cows"));
	PrintLine(TEXT("Please click on board and press 'Tab' to start"));
	//PrintLine(TEXT("Enter a ") + FString::FromInt(GameLevel + 3) + TEXT(" letter word...")); // what you would normally do if it wasn't defined elsewhere
	PrintLine(TEXT("Enter a %i letter word."), HiddenWord.Len());
}

void UBullCowCartridge::ProcessInput(FString Input)
{
	if (bEndPrompt) {
		if (Input.Len() == 1 && Input == "P" && bEndPrompt) {
			bResetGame = true;
			bEndPrompt = false;
		}
		if (Input.Len() == 1 && Input == "Q" && bEndPrompt) {
			bResetGame = false;
			bEndPrompt = false;
			PrintLine(TEXT("Bye."));
		}
	}

	if (bResetGame) 
	{
		ClearScreen();
		IntiateGame();
	}
	else {
		if (HiddenWord == Input)
		{
			PrintLine(TEXT("Nailed it."));
			PrintLine(TEXT("The Hidden word was %s"), *HiddenWord);
			EndGame();
		}
		else
		{
			if (Input.Len() != HiddenWord.Len())
			{
				PrintLine(TEXT("Enter a %i letter word."), HiddenWord.Len());
			}
			Lives--;
			if (Lives <= 0) {
				PrintLine(TEXT("You have lost dude."), Lives);
				EndGame();
			}
			else
			{
				PrintLine(TEXT("Try again. You have %i lives left."), Lives);
			}
		}
	}
}


void UBullCowCartridge::IntiateGame()
{
	//Intiate game(lives Levels hidden word)
	bResetGame = false;
	bEndPrompt = false;
	GameLevel = 1;
	Lives = GameLevel * LivesMultiplier;
	HiddenWord = GetHiddenWord();
	DisplayWelcomeMessage();
	if (bIsItDebugTime) { PrintLine(TEXT("The Hidden word is %s"), *HiddenWord); }
}

FString UBullCowCartridge::GetHiddenWord()
{
	HiddenWord = TEXT("asdf");
	return HiddenWord;
}

void UBullCowCartridge::EndGame()
{
	ContinueGamePrompt();
}

void UBullCowCartridge::ContinueGamePrompt()
{
	bEndPrompt = true;
	PrintLine(TEXT("'P'lay Again? or 'Q'uit?, then Enter"));
}


Privacy & Terms