use lazy_static::lazy_static; use serde::Deserialize; use serde_yaml; use std::collections::HashMap; use std::string::String; #[derive(Deserialize)] pub struct MagicItem { pub name: String, pub kind: MagicItemKind, } #[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Copy)] pub enum MagicItemKind { Sword, Potion, Scroll, Ring, RodStaffWand, Misc, ArmorShield, MiscWeapon, } lazy_static! { pub static ref MAGIC_ITEMS: HashMap = load_magic_items(); } // TODO: Is this actually needed? Is there a real race condition this is avoiding? fn load_magic_items() -> HashMap { let yaml_data = include_str!("../data/rules/magic_items.yaml"); serde_yaml::from_str(yaml_data).expect("Failed to parse magic items YAML") }