variants
This commit is contained in:
parent
c6bcd9ca07
commit
e50b51c829
6 changed files with 44 additions and 71 deletions
|
@ -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!();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue