Made checking nft value easier
This commit is contained in:
3 files changed
+24
-15
No files matched your search
+12
-8
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user