Here is my Code. Soon I will be working on setting up “lives”. More than 1/2 way done Section Three and still going
// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
SetupGame();// makes sense to set up game first: Lives and Word ready to go
PrintLine(TEXT("The Hidden word is: %s."), *HiddenWord);// debug line
// Welcomeing The Player
PrintLine(TEXT("Welcome to Bull Cow!"));
PrintLine(TEXT("Guess the %i letter word!"), HiddenWord.Len());
PrintLine(TEXT("Type in your guess and press \nenter to moove on..."));
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
ClearScreen();
// Checking the PlayerGuess
if (Input == HiddenWord)
{
// More Words to Complete?
// If Yes, Print: You Completed this Word --> Ask if Want to continue playering?
// set NextWord
// Set Lives
// Prompt for PlayerGuess
//if No,Print below
PrintLine(TEXT("You Win!"));
//Prompt Play again?
// If Yes Restart
// If No: QuitGame
}
else
{
if (Input.Len() != HiddenWord.Len())
{
PrintLine(TEXT("The Hidden Word is %i Characters Long, try again"), HiddenWord.Len());
}
PrintLine(TEXT("You Lose..."));
}
// Isogram?
// Prompt to GuessAgain
// Right Number of Characters?
// Prompt to GuessAgain
// Repeated Letters?
// Prompt to GuessAgain
// Remove life
// Lives > zero?
// If Yes, GuessAgain
// Show Lives Left
// If No Show GameOver --> Show Hidden word?
// Prompt to Play Again, Press Enter to Player Again?
// Check User Input
// Play Again or Quit?
}
void UBullCowCartridge::SetupGame()
{
HiddenWord = TEXT("words");
Lives = 6;
}