-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cpp
67 lines (58 loc) · 1.9 KB
/
Player.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
#include "Player.h"
Player::Player(){}
Player::Player(string name,int currentHealth,int attack,int defense,int crystal):GameCharacter(name,"Player",currentHealth,attack,defense){
this->crystal = crystal;
}
void Player::addItem(Item item){
inventory.push_back(item);
}
void Player::increaseStates(int health,int attack,int defense){
setCurrentHealth(getCurrentHealth() + health);
setAttack(getAttack() + attack);
setDefense(getDefense() + defense);
}
void Player::changeRoom(Room* changeRoom){
setPreviousRoom(getCurrentRoom());
setCurrentRoom(changeRoom);
}
void Player::setCurrentRoom(Room* currentRoom){
this->currentRoom = currentRoom;
}
void Player::setPreviousRoom(Room* previousRoom){
this->previousRoom = previousRoom;
}
void Player::setInventory(vector<Item> inventory){
for(int i=0;i<inventory.size();i++){
this->inventory.push_back(inventory[i]);
}
}
//crystal
void Player::setCrystal(int crystal){
this->crystal = crystal;
}
int Player::getCrystal(){
return this->crystal;
}
Room* Player::getCurrentRoom(){
return this->currentRoom;
}
Room* Player::getPreviousRoom(){
return this->previousRoom;
}
vector<Item> Player::getInventory(){
return this->inventory;
}
void Player::triggerEvent(Object* player,Object* player2){
cout << "Status: " << endl;
cout << "[" << player->getName() << "]" << endl;
Player* playerr = dynamic_cast<Player*>(player);
cout << "Health: " << playerr->getCurrentHealth() << "/" << playerr->getMaxHealth() << endl;
cout << "Attack: " << playerr->getAttack() << endl;
cout << "Defense: " << playerr->getDefense() << endl;
cout << "Crystal: " << playerr->getCrystal() << endl;
cout << "Inventory: ";
for(int i=0;i<inventory.size();i++){
cout << playerr->getInventory()[i].getName() << ", ";
}
cout << endl;
}