SNAPKITTYWEST's picture
chore: push full sov-kernel-monster content from local build
9425aed verified
Raw
History Blame Contribute Delete
761 Bytes
export class Inventory {
constructor(store) {
this.store = store;
}
collect(item, entityId) {
if (this.store.state.inventory.order.length >= this.store.state.inventory.capacity) return false;
if (this.store.state.inventory.byId[item.id]) return false;
this.store.dispatch("DOCUMENT_COLLECTED", { item: structuredClone(item) }, { entityId });
return true;
}
verify(itemId) {
const item = this.store.state.inventory.byId[itemId];
if (!item || item.verified) return false;
this.store.dispatch("DOCUMENT_VERIFIED", { itemId }, { entityId: itemId });
return true;
}
list() {
const inventory = this.store.state.inventory;
return inventory.order.map(id => inventory.byId[id]);
}
}