#include "tunnels_game_state.hpp"
#include "character_data.hpp"
#include "utils/godot_macros.h"
#include <godot_cpp/variant/array.hpp>

namespace godot {
void TunnelsGameState::_bind_methods() {
#define CLASSNAME TunnelsGameState
    GDPROPERTY_HINTED(weapons, Variant::ARRAY, PROPERTY_HINT_ARRAY_TYPE, GDRESOURCETYPE(WeaponData));
    GDPROPERTY_HINTED(characters, Variant::ARRAY, PROPERTY_HINT_ARRAY_TYPE, GDRESOURCETYPE(CharacterData));
}

void TunnelsGameState::set_weapons(Array weapons) {
    this->weapons.clear();
    for(size_t i = 0; i < weapons.size(); ++i)
        this->weapons.push_back(weapons[i]);
}

Array TunnelsGameState::get_weapons() const {
    Array array{};
    for(Ref<WeaponData> weapon : this->weapons)
        array.push_back(weapon);
    return array;
}

void TunnelsGameState::set_characters(Array characters) {
    this->characters.clear();
    for(size_t i = 0; i < characters.size(); ++i)
        this->characters.push_back(characters[i]);
}

Array TunnelsGameState::get_characters() const {
    Array array{};
    for(Ref<CharacterData> character : this->characters)
        array.push_back(character);
    return array;
}
}
