Advertisement
UnlimitedSupply

Roberts Game

Jun 19th, 2022
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.72 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. bool PlayAgain(std::string NameOfCurrentGame) {
  12.     std::cout << "Play again?\n" << "(Will be sent back to: " << NameOfCurrentGame << ")\n";
  13.     std::string Sure;
  14.     std::cin >> Sure;
  15.     if (Sure == "Y" || Sure == "y") {
  16.         return true;
  17.     } else if (Sure == "N" || Sure == "n") {
  18.         return false;
  19.     } else {
  20.         PlayAgain(NameOfCurrentGame);
  21.     }
  22. }
  23.  
  24. void RobertsTurn(int Shots) {
  25.     bool RobertsGone = false;
  26.     while (Shots != 0 && RobertsGone != true) {
  27.         int Chance = rand() % 6 + 1;
  28.         int ChanceForPull = rand() % 3 + 1;
  29.         if (ChanceForPull == 1) {
  30.             std::cout << "Robert spun!\n";
  31.             if (Chance <= 3) {
  32.                 std::cout << "Good thing too because he was on a bullet!\n\n";
  33.             } else {
  34.                 std::cout << "He was on a white bullet. (Empty shell)\n\n";
  35.             }
  36.         } else {
  37.             std::cout << "Robert pulled the trigger!\n";
  38.             Shots = Shots - 1;
  39.             if (Chance <= 3) {
  40.                 if (Shots == 0) {
  41.                     std::cout << "Poor Robert, the gun blew off at his last pull!\n\n";
  42.                     RobertsGone = true;
  43.                 } else {
  44.                     std::cout << "*POW* Robert landed on a bullet!\n\n";
  45.                     RobertsGone = true;
  46.                 }
  47.             } else {
  48.                 std::cout << "Robert landed on a white bullet. (empty shell)\n\n";
  49.             }
  50.         }
  51.     }
  52.     if (RobertsGone == false) {
  53.         std::cout << "Both Robert and you live.\n\n";
  54.     }
  55. }
  56.  
  57. void RobertsToyGunTheDuo(int OldNumber, int shots, bool HeGoes, bool CheatsEnabled) {
  58.     std::cout << OldNumber << " / " << shots << "\n";
  59.     int Chance = rand() % 6 + 1;
  60.     std::cout << "Want to spin or pull it?\n";
  61.     if (CheatsEnabled == true) {
  62.         if (Chance <= 3) {
  63.             std::cout << "Pull it.\n";
  64.         } else {
  65.             std::cout << "Spin it.\n";
  66.         }
  67.     }
  68.     std::string Chosen;
  69.     std::cin >> Chosen;
  70.     if (Chosen == "Spin" || Chosen == "spin" || Chosen == "S" || Chosen == "s") {
  71.         std::cout << "You spun!\n";
  72.         if (Chance >= 4) {
  73.             std::cout << "Good thing too; you were on a bullet!\n";
  74.         }
  75.         RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
  76.     } else if (Chosen == "Pull" || Chosen == "pull" || Chosen == "P" || Chosen == "p") {
  77.         if (Chance <= 3) {
  78.             std::cout << "You survived.\n\n";
  79.             int NewNumber = (OldNumber - 1);
  80.             if (NewNumber == 0) {
  81.                 std::cout << "YOU WON!\n\n\n";
  82.                 if (shots >= 25 && CheatsEnabled == false) {
  83.                     std::cout << "WOW! you won on hard mode! good for you! :)\n\n";
  84.                 } else if (shots >= 10 && CheatsEnabled == false) {
  85.                     std::cout << "Wow! you won on medium mode! lucky!\n\n";
  86.                 }
  87.                 if (HeGoes == true) {
  88.                     std::cout << "Now its Roberts turn!\n";
  89.                     RobertsTurn(shots);
  90.                 }
  91.             } else {
  92.                 RobertsToyGunTheDuo(NewNumber, shots, HeGoes, CheatsEnabled);
  93.             }
  94.         } else {
  95.             std::cout << "*POW* Robert won!\n";
  96.         }
  97.     } else if (Chosen == "Empty" || Chosen == "empty" && CheatsEnabled == true) {
  98.         NewNumber = (OldNumber - OldNumber);
  99.         RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
  100.     } else {
  101.         RobertsToyGunTheDuo(OldNumber, shots, HeGoes, CheatsEnabled);
  102.     }
  103.     if (PlayAgain("RobertsToyGunTheDuo") == true) {
  104.         RobertsToyGunTheDuo(shots, shots, HeGoes, CheatsEnabled);
  105.     }
  106. }
  107.  
  108. void SimonSays() {
  109.     std::cout << "WIP\n";
  110. }
  111.  
  112. void RobertsToyGun() {
  113.     int Chance = rand() % 6 + 1;
  114.     std::string Chosen;
  115.     std::cout << "Spin or pull?\n";
  116.     std::cin >> Chosen;
  117.     if (Chosen == "Spin" || Chosen == "spin" || Chosen == "S" || Chosen == "s") {
  118.         std::cout << "You spun it!\n";
  119.         RobertsToyGun();
  120.     } else if (Chosen == "Pull" || Chosen == "pull") {
  121.         if (Chance <= 3) {
  122.             int RareEnding = rand() % 250 + 1;
  123.             if (RareEnding == 1) {
  124.                 std::cout << "Your gun exploded.\n";
  125.             } else {
  126.                 std::cout << "*Click* you survived!\n";
  127.             }
  128.         } else {
  129.             std::cout << "*POW* Robert won!\n";
  130.         }
  131.     }
  132.     if (PlayAgain("RobertsToyGun") == true) {
  133.         RobertsToyGun();
  134.     }
  135. }
  136.  
  137. void enumguess(int MaxNumber) {
  138.     int ChosenLuckyNumber = rand() % MaxNumber + 1;
  139.     std::cout << "Pick a number 1 through " << MaxNumber << "\n";
  140.     int ChosenEnum;
  141.     std::cin >> ChosenEnum;
  142.     if (ChosenEnum == ChosenLuckyNumber) {
  143.         std::cout << "YOU WIN!!!\n";
  144.     } else {
  145.         std::cout << "You lost.\n";
  146.     }
  147.     if (PlayAgain("enumguess") == true) {
  148.         enumguess(MaxNumber);
  149.     }
  150. }
  151.  
  152. int main() {
  153.     std::cout << "Welcome to Test Game (VERY CREATIVE NAME)\n\n";
  154.     std::cout << "Which game do you want to play?\n\n";
  155.     std::cout << "1 (roberts toy gun)\n" << "2 (number guesser)\n" << "3 (RobertsToyGunTheDuo)\n";
  156.     int Choice;
  157.     std::cin >> Choice;
  158.     if (Choice == 1) {
  159.         RobertsToyGun();
  160.     } else if (Choice == 2) {
  161.         std::cout << "Pick max enum: ";
  162.         int Max;
  163.         std::cin >> Max;
  164.         std::cout << "\n\n";
  165.         enumguess(Max);
  166.     } else if (Choice == 3) {
  167.         int Shots;
  168.         bool HeGoesYes;
  169.         bool Cheatsenableder;
  170.         std::string HeGoesToo;
  171.         std::string Cheatsenabled;
  172.         std::cout << "How many shots?\n";
  173.         std::cin >> Shots;
  174.         std::cout << "Does Robert Play too?\n";
  175.         std::cin >> HeGoesToo;
  176.         if (HeGoesToo == "Y" || HeGoesToo == "y") {
  177.             HeGoesYes = true;
  178.         } else {
  179.             HeGoesYes = false;
  180.         }
  181.         std::cout << "Cheats Enabled?\n";
  182.         std::cin >> Cheatsenabled;
  183.         if (Cheatsenabled == "y" || Cheatsenabled == "Y" || Cheatsenabled == "yes" || Cheatsenabled == "Yes") {
  184.             Cheatsenableder = true;
  185.         } else {
  186.             Cheatsenableder = false;
  187.         }
  188.         RobertsToyGunTheDuo(Shots, Shots, HeGoesYes, Cheatsenableder);
  189.     } else if (Choice == 4) {
  190.         SimonSays();
  191.     } else {
  192.         main();
  193.     }
  194.     if (PlayAgain("Main Menu") == true) {
  195.         main();
  196.     }
  197. }
  198.  
  199.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement