Build a Text Adventure Challenge Project (C++)

Couldn’t figure out a scenario where I use the For loop in this instance. Had fun doing this and surprisingly it worked!

I have used C/C++ before and wanted to make a project.

It was fun, although I had to remember how the syntax, C++ libraries, and type errors work again.

[GitHub - CornSnek/build-a-text-adventure]

path to wild wisdom GitHub - Mairoslav/codecademyChallengeProjects

I need some help. For some reason when I try to run this, it skips the 2nd choice input.

It works normally until the code hits the 3rd loop and I cannot figure out how the 3rd loop breaks the 3rd loop

#include
#include
int main(){

std::string playerName;
int choice1;
bool luck = true;

std::cout << “-----------------------------------------------------------\n”;
std::cout << " WELCOME TO THE SHATTERED PLAINS\n";
std::cout << “-----------------------------------------------------------\n\n”;

std::cout << “You wake up in the Prison, a squat stone building with no windows. \nYou’re cold and sore and can barely remember your name.\n\nWhat is your name?\n”;

std::cin >> playerName;

std::cout << “\nThat’s right! Your name is " << playerName <<”.\n\n";

std::cout << “Suddenly you are dragged to Trial\n\n” << “Judge: " << playerName << " You are accused of kidnapping Princess Nadia. How do you Plead?\n\n”;

// First choice for the player

for(int i = 0; choice1 != 1 && choice1 != 2 && choice1 != 3 && i < 3; i++)
{std::cout << “\nHow do you Plead? (1-3)\n\n”;
std::cout << “1) Innocent!\n”;
std::cout << “2) Guilty\n”;
std::cout << “3) Stay Silent\n\n”;
std::cin >> choice1;
std::cout << "Confirm tries: " << i;}
switch (choice1){
case 1:
std::cout << “\nJudge: I see. The Jury will decide if you are tellling the truth. Chancellor, feel free to question the defendant.\n”;

              break;
case 2:
  std::cout << "You are executed for kidnapping the Princess. People generally take that pretty seriously. Maybe don't admit to that in your next life.\n\nGame Over\n";
   return 0;

case 3:
  std::cout << "\nJudge: Keeping silent won't help you. The Jury will decide your fate Chancellor, feel free to question the defendant.";
            break;

default:
std::cout << “\n\nYou did not enter a valid response.\n\n Game Over\n”;
return 0;
}

// Second choice for the player

int choice2;

std::cout << “Chancellor: Gladly! Witnesses say that you and the Princess had an altercation at the fair.\n Who caused the altercation?\n”;

for (int i = 0; choice2 != 1 && choice2 != 2 && choice2 !=3 && i < 3; i++){
std::cout << “What do you decide to say? (1-3)\n\n”;
std::cout << “1) I did.\n”;
std::cout << “2) She did.\n”;
std::cout << “3) It was an accident!\n\n”;
std::cin >> choice2;}

switch(choice2){

  case 1:
    std::cout << "\n\nChancellor: He admits to it! Ladies and gentlemen of the jury. This man is clearly guilty!\nThe crowed boos and jeers at you.\n";
    std::cout << "Judge: ORDER! ORDER IN THE COURT!";
      break;
  
  case 2:
    std::cout << "\n\nChancellor: I see, trying to push the blame on to the innocent princess! Ladies and gentlemen of the jury. This man is clearly guilty!\nThe crowed boos and jeers at you.\n";
      break;

    case 3:
      std::cout << "\nChancellor: An accident you say? Princess-napping is no accident!\n";
        break;
    
    default:
      std::cout << "\n\nYou did not enter a valid response.\n\n Game Over\n";
        return 0;
    }

// Player choice 3
int choice3;

std::cout << “\nChancellor: It is time for the verdict! Do you have any last words?\n\n”;
std::cout << playerName << “: I’m innocent! She asked me to show her around! Ask her yourself!\n\n”;
std::cout << choice2 <<“\n\n”;

 for(int i = 0; choice3 != 1 && choice3 != 2 && choice3 != 3 && i < 3; i++){

     std::cout << "1) Screw you all for framing me!\n";
     std::cout << "2) Please Princess, help me!\n";
     std::cout << "3) I have nothing more to say.\n\n";
     std::cin >> choice3; 
  }

  switch(choice3){
      case 1:
        std::cout << "The jury did not like that! You didn't buy yourself any sympathy points with that outburst.\n\n";
          break;

      case 2:
        std::cout << "The court was in such a frenzy that they hadn't listened the princess's story.\nShe now has a chance to explain that it was all her idea to run off together.\nYou breathe a sigh of relief.\n\n";
          break;

        case 3:
          std::cout << "The jury doesn't know what to make of this silence.\n\n";
            break;

        default:
          std::cout << "\n\nYou did not enter a valid response.\n\n Game Over\n";
            return 0;        
  }
   std::cout << "Judge: Members of the Jury. You have heard the testimony of " << playerName << " in this case of kidnapping the Princess.\nWhat is your verdict?\n\n";

Here is by Spiderman game lol

#include <iostream>

int main() {
  int answer1;
  int answer2;
  int answer3;

  int progress = true;
  int retry = 1;
  
  while (retry == 1) {
      std::cout << "Welcom to the story of the Amazing Spiderman!!!\n\n";
    
      std::cout << "A radioactive spider bites Peter - Y/N\n\n";
      std::cout << "1) Yes\n";
      std::cout << "2) No\n";
      std::cin >> answer1;
    
      std::cout << "Peter becomes a hero! - Y/N\n\n";
      std::cout << "1) Yes\n";
      std::cout << "2) No\n";
      std::cin >> answer2;
    
      std::cout << "Peter goes to Brookyn Bridge - Y/N\n\n";
      std::cout << "1) Yes\n";
      std::cout << "2) No\n";
      std::cin >> answer3;
    
      int ending = 100 * answer1 + 10 * answer2 + answer3;
      
      switch(ending) {
          case 111:
          std::cout << "Green Goblin kills Gwen\n";
          std::cout << "You got ending 1 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 112:
          std::cout << "Green Goblin kills Gwen & Peter\n";
          std::cout << "You got ending 2 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 121:
          std::cout << "Green Goblin kills Gwen\n";
          std::cout << "You got ending 3 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 122:
          std::cout << "Peter Saves Gwen and Green Goblin kills Peter\n";
          std::cout << "You got ending 4 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 211:
          std::cout << "Peter robs bankk Green Goblin kills Gwen\n";
          std::cout << "You got ending 5 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 212:
          std::cout << "Green Goblin kills Gwen & Peter kills Green Goblin\n";
          std::cout << "You got ending 6 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 221:
          std::cout << "Peter Saves Aunt May and Green Goblin kills Gwen\n";
          std::cout << "You got ending 7 of 8. Want to try again?\n";
          std::cout << "1) Yes\n";
          std::cout << "2) No\n";
          std::cin >> retry;
          break;
          case 222:
          std::cout << "Peter Saves Gwen and Green Goblin goes to jail\n";
          std::cout << "Congratulations; you got the perfect ending!!!\n";
          retry = 2;
          break;
      }
  }
return 0;
}