#pragma once #include "Types.h" #include "misc/Shapes.h" #include #include #include namespace td { namespace game { class Player; enum class TeamColor : std::int8_t { None = -1, Red, Blue }; class Spawn : public utils::shape::Rectangle { private: Direction m_Direction; public: Spawn() { setWidth(5); setHeight(5); } Direction getDirection() const { return m_Direction; } void setDirection(Direction direction) { m_Direction = direction; } }; class Team; class TeamCastle : public utils::shape::Rectangle { private: const Team* m_Team; float m_Life; public: 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 { private: std::vector m_Players; TeamColor m_Color; Spawn m_Spawn; TeamCastle m_TeamCastle; public: Team(TeamColor color); void addPlayer(Player* newPlayer); void removePlayer(const Player* player); TeamColor getColor() const; const Spawn& getSpawn() const { return m_Spawn; } Spawn& getSpawn() { return m_Spawn; } const TeamCastle& getCastle() const { return m_TeamCastle; } TeamCastle& getCastle() { return m_TeamCastle; } std::uint8_t getPlayerCount() const; }; typedef std::array TeamList; } // namespace game } // namespace td