Loop in a Text-Based RPG

So, I am working on my first RPG. Nothing fancy so far... I haven't developed a story or anything, just trying to get the gameplay hammered out. Anyway, I have a couple of NPCs and Items and I was wondering how I should program these interactive spots. I'm unsure whether I should loop the Room info or continue forward with if statements. With Items, I want to prevent the player trying to use the option to get the item again (after you pick up the item, the option is gone. Here are a couple examples of where I have the problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
else if(playerloc == 3)
        {
            cout << "There is a hooded figure in the corner. "
                 << "The person waves you over.\n";
            cout << "There are exits along the North and South walls.\n";
            cout << "1. Talk to the figure\n2. Go North\n3. Go South\n"
            cin >> userInput;
            
            if(userInput == 1)
            {
                cout << "There are hidden secrets in this dungeon.\nCome back to me when "
                     << "you have the dungeon key."
                     << " I will equip to face the Dungeon Lord\n"
                     /*More code for when the key is acquired.
                       Figure will tell you how to access the secret room*/
                       
            }
            else if(userInput == 2) playerloc = 2;
            else if(userInput == 3) playerloc = 4;
        }

What I want to do after the character interaction is complete is continue forward with the option to go south or east. I could return to the room menu, or continue by coding forward and allow the option to go east or south with more if-else-if chains... which would be the best approach?

In the next bit, I want to program the item to be picked up and then the treasure chest will be empty. What would be the best way to do this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  else if(playerloc == 5)
        {
            cout << "There is a treasure chest in the Northwest corner of this room.\n"
                 << "There are exits along the Southern and Eastern walls.\n";
            cout << "1. Inspect treasure chest\n"
                 << "2. Go East\n3. Go South\n";
            
            if(userInput == 1)
            {
                cout << "You carefully open the the treasure chest, peeking inside.\n";
                /*code for the item player finds goes here
                  after the item is found, ask to go east or south*/
            }
            else if(userInput == 2) playerloc = 4;
            else if(userInput == 3) playerloc = 6;
            
        }


Thank you!
I just skimmed your problem and don't really have a direct answer to your question.

However I did give design advise to someone on text adventure games in another thread. Maybe you might find it interesting.

http://www.cplusplus.com/forum/beginner/71141/#msg379639

But again... it may not answer your immediate question. If it doesn't, I apologize, but hopefully you will still find it useful.
Topic archived. No new replies allowed.