This commit is contained in:
JMARyA 2024-05-06 08:24:23 +02:00
parent c6bcd9ca07
commit e50b51c829
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 44 additions and 71 deletions

View file

@ -11,12 +11,27 @@ use crate::{
/// in the real world. It may include attributes or properties that deviate from
/// the standard definition of the item. For example, different colors, sizes, or
/// configurations.
#[derive(Debug, Clone)]
pub struct Variant {
pub item: String,
pub variant: String,
pub amount: u64,
}
impl Variant {
pub fn from_yml(json: &serde_yaml::Value, variant: &str, item: &str) -> Self {
Self {
item: item.to_string(),
variant: variant.to_string(),
amount: json
.as_mapping()
.unwrap()
.get("amount")
.map(|x| x.as_u64().unwrap())
.unwrap_or(1),
}
}
pub async fn demand(&self, uuid: &str, price: Price, destination: String) -> Option<String> {
let db = get_mongo!();