#pragma once

#include "Types.h"

#include "misc/Shapes.h"

#include <vector>
#include <memory>
#include <cmath>

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; }
};

struct TeamCastle : public utils::shape::Rectangle{
private:
    float m_Life;
public:
    TeamCastle() : m_Life(1000) {
        setWidth(5);
        setHeight(5);
    }

    float getLife() const { return m_Life; }

    void setLife(float life) { m_Life = life; }
    void damage(float damage) { m_Life = std::max(0.0f, m_Life - damage); }
};

class Team {
private:
    std::vector<Player*> 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;
};

} // namespace game
} // namespace td
