diff options
Diffstat (limited to 'src/rules/npcs.rs')
-rw-r--r-- | src/rules/npcs.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rules/npcs.rs b/src/rules/npcs.rs index fae1c69..d9fdc0f 100644 --- a/src/rules/npcs.rs +++ b/src/rules/npcs.rs @@ -73,6 +73,12 @@ impl Npc { .unwrap_or(0) as u32; debug!("After adding racial modifiers, now at {}", total); + // Ensure racial ability score limits are imposed. + // TODO: Use u8 for all of these, so no conversion from u32 will be needed. + let [min_score, max_score] = race_ref.ability_score_ranges.get(&ability).unwrap().male; + total = total.max(min_score as u32); + total = total.min(max_score as u32); + ability_score_rolls.insert(ability, total); } @@ -84,7 +90,6 @@ impl Npc { self.ability_scores = Some(score_collection); - // TODO: Apply racial minimums and maximums. // TODO: Verify legality of class based on alignment. // TODO: Verify legality of class based on race. // TODO: Verify legality of class based on ability scores. @@ -123,15 +128,17 @@ impl Npc { mod tests { use super::*; use crate::rules::classes::CLASSES; + use crate::rules::races::RACES; #[test] #[ignore] #[should_panic(expected = "Ability score generation isn't testable yet.")] fn test_roll_henchman_ability_scores() { let class_ref = CLASSES.get("fighter").unwrap(); + let race_ref = RACES.get("dwarf").unwrap(); let mut npc = Npc { alignment: Some(String::from("Lawful Good")), - race: Some(String::from("Dwarf")), + race: Some(race_ref), class: Some(class_ref), ability_scores: None, }; |