treballant en sistema de portes i claus

This commit is contained in:
2026-04-10 09:47:48 +02:00
parent 9aff4432df
commit 97c30bf9a1
37 changed files with 1236 additions and 110 deletions

View File

@@ -0,0 +1,34 @@
#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();
}