diff options
author | David Gay <eapoems@riseup.net> | 2024-01-31 03:14:53 -0500 |
---|---|---|
committer | David Gay <eapoems@riseup.net> | 2024-01-31 03:14:53 -0500 |
commit | e63dbbde68f81f8a65b48608d41ef6bf6be799e6 (patch) | |
tree | b6c9a200278974d6bc70ccdb9e3960b9e871344f /src/main.rs | |
parent | 05a13c4c3232f10ade9a2cc75de84e93278d22c6 (diff) |
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 44c162c..85c90fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,10 +27,19 @@ fn main() { std::process::exit(1); }); + let level = npc_matches + .get_one::<i32>("level") + .unwrap_or_else(|| { + eprintln!("Error: Couldn't parse level."); + std::process::exit(1); + }) + .clone(); + let mut npc = Npc::new( Some(RANDOM_TABLES.roll_table("npc_alignment")), None, Some(class_ref), + level, None, None, Vec::new(), @@ -39,9 +48,14 @@ fn main() { npc.add_random_magic_items(); println!( - "{} {}. {}", - npc.alignment.unwrap(), + "{} {} {}. {}", + npc.alignment + .unwrap() + .split_whitespace() + .map(|word| word.chars().next().unwrap()) + .collect::<String>(), npc.class.unwrap().name, + npc.level, npc.magic_items .iter() .map(|item| item.name.clone()) @@ -70,6 +84,7 @@ fn main() { Some(RANDOM_TABLES.roll_table("npc_alignment")), Some(race_ref), Some(class_ref), + 1, None, None, Vec::new(), @@ -86,7 +101,7 @@ fn main() { // string literal at compile time. if output_csv { println!( - "{},{},{},{},{},{},{},{},{},\"{}\"", + "{},{},{},{},{},{},{},{},{},{},\"{}\"", npc.alignment .unwrap() .split_whitespace() @@ -94,6 +109,7 @@ fn main() { .collect::<String>(), npc.race.unwrap().name, npc.class.unwrap().name, + npc.level, ability_scores.get_score(AbilityScore::Strength).unwrap(), ability_scores .get_score(AbilityScore::Intelligence) @@ -108,10 +124,15 @@ fn main() { ); } else { println!( - "{} {} {}. STR {}, INT {}, WIS {}, CON {}, DEX {}, CHA {}. {}", - npc.alignment.unwrap(), + "{} {} {} {}. STR {}, INT {}, WIS {}, CON {}, DEX {}, CHA {}. {}", + npc.alignment + .unwrap() + .split_whitespace() + .map(|word| word.chars().next().unwrap()) + .collect::<String>(), npc.race.unwrap().name, npc.class.unwrap().name, + npc.level, ability_scores.get_score(AbilityScore::Strength).unwrap(), ability_scores .get_score(AbilityScore::Intelligence) |