feat: add castle tooltip

This commit is contained in:
2021-12-12 13:32:39 +01:00
parent 4611a198c9
commit 24617c539f
11 changed files with 133 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ class Spawn : public utils::shape::Rectangle {
private:
Direction m_Direction;
public:
Spawn(){
Spawn() {
setWidth(5);
setHeight(5);
}
@@ -33,19 +33,34 @@ public:
void setDirection(Direction direction) { m_Direction = direction; }
};
struct TeamCastle : public utils::shape::Rectangle{
class Team;
class TeamCastle : public utils::shape::Rectangle {
private:
const Team* m_Team;
float m_Life;
public:
TeamCastle() : m_Life(1000) {
static constexpr int CastleMaxLife = 1000;
TeamCastle(const Team* team) : m_Team(team), m_Life(CastleMaxLife) {
setWidth(5);
setHeight(5);
}
TeamCastle() : TeamCastle(nullptr) {}
float getLife() const { return m_Life; }
const Team* getTeam() const { return m_Team; }
void setTeam(const Team* team) { m_Team = team; }
void setLife(float life) { m_Life = life; }
void damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
void setShape(utils::shape::Rectangle rect) {
setCenter(rect.getCenter());
setSize(rect.getSize());
}
};
class Team {
@@ -71,5 +86,7 @@ public:
std::uint8_t getPlayerCount() const;
};
typedef std::array<Team, 2> TeamList;
} // namespace game
} // namespace td