#ifndef INVENTORY_HPP
#define INVENTORY_HPP

#include "item.hpp"
#include "stats.hpp"
#include "utils/godot_macros.hpp"
#include <godot_cpp/classes/node.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/templates/pair.hpp>
#include <godot_cpp/templates/hash_map.hpp>

namespace gd = godot;
class Unit;

class Inventory : public gd::Node {
    GDCLASS(Inventory, gd::Node);
    static void _bind_methods();
public:
    virtual void _ready() override;
    Stats get_stats() const;
    Item const *get_capability_for(ItemCapability const &capability, gd::Object *target) const;
    void add_item(Item const *item, unsigned num);
    unsigned get_item_amount(Item const *item);
    bool has_item(Item const *item);

    void set_weapon(Item const *item);
    Item const *get_weapon() const;
    void set_armour(Item const *item);
    Item const *get_armour() const;
    void set_utility(Item const *item);
    Item const *get_utility() const;

    void set_weapon_id(int item_id);
    int get_weapon_id() const;
    void set_armour_id(int item_id);
    int get_armour_id() const;
    void set_utility_id(int item_id);
    int get_utility_id() const;
    void set_inventory_inspector(gd::Dictionary dict);
    gd::Dictionary get_inventory_inspector() const;
private:
    Item const *weapon{nullptr};
    Item const *utility{nullptr};
    Item const *armour{nullptr};
    Item const *helmet{nullptr};
    gd::HashMap<Item const *, unsigned> inventory{};

    Unit *parent_unit{nullptr};
};

#endif // !INVENTORY_HPP
