2019-06-11 18:39:25 +00:00
|
|
|
use rand::Rng;
|
2019-06-18 21:22:31 +00:00
|
|
|
use vek::*;
|
2019-06-11 18:39:25 +00:00
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub enum LocationKind {
|
|
|
|
Settlement,
|
2019-06-18 21:22:31 +00:00
|
|
|
Wildnerness,
|
2019-06-11 18:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct Location {
|
|
|
|
name: String,
|
2019-06-18 21:22:31 +00:00
|
|
|
center: Vec2<i32>,
|
2019-06-11 18:39:25 +00:00
|
|
|
kind: LocationKind,
|
2019-06-18 21:22:31 +00:00
|
|
|
kingdom: Option<Kingdom>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Location {
|
|
|
|
pub fn generate<R: Rng>(center: Vec2<i32>, 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()
|
|
|
|
}
|
2019-06-11 18:39:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct Kingdom {
|
|
|
|
name: String,
|
|
|
|
}
|
|
|
|
|
2019-06-18 21:22:31 +00:00
|
|
|
fn generate_name<R: Rng>(rng: &mut R) -> String {
|
2019-06-11 18:39:25 +00:00
|
|
|
let consts = [
|
2019-06-15 10:36:26 +00:00
|
|
|
"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",
|
2019-06-11 18:39:25 +00:00
|
|
|
];
|
|
|
|
let tails = [
|
2019-06-15 10:36:26 +00:00
|
|
|
"er", "in", "o", "on", "an", "ar", "is", "oon", "er", "aru", "ab", "um", "id", "and",
|
|
|
|
"eld", "ald", "oft", "aft", "ift", "ity", "ell", "oll", "ill", "all",
|
2019-06-11 18:39:25 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
let mut name = String::new();
|
2019-06-18 23:59:40 +00:00
|
|
|
for i in 0..rng.gen::<u32>() % 2 {
|
|
|
|
name += rng.choose(&consts).unwrap();
|
|
|
|
name += rng.choose(&vowels).unwrap();
|
2019-06-11 18:39:25 +00:00
|
|
|
}
|
2019-06-18 23:59:40 +00:00
|
|
|
name += rng.choose(&consts).unwrap();
|
|
|
|
name += rng.choose(&tails).unwrap();
|
2019-06-11 18:39:25 +00:00
|
|
|
|
|
|
|
name
|
|
|
|
}
|