-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter.cc
90 lines (74 loc) · 1.18 KB
/
Character.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "Character.h"
#include <string>
#include <iostream>
using namespace std;
Character::Character(int row, int col, char symbol, std::string type, int hp, int atk, int def) : Unit(row, col, symbol, type)
{
this->hp = hp;
this->atk = atk;
this->def = def;
isDead = false;
}
void Character::setIsDead(bool isDead)
{
this->isDead = isDead;
}
void Character::setHp(int hp)
{
this->hp = hp;
}
void Character::setAtk(int atk) {
this->atk = atk;
}
void Character::setDef(int def) {
this->def = def;
}
int Character::getHp()
{
return hp;
}
int Character::getAtk()
{
return atk;
}
int Character::getDef()
{
return def;
}
bool Character::getIsDead()
{
return isDead;
}
void Character::takeDamage(int damage) {
updateHp(-damage);
}
void Character::updateHp(int hp)
{
this->hp += hp;
if(this->hp <= 0)
{
dies();
}
}
void Character::updateAtk(int atk)
{
if(this->atk + atk < 0)
{
this->atk = 0;
}
else
{
this->atk += atk;
}
}
void Character::updateDef(int def)
{
if(this->def + def < 0)
{
this->def = 0;
}
else
{
this->def += def;
}
}