2019-06-26 00:27:41 +00:00
|
|
|
use super::Settlement;
|
2019-08-11 20:10:36 +00:00
|
|
|
use hashbrown::HashSet;
|
2019-07-29 13:42:26 +00:00
|
|
|
use rand::seq::SliceRandom;
|
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(Clone, Debug)]
|
|
|
|
pub struct Location {
|
2019-06-25 15:59:09 +00:00
|
|
|
pub(crate) name: String,
|
|
|
|
pub(crate) center: Vec2<i32>,
|
|
|
|
pub(crate) kingdom: Option<Kingdom>,
|
2019-08-11 20:10:36 +00:00
|
|
|
pub(crate) neighbours: HashSet<usize>,
|
2019-06-25 15:59:09 +00:00
|
|
|
pub(crate) settlement: Settlement,
|
2019-06-18 21:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Location {
|
2019-06-25 15:59:09 +00:00
|
|
|
pub fn generate(center: Vec2<i32>, rng: &mut impl Rng) -> Self {
|
2019-06-18 21:22:31 +00:00
|
|
|
Self {
|
|
|
|
name: generate_name(rng),
|
|
|
|
center,
|
|
|
|
kingdom: None,
|
2019-08-11 20:10:36 +00:00
|
|
|
neighbours: HashSet::default(),
|
2019-06-25 15:59:09 +00:00
|
|
|
settlement: Settlement::generate(rng),
|
2019-06-18 21:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
2019-06-19 09:38:20 +00:00
|
|
|
region_name: String,
|
2019-06-11 18:39:25 +00:00
|
|
|
}
|
|
|
|
|
2019-07-29 13:42:26 +00:00
|
|
|
fn generate_name(rng: &mut impl Rng) -> String {
|
2019-06-19 09:05:03 +00:00
|
|
|
let firstsyl = [
|
|
|
|
"Eri", "Val", "Gla", "Wilde", "Cold", "Deep", "Dura", "Ester", "Fay", "Dark", "West",
|
2019-06-22 14:30:53 +00:00
|
|
|
"East", "North", "South", "Ray", "Eri", "Dal", "Som", "Sommer", "Black", "Iron", "Grey",
|
|
|
|
"Hel", "Gal", "Mor", "Lo", "Nil", "Bel", "Lor", "Gold", "Red", "Marble", "Mana", "Gar",
|
|
|
|
"Mountain", "Red", "Cheo", "Far", "High",
|
2019-06-11 18:39:25 +00:00
|
|
|
];
|
2019-06-22 14:30:53 +00:00
|
|
|
let mid = ["ka", "se", "au", "da", "di"];
|
2019-06-11 18:39:25 +00:00
|
|
|
let tails = [
|
2019-06-23 19:43:02 +00:00
|
|
|
/*"mill",*/ "ben", "sel", "dori", "theas", "dar", "bur", "to", "vis", "ten", "stone",
|
|
|
|
"tiva", "id", "and", "or", "el", "ond", "ia", "eld", "ald", "aft", "ift", "ity", "well",
|
|
|
|
"oll", "ill", "all", "wyn", "light", " Hill", "lin", "mont", "mor", "cliff", "rok", "den",
|
|
|
|
"mi", "rock", "glenn", "rovi", "lea", "gate", "view", "ley", "wood", "ovia", "cliff",
|
|
|
|
"marsh", "kor", "ice", /*"river",*/ "acre", "venn", "crest", "field", "vale",
|
|
|
|
"spring", " Vale", "grasp", "fel", "fall", "grove", "wyn", "edge",
|
2019-06-11 18:39:25 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
let mut name = String::new();
|
2019-06-19 13:37:46 +00:00
|
|
|
if rng.gen() {
|
2019-07-29 13:42:26 +00:00
|
|
|
name += firstsyl.choose(rng).unwrap();
|
|
|
|
name += mid.choose(rng).unwrap();
|
|
|
|
name += tails.choose(rng).unwrap();
|
2019-06-19 09:38:20 +00:00
|
|
|
name
|
|
|
|
} else {
|
2019-07-29 13:42:26 +00:00
|
|
|
name += firstsyl.choose(rng).unwrap();
|
|
|
|
name += tails.choose(rng).unwrap();
|
2019-06-19 09:38:20 +00:00
|
|
|
name
|
|
|
|
}
|
2019-06-11 18:39:25 +00:00
|
|
|
}
|