#include "hero.h"

Hero::Hero(coordinate row, coordinate col, int initial_charges) :
    Entity(row, col),
    hero_charges(initial_charges),
    on_exit(false)
{}

void Hero::refillCharges(int append_charges)
{
    hero_charges += append_charges;
}

int Hero::charges() const noexcept
{
    return hero_charges;
}

bool Hero::useCharge()
{
    if (hero_charges > 0)
    {
        --hero_charges;
        return true;
    }

    return false;
}

void Hero::setCharges(int charges) noexcept
{
    hero_charges = charges;
}

void Hero::move(const Direction &direction)
{
    switch (direction)
    {
    case Direction::Up:
        --entity_row; break;
    case Direction::Down:
        ++entity_row; break;
    case Direction::Left:
        --entity_col; break;
    case Direction::Right:
        ++entity_col; break;
    case Direction::None:
        break;
    }
}

void Hero::reachExit() noexcept
{
    on_exit = true;
}

bool Hero::onExit() const noexcept
{
    return on_exit;
}
