summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/random_tables.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/random_tables.rs b/src/random_tables.rs
index 1d9df02..2428ad2 100644
--- a/src/random_tables.rs
+++ b/src/random_tables.rs
@@ -3,6 +3,7 @@ use serde_yaml;
use std::collections::HashMap;
use std::error::Error;
use std::string::String;
+use include_dir::{include_dir, Dir};
use crate::dice;
#[derive(Debug, Deserialize)]
@@ -27,10 +28,16 @@ pub struct RandomTables {
tables: HashMap<String, RandomTable>,
}
+const YAML_DIR : Dir = include_dir!("src/data/random_tables/");
+
impl RandomTables {
pub fn new() -> Result<Self, Box<dyn Error>> {
- let tables_yaml = include_str!("data/random_tables/ua_magic_items.yaml");
- let tables: HashMap<String, RandomTable> = serde_yaml::from_str(tables_yaml)?;
+ let mut tables_yaml = String::new();
+ for entry in YAML_DIR.files() {
+ tables_yaml.push_str(entry.contents_utf8().unwrap());
+ }
+
+ let tables: HashMap<String, RandomTable> = serde_yaml::from_str(tables_yaml.as_str())?;
Ok(RandomTables { tables })
}