Here is my First Version after i complete the TripleX Chapter. Haven’t Modified much… but i will
#include <iostream>
#include <ctime>
void PrintIntroduction(int Difficulty)
{
std::cout << "\n"
<< ".==================================================================.\n"
<< "|| ( ) ( ) ( ) ( ) ||\n"
<< "|'================================================================'|\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| .::::. ||\n"
<< "|| .::::::::. ||\n"
<< "|| ::::::::::: ||\n"
<< "|| ':::::::::::.. ||\n"
<< "|| :::::::::::::::' ||\n"
<< "|| ':::::::::::. ||\n"
<< "|| .::::::::::::::' ||\n"
<< "|| .:::::::::::... ||\n"
<< "|| ::::::::::::::'' ||\n"
<< "|| .:::. '::::::::'':::: ||\n"
<< "|| .::::::::. ':::::' ':::: ||\n"
<< "|| .::::':::::::. ::::: '::::. ||\n"
<< "|| .:::::' ':::::::::. ::::: ':::. ||\n"
<< "|| .:::::' ':::::::::.::::: '::. ||\n"
<< "|| .::::'' ':::::::::::::: '::. ||\n"
<< "|| .::'' ':::::::::::: :::... ||\n"
<< "|| ..:::: ':::::::::' .:' '''' ||\n"
<< "|| ..''''':' ':::::.' ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|| ||\n"
<< "|'================================================================'|\n \n";
std::cout << "You are a secret agent breaking into a security Level " << Difficulty << " server to get access to the hidden porn files. \n";
std::cout << "You need to enter the correct codes to continue... \n\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;
const int CodeSum = CodeA + CodeB + CodeC; //Summe
const int CodeProduct = CodeA * CodeB * CodeC; // Product
std::cout << std::endl;
std::cout << "+ There are 3 numbers in the code" << std::endl;
std::cout << "+ The code add-up to: " << CodeSum << std::endl; //Ausgabe Summe
std::cout << "+ The code multiply to give: " << CodeProduct << std::endl; //Ausgabe Produkt
std::cout << std::endl;
int GuessA, GuessB, GuessC;
std::cout << "Please Guess: " << std::endl;
std::cin >> GuessA >> GuessB >> GuessC;
int PlayerGuessSum = GuessA + GuessB + GuessC;
int PlayerGuessProduct = GuessA * GuessB * GuessC;
std::cout << "Sum: " << PlayerGuessSum << std::endl;
std::cout << "Multiply: " << PlayerGuessProduct << std::endl;
if (CodeSum == PlayerGuessSum && CodeProduct == PlayerGuessProduct)
{
std::cout << "You Win" << std::endl;
return true;
}
else
{
std::cout << "You lose" << std::endl;
return false;
}
}
int main()
{
srand(time(NULL)); // Creates new random sequence based on the time of day
const int MaxLevel = 3;
int Life = 3;
int LevelDifficulty = 1;
while (LevelDifficulty <= MaxLevel)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
//std::cout << bLevelComplete << std::endl;
std::cin.clear(); // Clears any errors
std::cin.ignore(); // Discard the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
else if (bLevelComplete == false && Life > 1)
{
Life--;
std::cout << Life << " Tries left";
}
else if (bLevelComplete == false && Life <= 1)
{
std::cout << "You got caught.";
std::exit(EXIT_SUCCESS);
}
}
(LevelDifficulty >= MaxLevel)? std::cout << "Gratulation Game Complete!": std::cout << "Something went wrong!";
return 0;
}