-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventory.h
61 lines (47 loc) · 1.62 KB
/
Inventory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef _INVENTORY_H
#define _INVENTORY_H
#include <vector>
class TypeSpec;
class Inventory
{
private:
// item primary type, quantity
std::map<unsigned int, unsigned int> m_Contents;
public:
Inventory(unsigned int id) {}
virtual ~Inventory() {}
bool has(unsigned int global_id) const {
return m_Contents.find(global_id) != m_Contents.end();
}
// adding directly does not follow rules
bool add(unsigned int type, unsigned int quantity = 1) {
if(m_Contents.find(type) == m_Contents.end())
return false;
m_Contents.push_back(type);
return true;
}
bool remove(unsigned int type) {
auto itr = m_Contents.find(type);
if(itr == m_Contents.end())
return false;
m_Contents.erase(itr);
return true;
}
bool anyOfType(const TypeSpec& type) const {
// TODO: quick pass to check for primary classes of items,
// then pass again for deep inspection
return false;
}
unsigned int numOfType(const TypeSpec& type) const {
// TODO: Do a deep type inspection for each contents entry
// and return all that match with type
return 0;
}
std::vector<unsigned int> getMatches(const TypeSpec& type) const {
// TODO: get a list of each object matching the type
// do deep inspection
return std::vector<unsigned int>();
}
bool empty() const { return m_Contents.empty(); }
};
#endif