I haven’t opted for my own story, but i’ve taken some liberties with the code
Please throw me any feedback or room for improvement/observations, I’m keen to learn more!
Cheers!
Ten
#include <iostream>
using std::cout; using std::cin; using std::endl;
void PrintIntroduction (int &Difficulty)
{
std::string ascii =
" .,,uod8B8bou,,.\n\
..,uod8BBBBBBBBBBBBBBBBRPFT?l!i:.\n\
,=m8BBBBBBBBBBBBBBBRPFT?!||||||||||||||\n\
!...:!TVBBBRPFT||||||||||!!^^\"\"\' ||||\n\
!.......:!?|||||!!^^\"\' ||||\n\
!.........|||| ||||\n\
!.........|||| ## ||||\n\
!.........|||| ||||\n\
!.........|||| ||||\n\
!.........|||| ||||\n\
!.........|||| ||||\n\
`.........|||| ,||||\n\
.;.......|||| _.-!!|||||\n\
.,uodWBBBBb.....|||| _.-!!|||||||||!:'\n\
!YBBBBBBBBBBBBBBb..!|||:..-!!|||||||!iof68BBBBBb....\n\
!..YBBBBBBBBBBBBBBb!!||||||||!iof68BBBBBBRPFT?!:: `.\n\
!....YBBBBBBBBBBBBBBbaaitf68BBBBBBRPFT?!::::::::: `.\n\
!......YBBBBBBBBBBBBBBBBBBBRPFT?!::::::;:!^\"`;::: `.\n\
!........YBBBBBBBBBBRPFT?!::::::::::^''...::::::; iBBbo.\n\
`..........YBRPFT?!::::::::::::::::::::::::;iof68bo. WBBBBbo.\n\
`..........:::::::::::::::::::::::;iof688888888888b. `YBBBP^'\n\
`........::::::::::::::::;iof688888888888888888888b. `\n\
`......:::::::::;iof688888888888888888888888888888b.\n\
`....:::;iof688888888888888888888888888888888899fT!\n\
`..::!8888888888888888888888888888888899fT|!^\"\'\n\
`\' !!988888888888888888888888899fT|!^\"\'\n\
`!!8888888888888888899fT|!^\"\'\n\
`!988888888899fT|!^\"\'\n\
`!9899fT|!^\"\'\n\
`!^\"\'\"\n";
cout << ascii << endl;
cout << "You are a secret agent breaking into a level " << Difficulty;
cout << " secure computer containing nuclear launch codes!\nYou need to enter the correct number sequences to steal the launch codes...\n" << endl;
}
bool PlayGame (int &Difficulty)
{
PrintIntroduction(Difficulty);
const int CodeNumbers[3] = {2, 4, 8};
const int CodeSum = CodeNumbers[0] + CodeNumbers[1] + CodeNumbers[2];
const int CodeProduct = CodeNumbers[0] * CodeNumbers[1] * CodeNumbers[2];
cout << "There are 3 numbers in the code:" << endl;
cout << "The codes add up to: " << CodeSum << endl;
cout << "The product of the codes is: " << CodeProduct << endl;
int PlayerGuess[3];
cin >> PlayerGuess[0] >> PlayerGuess[1] >> PlayerGuess[2];
const int GuessSum = PlayerGuess[0] + PlayerGuess[1] + PlayerGuess[2];
const int GuessProduct = PlayerGuess[0] * PlayerGuess[1] * PlayerGuess[2];
cout << "You entered : ";
for(int Guess : PlayerGuess)
{
cout << Guess << ", ";
}
if(GuessSum == CodeSum && GuessProduct == CodeProduct)
{
cout << "\nYou break through this firewall!" << endl;
return true;
} else
{
cout << "\nYou've been detected! Try again!\n" << endl;
system("pause");
system(("CLS"));
return false;
}
}
int main(int argc, char* argv[])
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;
while(LevelDifficulty <= MaxDifficulty)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
if(bLevelComplete)
{
++LevelDifficulty;
}
}
cout << "Codes Retrieved!\nXF00-XBAR-XFOO\nGood Work!" << endl;
return 0;
}