What do you print when the player wins/loses Triple X?

In this lesson we learn how to work with if else statements in C++.

What messages do you print to the player when they win and lose the game?

Overall Win message:

“You can finally give yourself a well deserved pat on the back after defeating all the locks to uncover the largest hoard of valuable minerals you’ve ever seen.”

Level Win Message:

“You can breathe again now that you’ve managed to get through the lock on the outer airlock door. Now onto the inner airlock door which will be harder to crack, but you can do it!”

I’m implementing code to have the names of the doors change as you move through the levels.

Lose Message:

" Damn, you’ve guessed the wrong code and now you’ve lit up 1 of the anti-hack indicators. If you get it wrong 2 more times you’ll be locked out forever."

I’m also looking to implement code that will allow me to record the number of guesses and end the game if they don’t get it right within 3 tries.

1 Like

Great idea! I like how the lectures are keeping everything basic but give you enough knowledge to maybe implement some of your own tweaks with a little research.

I went with a bank robbery theme so my win/lose outputs:

    // Evaluate guesses and return win/lose
	if (GuessSum == CodeSum && GuessProduct == CodeProduct)
	{
		std::cout << "The vault opens!  You make off with 100 million dollars!" << std::endl;
	}
	else
	{
		std::cout << "The code is incorrect.  The doors lock and the police have been notified." << std::endl;
	}
2 Likes

I like your messages.

When I’ve got my code finished today I’ll post it on here for others to see how I did things.

I followed my story of a thief trying to lockpick a chest in a noble’s mansion :

    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "Success! The chest opens and you fill your bag with everything that seems to be valuable." << std::endl;
        std::cout << "When you finally get out of the mansion, you notice something is moving from inside your bag!" << std::endl << std::endl;
        std::cout << "Perhaps your adventure is not over yet..." << std::endl;
    }
    else
    {
        std::cout << "The chests ignites and explodes at your face. You weren't fast enough to escape your fate..." << std::endl;
    }
2 Likes

This are my winning and losing messages:

woops. *vanishes. Fixed

 if (GuessSum == CodeSum && GuessProduct == CodeProduct) 
    {
        PrintNextLevel(Difficulty);  
        return true;
    }   
    else
    {
        std::cout << "Rats that's not the right code... what else might it be?\n\n";  //Add Set Number Of Tries
        return false; 
    }

I’ve gone for that so far as I wanted to have the difficulty being used in the next level text, currently working on a fail condition as well and perhaps different text for at least the last level so it can be something like “you’re almost there” instead of being so generic every time.

My story is about a archaeologist:

If the player wins: “An ancient stone door slowly opens to the next room. It is so slow that it feels comical rather than climactic…”

If the player loses: You were hit in the head by a flying rock. Before you died you thought ‘Huh, I didn’t know rocks could fly…’. As your light slowly fades away to darkness a winged creature (It wasn’t an angel trust me…) appears before you. ‘Rise Discount Indiana Jones, and try again.’ "

Following a more shadow run style break and enter mission:

My win lose at this stage is as follows:

    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        printLine("    Access Granted");
        printLine("");
        printLine("Looking up at the cam feed you see the panel turn green and the door slides open for your team they filter into the building quietly.");
    }else
    {
        printLine("    Access Denied notifying security");
        printLine("");
        printLine("Oh ***! Looking up at the cam feed you see the panel turn red and an alarm starts to blare, your team turn and run.");
    }

I made two different functions as I plan on tweaking it more later on.
In the win function, I have the following:

int win()
{
//This function is for when the player guesses all the codes correctly
system(“CLS”);
std::cout << “Congradulations Rookie! You successfuly defused all the bombs and saved everyone!” << std::endl;

return 0;

}

In the lose function, I have the following:

int boom()
{
//This function is for when the player guesses the wrong code
system(“CLS”);
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << " ======== ==== ==== ==== ====" << std::endl;
std::cout << " || \\ // \\ // \\ || \ / ||" << std::endl;
std::cout << " ||_____// || || || || || V ||" << std::endl;
std::cout << " ||~~~~~\\ || || || || || ||" << std::endl;
std::cout << " || // \\ // \\ // || ||" << std::endl;
std::cout << " ======== ==== ==== == ==" << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;
std::cout << " You guessed wrong…" << std::endl;
std::cout << " You just killed yourself and everyone else in a five block radius." << std::endl;

return 0;

}

It displays the picture below…

My win message:
*** Well done students! You are one step closer to delicious ice cream! ***

My lose message:
*** You entered the wrong code! Careful students…try again! ***

My level win message:
*** Great job students! You are in! Now grab all the ice cream and get out of there! ***

This is my win/lose output:

if ((GuessSum == CodeSum) && (GuessProduct == CodeProduct)) 
    {
        std::cout << "Amazing job, you're in! Now download the files and get out quick! This guy is going down!";
    }
else
    {
        std::cout << "Oh no, you failed! The system is shutting down and the place is going into lockdown! Good luck getting out of this.";
    }

My win/lose outputs.

    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "You got the shoe! Whew. Crisis averted.";
    }
    else
    {
        std::cout << "You failed! Oh no. That was a child lock, too. Embarassing.";
    }

My output

My win and lose output

Lose message:

Win message:

I tried to make it a bit optimistic in both ends :smile:

if(SumGuess == SumABC && ProdGuess == ProdABC)
    {
        std::cout << "You've nailed it, you're one step closer to saving humanity and yourself in the process!";
    }
else
    {
        std::cout << "You've lost and are forever doomed to see youself rott and your species perish from within your cell";
    }

:slight_smile: