summaryrefslogtreecommitdiff
path: root/src/rules/npcs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rules/npcs.rs')
-rw-r--r--src/rules/npcs.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/rules/npcs.rs b/src/rules/npcs.rs
index c3fc86a..9cc1650 100644
--- a/src/rules/npcs.rs
+++ b/src/rules/npcs.rs
@@ -1,5 +1,7 @@
-use crate::rules::ability_scores::AbilityScoreCollection;
+use crate::dice::{roll_formula, RollResult};
+use crate::rules::ability_scores::{AbilityScore, AbilityScoreCollection};
use crate::rules::classes::Class;
+use std::collections::HashMap;
// use std::fmt;
pub struct Npc {
@@ -23,6 +25,44 @@ impl Npc {
ability_scores,
}
}
+
+ pub fn roll_henchman_ability_scores(&mut self) {
+ rand::thread_rng();
+ let mut ability_score_rolls: HashMap<AbilityScore, RollResult> = HashMap::new();
+
+ for &ability in &[
+ AbilityScore::Strength,
+ AbilityScore::Intelligence,
+ AbilityScore::Wisdom,
+ AbilityScore::Dexterity,
+ AbilityScore::Constitution,
+ AbilityScore::Charisma,
+ ] {
+ // Roll 3d6 down the line.
+ let mut roll_result = roll_formula("3d6").unwrap();
+ let class_ref = self.class.unwrap();
+
+ // For ability scores which are prime requisites of the class,
+ // increase all dice by 1 which do not already show a 6.
+ if class_ref.prime_requisites.contains(&ability) {
+ roll_result.increase_sides_below_max(6, 1);
+ }
+
+ ability_score_rolls.insert(ability, roll_result);
+ }
+
+ // Create an AbilityScoreCollection for the Npc, using the above results.
+ let mut score_collection = AbilityScoreCollection::new();
+ for (ability, roll_result) in &ability_score_rolls {
+ let total_score = roll_result.total();
+ score_collection.add_score(*ability, total_score);
+ }
+
+ self.ability_scores = Some(score_collection);
+
+ // TODO: Modify results for race.
+ // TODO: Modify results for henchmen-specific class bonuses.
+ }
}
// impl fmt::Display for Npc {