mons_rust/models/
item.rs

1use crate::*;
2
3#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
4pub enum Item {
5    Mon { mon: Mon },
6    Mana { mana: Mana },
7    MonWithMana { mon: Mon, mana: Mana },
8    MonWithConsumable { mon: Mon, consumable: Consumable },
9    Consumable { consumable: Consumable },
10}
11
12impl Item {
13    pub fn mon(&self) -> Option<&Mon> {
14        match self {
15            Item::Mon { mon }
16            | Item::MonWithMana { mon, .. }
17            | Item::MonWithConsumable { mon, .. } => Some(mon),
18            _ => None,
19        }
20    }
21
22    pub fn mana(&self) -> Option<&Mana> {
23        match self {
24            Item::Mana { mana } | Item::MonWithMana { mana, .. } => Some(mana),
25            _ => None,
26        }
27    }
28
29    pub fn consumable(&self) -> Option<&Consumable> {
30        match self {
31            Item::MonWithConsumable { consumable, .. } | Item::Consumable { consumable } => Some(consumable),
32            _ => None,
33        }
34    }
35}