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.

52 lines
853 B
C++

#include "hero.h"
Hero::Hero(int position_x, int position_y, int initial_charges) :
hero_charges(initial_charges),
pos_x(position_x),
pos_y(position_y)
{}
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::position(int &x, int &y) const noexcept
{
x = pos_x;
y = pos_y;
}
void Hero::move(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;
}
}