use serde::Deserialize; #[derive(Debug, Deserialize, PartialEq, Eq)] pub struct EnemyDrop { pub from: String, pub chance: u8, #[serde(default)] pub info: Option, } impl EnemyDrop { pub fn texture(&self) -> String { self.from.replace(" ", "_").to_lowercase() } } #[derive(Debug, Deserialize, PartialEq, Eq)] pub struct MaterialDrops { pub kind: String, pub shard: Vec, pub stone: Vec, pub gem: Vec, pub crystal: Vec, } impl MaterialDrops { pub fn drops(&self, kind: &str) -> &[EnemyDrop] { match kind { "shard" => &self.shard, "stone" => &self.stone, "gem" => &self.gem, "crystal" => &self.crystal, _ => &self.shard, } } }