initiative_core/world/npc/ethnicity/
dragonborn.rs

1use super::{Age, Gender, Generate, GenerateSimple};
2use rand::prelude::*;
3
4pub struct Ethnicity;
5
6impl GenerateSimple for Ethnicity {
7    fn syllable_fname_count_f() -> &'static [(u8, usize)] {
8        &[(2, 32), (3, 34), (4, 19), (5, 13), (6, 3), (7, 3)]
9    }
10
11    #[rustfmt::skip]
12    fn syllable_fname_first_f() -> &'static [(&'static str, usize)] {
13        &[
14            ("Za", 3), ("Na", 3), ("Che", 2), ("Vo", 2), ("Nar", 2), ("Ma", 2), ("Va", 2),
15            ("Arel", 1), ("Arveia", 1), ("Asho", 1), ("Au", 1), ("Bi", 1), ("Bo", 1), ("Ca", 1),
16            ("Cae", 1), ("Clau", 1), ("Cly", 1), ("Dar", 1), ("Dheub", 1), ("Emy", 1), ("Ere", 1),
17            ("Essem", 1), ("Fll'", 1), ("Fy", 1), ("Gar", 1), ("Gau", 1), ("Ges", 1), ("Ghau", 1),
18            ("Ica", 1), ("Idriz", 1), ("Isen", 1), ("Iskda", 1), ("Ja", 1), ("Je", 1), ("Jha", 1),
19            ("Jhi", 1), ("Ka", 1), ("Kar", 1), ("Kas", 1), ("Ke", 1), ("Khor", 1), ("Lham", 1),
20            ("Min", 1), ("Mis", 1), ("Mo", 1), ("Ni", 1), ("Orlar", 1), ("Orma", 1), ("Otaa", 1),
21            ("Ou", 1),
22        ]
23    }
24
25    #[rustfmt::skip]
26    fn syllable_fname_last_f() -> &'static [(&'static str, usize)] {
27        &[
28            ("la", 6), ("ra", 6), ("tha", 5), ("na", 5), ("tar", 3), ("ri", 3), ("rith", 2),
29            ("va", 2), ("thra", 2), ("deh", 2), ("rath", 2), ("rak", 2), ("ka", 2), ("lax", 1),
30            ("leen", 1), ("les", 1), ("lian", 1), ("lin", 1), ("lon", 1), ("loss", 1), ("lym", 1),
31            ("lynx", 1), ("ma", 1), ("mar", 1), ("mi", 1), ("mix", 1), ("ni", 1), ("niius", 1),
32            ("nos", 1), ("pyl", 1), ("race", 1), ("racht", 1), ("raele", 1), ("rakh", 1),
33            ("ree", 1), ("rene", 1), ("rial", 1), ("ris", 1), ("rose", 1), ("ru", 1), ("ryu", 1),
34            ("ryx", 1), ("sar", 1), ("saya", 1), ("shkin", 1), ("shna", 1), ("shni", 1),
35            ("shva", 1), ("sjach", 1), ("ta", 1),
36        ]
37    }
38
39    fn syllable_fname_count_m() -> &'static [(u8, usize)] {
40        &[(2, 82), (3, 68), (4, 35), (5, 14), (6, 5), (7, 2)]
41    }
42
43    #[rustfmt::skip]
44    fn syllable_fname_first_m() -> &'static [(&'static str, usize)] {
45        &[
46            ("Ba", 4), ("Sa", 3), ("Nar", 2), ("Me", 2), ("Ca", 2), ("Hes", 2), ("Ver", 2),
47            ("Ma", 2), ("Mi", 2), ("Des", 2), ("Olo", 2), ("La", 2), ("Tha", 2), ("Aswi", 1),
48            ("Asta", 1), ("Angla", 1), ("Ashar", 1), ("Asa", 1), ("Anda", 1), ("Aeg", 1),
49            ("Cha", 1), ("Fy", 1), ("Char", 1), ("Charth", 1), ("Chel", 1), ("Con", 1),
50            ("Cryo", 1), ("Arjha", 1), ("Do", 1), ("Dom", 1), ("Bu", 1), ("Brom", 1), ("Argu", 1),
51            ("Ami", 1), ("Fel", 1), ("Eskor", 1), ("Bha", 1), ("Eshu", 1), ("Fer", 1), ("Fir", 1),
52            ("Friz", 1), ("Ful", 1), ("Esham-", 1), ("Ga", 1), ("Gar", 1), ("Gesh", 1),
53            ("Ghau", 1), ("Ghed", 1), ("Ghon", 1), ("Arcti", 1),
54        ]
55    }
56
57    #[rustfmt::skip]
58    fn syllable_fname_last_m() -> &'static [(&'static str, usize)] {
59        &[
60            ("ros", 3), ("thor", 3), ("dar", 3), ("rash", 3), ("rax", 3), ("fang", 2), ("das", 2),
61            ("noth", 2), ("tar", 2), ("tor", 2), ("rinn", 2), ("gar", 2), ("roth", 2), ("dyr", 2),
62            ("rac", 2), ("mark", 2), ("reth", 2), ("rin", 2), ("thon", 2), ("zar", 2), ("lar", 2),
63            ("thar", 2), ("nak", 2), ("sar", 2), ("far", 1), ("dan", 1), ("chaud", 1), ("dusk", 1),
64            ("dun", 1), ("farn", 1), ("dain", 1), ("droth", 1), ("drel", 1), ("dac", 1),
65            ("can", 1), ("bar", 1), ("dos", 1), ("dorg", 1), ("cus", 1), ("gyrt", 1), ("groth", 1),
66            ("dor", 1), ("hael", 1), ("hen", 1), ("ho", 1), ("hor", 1), ("kaan", 1), ("kan", 1),
67            ("kar", 1), ("gras", 1),
68        ]
69    }
70
71    fn syllable_fname_count() -> &'static [(u8, usize)] {
72        &[(2, 125), (3, 120), (4, 62), (5, 29), (6, 8), (7, 6)]
73    }
74
75    #[rustfmt::skip]
76    fn syllable_fname_first() -> &'static [(&'static str, usize)] {
77        &[
78            ("Ver", 4), ("Nar", 4), ("Na", 4), ("Za", 4), ("Sa", 4), ("Ba", 4), ("Ma", 4),
79            ("Tha", 3), ("Ve", 3), ("Ha", 3), ("Me", 3), ("Ca", 3), ("Rau", 2), ("Si", 2),
80            ("Olo", 2), ("Ana", 2), ("Vo", 2), ("Ta", 2), ("Slar", 2), ("Va", 2), ("Ri", 2),
81            ("To", 2), ("Ni", 2), ("Ze", 2), ("Ra", 2), ("Ry", 2), ("Mi", 2), ("Au", 2),
82            ("Che", 2), ("La", 2), ("Kar", 2), ("Gor", 2), ("Ghau", 2), ("Fy", 2), ("Des", 2),
83            ("Gar", 2), ("Hes", 2), ("Ven", 2), ("Aur", 1), ("Angla", 1), ("Athaug", 1),
84            ("Anda", 1), ("Akre", 1), ("Aswi", 1), ("Asta", 1), ("Ana-", 1), ("Cryo", 1),
85            ("Asho", 1), ("Con", 1), ("Cly", 1),
86        ]
87    }
88
89    #[rustfmt::skip]
90    fn syllable_fname_last() -> &'static [(&'static str, usize)] {
91        &[
92            ("ra", 7), ("tar", 6), ("la", 6), ("tha", 6), ("na", 6), ("dar", 4), ("thor", 4),
93            ("xis", 4), ("rax", 4), ("sar", 3), ("rin", 3), ("ros", 3), ("rath", 3), ("rash", 3),
94            ("roth", 3), ("ri", 3), ("mar", 3), ("rak", 3), ("zar", 3), ("nos", 3), ("trix", 2),
95            ("thax", 2), ("va", 2), ("rith", 2), ("rinn", 2), ("ris", 2), ("thar", 2), ("thon", 2),
96            ("thra", 2), ("tor", 2), ("ran", 2), ("gar", 2), ("deh", 2), ("noth", 2), ("ni", 2),
97            ("rac", 2), ("reth", 2), ("fang", 2), ("das", 2), ("nak", 2), ("dyr", 2), ("mi", 2),
98            ("lon", 2), ("mark", 2), ("lan", 2), ("lar", 2), ("kas", 2), ("ka", 2), ("lian", 2),
99            ("naar", 2),
100        ]
101    }
102
103    #[rustfmt::skip]
104    fn syllable_fname_middle() -> &'static [(&'static str, usize)] {
105        &[
106            ("ra", 20), ("la", 18), ("ma", 12), ("ri", 8), ("ti", 8), ("na", 8), ("li", 7),
107            ("da", 6), ("ro", 6), ("lo", 5), ("mi", 5), ("za", 5), ("ta", 5), ("va", 5), ("sa", 4),
108            ("nar", 4), ("ren", 4), ("ga", 4), ("the", 3), ("tu", 3), ("tha", 3), ("no", 3),
109            ("me", 3), ("run", 3), ("lan", 3), ("ryn", 3), ("ly", 3), ("ni", 3), ("thi", 2),
110            ("thon", 2), ("clu", 2), ("dri", 2), ("than", 2), ("sin", 2), ("se", 2), ("ry", 2),
111            ("ron", 2), ("go", 2), ("ral", 2), ("nes", 2), ("mor", 2), ("de", 2), ("le", 2),
112            ("lin", 2), ("di", 2), ("ge", 2), ("lar", 2), ("gau", 2), ("kan", 2), ("han", 2),
113        ]
114    }
115
116    fn syllable_lname_count() -> &'static [(u8, usize)] {
117        &[(2, 17), (3, 2), (5, 1)]
118    }
119
120    #[rustfmt::skip]
121    fn syllable_lname_first() -> &'static [(&'static str, usize)] {
122        &[
123            ("Las", 2), ("Arden", 1), ("Crown", 1), ("Cyn", 1), ("Drag", 1), ("Dre", 1),
124            ("Dread", 1), ("Dup", 1), ("Flame", 1), ("Ga", 1), ("He", 1), ("Just", 1),
125            ("Alaerth", 1), ("Sil", 1),
126        ]
127    }
128
129    #[rustfmt::skip]
130    fn syllable_lname_middle() -> &'static [(&'static str, usize)] {
131        &[
132            ("ka", 1), ("res", 1), ("tis", 1), ("ton", 1), ("ver", 1),
133        ]
134    }
135
136    #[rustfmt::skip]
137    fn syllable_lname_last() -> &'static [(&'static str, usize)] {
138        &[
139            ("san", 2), ("dark", 1), ("dusk", 1), ("gore", 1), ("gue", 1), ("kesh", 1),
140            ("maugh", 1), ("renth", 1), ("shield", 1), ("thyl", 1), ("thyn", 1), ("va", 1),
141            ("claw", 1), ("wing", 1),
142        ]
143    }
144
145    fn compound_word_probability() -> f64 {
146        0.01652892561983471
147    }
148
149    #[rustfmt::skip]
150    fn word_lname_first() -> &'static [(&'static str, usize)] {
151        &[
152            ("Crown", 1), ("Drag", 1), ("Dread", 1), ("Flame", 1), ("Just", 1), ("Silver", 1),
153        ]
154    }
155
156    #[rustfmt::skip]
157    fn word_lname_last() -> &'static [(&'static str, usize)] {
158        &[
159            ("claw", 1), ("dark", 1), ("gore", 1), ("shield", 1), ("tongue", 1), ("wing", 1),
160        ]
161    }
162}
163
164impl Generate for Ethnicity {
165    fn gen_name(rng: &mut impl Rng, _age: &Age, gender: &Gender) -> String {
166        format!(
167            "{} {}",
168            Self::gen_fname_simple(rng, gender),
169            Self::gen_lname_simple(rng),
170        )
171    }
172}
173
174#[cfg(test)]
175mod test {
176    use super::*;
177    use crate::world::npc::ethnicity::{test_utils as test, Ethnicity};
178
179    use Age::Adult;
180    use Ethnicity::Dragonborn;
181    use Gender::{Feminine, Masculine, NonBinaryThey};
182
183    #[test]
184    fn gen_name_test() {
185        let mut rng = SmallRng::seed_from_u64(0);
186
187        assert_eq!(
188            [
189                "Astaneshor Dragva",
190                "Ghonthor Crowngore",
191                "Gaumadasar Dreva",
192                "Bitar Lasthyl",
193                "Halalorax Flamesan",
194                "Akrena Ardendark",
195            ],
196            [
197                test::gen_name(&mut rng, Dragonborn, Adult, Masculine),
198                test::gen_name(&mut rng, Dragonborn, Adult, Masculine),
199                test::gen_name(&mut rng, Dragonborn, Adult, Feminine),
200                test::gen_name(&mut rng, Dragonborn, Adult, Feminine),
201                test::gen_name(&mut rng, Dragonborn, Adult, NonBinaryThey),
202                test::gen_name(&mut rng, Dragonborn, Adult, NonBinaryThey),
203            ],
204        );
205    }
206}