You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
971 B
C++
60 lines
971 B
C++
#include "hero.h"
|
|
|
|
Hero::Hero(coordinate position_x, coordinate position_y, int initial_charges) :
|
|
Entity(position_x, position_y),
|
|
hero_charges(initial_charges)
|
|
{}
|
|
|
|
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:
|
|
--pos_y; break;
|
|
case Direction::Down:
|
|
++pos_y; break;
|
|
case Direction::Left:
|
|
--pos_x; break;
|
|
case Direction::Right:
|
|
++pos_x; break;
|
|
case Direction::None:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void Hero::reachExit() noexcept
|
|
{
|
|
on_exit = true;
|
|
}
|
|
|
|
bool Hero::onExit() const noexcept
|
|
{
|
|
return on_exit;
|
|
}
|