My header is a collection of all neccesary headers and using namespace std;
When I run this, it always says that my command is invalid no matter what I write.
#include "rpghead.h"
int state = 1;
void help();
void room1();
int main()
{
cout<<"\nPlease do all typing in lowercase.\n";
while(state != -1)
{
switch(state)
{
case 1:
room1();
break;
}
}
}
void room1()
{
string action;
cout<<"\nYou wake up with no recollection of who you are. You sit up and look around. It apears to be a small, square room about 20 ft. by 20 ft. by 20 ft. Besides the thin cot you are sleeping on, there is a round, wooden table and a chest at the foot of the cot. There is a door on the west wall. There are no windows. The four walls are made completely out of stone. What do you want to do (type \"help\" for a list of commands)?\n>";
getline(cin, action);
if(action != "help" || action != "open door" || action != "open chest")
{
while(action != "help" || action != "open door" || action != "open chest")
{
cout<<"\nThat is not valid. What do you want to do?\n>";
getline(cin, action);
}
}
if(action == "help")
{
help();
}
if(action == "open door")
{
cout<<"\nYou open it and find yourself staring at a brick wall. There must be another way out. What do you want to do?\n>";
getline(cin, action);
if(action != "help" || action != " open chest")
{
while(action != "help" || action != " open chest")
{
cout<<"\nThat is invalid. What do you want to do?\n>";
getline(cin, action);
}
}
}
if(action == "help")
{
help();
}
if(action == "open chest")
{
cout<<"\nInside the chest you find:\n-50 gold\n-a rusty short sword\n-a backpack\n\nSuddenly, a false door on the east wall is opened. An orc with what appears to be an axe in his hand, steps into the room with an intent to kill you.";
}
}
void help()
{
cout<<"\nCommands:\n-open door\n-open chest\n";
return;
}
Can you think of ANY value for action, for which this comes out as false? No, you can't, because there isn't one. This will ALWAYS come out as true. I suspect you meant to say
so i fixed that and now it says "invalid operands to binary expression ('bool' and 'string' (aka 'basic_string<char>))" Im not even going to pretend like i no what that means