#include
#include
void WelcomeMessages()
{
//info about situation
std::cout<<"\n\nHello agent 001 the world is filled with zombies.\nIts a zombie acocalypse!\n";
std::cout<<"\nYour task is to get to our headquaters for further discussions about the acocalypse and the actions to be taken";
std::cout<<"\nRemember its no easy task to reach the headquaters! You have to unlock 10 doors with number locks which were constructed for security reasons.";
std::cout<<"\nWe don't want to get infected by the virus. Its goining to be difficult as you progress";
std::cout<<"\nGood luck see you soon";
}
int PlayGame(int Lev)
{
//declare code variables
const int CodeA = (rand()%(Lev+4))+1;
const int CodeB = (rand()%(Lev+4))+1;
const int CodeC = (rand()%(Lev+4))+1;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//printing the values
std::cout<<"\n\nStage "<<Lev;
std::cout<<"\n\n++There are three numberers which you have to find to unlock the door.";
std::cout<<"\n++The sum of 3 numbers is: "<<CodeSum;
std::cout<<"\n++The product of 3 numbers is: "<<CodeProduct;
//getting player's guesses
int GuessA, GuessB, GuessC;
std::cout<<"\n\nPlease enter the 3 numbers\n";
std::cin>>GuessA>> GuessB>> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//checking if the guess is correct
if(CodeSum == GuessSum && CodeProduct == GuessProduct)
{
std::cout<<"\n\nCongratulations on solving stage "<<Lev <<" the door will open now";
return Lev;
}
else
{
std::cout<<"\nYou have entered wrong code";
Lev-=1;
return Lev;
}
}
int main()
{
srand(time(NULL));//This creates random number based on time so the numbers are not repeated
WelcomeMessages();
int Level = 1;
int Attempts = 0;
int LevelCount;
while (Level<=5)
{
LevelCount=Level; //LevelCount will have the same value as the current level before the user enters ans
Level = PlayGame(Level);
Level+=1;
if (LevelCount == Level)// if both Level and Level count have same value then the attempts will increase
{
Attempts+=1;
std::cout<<". You have "<< 4 - Attempts<<" attemps left";
}
else
{
Attempts=0;
}
if (Attempts == 4)
{
std::cout<<"\n\nYou have exeeded the limit of attempts. Please wait for the cooldown time.";
break;
}
}
std::cout<<"\n\nAccess Granted. Welcome to the Headquaters agent 001.";
std::cout<<"\nYou are requested to join the meeting.";
return 0;
}