aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/Actor.cpp
blob: a6dc59709186b3f8c1dda1b1b590826740159dee (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) :
    name(_name), maxHp(_maxHp)
{}

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;
    }
}