Basic inventory system working and can pick up items but needs to be reflected in the UI next.
This commit is contained in:
parent
d7353a02df
commit
135d9a128b
14 changed files with 212 additions and 48 deletions
31
inventory.hpp
Normal file
31
inventory.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include "lights.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <fmt/core.h>
|
||||
|
||||
|
||||
namespace components {
|
||||
using namespace nlohmann;
|
||||
using lighting::LightSource;
|
||||
|
||||
struct InventoryItem {
|
||||
int count;
|
||||
json data;
|
||||
};
|
||||
|
||||
struct Inventory {
|
||||
int gold;
|
||||
LightSource light;
|
||||
std::unordered_map<std::string, InventoryItem> items;
|
||||
|
||||
size_t count() { return items.size(); }
|
||||
|
||||
void add(InventoryItem item);
|
||||
|
||||
bool decrease(std::string id, int count);
|
||||
|
||||
InventoryItem& get(std::string id);
|
||||
|
||||
void remove_all(std::string id);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue