summaryrefslogtreecommitdiff
path: root/src/rules/magic_items.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rules/magic_items.rs')
-rw-r--r--src/rules/magic_items.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/rules/magic_items.rs b/src/rules/magic_items.rs
new file mode 100644
index 0000000..6806a60
--- /dev/null
+++ b/src/rules/magic_items.rs
@@ -0,0 +1,32 @@
+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 {
+ Potion,
+ Scroll,
+ Ring,
+ RodStaffWand,
+ Misc,
+ ArmorShield,
+ MiscWeapon,
+}
+
+lazy_static! {
+ pub static ref MAGIC_ITEMS: HashMap<String, MagicItem> = load_magic_items();
+}
+
+// TODO: Is this actually needed? Is there a real race condition this is avoiding?
+fn load_magic_items() -> HashMap<String, MagicItem> {
+ let yaml_data = include_str!("../data/rules/magic_items.yaml");
+ serde_yaml::from_str(yaml_data).expect("Failed to parse magic items YAML")
+}