4 * Created on: Aug 9, 2012
12 Inventory::Inventory() {
16 bool Inventory::Add(const Item *item, int count) {
17 if (count > 99) return false;
19 Entry *entry(FindItem(item));
21 if (entry->count + count > 99) {
24 entry->count += count;
28 for (int i(0); i < MaxItems(); ++i) {
30 entries[i].item = item;
31 entries[i].count = count;
39 void Inventory::Remove(const Item *item, int count) {
40 Entry *entry(FindItem(item));
43 if (entry->count <= count) {
47 entry->count -= count;
51 Inventory::Entry *Inventory::FindItem(const Item *item) {
52 for (int i(0); i < MaxItems(); ++i) {
53 if (item == ItemAt(i)) {
60 bool Inventory::SloteFree(int offset) const {
61 return !ItemAt(offset);