blob: a03492202386f7d91ca2bf182a6681a6afadebdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
use crate::rules::ability_scores::AbilityScore;
use serde::Deserialize;
use serde_yaml;
use std::collections::HashMap;
// use std::fmt;
use lazy_static::lazy_static;
use std::string::String;
#[derive(Deserialize)]
pub struct Class {
pub name: String,
pub prime_requisites: Vec<AbilityScore>,
#[serde(default)]
pub npc_ability_score_modifiers: HashMap<AbilityScore, i32>,
}
lazy_static! {
pub static ref CLASSES: HashMap<String, Class> = load_classes();
}
// TODO: Is this actually needed? Is there a real race condition this is avoiding?
fn load_classes() -> HashMap<String, Class> {
let yaml_data = include_str!("../data/rules/classes.yaml");
serde_yaml::from_str(yaml_data).expect("Failed to parse classes YAML")
}
//
// impl fmt::Display for Class {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// write!(f, "{}", self.name)
// }
// }
|