aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/Actor.cpp
blob: 08911c58cce10f409cad221b930826c439b1dcc3 (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
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
#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;
    }
}

void Actor::store(Item &item)
{
    // TODO check if item is already in inventory
    _inventory.push_front(&item);
}

Item* Actor::drop()
{
    // TODO
    Item *item = _inventory.front();
    _inventory.pop_front();

    return item;
}

unsigned Actor::stat(Actor::Stat stat) const
{
    return _stats.at(stat);
}

unsigned Actor::skill(Actor::Skill skill) const
{
    // TODO
    // return _skills.at(skill);
    return 0;
}