#include <iostream>
#include <ctime>
void PrintIntroduction()
{
std::cout << " _____ ____ _ ____ _ _____ ___ __" << std::endl;
std::cout << "/__ __\\ / __\\ / \\ / __\\ / \\ / __/ \\ \\/ /" << std::endl;
std::cout << " / \\ | \\/| | | | \\/| | | | \\ \\ / " << std::endl;
std::cout << " | | | / | | | __/ | |_/\\ | /_ / \\ " << std::endl;
std::cout << " \\_/ \\_/\\_\\ \\_/ \\_/ \\____/ \\____\\ /__/\\_\\ " << std::endl;
std::cout << "\nIsola, good to hear from you!\n";
std::cout << "Ok, so you're one step away from the runic room.\n";
std::cout << "If you manage to get through the door, the power of the runes will be ours!\n";
std::cout << "Seems like it's not going to be easy though, there are secret codes that you need to figure out.\n";
std::cout << "If I'm right you'll have to solve a puzzle...\n";
std::cout << "I'm not entirely sure if this room has security measures in place, so be careful!\n";
}
bool PlayGame(int Level)
{
const int CodeA = rand() % Level + Level;
const int CodeB = rand() % Level + Level;
const int CodeC = rand() % Level + Level;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
int GuessA;
int GuessB;
int GuessC;
std::cout << "\nFor now, looks like you're at the security level " << Level << ".\n";
std::cout << "You have to find three numbers that add up to " << CodeSum << ".\n";
std::cout << "The same three numbers also multiplie to give " << CodeProduct << ".\n";
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\nIsola, you got through security level " << Level << ", nice job!\n";
return true;
}
else
{
std::cout << "\nDamn, it didn't work!\n";
std::cout << "Isola, I'm detecting movement, whatever's coming knows you're there, run!\n";
exit(0);
}
}
int main()
{
PrintIntroduction();
srand(time(NULL));
const int MaxLevel = 5;
int CurrentLevel = 1;
while (CurrentLevel <= MaxLevel)
{
bool bLevelComplete = PlayGame(CurrentLevel);
std::cin.clear();
std::cin.ignore();
if (bLevelComplete)
{
++CurrentLevel;
}
}
std::cout << "You've done it Isola!\n";
std::cout << "Now take the runes and run!\n";
return 0;
}
2 Likes
Phenomenal job!
2 Likes