summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dice.rs33
-rw-r--r--src/rules/npcs.rs4
2 files changed, 37 insertions, 0 deletions
diff --git a/src/dice.rs b/src/dice.rs
index cd6cf29..a2a3529 100644
--- a/src/dice.rs
+++ b/src/dice.rs
@@ -2,6 +2,7 @@ use rand::Rng;
use std::fmt;
use std::fmt::Formatter;
+#[derive(PartialEq, Debug)]
pub struct DieRoll {
sides: u32,
face: u32,
@@ -92,3 +93,35 @@ pub fn roll_formula(formula: &str) -> Option<RollResult> {
Some(roll_result)
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_roll_result_total() {
+ let mut roll_result = RollResult::new();
+ roll_result.add_roll(DieRoll::new(6, 4));
+ roll_result.add_roll(DieRoll::new(6, 2));
+ roll_result.add_roll(DieRoll::new(6, 6));
+ assert_eq!(roll_result.total(), 12);
+ }
+
+ #[test]
+ fn test_increase_sides_below_max() {
+ let mut roll_result = RollResult::new();
+ roll_result.add_roll(DieRoll::new(6, 4));
+ roll_result.add_roll(DieRoll::new(6, 2));
+ roll_result.add_roll(DieRoll::new(6, 6));
+
+ roll_result.increase_sides_below_max(6, 1);
+
+ let expected_rolls = vec![
+ DieRoll::new(6, 5), // Increased from 4.
+ DieRoll::new(6, 3), // Increased from 2.
+ DieRoll::new(6, 6), // Remains the same, as it's 6.
+ ];
+
+ assert_eq!(roll_result.rolls, expected_rolls);
+ }
+}
diff --git a/src/rules/npcs.rs b/src/rules/npcs.rs
index 9cc1650..e190952 100644
--- a/src/rules/npcs.rs
+++ b/src/rules/npcs.rs
@@ -62,6 +62,10 @@ impl Npc {
// TODO: Modify results for race.
// TODO: Modify results for henchmen-specific class bonuses.
+ // 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.
}
}