I made one quality-of-life adjustment increasing the size of the sign, as well as the column and line count & decreased the font size to have more guesses logged.
I also tried to implement difficulty, but I can’t get it to work yet.
I wrote the function
void UBullCowCartridge::DifficultyPrompt(FString Choice)//asking for difficulty setting
{
PrintLine(TEXT("Select Difficulty:\n[E]asy\n[F]air\n[C]hallenging\n[N]ightmare\n[U]ltra Nightmare"));
}
to prompt the player to pick a difficulty, and then
void UBullCowCartridge::DifficultySelection()
{
DifficultyPrompt(Choice);//choice registered
{
Isograms = GetValidWords(Words);
HiddenWord = Isograms[FMath::RandRange(0, Isograms.Num() - 1)];
if (Choice = DiffArray[0])
{
Lives = HiddenWord.Len() * 3;
return;
}
if (Choice = DiffArray[1])
return;
{
Lives = HiddenWord.Len() * 2;
return;
}
if (Choice = DiffArray[2])
{
Lives = HiddenWord.Len();
return;
}
if (Choice = DiffArray[3])
{
Lives = HiddenWord.Len() / 2;
return;
}
if (Choice = DiffArray[4])
{
Lives = HiddenWord.Len() / 3;
return;
}
else
{
PrintLine(TEXT("Please make a valid selection."));
return;
}
}
return Isograms;
return Lives;
return HiddenWord;
}
to adjust the lives count based on the choice. I pulled Isograms and HiddenWord insto the second function and then have it return Isograms, HiddenWords and Lives to use in the later functions.
I made the array to evaluate the choice of difficulty a separate list modeled on the HiddenWordList.h
But I can’t get it to run. I have been futzing around with it for the last 6ish hours, and I am just chasing my tail on whether the functions should be constant, be made structs, anything else I can think of to make it work. I think I have the nesting right, I tried to model it on the hierarchy we used for taking in and processing the guess.
This is how I modified SetupGame()
void UBullCowCartridge::SetupGame()//asking for guess
{
DifficultySelection(Choice);
//ProcessDifficulty(Choice);********************
//Lives = HiddenWord.Len() * 2;
bGameOver = false;
PrintLine(TEXT("Welcome to Bulls and Cows!\nGuess the %i letter isogram."), HiddenWord.Len());
PrintLine(TEXT("Bull: Letter in the correct position.\nCow: Correct letter in the wrong position.Letters don't repeat."));
PrintLine(TEXT("You have %i tries."), Lives);
PrintLine(TEXT("\nMake your first guess and press [ENTER]."));
}
calling the function that should return Lives, HiddenWord and Isograms.
This is the state of my BullCowCartridge.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"
struct FBullCowCount
{
int32 Bulls = 0;
int32 Cows = 0;
};
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class BULLCOWGAME_API UBullCowCartridge : public UCartridge
{
GENERATED_BODY()
public:
virtual void BeginPlay() override;
virtual void OnInput(const FString& Input) override;
void SetupGame();
void EndGame();
void WinGame();
void ProcessGuess(const FString& Guess);
bool IsIsogram(const FString& Word) const;
TArray<FString> GetValidWords(const TArray<FString>& WordList) const;
FBullCowCount GetBullCows(const FString& Guess) const;
void DifficultyPrompt(FString Choice);
void DifficultySelection();
// Your declarations go below!
private:
FString HiddenWord;
int32 Lives;
bool bGameOver;
TArray<FString> Isograms;
};
I welcome any ideas/observations/help to send me on my way