#pragma once

#include <cstdint>
#include <vector>

#include "adapters/eft/items/wishlist/WishlistService.h"
#include "adapters/eft/world/WorldTypes.h"
#include "adapters/eft/runtime/EftGameContext.h"
#include "features/world/IWorldGateway.h"

namespace ta::adapters::eft::items
{
    class ItemTemplateCatalogService;
}

namespace ta::adapters::eft::world
{
class EftWorldGateway final : public ta::features::world::IWorldGateway
{
public:
    EftWorldGateway(ta::adapters::eft::runtime::EftGameContext& context,
                    ta::adapters::eft::items::WishlistService& wishlist_service,
                    ta::adapters::eft::items::ItemTemplateCatalogService& item_catalog_service);
    void game_tick(const ta::features::world::WorldSettings& settings,
                   std::vector<ta::features::world::WorldCommand> commands) override;

private:
    [[nodiscard]] ItemTeleportRequest build_teleport_request(
        const ta::features::world::WorldSettings& settings,
        const ta::features::world::WorldCommand& command) const;
    void execute(const ta::features::world::WorldSettings& settings,
                 const ta::features::world::WorldCommand& command,
                 const ta::adapters::eft::runtime::EftGameContextSnapshot& context);
    static void log_result(const WorldActionResult& result,
                           std::uint64_t trace_id,
                           const char* component);

    ta::adapters::eft::runtime::EftGameContext& context_;
    ta::adapters::eft::items::WishlistService& wishlist_service_;
    ta::adapters::eft::items::ItemTemplateCatalogService& item_catalog_service_;
};
}
