summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
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)