20 lines
454 B
JavaScript
20 lines
454 B
JavaScript
class EquipmentLimiter {
|
|
constructor(info) {
|
|
this.quantity = {
|
|
current: 0,
|
|
maximum: info.maximum
|
|
};
|
|
};
|
|
|
|
count(quantity) {
|
|
|
|
if (!quantity) return false;
|
|
if (this.quantity.current + quantity > this.quantity.maximum || this.quantity.current + quantity < 0) return false;
|
|
|
|
this.quantity.current += quantity;
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
module.exports = EquipmentLimiter; |