#include "adapters/config/PlayerConfigAdapter.h"

#include <utility>


namespace ta::adapters::config
{
    PlayerConfigAdapter::PlayerConfigAdapter()
        : ta::application::config::ConfigOwner("player", "Player", ta::application::config::ConfigCategory::Exploit)
    {
    }

    ta::features::player::PlayerSettings PlayerConfigAdapter::read() const
    {
        return {
            god_mode_->get_value(),
            infinite_stamina_->get_value(),
            no_hunger_thirst_->get_value(),
            instant_search_->get_value(),
            speed_hack_->get_value(),
            speed_hotkey_->get_value(),
            speed_->get_value(),
            fly_mode_->get_value(),
            fly_hotkey_->get_value(),
            up_->get_value(),
            down_->get_value(),
            always_survive_->get_value(),
            no_malfunction_->get_value(),
            infinite_ammo_->get_value()
        };
    }

    void PlayerConfigAdapter::set_speed_hack(const bool enabled)
    {
        static_cast<void>(speed_hack_->set_value(enabled));
    }

    void PlayerConfigAdapter::set_fly_mode(const bool enabled)
    {
        static_cast<void>(fly_mode_->set_value(enabled));
    }

    ta::features::player::PlayerCommand PlayerConfigAdapter::make_add_exp_command(const std::uint64_t trace_id) const
    {
        ta::features::player::PlayerCommand command;
        command.trace_id = trace_id;
        command.add_exp = true;
        command.exp_type = exp_type_->get_selected();
        command.exp_amount = exp_amount_->get_value();
        command.trace_action = "add exp";
        return command;
    }

    ta::features::player::PlayerCommand PlayerConfigAdapter::make_add_fence_rep_command(const std::uint64_t trace_id) const
    {
        ta::features::player::PlayerCommand command;
        command.trace_id = trace_id;
        command.add_fence_rep = true;
        command.fence_rep_amount = fence_rep_amount_->get_value();
        command.fence_rep_source = fence_rep_source_->get_value();
        command.trace_action = "add fence reputation";
        return command;
    }

    ta::features::player::PlayerCommand PlayerConfigAdapter::make_add_trader_rep_command(const std::uint64_t trace_id) const
    {
        ta::features::player::PlayerCommand command;
        command.trace_id = trace_id;
        command.add_trader_rep = true;
        command.trader_index = trader_select_->get_value();
        command.trader_name = trader_select_->get_selected();
        command.trader_rep_amount = trader_rep_amount_->get_value();
        command.trace_action = "add trader reputation";
        return command;
    }

    ta::features::player::PlayerCommand PlayerConfigAdapter::make_set_skill_command(const std::uint64_t trace_id) const
    {
        ta::features::player::PlayerCommand command;
        command.trace_id = trace_id;
        command.set_skill = true;
        command.skill_name = skill_select_->get_selected();
        command.skill_level = skill_level_->get_value();
        command.trace_action = "set skill";
        return command;
    }
}
