#include <iostream>
void PrintIntroduction(int Difficulty)
{
std::cout << "\n\nYou are a sorcerer on a quest to find " << Difficulty;
std::cout << " INCL staff...\nYou need to construct the better magic circles to defeat your enemies to continue...\n\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
//Declaration
const int CodeA = rand();
const int CodeB = rand();
const int CodeC= rand();
//Matematic operations
const int CodeSum= CodeA + CodeB + CodeC;
const int CodeProduct= CodeA * CodeB * CodeC;
//Print results
std::cout << "+ There are 3 numbers in the magic circle to defeat your enemy";
std::cout << "\n+ The magic circle numbers add-up to: " << CodeSum;
std::cout << "\n+ The magic numbers multiply to give: "<< CodeProduct << std::endl;
//Store player guesses
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Different endings for player guesses
if(GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n***You defeated your enemy***\n";
return true;
}
else
{
std::cout << "\n***Your magic circle wasn't the right one and your enemy has defeated you***\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 10;
while (LevelDifficulty <= MaxDifficulty) // Loop until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear();
std::cin.ignore();
if (bLevelComplete)
{
++LevelDifficulty;
}
else
{
std::cout << "\nRetrying the quest\n";
}
}
std::cout << "\n***Congratulations, you finished the quests!!***\n";
return 0;
}
1 Like
Awesome!