I'll probably have more questions later on but I know I need some kind of loop to read in the particular things in the txt file, I just don't know how its supposed to look. For example, part of it is, " ROOM: Outside Marksbury ", there are other rooms as well and I think I need to put each of those in an array. I need to display the first one and every subsequent one that user goes as they arrive. In order to win you take the win items and drop them in the win room. True means that you can take the item
Here is part of the text file:
WIN_ROOM: 15
WIN_ITEM: burger
WIN_ITEM: fries
WIN_ITEM: bottle
WIN_TEXT: Joiner arrives, scarfs down the lunch, and pats you on your head, smiling. You win!
ROOM: Outside Marksbury
You are standing outside the Marksbury building at the east entrance. A glass doorway leads north inside the building, while the sidewalk leads east toward a parking lot.
ROOM_ITEM: true cell phone
Its your cell phone. There is a text from Joiner: GET ME SOME LUNCH! BURGER, FRIES, AND SOMETHING TO DRINK. DROP IT OFF IN MY OFFICE.
ROOM_ITEM: false flowers
Yellow buttercups are growing along the sidewalk, heralding the arrival of spring.
EXIT: 9 north
EXIT: 1 east
ROOM: small street
You are standing in a small street between the Marksbury building to the west and a parking lot to the east.
EXIT: 0 west
EXIT: 2 east
ROOM: parking lot
You are in a parking lot, with no spots available as usual. You see the Marksbury building further west, a small strip mall to the east, and Wildcat Lodge to the south.
ROOM_ITEM: false Wildcat Lodge
It is a small dorm for the royalty of UK, rumored to have gold toilet seats. There are no obvious entrances here.
EXIT: 1 west
EXIT: 3 east
ROOM: outside a strip mall
You are outside a strip mall with entrances to a few small shops. There is an entrance to one shop to the north, a parking lot to the west and the strip mall continues further east.
ROOM_ITEM: false shop
The sign says "Coliseum Liquors". You probably are too young to enter.
EXIT: 6 north
EXIT: 4 east
EXIT: 2 west
ROOM: outside a strip mall
You are outside a strip mall where the heavenly aroma of coffee and chocolate fills the air. There is an entrance to one shop to the north, while the strip mall continues east and west.
ROOM_ITEM: false shop
The sign says "Coffea", and the smells wafting out the door entice you to enter.
EXIT: 7 north
EXIT: 5 east
EXIT: 3 west
ROOM: outside a strip mall
You are at the end of a strip mall, outside the last shop. There is an entrance to the shop to the north, while the strip mall continues to the west.
ROOM_ITEM: false shop
The sign says Burger Fi. Maybe they have some deals on some grub today.
EXIT: 8 north
EXIT: 4 west
ROOM: Colesium Liquor
You are inside a liquor store. While most of the shelves are full of Devil Water, there are a few other things for sale here too.
ROOM_ITEM: true bottle
It's a bottle of gin. Who would want to drink fermented juniper berries? YUCK!
EXIT: 3 south
ROOM: Coffea
There are small tables and comfortable couches scattered around a coffee bar full of delightful drinks.
Here is part of the loop I was trying to build (ignore the command, I was copied and pasted from the loop that I used to build a loop of the functions needed):
int aGame::splitFirst(string aline, string & first, string & rest) {
first = rest = ""; // init results to empty string
if (aline == "") return 0; // if nothing to split, we're done
string next; // next word in aline
istringstream iss(aline); // converts aline into a input string stream
iss >> first; // extract the first word, if any
iss >> rest; // extract the second word, if any
if (rest == "") return 1; // if the second word is empty, only 1 word in aline
iss >> next; // extract the third word, if any
while (iss && next != "") { // while there are more words in the stream
rest = rest + " " + next; // stick it on the end of rest
iss >> next; // get the next word, if any
}
return 2; // aline was split into two parts.
} //This is split function
//This is part of a different function
string tag;
while (tag.compare("quit") != 0) {
else if (tag.compare("ROOM_ITEM:") == 0) {
f.ignore();
getline(f, aline);
splitFirst(aline, command, rest);
if (command == "ROOM_ITEM:") {
for(int i = 0; i < )
}
}
else if (tag.compare("EXIT:") == 0) {
f.ignore();
getline(f, aline);
splitFirst(aline, command, rest);
if (command == "EXIT:") {
exit[].
}
}
The first thing that is supposed to be displayed is:
Outside Marksbury
Exits: north, east.
==> // cout.
I'm not sure what the numbers before the exits are.
I figured out the solutions to parts of the loop.