aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/Actor.cpp
blob: 219488d2978cca9494f00698296df1d53c6c8476 (plain)
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
#include "Actor.hpp"

Actor::Actor(std::string _name, unsigned _maxHp, Type _type) :
    name(_name), maxHp(_maxHp), type(_type)
{}

Actor::~Actor()
{}

void Actor::damage(int amt)
{
    _hp -= amt;

    if (_hp < 0) {
        _hp = 0;
        _alive = false;
    }
}

void Actor::heal(int amt)
{
    _hp += amt;

    if (_hp > maxHp) {
        _hp = maxHp;
    }
}