Files
splinter/client/src/components/Cards/Inventory.js
2022-03-29 13:36:37 -05:00

40 lines
924 B
JavaScript

import Card from "./Card";
export default class Inventory {
constructor(state) {
this.state = {
materials: {
acorns: state.acorns,
pineCones: state.pineCones,
walnuts: state.walnuts,
apples: state.apples,
twigs: state.twigs,
resin: state.resin
},
reservedCards: [],
cardsInInventory: []
};
}
sortCards() {
for (let card of this.cardsInInventory) {
// sorting algorithm of some kind
return card;
}
}
pickUpCard(card) {
if (!card instanceof Card) {
throw new Error("card is not card!");
}
this.state.cardsInInventory.push(card);
this.sortCards();
}
reserveCard(card) {
if (!this.state.materials.resin) {
return;
}
}
}