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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
using namespace std;
enum en_DIRS {NORTH, EAST, SOUTH, WEST};
enum en_ROOMS {EASTSTREET, WESTSTREET, FRONTYARD_1, FRONTYARD_2, FRONTYARD_3, FRONTYARD_4,
LIVINGROOM_1,LIVINGROOM_2,LIVINGROOM_3,LIVINGROOM_4, KITCHEN_1, KITCHEN_2, KITCHEN_3,
KITCHEN_4, HALLWAY_1, HALLWAY_2, HALLWAY_3, HALLWAY_4, RESTROOM_1, RESTROOM_2,
RESTROOM_3, RESTROOM_4, BEDROOM_1, BEDROOM_2, BEDROOM_3, BEDROOM_4, BEDROOM_5,
BEDROOM_6, BEDROOM_7, BEDROOM_8, HOUSE_1, HOUSE_2, HOUSE_3, HOUSE_4};
enum en_VERBS {GET, DROP, USE, OPEN, CLOSE, EXAMINE, INVENTORY, LOOK, YELL, SIT}; //2 more verbs
enum en_NOUNS {FRIDGE, CHAIR, TABLE, DOOR, MAILBOX, PIZZA, GARBAGECAN, WOMAN, MAN, KID, BIKE, CAR,BAT, NEWSPAPER, LAWNMOWER}; //make 15+ nouns
// New nouns = FRIDGE, CHAIR, TABLE, DOOR, MAILBOX, PIZZA, GARBAGECAN, WOMAN, MAN, KID, BIKE, CAR,
// BAT, NEWSPAPER, LAWNMOWER
const int NONE= -1;
const int DIRS = 4;
const int ROOMS = 11; // make 30 rooms
const int VERBS = 8; // make 2 more verbs with appropriate actions
const int NOUNS = 6;
class Words
{
public:
Words();
string word;
int code;
};
Words::Words()
{
}
class Room
{
public:
Room();
Room(string desc, int exitNORTH, int exitEAST, int exitSOUTH, int exitWEST);
string description;
int exits_to_room [DIRS];
};
Room::Room()
{
}
Room::Room(string desc, int exitNORTH, int exitEAST, int exitSOUTH, int exitWEST)
{
description = desc;
exits_to_room[NORTH] = exitNORTH;
exits_to_room[EAST] = exitEAST;
exits_to_room[SOUTH] = exitSOUTH;
exits_to_room[WEST] = exitWEST;
}
class Noun
{
public:
Noun();
string word;
string description;
int code;
int location;
bool can_carry;
};
Noun::Noun()
{
}
//-------------------------------------------------------------------
void set_rooms (vector<Room> &rms)
{
rms.push_back(Room("We're in the street", FRONTYARD_1, EASTSTREET, FRONTYARD_2, NONE));
rms.push_back(Room("We're in the street", FRONTYARD_3, NONE, FRONTYARD_4, WESTSTREET));
rms.push_back(Room("The front yard", HOUSE_1, FRONTYARD_3, WESTSTREET, NONE));
rms.push_back(Room("The Front yard", WESTSTREET, FRONTYARD_4, HOUSE_3, NONE));
rms.push_back(Room("The Front yard", HOUSE_3, NONE, EASTSTREET, FRONTYARD_1));
rms.push_back(Room("The Front yard", EASTSTREET, NONE, HOUSE_4, FRONTYARD_2));
rms.push_back(Room("The living room", KITCHEN_1, NONE, HOUSE_1, BEDROOM_2));
rms.push_back(Room("The living room", HOUSE_2, NONE, KITCHEN_2, BEDROOM_3));
rms.push_back(Room("The living room", KITCHEN_3, NONE, HOUSE_3, BEDROOM_6));
rms.push_back(Room("The living room", HOUSE_4, NONE, KITCHEN_4, BEDROOM_7));
rms.push_back(Room("The kitchen", NONE, NONE, LIVINGROOM_1, BEDROOM_1));
rms.push_back(Room("The kitchen", LIVINGROOM_2, NONE, NONE, BEDROOM_4));
rms.push_back(Room("The kitchen", NONE, NONE, LIVINGROOM_3, BEDROOM_5));
rms.push_back(Room("The kitchen", LIVINGROOM_4, NONE, NONE, BEDROOM_8));
rms.push_back(Room("The hallway", NONE, NONE, NONE, NONE));
rms.push_back(Room("The hallway", NONE, NONE, NONE, NONE));
rms.push_back(Room("The hallway", NONE, NONE, NONE, NONE));
rms.push_back(Room("The hallway", NONE, NONE, NONE, NONE));
rms.push_back(Room("The restroom", NONE, NONE, NONE, NONE));
rms.push_back(Room("The restroom", NONE, NONE, NONE, NONE));
rms.push_back(Room("The restroom", NONE, NONE, NONE, NONE));
rms.push_back(Room("The restroom", NONE, NONE, NONE, NONE));
rms.push_back(Room("The restroom", NONE, NONE, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, KITCHEN_1, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, LIVINGROOM_1, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, LIVINGROOM_2, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, KITCHEN_2, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, KITCHEN_3, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, LIVINGROOM_3, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, LIVINGROOM_4, NONE, NONE));
rms.push_back(Room("The bedroom", NONE, KITCHEN_4, NONE, NONE));
rms.push_back(Room("Welcome to our house", LIVINGROOM_1, NONE, FRONTYARD_1, NONE));
rms.push_back(Room("Welcome to our house", FRONTYARD_2, NONE, LIVINGROOM_2, NONE));
rms.push_back(Room("Welcome to our house", LIVINGROOM_3, NONE, FRONTYARD_3, NONE));
rms.push_back(Room("Welcome to our house", FRONTYARD_4, NONE, LIVINGROOM_4, NONE));
}
//--------------------------------------------------------------------------------
void set_directions(vector<Words> &dir)
{
dir [NORTH].code = NORTH;
dir [NORTH].word = "NORTH";
dir [EAST].code = EAST;
dir [EAST].word ="EAST";
dir [SOUTH].code = SOUTH;
dir [SOUTH].word ="SOUTH";
dir [WEST].code = WEST;
dir [WEST].word = "WEST";
}
//------------------------------------------------------------------------------------
void set_verbs(vector<Words> &vbs)
{
//enum en_VERBS {GET, DROB, USE, OPEN, CLOSE, EXAMINE, INVENTORY, LOOK};
vbs[GET].code = GET;
vbs[GET].word = "GET";
vbs[DROP].code = DROP;
vbs[DROP].word = "DROP";
vbs[USE].code = USE;
vbs[USE].word ="USE";
vbs[OPEN].code = OPEN;
vbs[OPEN].word ="OPEN";
vbs[CLOSE].code = CLOSE;
vbs[CLOSE].word ="CLOSE";
vbs[EXAMINE].code= EXAMINE;
vbs[EXAMINE].word= "EXAMINE";
vbs[INVENTORY].code = INVENTORY;
vbs[INVENTORY].word ="INVENTORY";
vbs[LOOK].code = LOOK;
vbs[LOOK].word = "LOOK";
vbs[YELL].code = YELL;
vbs[YELL].word = "YELL";
vbs[SIT].code = SIT;
vbs[SIT].word = "SIT";
}
//--------------------------------------------------------------------------------------
|