diff --git a/Room.h b/Room.h new file mode 100644 index 0000000..9e70af1 --- /dev/null +++ b/Room.h @@ -0,0 +1,112 @@ +//code adapted from: https://www.youtube.com/watch?v=ajL1KjTch2A&t=7s and https://www.youtube.com/watch?v=ikA4yiurkug +#ifndef ROOM_H +#define ROOM_H + +#include +#include + +using namespace std; + +enum Direction { NORTH = 0, SOUTH = 1, EAST = 2, WEST = 3}; + +string GetPositionString(Direction direction) { + + if (direction == NORTH) { return "NORTH"; } + else if (direction == SOUTH) { return "SOUTH"; } + else if (direction == EAST) { return "EAST"; } + else if (direction == WEST) { return "WEST"; } + else { return "UNKNOWN"; } +} + + +struct Room { + + Room(); + Room(string r_name, string r_description); + void CloseRooms(string toNorthRoom, string toEastRoom, string toSouthRoom, string toWestRoom); + void Begin(string id = "", string name = "", string description = ""); + + void OutputRinfo(); + void OutputCloseRooms(); + bool CanMoveto(Direction direction); + string GetCloseRoomId(Direction direction); + string GetID(); + + string id; + string name; + string description; + string closeroomIds[4]; + + +}; + +Room::Room() { + + Begin(); + +}; + +Room::Room(string id, string name, string description) { + + Begin(id, name, description); + +}; + +void Room::Begin(string id /*= ""*/, string name/*= ""*/, string description/*= ""*/) { + + this->id = id; + this->name = name; + this->description = description; + + for (int i = 0; i < 4; i++) + { + closeroomIds[i] = "NULL"; + } + +}; + +void Room::CloseRooms(string toNorthRoom, string toEastRoom, string toSouthRoom, string toWestRoom) { + + closeroomIds[NORTH] = toNorthRoom; + closeroomIds[SOUTH] = toSouthRoom; + closeroomIds[EAST] = toEastRoom; + closeroomIds[WEST] = toWestRoom; + +}; + +void Room::OutputRinfo() { + + string userInput; + + cout<< "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl + << name << endl + << description << endl + <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" + << endl; + + OutputCloseRooms(); + cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl; + + cout << "What will you do?" << endl; + cout << "=>"; + + getline(cin, userInput); +} + +void Room::OutputCloseRooms() { + + cout << "\t You can go: "; + + for (int i = 0; i < 4; i++) + { + if (closeroomIds[i] != "NULL") + { + cout << GetPositionString(Direction(i)) << " "; + } + } + + cout << endl; +} + + +#endif