Dialogue might be lacking however I think it still fits with mechanic of game.
I’m new to this so if there are any improvements that I could of made, let me know.
I feel like the user experience could be improved a lot somehow.
#include <iostream>
#include <ctime>
void PrintIntroduction(int Difficulty)
{
// Print game scenario to terminal
std::cout << R"(
$$$$$$\ $$\ $$\ $$\ $$\
$$ __$$\ $$ | $$ | $$ |\__|
$$ / \__|$$\ $$\ $$$$$$$\ $$ | $$$$$$\ $$ |$$ / $$\ $$$$$$$\ $$$$$$\
$$ | $$ | $$ |$$ _____|$$ |$$ __$$\ $$$$$ / $$ |$$ __$$\ $$ __$$\
$$ | $$ | $$ |$$ / $$ |$$$$$$$$ | $$ $$< $$ |$$ | $$ |$$ / $$ |
$$ | $$\ $$ | $$ |$$ | $$ |$$ ____| $$ |\$$\ $$ |$$ | $$ |$$ | $$ |
\$$$$$$ |\$$$$$$$ |\$$$$$$$\ $$ |\$$$$$$$\ $$ | \$$\ $$ |$$ | $$ |\$$$$$$$ |
\______/ \____$$ | \_______|\__| \_______| \__| \__|\__|\__| \__| \____$$ |
$$\ $$ | $$\ $$ |
\$$$$$$ | \$$$$$$ |
\______/ \______/
-------- __@ __@ __@ __@ __~@ __~@ __~@ __~@
----- _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_ _`\<,_
---- (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*) (*)/ (*)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)";
std::cout << "\n\nYou're an entrepreneur trying to source bikes to open up your own Cycle Store... \n";
std::cout << "You need to enter the correct level " << Difficulty <<" padlock code to successfully gain ownership of a new bike... \n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
// Declare 3 number code
const int CodeA = rand() % Difficulty + Difficulty;
const int CodeB = rand() % Difficulty + Difficulty;
const int CodeC = rand() % Difficulty + Difficulty;
//Calculate and declare sum and product of 3 number code
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//Print sum and product to terminal
std::cout << "\n+ Modern padlocks only have 3 numbers nower days. \n";
std::cout << "+ These 3 numbers add up to: " << CodeSum << std::endl;
std::cout << "+ These 3 numbers multiply to give: " << CodeProduct << std::endl;
// Store player guess
int GuessA, GuessB, GuessC;
std::cout << "\nEnter your 3 numbers separated by a space or the enter key: \n";
std::cin >> GuessA >> GuessB >> GuessC;
//Calculate and declare sum and product of player guess
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Print Win/Lose to terminal
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\nGood job, you're one bike closer to your empire, now leave the scene casually and quickly, there's more work to be done... \n\n";
return true;
}
else
{
std::cout << "\nUnlucky, you spent too long guessing the wrong numbers and the owner caught you... \nLost a few teeth, but don't worry, you can buy some replacements when you're rolling in that Cycle Store money. \nDon't give up now! \n\n";
return false;
}
}
int main()
{
srand(time(NULL)); // Creates a new random sequence based on time of day
int LevelDifficulty = 1;
const int MaxLevel = 5;
while (LevelDifficulty <= MaxLevel) // Loop the game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
//Increase level difficulty
}
}
std::cout << "\nNice work out there, you've aquired enough merchandise to call it a selection. Now to find some bike-less chumps to sell 'em to. \n";
return 0;
}