-
Notifications
You must be signed in to change notification settings - Fork 0
/
character.cc
52 lines (41 loc) · 1.04 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
#include "character.h"
#include "entity.h"
#include <string>
using namespace std;
Character::Character() : hp{0}, atk{0}, def{0} {}
Character::Character(int hp, int atk, int def, char symbol, string name) : Entity{symbol}, hp{hp}, atk{atk}, def{def}, name{name} {}
Character::Character(int hp, int atk, int def, char symbol, std::string name, std::string color) : Entity{symbol, color}, hp{hp}, atk{atk}, def{def}, name{name} {}
// Move the character by a
// Left: dx = -1, dy = 0
// Right: dx = 1, dy = 0
// Up: dx = 0, dy = -1
// Down: dx = 0, dy = 1
void Character::move(int dx, int dy) {
setX(getX()+dx);
setY(getY()+dy);
}
int Character::getHP() {
return hp;
}
int Character::getAtk() {
return atk;
}
int Character::getDef() {
return def;
}
string Character::getName() {
return name;
}
void Character::setHP(int newHP)
{
hp = newHP;
}
void Character::setDef(int newDef)
{
def = newDef;
}
void Character::setAtk(int newAtk)
{
atk = newAtk;
}
int Character::attack(std::shared_ptr<Character> defender) {return 0;}