summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDavid Gay <eapoems@riseup.net>2023-10-15 01:36:37 -0400
committerDavid Gay <eapoems@riseup.net>2023-10-15 01:36:37 -0400
commit1591a38ea4d1c7dd5075773a8c7b5b321f8de8c7 (patch)
tree7e857cdec3c1ae86073eee9b413c71a250259208 /src/main.rs
parent47ee997edcf7607c4dc1ed0ea8f6637ec1d66d42 (diff)
Hook up races
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
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