summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Gay <eapoems@riseup.net>2023-10-15 02:35:16 -0400
committerDavid Gay <eapoems@riseup.net>2023-10-15 02:47:38 -0400
commit327af68c9de15ffb2ccb94167d308a8cf8deb778 (patch)
treea9faf218ed4bb73fdf6f486b9227198b5ead1ccf /src
parent0c1fc5be9d5857c6c73724e0d950e765b12400c7 (diff)
Add some simple debug logging
Diffstat (limited to 'src')
-rw-r--r--src/main.rs3
-rw-r--r--src/rules/npcs.rs6
2 files changed, 9 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 46fd094..307c1f9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,10 +4,13 @@ use dmn::rules::ability_scores::AbilityScore;
use dmn::rules::classes::CLASSES;
use dmn::rules::npcs::Npc;
use dmn::rules::races::RACES;
+use env_logger;
mod cli;
fn main() {
+ env_logger::init();
+
let matches = cli::cli().get_matches();
let random_tables = RandomTables::new().expect("Failed to load random tables.");
diff --git a/src/rules/npcs.rs b/src/rules/npcs.rs
index 4ee687f..fae1c69 100644
--- a/src/rules/npcs.rs
+++ b/src/rules/npcs.rs
@@ -2,6 +2,7 @@ use crate::dice::roll_formula;
use crate::rules::ability_scores::{AbilityScore, AbilityScoreCollection};
use crate::rules::classes::Class;
use crate::rules::races::Race;
+use log::debug;
use std::collections::HashMap;
// use std::fmt;
@@ -39,8 +40,10 @@ impl Npc {
AbilityScore::Constitution,
AbilityScore::Charisma,
] {
+ debug!("Generating score for {}", &ability.abbr());
// Roll 3d6 down the line.
let mut roll_result = roll_formula("3d6").unwrap();
+ debug!("Rolled {}", roll_result.total());
let class_ref = self.class.unwrap();
let race_ref = self.race.unwrap();
@@ -49,6 +52,7 @@ impl Npc {
if class_ref.prime_requisites.contains(&ability) {
roll_result.increase_sides_below_max(6, 1);
}
+ debug!("Bumped prime requisites, now at {}", roll_result.total());
// At this point we don't need the individual dice anymore.
let mut total = roll_result.total();
@@ -59,6 +63,7 @@ impl Npc {
.get(&ability)
.copied()
.unwrap_or(0) as u32;
+ debug!("After adding NPC class modifiers, now at {}", total);
// Add racial ability score modifiers.
total += race_ref
@@ -66,6 +71,7 @@ impl Npc {
.get(&ability)
.copied()
.unwrap_or(0) as u32;
+ debug!("After adding racial modifiers, now at {}", total);
ability_score_rolls.insert(ability, total);
}