Triple X Final

#include <iostream>
#include <ctime>
using namespace std;

void PrintIntroduction()
{
    cout << " _______  _                  _______      _       \n"
    "(_______)| |                ( ______)    (_)  \n"
    " _       | | _    ____       \\ \\   ____   _   ____   ____ \n"
    "| |      | || \\  / _  )       \\ \\ |  _ \\ | | / ___) / _  )\n"
    "| |_____ | | | |( (/ /    _____) )| | | || || |    ( (/ /\n"
    " \\______)|_| |_| \\____)  (______/ | ||_/ |_||_|     \\____)\n"
    "                                  |_|                     \n";

     //Create the setting for the puzzle
    cout << "You enter The Spire and find a door on the other end. \n"; 
    cout << "You must enter the correct numbers to move through the next door... \n";
}

void PrintLevel(int Difficulty)
{
    cout << "\nRoom "<< Difficulty << endl;
}

bool PlayGame(int Difficulty, int MaxDifficulty)
{
    
    //Declare 3 number code
    const int CodeA = rand() % Difficulty + Difficulty;
    const int CodeB = rand() % Difficulty + Difficulty; 
    const int CodeC = rand() % Difficulty + Difficulty; 

    //Calculate the sum and product 
    const int CodeSum = CodeA + CodeB + CodeC;
    const int CodeProd = CodeA * CodeB * CodeC;

    //Print sum and product to terminal
    cout << endl;
    cout << "+ There are 3 numbers in the code \n";
    cout << "+ The sum of the numbers is: " << CodeSum << endl;
    cout << "+ The product of the numbers is: " << CodeProd << endl;
    
    int GuessA, GuessB, GuessC;

    cout << "\n Enter your guess:\n";

    // Store player guess
    cin >> GuessA >> GuessB >> GuessC;
    
    
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProd = GuessA * GuessB * GuessC;

    // Check guess 
    if (GuessSum == CodeSum && GuessProd == CodeProd)
    {
        if (Difficulty < MaxDifficulty)
        {
        cout << "\nThe floor rumbles beneath you.\nThe door slides open...\n";
        }
        else 
        {
            cout << "\nCongratulations, you have made it through " << MaxDifficulty << " rooms of The Spire."
            "\nYou return to the spaceship to take a rest.\n";
        }
   
       return true;
    }
    else
    {
        cout << "\nTitanium blades shoot out across the room dicing you to pieces.\nDr. Trintigant puts you back together.\n"
        "Try Again.\n";
        return false;
    }
}




int main()
{   
    srand(time(NULL));
    int LevelDifficulty = 1;
    const int MaxDifficulty = 5;
    PrintIntroduction();
    bool bLevelComplete = true;

    while (LevelDifficulty <= MaxDifficulty) // Loop game until all levels are completed
    {
        PrintLevel(LevelDifficulty);
        bLevelComplete =  PlayGame(LevelDifficulty, MaxDifficulty);
        cin.clear(); // Clears any errors
        cin.ignore(); // Discards the buffer
        
        if (bLevelComplete)
        {
            ++LevelDifficulty; 
        }
        
    }


    return 0;      
}
 _______  _                  _______      _       
(_______)| |                ( ______)    (_)
 _       | | _    ____       \ \   ____   _   ____   ____
| |      | || \  / _  )       \ \ |  _ \ | | / ___) / _  )
| |_____ | | | |( (/ /    _____) )| | | || || |    ( (/ /
 \______)|_| |_| \____)  (______/ | ||_/ |_||_|     \____)
                                  |_|
You enter The Spire and find a door on the other end. 
You must enter the correct numbers to move through the next door...

Room 1

+ There are 3 numbers in the code
+ The sum of the numbers is: 3
+ The product of the numbers is: 1

 Enter your guess:
1
1
1

The floor rumbles beneath you.
The door slides open...

Room 2

+ There are 3 numbers in the code
+ The sum of the numbers is: 8
+ The product of the numbers is: 18

 Enter your guess:
2
3
3

The floor rumbles beneath you.
The door slides open...

Room 3

+ There are 3 numbers in the code
+ The sum of the numbers is: 11
+ The product of the numbers is: 48

 Enter your guess:
2
2
7

Titanium blades shoot out across the room dicing you to pieces.
Dr. Trintigant puts you back together.
Try Again.

Room 3

+ There are 3 numbers in the code
+ The sum of the numbers is: 10
+ The product of the numbers is: 36

 Enter your guess:
6
2
2

Titanium blades shoot out across the room dicing you to pieces.
Dr. Trintigant puts you back together.
Try Again.

Room 3

+ There are 3 numbers in the code
+ The sum of the numbers is: 13
+ The product of the numbers is: 75

 Enter your guess:
5
5
3

The floor rumbles beneath you.
The door slides open...

Room 4

+ There are 3 numbers in the code
+ The sum of the numbers is: 18
+ The product of the numbers is: 196

 Enter your guess:
7
7
4

The floor rumbles beneath you.
The door slides open...

Room 5

+ There are 3 numbers in the code
+ The sum of the numbers is: 19
+ The product of the numbers is: 240

 Enter your guess:
8
5
6

Congratulations, you have made it through 5 rooms of The Spire.
You return to the spaceship to take a rest.
2 Likes

Wow! Great job! You outdid yourself :grinning_face_with_smiling_eyes:

Excellent, mine was nothing compared to this :rofl: best TripleX game I’ve seen so far. Great work.

Privacy & Terms