Code so far

// 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); // Debug Line
    SetupGame();
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    if (bGameOver)
    {
        ClearScreen();
        SetupGame();
    }
    else
    {
        if (Input == HiddenWord)
        {
            PrintLine(TEXT("Moo! You guessed my word."));
            EndGame();
        }
        else
        {
            if (HiddenWord.Len() != Input.Len())
            {
                PrintLine(TEXT("Udderly crazy! That's not even the right number of letters."));
            }
            else
            {
                PrintLine(TEXT("Bully for me! You're wrong!"));
                EndGame();
            }
        }
    }
    // Check if Isogram
    // Case sensitive?
    // Report on correct letters and correct placing?

    // Remove life
    // Lives <= 0? If so, exit loop
    // Show Lives Left
    // Game over, show hidden word?
    // Restart game? Press Enter to play again?
    // Play again or quit
}

void UBullCowCartridge::SetupGame()
{
    PrintLine(TEXT("Moo! Welcome to BullCow - The Game!"));
    bGameOver = false;
    HiddenWord = TEXT("mars");
    Lives = 3;
    PrintLine(TEXT("I'm chewing the cud over a %i letter word"), HiddenWord.Len());
    PrintLine(TEXT("and you have %i lives left"), Lives);
    PrintLine(TEXT("Type in your guess and press Enter"));
}

void UBullCowCartridge::EndGame()
{
    bGameOver = true;
    PrintLine(TEXT("***GAME OVER***"));
    PrintLine(TEXT("Press Enter to play again..."));
}
1 Like

Great job with your code!

Privacy & Terms