fish_lib/models/item/
attributes.rs

1use crate::models::item::attributes::bait::BaitAttributes;
2use crate::models::item::attributes::purchasable::PurchasableAttributes;
3use crate::models::item::attributes::rod::RodAttributes;
4use serde::{Deserialize, Serialize};
5
6pub mod bait;
7pub mod purchasable;
8pub mod rod;
9
10#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
11pub enum ItemAttributesType {
12    Bait,
13    Purchasable,
14    Rod,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ItemAttributes {
20    Bait(BaitAttributes),
21    Purchasable(PurchasableAttributes),
22    Rod(RodAttributes),
23}
24
25impl ItemAttributes {
26    pub fn bait(level: u64) -> Self {
27        Self::Bait(BaitAttributes::new(level))
28    }
29
30    pub fn purchasable(cost: u32) -> Self {
31        Self::Purchasable(PurchasableAttributes::new(cost))
32    }
33
34    pub fn rod(level: u64) -> Self {
35        Self::Rod(RodAttributes::new(level))
36    }
37}