// Fill out your copyright notice in the Description page of Project Settings.
#include “BullCowCartridge.h”
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
SetupGmae();
HiddenWord=TEXT(“chep”);
PrintLine(TEXT(“you have to guess %s letter word”), *HiddenWord);//debug
}
void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
//check the correct word
if (BGameOver)
{
ClearScreen();
SetupGmae();
}
else
{
if(Input==HiddenWord)
{
PrintLine(TEXT("You won"));
Endgame();
}
else
{
PrintLine(TEXT("You loose"));
if(HiddenWord.Len() != Input.Len())
{
PrintLine(TEXT("damm man you just find my word"));
}
else
{
PrintLine(TEXT("you are wrong"));
Endgame();
}
}
}
}
void UBullCowCartridge::SetupGmae()
{
//set hiddenword
HiddenWord=TEXT(“chepr”);
//setlives
Lives=4;
//set boolean
BGameOver = false;
//welcome player
PrintLine(TEXT(“Welcome player”));
PrintLine(TEXT(“you have to guess %i letter word”),HiddenWord.Len());//letters
PrintLine(TEXT(“PRESS ENTER TO CONTINUE”));
}
void UBullCowCartridge::Endgame()
{
BGameOver=true;
//it it is wrong than you have restaer the game or exit
PrintLine(TEXT(“GAME OVER”));
PrintLine(TEXT(“PRESS ENTER TO PLAY AGAIN”));
}