2020-02-19 18:50:09 +01:00
|
|
|
#ifndef HERO_H
|
|
|
|
#define HERO_H
|
|
|
|
|
2020-02-20 19:34:41 +01:00
|
|
|
enum class Direction
|
|
|
|
{
|
2020-02-21 15:13:12 +01:00
|
|
|
Left,
|
|
|
|
Up,
|
|
|
|
Right,
|
|
|
|
Down,
|
|
|
|
None
|
2020-02-20 19:34:41 +01:00
|
|
|
};
|
|
|
|
|
2020-02-21 15:13:12 +01:00
|
|
|
using coordinate = unsigned int;
|
|
|
|
|
2020-02-20 19:34:41 +01:00
|
|
|
/// Represents a controlable by player game character
|
2020-02-19 18:50:09 +01:00
|
|
|
class Hero
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int hero_charges;
|
2020-02-21 15:13:12 +01:00
|
|
|
coordinate pos_x, pos_y;
|
2020-02-19 18:50:09 +01:00
|
|
|
|
|
|
|
public:
|
2020-02-21 15:13:12 +01:00
|
|
|
explicit Hero(coordinate position_x = 0, coordinate position_y = 0, int initial_charges = 0);
|
2020-02-20 19:34:41 +01:00
|
|
|
|
|
|
|
/// Add more charges for hero to use
|
|
|
|
void refillCharges(int append_charges);
|
|
|
|
|
|
|
|
/// Get amount of charges
|
|
|
|
int charges() const noexcept;
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-02-20 19:34:41 +01:00
|
|
|
/// Spend one charge on action
|
|
|
|
bool useCharge();
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-02-20 19:34:41 +01:00
|
|
|
/// Get current Hero position
|
2020-02-21 15:13:12 +01:00
|
|
|
void position(coordinate &x, coordinate &y) const noexcept;
|
|
|
|
|
|
|
|
/// Set Hero position explicitly
|
|
|
|
void setPosition(coordinate x, coordinate y);
|
2020-02-19 18:50:09 +01:00
|
|
|
|
2020-02-20 19:34:41 +01:00
|
|
|
/// Move hero by one cell to any direction
|
2020-02-21 15:13:12 +01:00
|
|
|
void move(const Direction &direction);
|
2020-02-19 18:50:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HERO_H
|