diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index f97cf31..46fd094 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use dmn::random_tables::RandomTables; use dmn::rules::ability_scores::AbilityScore; use dmn::rules::classes::CLASSES; use dmn::rules::npcs::Npc; +use dmn::rules::races::RACES; mod cli; @@ -16,6 +17,7 @@ fn main() { match random_command { ("henchman", _) => { let class_name = random_tables.roll_table("henchman_class").to_string(); + let race_name = random_tables.roll_table("henchman_race").to_string(); // HACK: Need a proper way to do lookups, shouldn't rely on // downcasing the class name. This whole situation is really // indicative of the need for an architectural improvement. @@ -25,9 +27,14 @@ fn main() { eprintln!("Class '{}' not found.", &*class_name); std::process::exit(1); }); + let race_ref = RACES.get(&*race_name.to_lowercase()).unwrap_or_else(|| { + eprintln!("Race '{}' not found.", &*class_name); + std::process::exit(1); + }); + let mut npc = Npc::new( Some(random_tables.roll_table("npc_alignment")), - Some(random_tables.roll_table("henchman_race")), + Some(race_ref), Some(class_ref), None, ); @@ -36,7 +43,7 @@ fn main() { println!( "{} {} {}. STR {}, INT {}, WIS {}, CON {}, DEX {}, CHA {}", npc.alignment.unwrap(), - npc.race.unwrap(), + npc.race.unwrap().name, npc.class.unwrap().name, ability_scores.get_score(AbilityScore::Strength).unwrap(), ability_scores |