#include
void PrintIntroduction(int Difficulty)
{
// Introductory text for the game, output into the terminal.
std::cout << "\n\nMurderers and Savages, welcome to the most thrilling, heartpounding event in the whole of the Wasteland: THE DEATHBALL!\n";
std::cout << "Our particpant tonight will need to enter the correct codes into the level " << Difficulty;
std::cout << " The Heart Chamber to win. But don't worry if you lose, kiddo. It'll only result in your death! HAHAHA!!\nBEGIN!\n\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
// Initialising variables that will be given to the player to help figure out the puzzles.
const int CodeA = rand();
const int CodeB = rand();
const int CodeC = rand();
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
// Printing sum and product to the terminal.
std::cout << "- There are three numbers in the code.";
std::cout << "\n- The codes add up to: " << CodeSum;
std::cout << "\n- The codes multiply to give: " << CodeProduct << "\n\n";
// Player's guess is stored
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
//Sum and product of three code numbers initialised
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
// Check if player guesses are
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\nThat's a level of The Heart Chamber cracked! Let's see how much further they can get!\n";
return true;
}
else
{
std::cout << "\nOooh, looks like you messed that one up kiddo! Let's see you give it another go, just for our amusement!\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;
while (LevelDifficulty <= MaxDifficulty) // Loop game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "\n And that is it, boys and girls, our contestant has done it! They've cracked into the centre of The Heart Chamber! And with it, Hell itself is released! HAHAHAHA!!\n";
return 0;