1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#include "rpghead.h"
int state = 1;
void help();
void room1();
void roomdes1();
void roomdes2();
void room2();
int main()
{
cout<<"\nPlease do all typing in lowercase.\n\nYou wake up with no recollection of who you are. You sit up and look around.";
while(state != -1)
{
switch(state)
{
case 1:
roomdes1();
break;
case 2:
room1();
break;
case 3:
roomdes2();
break;
case 4:
room2();
break;
}
}
}
void roomdes1()
{
cout<<"\nThe room 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.\n";
state = 2;
}
void room1()
{
string action, door;
cout<<"\nWhat 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" && action != "describe room" && action != "leave room")
{
while(action != "help" && action != "open door" && action != "open chest" && action != "describe room")
{
cout<<"\nThat is not valid. What do you want to do?\n>";
getline(cin, action);
}
}
if(action == "open door")
{
door = "open";
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" && action != "describe room")
{
while(action != "help" && action != "open chest" && action != "describe room")
{
cout<<"\nThat is invalid. What do you want to do?\n>";
getline(cin, action);
}
}
}
if(action == "describe room")
{
roomdes1();
}
if(action == "help")
{
help();
}
if(action == "leave room")
{
if(door == "open")
{
cout<<"\nAs you leave, you feel compelled to turn around. When you do, you see a strange man with a red cloak and white beard saying something you can't understand. There is a sword at his feet. Before you can go to pick it up, he finishes and the door closes and disappears, leaving behind a stone wall. This seems vaguely familiar.You turn around and leave the room.\n";
}
state = 3;
}
if(action == "open chest")
{
cout<<"\nInside the chest you find:\n-50 gold\n-a rusty short sword\n-a backpack\nYou put the gold in the backpack and carry it on your back. You put the sword in your hand.\nSuddenly, a false door on the east wall is opened. It must have been triggered by the chest. What do you want to do?\n>";
getline(cin, action);
if(action != "describe room" && action != "leave room" && action != "help")
{
while(action != "describe room" && action != "leave room" && action != "help")
{
cout<<"\nThat is not valid. What do you want to do?\n>";
getline(cin, action);
}
}
if(action == "describe room")
{
roomdes1();
}
if(action == "help")
{
help();
}
if(action == "leave room")
{
state = 3;
if(door == "open")
{
cout<<"\nAs you leave, you feel compelled to turn around. When you do, you see a strange man with a red cloak and white beard saying something you can't understand. There is a sword at his feet. Before you can go to pick it up, he finishes and the door closes and disappears, leaving behind a stone wall. This seems vaguely familiar. You turn around and exit the room.\n";
}
}
}
}
void roomdes2()
{
cout<<"\nAs soon as you enter the door shuts behind you and seals magically.\n";
}
void help()
{
cout<<"\nCommands:\n-open door\n-leave room\n-open chest\n-loot [insert name of monster here]\n-equip [item name]\n-describe [object]\n";
}
|