-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoom.cpp
More file actions
93 lines (82 loc) · 1.76 KB
/
Room.cpp
File metadata and controls
93 lines (82 loc) · 1.76 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
82
83
84
85
86
87
88
89
90
91
92
93
#include "Room.h"
Room::Room(){
description="Room without name";
for (int i=0; i<4; i++){
exits[i]=nullptr;
}
tieneLlave=false;
}
Room::Room(std::string desc, bool cerrado){
description=desc;
for (int i=0; i<4; i++){
exits[i]=nullptr;
}
tieneLlave=cerrado;
}
Room* Room::getExit(std::string dir){
int num=getMove(dir);
if(num>=0){
return exits[num];
}
return nullptr;
}
void Room::setexits(Room* n, Room* s, Room* e, Room* o){
exits[0]=n;
exits[1]=s;
exits[2]=e;
exits[3]=o;
}
std::string Room::getDescription(){
return description;
}
Item* Room::getItem(int num){
if (num>=0 && num<stuff.size()){
return stuff[num];
}
return nullptr;
}
bool Room::keyRequired(){
return tieneLlave;
}
void Room::addItem(Item* cosita){
stuff.push_back(cosita);
}
int Room::searchItem(std::string que){
for(int i=0; i<stuff.size();i++){
if(stuff[i]->getName()==que){
return i; //devuelve la posición donde está ese objeto
}
}
return -1; //regresa -1 si no encontró ese item
}
void Room::deleteItem(int pos){
stuff.erase(stuff.begin()+pos); //Borra el de la posicion pos del vector
}
void Room::longDescription(){
std::cout << description << std::endl;
std::cout << "Inside this room we have: " << std::endl;
for (int i=0; i<stuff.size(); i++){
std::cout << stuff[i]->getDescription() << std::endl;
}
}
int Room::getMove(std::string dir){
if (dir=="N"){
return 0;
}
if (dir=="S"){
return 1;
}
if (dir=="E"){
return 2;
}
if (dir=="W"){
return 3;
}
return -1;
}
NPC* Room::getNPC(){
return NPC1;
}
void Room::setNPC(NPC* _NPc){
NPC1 = _NPc;
}