diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index bc9e200..44c162c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,38 @@ fn main() { Some(("random", sub_matches)) => { let random_command = sub_matches.subcommand().unwrap(); match random_command { + ("npc", npc_matches) => { + let class_name = npc_matches.get_one::<String>("class").unwrap_or_else(|| { + eprintln!("Error: Class is required."); + std::process::exit(1); + }); + let class_ref = CLASSES.get(&*class_name.to_lowercase()).unwrap_or_else(|| { + eprintln!("Class '{}' not found.", &*class_name); + std::process::exit(1); + }); + + let mut npc = Npc::new( + Some(RANDOM_TABLES.roll_table("npc_alignment")), + None, + Some(class_ref), + None, + None, + Vec::new(), + ); + + npc.add_random_magic_items(); + + println!( + "{} {}. {}", + npc.alignment.unwrap(), + npc.class.unwrap().name, + npc.magic_items + .iter() + .map(|item| item.name.clone()) + .collect::<Vec<String>>() + .join(", "), + ); + } ("henchman", henchman_matches) => { let class_name = RANDOM_TABLES.roll_table("henchman_class").to_string(); let race_name = RANDOM_TABLES.roll_table("henchman_race").to_string(); |