-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.cpp
More file actions
63 lines (48 loc) · 1.77 KB
/
Entity.cpp
File metadata and controls
63 lines (48 loc) · 1.77 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
#include "Entity.h"
Entity::~Entity() = default;
Entity& Entity::operator+=(int num) {
if (num >= 0) {
this->currentAmountOfLife += num;
}
//to make sure the current amount of life don't increase more than the maximum level
if (this->currentAmountOfLife >= this->maxAmountOfLife) {
this->currentAmountOfLife = this->maxAmountOfLife;
}
return *this;
}
Entity& Entity::operator-=(int num) {
this->attackValue -= num;
return *this;
}
Monster & Entity::MonsterAttackPlayer(Player &player) {
}
Player & Entity::PlayerAttackMonster(Monster &monster) {
}
Entity& Entity::operator=(const Entity& other) {
if (this == &other)
return *this;
this->name = other.name;
this->currentAmountOfLife = other.currentAmountOfLife;
this->maxAmountOfLife = other.maxAmountOfLife;
this->attackValue = other.attackValue;
return *this;
}
int Entity::getCurrentAmountOfLife() const {
return this->currentAmountOfLife;
}
int Entity::getAttackValue() const {
return this->attackValue;
}
bool Entity::operator==(const Entity& other) const {
return this->attackValue * this->currentAmountOfLife == other.attackValue * other.currentAmountOfLife;
}
bool Entity::operator>(const Entity &other) const {
return this->attackValue * this->currentAmountOfLife > other.attackValue * other.currentAmountOfLife;
}
bool Entity::operator<(const Entity &other) const {
return this->attackValue * this->currentAmountOfLife < other.attackValue * other.currentAmountOfLife;
}
ostream& operator<<(ostream& os, const Entity& other) {
os << other.name << " (" << other.currentAmountOfLife << "/" << other.maxAmountOfLife << ")" << " - " << other.attackValue;
return os;
}