|
|
@ -30,18 +30,17 @@ pub enum RareDropItem { |
|
|
|
impl RareDropItem {
|
|
|
|
pub fn from_string(name: String) -> RareDropItem {
|
|
|
|
let parse_funcs: [Box<dyn Fn(&String) -> Option<RareDropItem>>; 6] = [
|
|
|
|
Box::new(|i| Some(RareDropItem::Weapon(str::parse::<WeaponType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Armor(str::parse::<ArmorType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Shield(str::parse::<ShieldType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Unit(str::parse::<UnitType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Tool(str::parse::<ToolType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Mag(str::parse::<MagType>(&i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Weapon(str::parse::<WeaponType>(i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Armor(str::parse::<ArmorType>(i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Shield(str::parse::<ShieldType>(i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Unit(str::parse::<UnitType>(i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Tool(str::parse::<ToolType>(i).ok()?))),
|
|
|
|
Box::new(|i| Some(RareDropItem::Mag(str::parse::<MagType>(i).ok()?))),
|
|
|
|
];
|
|
|
|
|
|
|
|
for parse in parse_funcs.iter() {
|
|
|
|
match parse(&name) {
|
|
|
|
Some(k) => return k,
|
|
|
|
None => {},
|
|
|
|
if let Some (k) = parse(&name) {
|
|
|
|
return k
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
@ -151,7 +150,7 @@ impl RareDropTable { |
|
|
|
else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}).nth(0)
|
|
|
|
}).next()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|