//
// Created by gigaw on 4/4/2023.
//

#ifndef FINALPROJECT_JAGGUARS_HEALTHCOMPONENT_H
#define FINALPROJECT_JAGGUARS_HEALTHCOMPONENT_H

#include "Component.hpp"
#include <string>

/**
 * A Component implementation to record health for a GameObject.
 */
class HealthComponent : public Component {
public:
    /**
     * Construct a new Health Component object
     * 
     * @param totalHealth the maximum the GameObject's health can be
     */
    HealthComponent(int totalHealth);

    /**
     * Destroy the Health Component object
     */
    ~HealthComponent();

    void Update(SDL_Event r, int frame, std::vector<std::string> broadcastList) override;

    void Render(SDL_Renderer *ren) override;

    void ShowComponentEditor(bool* showEditor) override;

    /**
     * Set the current health.
     * 
     * @param newHealth the new health value
     */
    void SetHealth(int newHealth);

    /**
     * Modify the health by the given value.
     * 
     * @param changeInHealth a modifier to the health value. Set it to a positive value for healing and a negative value for damaging
     */
    void UpdateHealth(int changeInHealth);

    const char* ComponentTypeName() override {return "Health Component";}

private:
    int m_totalHealth;
    int m_currentHealth;

};


#endif //FINALPROJECT_JAGGUARS_HEALTHCOMPONENT_H
