-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.cpp
96 lines (75 loc) · 1.47 KB
/
room.cpp
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
#include "room.hpp"
Room::Room(std::string newName, std::string newDescription, Enemy* newEnemy, Item* newItem) {
name = newName;
description = newDescription;
if(newItem != nullptr)
{
itemList.push_back(newItem);
}
else{
delete newItem;
}
if(newEnemy != nullptr)
{
enemyList.push_back(newEnemy);
}
else{
delete newEnemy;
}
visited = false;
}
void Room::setNorth(Room * northRoom) {
north = northRoom;
}
void Room::setSouth(Room * southRoom) {
south = southRoom;
}
void Room::setEast(Room * eastRoom) {
east = eastRoom;
}
void Room::setWest(Room * westRoom) {
west = westRoom;
}
std::string Room::getDescription() {
return description;
}
Room* Room::getNorth() {
return north;
}
Room* Room::getSouth() {
return south;
}
Room* Room::getEast() {
return east;
}
Room* Room::getWest() {
return west;
}
std::string Room::getName() {
return name;
}
bool Room::hasEnemies() {
return !enemyList.empty();
}
bool Room::hasItems() {
return !itemList.empty();
}
Enemy* Room::getEnemy() {
return enemyList[0];
}
Item* Room::getItem() {
return itemList[0];
}
void Room::killEnemy(Enemy* enemyToDie){
std::cout<<enemyToDie->getName()<<" has fallen! \n";
enemyList.erase(enemyList.begin());
}
bool Room::beenVisited() {
return visited;
}
void Room::setVisited() {
visited = true;
}
void Room::removeItem() {
itemList.erase(itemList.begin());
}