Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- bool PlayAgain(std::string NameOfCurrentGame) {
- std::cout << "Play again?\n" << "(Will be sent back to: " << NameOfCurrentGame << ")\n";
- std::string Sure;
- std::cin >> Sure;
- if (Sure == "Y" || Sure == "y") {
- return true;
- } else if (Sure == "N" || Sure == "n") {
- return false;
- } else {
- PlayAgain(NameOfCurrentGame);
- }
- }
- void RobertsTurn(int Shots) {
- bool RobertsGone = false;
- while (Shots != 0 && RobertsGone != true) {
- int Chance = rand() % 6 + 1;
- int ChanceForPull = rand() % 3 + 1;
- if (ChanceForPull == 1) {
- std::cout << "Robert spun!\n";
- if (Chance <= 3) {
- std::cout << "Good thing too because he was on a bullet!\n\n";
- } else {
- std::cout << "He was on a white bullet. (Empty shell)\n\n";
- }
- } else {
- std::cout << "Robert pulled the trigger!\n";
- Shots = Shots - 1;
- if (Chance <= 3) {
- if (Shots == 0) {
- std::cout << "Poor Robert, the gun blew off at his last pull!\n\n";
- RobertsGone = true;
- } else {
- std::cout << "*POW* Robert landed on a bullet!\n\n";
- RobertsGone = true;
- }
- } else {
- std::cout << "Robert landed on a white bullet. (empty shell)\n\n";
- }
- }
- }
- if (RobertsGone == false) {
- std::cout << "Both Robert and you live.\n\n";
- }
- }
- void RobertsToyGunTheDuo(int OldNumber, int shots, bool HeGoes, bool CheatsEnabled) {
- std::cout << OldNumber << " / " << shots << "\n";
- int Chance = rand() % 6 + 1;
- std::cout << "Want to spin or pull it?\n";
- if (CheatsEnabled == true) {
- if (Chance <= 3) {
- std::cout << "Pull it.\n";
- } else {
- std::cout << "Spin it.\n";
- }
- }
- std::string Chosen;
- std::cin >> Chosen;
- if (Chosen == "Spin" || Chosen == "spin" || Chosen == "S" || Chosen == "s") {
- std::cout << "You spun!\n";
- if (Chance >= 4) {
- std::cout << "Good thing too; you were on a bullet!\n";
- }
- RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
- } else if (Chosen == "Pull" || Chosen == "pull" || Chosen == "P" || Chosen == "p") {
- if (Chance <= 3) {
- std::cout << "You survived.\n\n";
- int NewNumber = (OldNumber - 1);
- if (NewNumber == 0) {
- std::cout << "YOU WON!\n\n\n";
- if (shots >= 25 && CheatsEnabled == false) {
- std::cout << "WOW! you won on hard mode! good for you! :)\n\n";
- } else if (shots >= 10 && CheatsEnabled == false) {
- std::cout << "Wow! you won on medium mode! lucky!\n\n";
- }
- if (HeGoes == true) {
- std::cout << "Now its Roberts turn!\n";
- RobertsTurn(shots);
- }
- } else {
- RobertsToyGunTheDuo(NewNumber, shots, HeGoes, CheatsEnabled);
- }
- } else {
- std::cout << "*POW* Robert won!\n";
- }
- } else if (Chosen == "Empty" || Chosen == "empty" && CheatsEnabled == true) {
- NewNumber = (OldNumber - OldNumber);
- RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
- } else {
- RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
- }
- if (PlayAgain("RobertsToyGunTheDuo") == true) {
- RobertsToyGunTheDuo(shots, shots, HeGoes, CheatsEnabled);
- }
- }
- void SimonSays() {
- std::cout << "WIP\n";
- }
- void RobertsToyGun() {
- int Chance = rand() % 6 + 1;
- std::string Chosen;
- std::cout << "Spin or pull?\n";
- std::cin >> Chosen;
- if (Chosen == "Spin" || Chosen == "spin" || Chosen == "S" || Chosen == "s") {
- std::cout << "You spun it!\n";
- RobertsToyGun();
- } else if (Chosen == "Pull" || Chosen == "pull") {
- if (Chance <= 3) {
- int RareEnding = rand() % 250 + 1;
- if (RareEnding == 1) {
- std::cout << "Your gun exploded.\n";
- } else {
- std::cout << "*Click* you survived!\n";
- }
- } else {
- std::cout << "*POW* Robert won!\n";
- }
- }
- if (PlayAgain("RobertsToyGun") == true) {
- RobertsToyGun();
- }
- }
- void enumguess(int MaxNumber) {
- int ChosenLuckyNumber = rand() % MaxNumber + 1;
- std::cout << "Pick a number 1 through " << MaxNumber << "\n";
- int ChosenEnum;
- std::cin >> ChosenEnum;
- if (ChosenEnum == ChosenLuckyNumber) {
- std::cout << "YOU WIN!!!\n";
- } else {
- std::cout << "You lost.\n";
- }
- if (PlayAgain("enumguess") == true) {
- enumguess(MaxNumber);
- }
- }
- int main() {
- std::cout << "Welcome to Test Game (VERY CREATIVE NAME)\n\n";
- std::cout << "Which game do you want to play?\n\n";
- std::cout << "1 (roberts toy gun)\n" << "2 (number guesser)\n" << "3 (RobertsToyGunTheDuo)\n";
- int Choice;
- std::cin >> Choice;
- if (Choice == 1) {
- RobertsToyGun();
- } else if (Choice == 2) {
- std::cout << "Pick max enum: ";
- int Max;
- std::cin >> Max;
- std::cout << "\n\n";
- enumguess(Max);
- } else if (Choice == 3) {
- int Shots;
- bool HeGoesYes;
- bool Cheatsenableder;
- std::string HeGoesToo;
- std::string Cheatsenabled;
- std::cout << "How many shots?\n";
- std::cin >> Shots;
- std::cout << "Does Robert Play too?\n";
- std::cin >> HeGoesToo;
- if (HeGoesToo == "Y" || HeGoesToo == "y") {
- HeGoesYes = true;
- } else {
- HeGoesYes = false;
- }
- std::cout << "Cheats Enabled?\n";
- std::cin >> Cheatsenabled;
- if (Cheatsenabled == "y" || Cheatsenabled == "Y" || Cheatsenabled == "yes" || Cheatsenabled == "Yes") {
- Cheatsenableder = true;
- } else {
- Cheatsenableder = false;
- }
- RobertsToyGunTheDuo(Shots, Shots, HeGoesYes, Cheatsenableder);
- } else if (Choice == 4) {
- SimonSays();
- } else {
- main();
- }
- if (PlayAgain("Main Menu") == true) {
- main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement