-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.cc
71 lines (54 loc) · 1.25 KB
/
player.cc
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
#include <cmath>
#include "player.h"
#include "potion.h"
#include "treasure.h"
Player::Player(int HP, int Atk, int Def):
Character{HP, Atk, Def}, maxHP{HP}, defaultAtk{Atk}, defaultDef{Def}{
type = Type::Plyr;
}
void Player::addTreasure(double t) {
treasure += t;
}
double Player::getTreasure() const {return treasure;}
void Player::setSuit(bool suit) {
hasSuit = suit;
}
void Player::setCompass(bool comp) {
hasCompass = comp;
}
bool Player::getSuit() const {
return hasSuit;
}
int Player::getDefaultAtk() const {
return defaultAtk;
}
int Player::getDefaultDef() const {
return defaultDef;
}
void Player::beAttacked(std::shared_ptr<Stuff> c) {
double damage = ceil((100 / (100 + static_cast<double>(this->getDef()))) * c->getAtk());
if (getSuit()) {
setHP(getHP() - ceil(damage / 2) <= 0 ? 0 : getHP() - ceil(damage / 2));
} else {
setHP(getHP() - damage <= 0 ? 0 : getHP() - damage);
}
}
void Player::setKilledMerch(bool has){
killedMerch = has;
}
bool Player::hasKilledMerch() const {
return killedMerch;
};
void Player::removePotion() {
setAtk(getDefaultAtk());
setDef(getDefaultDef());
}
char Player::getChar() const {
return '@';
}
std::string Player::getRace() const {
return race;
}
int Player::getMaxHP() const {
return maxHP;
}