|
|
@ -16,6 +16,7 @@ use crate::ship::drops::generic_weapon::AttributeTable; |
|
|
|
use crate::ship::drops::generic_armor::GenericArmorTable;
|
|
|
|
use crate::ship::drops::generic_shield::GenericShieldTable;
|
|
|
|
|
|
|
|
type ItemParseFn = Box<dyn Fn(&String) -> Option<RareDropItem>>;
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub enum RareDropItem {
|
|
|
@ -29,7 +30,7 @@ pub enum RareDropItem { |
|
|
|
|
|
|
|
impl RareDropItem {
|
|
|
|
pub fn from_string(name: String) -> RareDropItem {
|
|
|
|
let parse_funcs: [Box<dyn Fn(&String) -> Option<RareDropItem>>; 6] = [
|
|
|
|
let parse_funcs: [ItemParseFn; 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()?))),
|
|
|
|