Wanted to update on my Triple X project. There is one more thing I would like to implement: lives! But I think I need to carry on with the course a bit before I figure out how to do that.
#include <iostream>
#include <ctime>
void PrintIntroduction()
{
//Print welcome message
std::cout<< "\n\n" << R"( .
/^\ .
/\ "V"
/__\ I O o
//..\\ I .
\].`[/ I
/l\/j\ (] . O
/. ~~ ,\/I .
\\L__j^\/I o
\/--v} I o .
| | I _________
| | I c(` ')o
| l I \. ,/
_/j L l\_! _//^---^\\_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~)" << std::endl;
std::cout << "Welcome, wizard. You've found the Tome of Truth.\n";
std::cout << "Many people have tried to divine the formula within to claim the Elixir of Life, but few succeed.\n";
std::cout << "Will you be able to succeed where so many have failed?\n";
std::cout << "Be careful! A single mistake can prove fatal...\n";
}
bool bPlayGame(int Difficulty)
{
//Declare 3 number code
const int IngredientA = rand() % Difficulty + Difficulty - 1;
const int IngredientB = rand() % Difficulty + Difficulty - 1;
const int IngredientC = rand() % Difficulty + Difficulty - 1;
const int IngredientSum = IngredientA + IngredientB + IngredientC;
const int IngredientProduct = IngredientA * IngredientB * IngredientC;
//Print IngredientSum d prod to terminal
std::cout << "\nPage " << Difficulty - 1 <<std::endl;
std::cout << "\n* Each part of the potion requires careful mixing of three ingredients.\n";
std::cout << "* The ingredients add-up to: " << IngredientSum;
std::cout << "\n* The ingredients multiply to give: " << IngredientProduct << std::endl;
//Store players guess and output with flavour text
int PlayerGuessA, PlayerGuessB, PlayerGuessC;
std::cin >> PlayerGuessA >> PlayerGuessB >> PlayerGuessC;
std::cout << "\nYou mixed: " << PlayerGuessA <<" poisoned entrails, " << PlayerGuessB << " drops of toad sweat & " << PlayerGuessC << " eyes of newt.\n";
// Check if the guess is correct
int GuessSum = PlayerGuessA + PlayerGuessB + PlayerGuessC;
int GuessProduct = PlayerGuessA * PlayerGuessB * PlayerGuessC;
if (GuessSum == IngredientSum && GuessProduct == IngredientProduct)
{
std::cout << "\nThe cauldron begins to swirl and bubble with magical energy! Keep going!";
return true;
}
else
{
std::cout << "\nThe cauldron begins to bubble...but too much!\n";
std::cout << "The potion splashes you with burning acid...be careful!\n";
return false;
}
}
int main()
{
srand(time(NULL));
PrintIntroduction();
int LevelDifficulty = 2;
const int MaxDifficulty = 6;
while (LevelDifficulty <= MaxDifficulty) //Loops the game until all levels complete
{
bool bLevelComplete = bPlayGame(LevelDifficulty);
std::cin.clear();
std::cin.ignore();
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "\n\n" << R"( (
) )
______(____
(___________)
/ \
/ \
| |
____\ /____
()____'.__ __.'____()
.'` .'```'. `-.
().'` `'.())"<< std::endl;
std::cout << "\nYou've done it! The Elixir of Life bubbles gently in the cauldron in front of you.";
std::cout << "\nWith a single sip you feel your old body begin to rebuild, youth and vigour returns!";
std::cout << "\nYou have beaten the game of life and cheated death itself. Congratulations.";
std::cout << "\n\n" << R"( .''.
.''. . *''* :_\/_: .
:_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
.''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=-
:_\/_:'.:::. ' *''* * '.\'/.' _\(/_'.':'.'
: /\ : ::::: *_\/_* -= o =- /)\ ' *
'..' ':::' * /\ * .'/.\'. '
* *..* :
*
*)";
return 0;
}