summaryrefslogtreecommitdiff
path: root/src/rules/races.rs
blob: 700c7ea5f79c959d7c3f1ad22e48e53629fc9697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::rules::ability_scores::AbilityScore;
use lazy_static::lazy_static;
use serde::Deserialize;
use serde_yaml;
use std::collections::HashMap;
use std::string::String;

#[derive(Deserialize)]
pub struct Race {
    pub name: String,
    pub ability_score_modifiers: HashMap<AbilityScore, i32>,
    pub npc_ability_score_modifiers: HashMap<AbilityScore, i32>,
}

lazy_static! {
    pub static ref RACES: HashMap<String, Race> = load_races();
}

// TODO: Is this actually needed? Is there a real race condition this is avoiding?
fn load_races() -> HashMap<String, Race> {
    let yaml_data = include_str!("../data/rules/races.yaml");
    serde_yaml::from_str(yaml_data).expect("Failed to parse races YAML")
}