-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuseItem.cpp
More file actions
28 lines (26 loc) · 1.12 KB
/
useItem.cpp
File metadata and controls
28 lines (26 loc) · 1.12 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
#include "useItem.h"
useItem::useItem(Character* _Player):Command("useItem", ""){
Player = _Player;
}
void useItem::execute(){
if (!promptExistance()){
std::cout<< "¿What item you wanna use?,you have to specify with one you wnt to use" << std::endl;
}
else{
std::string cosa = getprompt();
Item* cosita = Player->getItem(cosa); //veo si está en el cuarto (posicion dentro del vector)
Player->deleteItem(cosa);
if (cosa == cosita->getName()){
if (cosa == "Starbucks"){
Player->setHealthC(Player->getHealth()+cosita->execute());
Player->setHealth(Player->getHealth()+cosita->execute());
std::cout << "The starbucks increased your health by " << std::to_string(cosita->execute()) << std::endl;
} else if (cosa == "pen"){
Player->setAttack(*Player + cosita);
std::cout << "The pen increased your damage by " << std::to_string(cosita->execute()) << std::endl;
}
} else {
std::cout<< "You don't have this item in your inventory" << std::endl;
}
}
}