tweak fn generate_biome in namegen

This commit is contained in:
floppy 2022-01-17 19:03:15 +01:00
parent 609d23ae4f
commit 88a39476bc

View File

@ -3,6 +3,8 @@ use rand::prelude::*;
pub struct NameGen<'a, R: Rng> {
// 2..
pub approx_syllables: usize,
pub approx_syllables_long: usize,
rng: &'a mut R,
}
@ -10,6 +12,8 @@ impl<'a, R: Rng> NameGen<'a, R> {
pub fn location(rng: &'a mut R) -> Self {
Self {
approx_syllables: rng.gen_range(1..4),
approx_syllables_long: rng.gen_range(2..4),
rng,
}
}
@ -75,7 +79,7 @@ impl<'a, R: Rng> NameGen<'a, R> {
let mut name = String::new();
name += start.choose(self.rng).unwrap();
for _ in 0..self.approx_syllables.saturating_sub(2) + 1 {
for _ in 0..self.approx_syllables_long.saturating_sub(2) {
name += vowel.choose(self.rng).unwrap();
name += middle.choose(self.rng).unwrap();
}