-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractiveobject.cpp
More file actions
68 lines (51 loc) · 1.18 KB
/
Copy pathinteractiveobject.cpp
File metadata and controls
68 lines (51 loc) · 1.18 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
64
65
66
67
#include "interactiveobject.h"
namespace SSJServer {
InteractiveObject::InteractiveObject() : Object()
{
this->maxHP = 100;
this->hp = 100;
}
void InteractiveObject::setHP(size_t hp)
{
if(this->maxHP <= hp && hp >= 0)
this->hp = hp;
}
void InteractiveObject::setMaxHP(size_t hp)
{
this->maxHP = hp;
}
void InteractiveObject::addHP(size_t hp)
{
if(this->maxHP <= this->hp+hp && this->hp+hp >= 0)
this->hp += hp;
}
void InteractiveObject::subHP(size_t hp)
{
if(this->maxHP <= this->hp-hp && this->hp-hp >= 0)
this->hp -= hp;
}
size_t InteractiveObject::getHP()
{
return this->hp;
}
size_t InteractiveObject::getMaxHP()
{
return this->maxHP;
}
void InteractiveObject::decreaseHp(int value)
{
this->hp -= value;
if(this->hp < 0)
this->hp = 0;
}
bool InteractiveObject::isDead(){
if(this->hp <= 0)
return true;
else
return false;
}
Json::Value InteractiveObject::serialize()
{
return Json::nullValue;
}
}