-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroom.cpp
More file actions
81 lines (69 loc) · 1.46 KB
/
Copy pathroom.cpp
File metadata and controls
81 lines (69 loc) · 1.46 KB
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
#include "room.h"
#include "enemy.h"
#include "game.h"
#include <algorithm>
Room::Room(string name) :
name(name)
{
exits["north"] = nullptr;
exits["east"] = nullptr;
exits["south"] = nullptr;
exits["west"] = nullptr;
}
string Room::getName()
{
return name;
}
void Room::setExits(Room* north, Room* east, Room* south, Room* west)
{
exits["north"] = north;
exits["east"] = east;
exits["south"] = south;
exits["west"] = west;
}
Room* Room::getExit(string direction)
{
return exits[direction];
}
void Room::setItem(Item* inItem)
{
itemsInRoom.push_back(inItem);
}
bool Room::isItemHere()
{
if (this->itemsInRoom.size() > 0) {
return true;
}
else
{
return false;
}
}
string Room::displayItem() {
string temp;
if (itemsInRoom.size() > 0) {
temp = itemsInRoom[0]->getShortDescription();
}
return temp;
}
void Room::addEnemy(Enemy* inEnemy)
{
enemiesInRoom.push_back(inEnemy);
}
bool Room::isEnemyHere()
{
if (enemiesInRoom.size() > 0) {
return true;
}
else
{
return false;
}
}
string Room::displayEnemy() {
string temp = "Enemy Spotted! \nEnemies present = ";
if (enemiesInRoom.size() > 0) {
temp = temp + enemiesInRoom[0]->getName() + "\n" + "Enemy Health: " + to_string(enemiesInRoom[0]->getHealth());
}
return temp;
}