tavern_keeper/src/generators.rs

18 lines
599 B
Rust

use rand::seq::SliceRandom;
pub struct TownNameGenerator {
}
impl TownNameGenerator {
pub fn name() -> String {
let first = include_str!("names/towns/first.txt").split("\n").collect::<Vec<&str>>();
let second = include_str!("names/towns/second.txt").split("\n").collect::<Vec<&str>>();
let mut rng = rand::thread_rng();
let first = first.choose(&mut rng).unwrap();
let second = second.choose(&mut rng).unwrap();
let name = format!("{}{}", first, second);
// capitalize first letter
name[0..1].to_uppercase() + &name[1..]
}
}