-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtakeCommand.cpp
More file actions
26 lines (23 loc) · 885 Bytes
/
takeCommand.cpp
File metadata and controls
26 lines (23 loc) · 885 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
#include "takeCommand.h"
takeCommand::takeCommand(Character* _Player):Command("take", ""){
Player= _Player;
}
void takeCommand::execute(){
if (!promptExistance()){
std::cout<<"What you wanna do here?...\n" << "I can't help you if i don't have all the information..." << std::endl;
}
else{
std::string cosa = getprompt();
Room* actual= Player->getPosition();
int num=actual->searchItem(cosa); //veo si está en el cuarto (posicion dentro del vector)
if (num!=-1){
Item* paraJugador=actual->getItem(num);
Player->addItem(paraJugador);
actual->deleteItem(num);
std::cout << "Now you have the power: "<< std::endl;
std::cout << paraJugador->getName() << std::endl;
}else{
std::cout<< "This object is not in this room..."<<std::endl;
}
}
}