38 lines
713 B
Rust
38 lines
713 B
Rust
|
|
use serde::Deserialize;
|
||
|
|
|
||
|
|
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
||
|
|
pub struct EnemyDrop {
|
||
|
|
pub from: String,
|
||
|
|
pub chance: u8,
|
||
|
|
|
||
|
|
#[serde(default)]
|
||
|
|
pub info: Option<String>,
|
||
|
|
}
|
||
|
|
|
||
|
|
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<EnemyDrop>,
|
||
|
|
pub stone: Vec<EnemyDrop>,
|
||
|
|
pub gem: Vec<EnemyDrop>,
|
||
|
|
pub crystal: Vec<EnemyDrop>,
|
||
|
|
}
|
||
|
|
|
||
|
|
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,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|