35 lines
856 B
C++
35 lines
856 B
C++
#include "game/gameplay/inventory.hpp"
|
|
|
|
// [SINGLETON]
|
|
Inventory* Inventory::inventory = nullptr;
|
|
|
|
// [SINGLETON] Crearemos el objeto con esta función estática
|
|
void Inventory::init() {
|
|
Inventory::inventory = new Inventory();
|
|
}
|
|
|
|
// [SINGLETON] Destruiremos el objeto con esta función estática
|
|
void Inventory::destroy() {
|
|
delete Inventory::inventory;
|
|
}
|
|
|
|
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
|
auto Inventory::get() -> Inventory* {
|
|
return Inventory::inventory;
|
|
}
|
|
|
|
// Añade una llave al inventario
|
|
void Inventory::addKey(const std::string& key_id) {
|
|
keys_.insert(key_id);
|
|
}
|
|
|
|
// Comprueba si el inventario contiene una llave
|
|
auto Inventory::hasKey(const std::string& key_id) const -> bool {
|
|
return keys_.contains(key_id);
|
|
}
|
|
|
|
// Vacía el inventario
|
|
void Inventory::clear() {
|
|
keys_.clear();
|
|
}
|