#ifndef ATTRIBUTE_COMPONENT_HPP_
#define ATTRIBUTE_COMPONENT_HPP_

#include <Entity/PhysicsEntity/CameraEntity/Player/Player.hpp>
#include <MachineComponent/MachineComponent.hpp>
#include <Serialize/Utils.hpp>
#include <cstdint>
#include <string>
#include <unordered_map>

/**
 * @brief Component which tracks what machine actions should be attributed to which players.
 */
class AttributionComponent final : public MachineComponent
{
private:
    std::unordered_map<std::string, std::string> attribTable;

public:
    static std::string tagName;

    AttributionComponent(Machine &machine);

    /**
     * @brief Attribute an action to a player.
     */
    void attribute(const std::string &action, Player &player);

    /**
     * @brief Grant an achievement for the player that performed the specified action.
     */
    void grantAchievementFor(const std::string &action, const std::string &milestoneId, int achievementId);

    virtual void serializeState(std::vector<uint8_t> &outBytes) override;
    virtual void deserializeState(const uint8_t *bytes, size_t size) override;
};

#endif