This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOne.cpp
94 lines (69 loc) · 2.98 KB
/
GameOne.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
Developer: @skywalkerSam
Purpose: Game-I
Stardate: 12021.255.19:45:00
*/
#include <iostream>
#include <ctime>
// User Defined Functions
void GameIntro(int Difficulty)
{
std::cout << "\n\t AIM : \n\t*** ASAI's Research Lab Is Under Attack, Break The Codes To Get Into The 'LEVEL "<< Difficulty;
std::cout << "' Secured Datacentre Facility, Cut The Hard Line & Save The Research Data From Going Into The Wrong Hands... *** \n\n\n";
}
bool PlayGame(int Difficulty) // bool must return boolean...
{
GameIntro(Difficulty);
int CodeA = rand() % Difficulty + Difficulty; // rand() genrates values upto 32000. To get smaller values, we're using modulo operator...
int CodeB = rand() % Difficulty + Difficulty; // "Difficulty + Difficulty" to make it much difficult...
int CodeC = rand() % Difficulty + Difficulty; // " +1 " to remove any 0 values & make it more difficult...
int CodeSum = CodeA + CodeB + CodeC;
int CodeProduct = CodeA * CodeB * CodeC;
std::cout << ">_ Here's Some Informations About The Code...\n\n";
std::cout << "+ The Total Series Of Code: 3 ( X X X )\n";
std::cout << "+ The Codes Join Upto: " << CodeSum << std::endl;
std::cout << "+ The Codes Product Upto: " << CodeProduct << std::endl;
int GuessA, GuessB, GuessC;
std::cout << "\n\tNow, Enter The Codes: ";
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n\t\t\t ### Welcome To The ASAI'S 'LEVEL "<< Difficulty;
std::cout << "' Datacentre Facility :) ### \n\n";
return true;
}
else
{
std::cout << "\n\t\t ### Alert! There's A Breach In The 'LEVEL "<< Difficulty;
std::cout << "' Datacentre Facility :( ### \n\n";
// std::cout << "\tWell, The Codes Were: " << CodeA << CodeB << CodeC << std::endl;
return false;
}
}
// Main Function
int main(int argc, char const *argv[])
{
srand(time(NULL)); // More complex random numbers based on time of the day...
int LevelDifficulty = 1; // Remember The Variable Scope...
const int MaxDifficulty = 5;
// While Loop
while (LevelDifficulty <= MaxDifficulty)
{
// std::cout << rand() % 5 << '\n';
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); // Clears any error...
std::cin.ignore(); // Discard the buffer...
if (bLevelComplete)
{
++LevelDifficulty; // LevelDefficulty = LevelDifficulty + 1
}
else
{
std::cout << "\n ### You've Entered An Incorrect Code :( After One More Unsuccessful Attempt, Lockdown Procedures Will Be Initiated... ### \n\n";
}
}
std::cout << "\n ### You've Saved The ASAI's Research Lab Today, You're Awesome :) ### \n\n";
return 0;
}