summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--src/data/rules/magic_items.yaml11
-rw-r--r--src/rules.rs1
-rw-r--r--src/rules/magic_items.rs32
4 files changed, 45 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 739244d..1b2e3d8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -106,7 +106,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "dmn"
-version = "0.0.3"
+version = "0.0.2"
dependencies = [
"clap",
"env_logger",
diff --git a/src/data/rules/magic_items.yaml b/src/data/rules/magic_items.yaml
new file mode 100644
index 0000000..c474cf0
--- /dev/null
+++ b/src/data/rules/magic_items.yaml
@@ -0,0 +1,11 @@
+sword_plus_one:
+ name: "Sword +1"
+ kind: sword
+
+ring_of_animal_friendship:
+ name: "Ring of Animal Friendship"
+ kind: ring
+
+rod_of_absorption:
+ name: "Rod of Absorption (C, M)"
+ kind: rod_staff_wand
diff --git a/src/rules.rs b/src/rules.rs
index 1807fc3..7d33038 100644
--- a/src/rules.rs
+++ b/src/rules.rs
@@ -1,4 +1,5 @@
pub mod ability_scores;
pub mod classes;
+pub mod magic_items;
pub mod npcs;
pub mod races;
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")
+}