dmn 0.0.2

CLI and library for DMs and other players of Advanced Dungeons & Dragons (AD&D)
Documentation
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>,
    pub ability_score_ranges: HashMap<AbilityScore, AbilityScoreRange>,
}

// TODO: Allow configuration of whether to use female ranges or not.
#[derive(Deserialize)]
pub struct AbilityScoreRange {
    pub male: [u8; 2],
    // pub female: [u8; 2], // TODO: Enable female ranges.
}

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")
}