This commit is contained in:
JMARyA 2024-09-12 10:58:49 +02:00
parent a8dfe5f0e9
commit 37475460e2
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 93 additions and 2 deletions

View file

@ -239,6 +239,18 @@ impl Variant {
.clone()
}
/// Check if item variant is below minimum. Returns if this is the case and the number needed to fulfill minimum
pub async fn is_below_min(&self) -> (bool, i64) {
if let Some(min) = self.min {
let amount = self.inventory().await.len() as i64;
if amount < min {
return (true, min - amount);
}
}
(false, 0)
}
pub async fn stat(&self) -> serde_json::Value {
let active_transactions = self.inventory().await;