i would like to have the ability to tell the player they cannot go that way if the exit does not exist the rooms are in a text file that is read in, i know i should use a if function but dont know where to put it, any help would be appreciated, if you need more or all of the code just say
void RoomsGame()
{
char choice;
int playerPos = 0;
initDungeon();
cout << "Choice : ";
cin >> choice;
choice = tolower(choice);
while (choice != 'q')
{
if ((choice == 'n') && (testRooms[playerPos].getNorth() != -1))
{
playerPos = testRooms[playerPos].getNorth();
}
else if ((choice == 'e') && (testRooms[playerPos].getEast() != -1))
{
playerPos = testRooms[playerPos].getEast();
}
else if ((choice == 's') && (testRooms[playerPos].getSouth() != -1))
{
playerPos = testRooms[playerPos].getSouth();
}
else if ((choice == 'w') && (testRooms[playerPos].getWest() != -1))
{
playerPos = testRooms[playerPos].getWest();
}
else if (choice == 'i')
{
inventory();
}
cout << "You Are Currently Standing in = " ;
cout << testRooms[playerPos].getDescription();
cout << endl;
cout<< "Where Do You Dare To Go Now ? : ";
cin >> choice;
choice = tolower(choice);
cout<<endl;
}
}
thanks in advance