Hi can anyone help me?


I can’t fix these problems

Would you mind showing your code? I believe it’s complaining about you passing in FString as an argument but need to see your code to better see why.

// 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();
    PrintLine(TEXT("The HiddenWord is %s."),*HiddenWord); //Debug LINE
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    if(bGameOver)
    {
      ClearScreen();
      SetupGame();
    }
    else //checking player guess
    {
      ProcessGuess(Input);
    }
}

void UBullCowCartridge::SetupGame()
{
  // Welcoming the player
    PrintLine(TEXT("Welcome to Bull Cows Game!!"));
    HiddenWord = TEXT("cakes"); 
    Lives = HiddenWord.Len();
    bGameOver = false;
    PrintLine(TEXT("Guess the %i letter word !! "), HiddenWord.Len());
    PrintLine(TEXT("You have %i lives."), Lives);
    PrintLine(TEXT("Type in your guess and \nPress enter to continue....."));// Prompt Player For Guess
}

void UBullCowCartridge::EndGame()
{
    bGameOver= true;
    PrintLine(TEXT("\nPress enter to play agian"));
}

void UBullCowCartridge::ProcessGuess(FString Guess)
{
    if(Guess == HiddenWord)
    {
        PrintLine(TEXT("You win!!"));
        EndGame();
        return;
    }
    // //Check If Isogram
    // if(!IsIsogram)
    // {
    //   PrintLine(TEXT(" NO repeating letters, guess again"))
    // }
    if(Guess.Len() != HiddenWord.Len())
    {
        PrintLine(TEXT("The hidden word is %i letters long"),HiddenWord.Len());
        PrintLine(TEXT(" Sorry, try guessing agian, You have %i lives left "), Lives);
        return;
    }
    
    // Remove Life
    PrintLine(("Lost a life !"));
    --Lives;

    if(Lives <= 0)
    {
        ClearScreen();
        PrintLine(TEXT("You have no lives left !"));
        PrintLine(TEXT("The hidden word was: %s"), HiddenWord);
        EndGame();
        return;
    }
    // Show the player Bulls and Cows
     PrintLine(TEXT("Guess agian, you have %i lives left"), Lives); 
}

I’m curious if Guess==HiddenWord isn’t comparing two different types. But looking at this on my phone is driving me nuts. So this is more to give you something to test until I can get to a place to see it better. When in doubt, commenting out and retesting from a known point is an awesome way to make progress on what exactly is causing it. Then you don’t risk losing it, but can test moving parts separately.

I’ve edited your post to use a code block. Please see how that is done and please use it in the future.

Your issue is due to missing * for printing the hidden word using formatting in your block for if (Lives <= 0)

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms