#ifndef RTS_ENTITY_HEALTH_HPP
#define RTS_ENTITY_HEALTH_HPP

#include <godot_cpp/classes/node.hpp>

namespace gd = godot;

class Unit;

class EntityHealth : public gd::Node {
    GDCLASS(EntityHealth, gd::Node);
    static void _bind_methods();
public:
    virtual void _enter_tree() override;
    void damaged_by(int amount, Unit *source);
    void healed_by(int amount, Unit *source);
    void heal_and_revive(int heal_amount, Unit *source);
private:
    void receive_wounds(int incoming_amount, Unit *source);
    void receive_injury(int incoming_amount, Unit *source);
    float get_wounds_damage_factor() const;
public:
    bool is_conscious() const;
    bool can_be_revived() const;
    bool can_be_healed() const;
    bool can_be_damaged() const;
    bool is_dead() const;
    void set_injury_max(int max_health);
    int get_injury_max() const;
    int get_injury_current() const;
    void set_wounds_max(int max_health);
    int get_wounds_max() const;
    int get_wounds_current() const;
private:
    // long term health
    int injury_max{10};
    int injury_current{0};
    // short term health
    int wounds_max{10};
    int wounds_current{0};
};

#endif // !RTS_ENTITY_HEALTH_HPP
