My formated strings so far

Hello there!
Here is my practice!

#include "BullCowCartridge.h"

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

    InitGame(); // Play the Bull & Cows's Videogame!
    
    // Welcomes the player
    PrintLine(TEXT("Welcome to Bull Cows!"));
    PrintLine(TEXT("The hidden word is %s"), *HiddenWord);
    PrintLine(TEXT("Type %i characters and press Enter..."), HiddenWord.Len());
}

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

    if (Input.Compare(HiddenWord) == 0)
    {
        PrintLine(TEXT("Correct! You Win!"));
    }
    else
    {
        PrintLine(TEXT("Wrong"));

        if (Input.Len() != HiddenWord.Len())
        {
            PrintLine(TEXT("The word has not %i characters!"), HiddenWord.Len());
        }

        PrintLine(TEXT("Try again"));
    }

    //  ----------------------------------------  
    //  -----------    PSEUDOCODE    -----------
    //  ----------------------------------------
    //          
    //  PrintWelcomeMessage()
    //
    //  StartTheGame()
    //  {
    //      SetLifes(amount)
    //      SetHiddenWord(value)
    //
    //      AsksForGuess()
    //
    //      CHECK:
    //      If: Is not a Isogram && Chars's length match input's guess length.
    //
    //          WinTheGame()
    //
    //      Else:
    //
    //          SubstractLife()
    //
    //          CHECK:
    //          If: Are lifes > 0?
    //
    //              AsksForGuess()
    //   
    //          Else:
    //
    //              PrintGameLost()
    //              PromptTryAgain()
    //
    //              CHECK:
    //              If: Play Again?
    //
    //                  AsksForGuess()
    //
    //              Else:
    //
    //                  ExitTheGame()
    //
    // }  
}

void UBullCowCartridge::InitGame()
{ 
    SetHiddenWord("Cakes");  
    SetLives(4);
}

void UBullCowCartridge::SetLives(int32 _lives)
{ 
    Lives = _lives;
}

void UBullCowCartridge::SubstractLive()
{ 
    --Lives;
}

void UBullCowCartridge::SetHiddenWord(FString word)
{
    HiddenWord = word;
}

int32 UBullCowCartridge::GetLives()
{
	return Lives;
}
2 Likes

How do you feel with strings?

Privacy & Terms