diff options
-rw-r--r-- | src/data/rules/races.yaml | 50 | ||||
-rw-r--r-- | src/rules.rs | 1 | ||||
-rw-r--r-- | src/rules/races.rs | 23 |
3 files changed, 74 insertions, 0 deletions
diff --git a/src/data/rules/races.yaml b/src/data/rules/races.yaml new file mode 100644 index 0000000..96e0142 --- /dev/null +++ b/src/data/rules/races.yaml @@ -0,0 +1,50 @@ +dwarf: + name: "Dwarf" + ability_score_modifiers: + Constitution: +1 + Charisma: -1 + npc_ability_score_modifiers: + Strength: +1 + Constitution: +1 + Charisma: -1 + +elf: + name: "Elf" + ability_score_modifiers: + Dexterity: +1 + Constitution: -1 + npc_ability_score_modifiers: + Intelligence: +1 + Dexterity: +1 + +gnome: + name: "Gnome" + npc_ability_score_modifiers: + Wisdom: +1 + Constitution: +1 + Charisma: -1 + +half-elf: + name: "Half-elf" + +halfling: + name: "Halfling" + ability_score_modifiers: + Strength: -1 + Dexterity: +1 + npc_ability_score_modifiers: + Dexterity: +1 + Constitution: +1 + +half-orc: + name: "Half-orc" + ability_score_modifiers: + Strength: +1 + Constitution: +1 + Charisma: -1 + npc_ability_score_modifiers: + Dexterity: +1 + Constitution: +1 + +human: + name: "Human" diff --git a/src/rules.rs b/src/rules.rs index 68f12f7..1807fc3 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -1,3 +1,4 @@ pub mod ability_scores; pub mod classes; pub mod npcs; +pub mod races; diff --git a/src/rules/races.rs b/src/rules/races.rs new file mode 100644 index 0000000..700c7ea --- /dev/null +++ b/src/rules/races.rs @@ -0,0 +1,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") +} |