use rand::Rng; use vek::*; #[derive(Copy, Clone, Debug)] pub enum LocationKind { Settlement, Wildnerness, } #[derive(Clone, Debug)] pub struct Location { name: String, center: Vec2, kind: LocationKind, kingdom: Option, } impl Location { pub fn generate(center: Vec2, rng: &mut R) -> Self { Self { name: generate_name(rng), center, kind: LocationKind::Wildnerness, kingdom: None, } } pub fn name(&self) -> &str { &self.name } pub fn kingdom(&self) -> Option<&Kingdom> { self.kingdom.as_ref() } } #[derive(Clone, Debug)] pub struct Kingdom { name: String, } fn generate_name(rng: &mut R) -> String { let consts = [ "st", "tr", "b", "n", "p", "ph", "cr", "g", "c", "d", "k", "kr", "kl", "gh", "sl", "st", "cr", "sp", "th", "dr", "pr", "dr", "gr", "br", "ryth", "rh", "sl", "f", "fr", "p", "pr", "qu", "s", "sh", "z", "k", "br", "wh", "tr", "h", "bl", "sl", "r", "kl", "sl", "w", "v", "vr", "kr", ]; let vowels = [ "oo", "o", "oa", "au", "e", "ee", "ea", "ou", "u", "a", "i", "ie", ]; let tails = [ "er", "in", "o", "on", "an", "ar", "is", "oon", "er", "aru", "ab", "um", "id", "and", "eld", "ald", "oft", "aft", "ift", "ity", "ell", "oll", "ill", "all", ]; let mut name = String::new(); for i in 0..rng.gen::() % 2 { name += rng.choose(&consts).unwrap(); name += rng.choose(&vowels).unwrap(); } name += rng.choose(&consts).unwrap(); name += rng.choose(&tails).unwrap(); name }