Made checking nft value easier

This commit is contained in:
joeyahines committed 2024-03-31 12:35:20 -06:00
1 parent 93975f463c
commit 747aa81d62
3 files changed
+24 -15

No files matched your search

+12 -8
View File
@@ -108,6 +108,17 @@ impl Display for ItemType {
}
}
pub fn nft_value(s: &String) -> i64 {
let mut hasher = DefaultHasher::new();
s.hash(&mut hasher);
let hash = hasher.finish();
let per_value = (hash as f64) / (u64::MAX as f64);
((2000.0 * per_value) as i64) - 500
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InventorySlot {
pub quantity: i64,
@@ -132,14 +143,7 @@ impl InventorySlot {
match self.item_type {
ItemType::Nft => {
if let Some(ItemData::Nft(s)) = &self.item_data {
let mut hasher = DefaultHasher::new();
s.hash(&mut hasher);
let hash = hasher.finish();
let per_value = (hash as f64) / (u64::MAX as f64);
((2000.0 * per_value) as i64) - 500
nft_value(s)
} else {
0
}