#include <iostream>
#include <curses.h>
#include <ctime>
void PrintIntroduction(int Difficulty, bool bComplete)
{
std :: cout << "Hello and Welcome to Jewel Thief!\n";
std :: cout << "In this game you have to find random number codes to get to the next level. There are some rules.\n\n";
std :: cout << "1. This game contains 10 levels. You can always replay the game and it will be different each time because the codes are randomised.\n";
std :: cout << "2. You have to enter each number of the code with spaces. For example, 1 2 3 not 123.\n";
std :: cout << "3. If you accidentally type in a letter or the code without the spaces, just restart the game.\n";
std :: cout << "4. The game will give you clues about the code and you have to guess it based on that.\n\n";
std :: cout << "Lets Play!\n\n";
std :: cout << "You are a Jewel Thief, and you are stealing the biggest Diamond on Earth!";
std :: cout << std :: endl;
std :: cout << "There is a door in front of you with a keypad and the sign Level 1, it seems that it wants a 3 digit code...";
std :: cout << std :: endl;
}
void PlayGame(int Difficulty, bool bComplete)
{
int CodeA =rand() % Difficulty + Difficulty;
int CodeB =rand() % Difficulty + Difficulty;
int CodeC =rand() % Difficulty + Difficulty;
int CodeSum = CodeA + CodeB + CodeC;
int CodeProduct = CodeA * CodeB * CodeC;
std :: cout << std :: endl;
std :: cout<< "Clues :\n";
std :: cout << "* The sum of the numbers is " << CodeSum;
std :: cout << std :: endl;
std :: cout << "* The product of the numbers is \n" << CodeProduct;
int GuessA, GuessB, GuessC, GuessSum, GuessProduct;
std :: cout << std :: endl;
std :: cout << "Enter the Code : ";
std :: cin >> GuessA;
std :: cin >> GuessB;
std :: cin >> GuessC;
GuessSum = GuessA + GuessB + GuessC;
GuessProduct = GuessA * GuessB * GuessC;
if (GuessSum == CodeSum && GuessProduct == CodeProduct && Difficulty < 10)
{
std :: cout << "\n\nThe Door Opens! But there is another door with the sign of Level "<< Difficulty;
bComplete = true;
}
else if (GuessSum == CodeSum && GuessProduct == CodeProduct && Difficulty == 10)
{
std :: cout << "You opened the Final Door! You steal the diamond and live the rest of your life happily as a Billionaire!" ;
}
else
{
std :: cout << "\nThe Alarms starts blaring and you are quickly caught by the police! You spend the rest of your life in prison.";
std :: cout << "\nGAME OVER!!!";
bComplete = false;
}
}
int main()
{
srand(time(NULL));
int LevelDifficulty = 1;
bool bComplete;
PrintIntroduction(LevelDifficulty, bComplete);
while (LevelDifficulty <= 10)
{
PlayGame(LevelDifficulty, bComplete);
++LevelDifficulty;
}
std :: cout << "Thank you for Playing! Hope you enjoyed!\n";
return 0;
}
Hey guys, this is from the unreal cpp triple x game.
When i give the wrong answer the game displays the wrong message as expexcted but it still gives clues and asks the next question. How do i make it exit? Please help me.