-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.cpp
More file actions
46 lines (40 loc) · 877 Bytes
/
Room.cpp
File metadata and controls
46 lines (40 loc) · 877 Bytes
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
#include "Room.h"
Room::Room(string description)
{
this->description = description;
}
void Room::setExits(Room *north, Room *east, Room *south, Room *west)
{
if (north != NULL)
exits["north"] = north;
if (east != NULL)
exits["east"] = east;
if (south != NULL)
exits["south"] = south;
if (west != NULL)
exits["west"] = west;
}
string Room::shortDescription()
{
return description;
}
string Room::longDescription()
{
return "You are in " + description + ".\n"+ exitString();
}
string Room::exitString()
{
string returnString = "Exits:";
for (map<string, Room*>::iterator i = exits.begin(); i != exits.end(); i++)
returnString += " " + i->first;
return returnString;
}
Room* Room::nextRoom(string direction)
{
map<string, Room*>::iterator next = exits.find(direction);
if (next == exits.end())
{
return NULL;
}
return next->second;
}