The Troubles of Being Rich + Endless edition (Triplex)

This is my Triplex I didn’t bother to see if the endless edition is actually endless (it probably is though) but there is a story and what else can I say.CODE FOR TRIPLEX:

#include
#include
//funcion list
void PrintIntroduction(int Difficulty)
{
std::cout << “You are walking to your mansion after the ‘Grand Rich Only Party Exellent’ also known as GRAPE…\n”;
std::cout << “Being rich and all you are a major target so that evening you are knocked out by a thief…\n”;
std::cout << “When you wake up you don’t remember much but all you know is where your house is…\n”;
std::cout << “You get to your house but unforunetly you can’t remeber the password but you find a piece of paper under the welcome mat\n”;
std::cout << “it reads’decode these 3 numbers to find the 3 number password’this is " << Difficulty;
std::cout << " lock out of 5\n”;
}

bool PlayGame(int Difficulty)
 {

PrintIntroduction(Difficulty);

//These are const do not change
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;

//This is where I set words = to something
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;

//This is the puzzel itself
std::cout << "+ the codes add up to " << CodeSum << std::endl;
std::cout << "+ the codes muliply each other to " << CodeProduct << std::endl;
std::cout << std::endl;

//Store player guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
   

int GuessSum = GuessA + GuessB + GuessC; 
int GuessProduct = GuessA * GuessB * GuessC; 

//Check if player was correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{  
   std::cout << "You unlocked " << Difficulty;
   std::cout << " lock/s out of 5\n\n";
   return true;
}
else
{ 
    std::cout << "The password you enter was wrong and you start to think 'maybe this wasn't my house' but the next day the newspaper says that\n";
    std::cout << "your mansion has been robbed and the theif that knocked you out took everything down to the last penny!\n";
    std::cout << "Looks like you have to start a new life.\n";
    std::cout << "GAME OVER\n\n";
    return false;
    }
 }

int main()
{
srand(time(NULL));//Random Number Generator based on time

int LevelDifficulty = 1;
int const MaxDifficulty = 5;
while (LevelDifficulty <= MaxDifficulty)
{
bool blevelComplete = PlayGame (LevelDifficulty);
std::cin.clear();//clears errors
std::cin.ignore();//ignores buffers

 if (blevelComplete)
 {
  ++LevelDifficulty;
 }

}
std::cout << “You entered all 5 of your passwords correctly(you really are paranoid)and caught the criminal before he robed your 27’th favorite tv\ncongradulations!”;

 return 0;
}

CODE FOR TRIPLEX ENDLESS EDITION:

#include
#include
//funcion list
void PrintIntroduction(int Difficulty)
{
std::cout << “You are walking to your mansion after the ‘Grand Rich Only Party Exellent’ also known as GRAPE…\n”;
std::cout << “Being rich and all you are a major target so that evening you are knocked out by a thief…\n”;
std::cout << “When you wake up you don’t remember much but all you know is where your house is…\n”;
std::cout << “You get to your house but unforunetly you can’t remeber the password but you find a piece of paper under the welcome mat\n”;
std::cout << “it reads’decode these 3 numbers to find the 3 number password’this is " << Difficulty;
std::cout << " lock out of infinite,yes you have infinite locks\n”;
}

bool PlayGame(int Difficulty)
 {

PrintIntroduction(Difficulty);

//These are const do not change
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;

//This is where I set words = to something
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;

//This is the puzzel itself
std::cout << "+ the codes add up to " << CodeSum << std::endl;
std::cout << "+ the codes muliply each other to " << CodeProduct << std::endl;
std::cout << std::endl;

//Store player guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
   

int GuessSum = GuessA + GuessB + GuessC; 
int GuessProduct = GuessA * GuessB * GuessC; 

//Check if player was correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{  
   std::cout << "You unlocked " << Difficulty;
   std::cout << " lock/s out of infinite\n\n";
   return true;
}
else
{ 
    std::cout << "The password you enter was wrong and you start to think 'maybe this wasn't my house' but the next day the newspaper says that\n";
    std::cout << "your mansion has been robbed and the theif that knocked you out took everything down to the last penny!\n";
    std::cout << "Looks like you have to start a new life(maybe you shoudn't have infinite locks next time).\n";
    std::cout << "GAME OVER\n\n";
    return false;
    }
 }

int main()
{
srand(time(NULL));//Random Number Generator based on time

int LevelDifficulty = 1;
while (LevelDifficulty)
{
bool blevelComplete = PlayGame (LevelDifficulty);
std::cin.clear();//clears errors
std::cin.ignore();//ignores buffers

 if (blevelComplete)
 {
  ++LevelDifficulty;
 }

}
std::cout << “You entered all 5 of your passwords correctly(you really are paranoid)and caught the criminal before he robed your 27’th favorite tv\ncongradulations!”;

 return 0;
}

Sorry for the weird page, this is my first post.

1 Like

It’s all good man! You will get better in time. I love that you posted it and put yourself out there!