diff options
Diffstat (limited to 'src/random_tables.rs')
-rw-r--r-- | src/random_tables.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/random_tables.rs b/src/random_tables.rs index 831fd86..9116659 100644 --- a/src/random_tables.rs +++ b/src/random_tables.rs @@ -1,6 +1,7 @@ use crate::dice; use crate::rules::classes::CLASSES; use include_dir::{include_dir, Dir}; +use lazy_static::lazy_static; use serde::Deserialize; use serde_yaml; use std::collections::HashMap; @@ -40,12 +41,17 @@ struct TableRowStep { // } // } -pub struct RandomTables { - tables: HashMap<String, RandomTable>, +lazy_static! { + pub static ref RANDOM_TABLES: RandomTables = + RandomTables::new().expect("Failed to load random tables."); } const YAML_DIR: Dir = include_dir!("src/data/random_tables/"); +pub struct RandomTables { + tables: HashMap<String, RandomTable>, +} + impl RandomTables { pub fn new() -> Result<Self, Box<dyn Error>> { let mut tables_yaml = String::new(); |