omicron/src/inventory.c

30 lines
586 B
C

#include "inventory.h"
void Inventory_reset(Inventory *m) {
for(int i = 0; i < INVENTORY_COUNT_LEN; i++) {
m->count[i] = 0;
}
}
int Inventory_collect(Inventory *m, int w) {
if(m->count[w] < 255) { // Stack size ... What would be a better value? A twelve mutiple?
m->count[w]++;
return 1;
} else {
return 0;
}
}
int Inventory_use(Inventory *m, int w) {
if(m->count[w]) {
m->count[w]--;
return 1;
} else {
return 0;
}
}
uint8_t Inventory_getCount(Inventory *m, int w) {
return m->count[w];
}