cirno-puzzle/hero.h

45 lines
882 B
C
Raw Normal View History

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