Yes you were very very helpful, can't thank you enough. This will keep me busy for quite some time before I have to overcome my next programming hurdle :)
I am going to attempt to take this example and do something a bit different.
In addition to my currentLocation i have a lastLocation, in this manner I want to present a different description if reaching location HOME from FARM for example. So my currentLocation is farm, and lastLocation is house, so something along the lines of
1 2 3 4
last current description
FARM HOUSE |You walk from the farm to the house|
HOUSE FARM |You walk from the house to the farm|
I feel like this will create a bit more depth to the game, instead of presenting the same message everytime you reach a location, it will present a different description if you approach from the south or north, hard part is coding it as always! lol.
void map::displayAreaDescription()
{
std::map<std::string, std::string> sentences;
std::ifstream load_description("game_text_files/story.txt");
while ( load_description.is_open() )
{
std::string line;
while ( std::getline(load_description, line) )
{
std::string location = std::string(line, 0, line.find_first_of(" "));
std::size_t first = line.find_first_of("|");
std::size_t second = line.find_first_of("|", first + 1);
std::string sentence = std::string(line, first + 1, (second - first) - 1);
sentences[location] = sentence;
}
load_description.close();
}
std::string which; //next 3 lines are new, and in my text-file I have HOMEFARM, shouldn't this work if my current location is HOME and last FARM?
which = currentLocation;
which = which + lastLocation;
if (sentences.find(which) != sentences.end())
{
std::cout << sentences[which];
}
}