#pragma once

#include <optional>
#include <string>
#include <vector>

#include "adapters/il2cpp/Il2CppObjectInstance.h"
#include "adapters/eft/common/EftMongoId.h"

namespace ta::adapters::eft::quests
{
    struct QuestTaskConditionCounter
    {
        Il2CppObject* counter = nullptr;
        Il2CppObject* condition = nullptr;
        ta::adapters::eft::common::EftMongoId id{};
    };

    class QuestConditionInterop
    {
    public:
        static std::vector<QuestTaskConditionCounter> collect_counters(
            ta::adapters::il2cpp::Il2CppObjectInstance& quest,
            ta::adapters::il2cpp::Il2CppObjectInstance main_player);

        static std::string mongo_id_string(const ta::adapters::eft::common::EftMongoId& id);
        static bool same_mongo_id(const ta::adapters::eft::common::EftMongoId& left,
                                  const ta::adapters::eft::common::EftMongoId& right);
        static bool condition_id(Il2CppObject* condition, ta::adapters::eft::common::EftMongoId& id);

        static Il2CppObject* completed_conditions(ta::adapters::il2cpp::Il2CppObjectInstance& quest);
        static std::optional<bool> contains_completed(
            Il2CppObject* completed_set,
            const ta::adapters::eft::common::EftMongoId& condition_id);
        static std::optional<bool> add_completed(
            Il2CppObject* completed_set,
            const ta::adapters::eft::common::EftMongoId& condition_id);

        static std::optional<int> condition_target(Il2CppObject* condition);
        static std::optional<int> counter_value(Il2CppObject* counter);
        static bool set_counter_value(Il2CppObject* counter, int value);

        static std::string formatted_description(Il2CppObject* condition);
        static std::string condition_type(Il2CppObject* condition);
        static std::vector<Il2CppObject*> display_conditions(Il2CppObject* condition);
        static std::string primary_target_id(Il2CppObject* condition);
    };
}
