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, 21), (3, 1)]
9 }
10
11 #[rustfmt::skip]
12 fn syllable_fname_first_f() -> &'static [(&'static str, usize)] {
13 &[
14 ("Baer", 1), ("Boo", 1), ("Cha", 1), ("Grib", 1), ("Jo", 1), ("Kreo", 1), ("Lar", 1),
15 ("Lo", 1), ("Mut", 1), ("Nag", 1), ("Oo", 1), ("Quet", 1), ("Rai", 1), ("Rath", 1),
16 ("Ta", 1), ("Thu", 1), ("Yag", 1), ("Zo", 1),
17 ]
18 }
19
20 #[rustfmt::skip]
21 fn syllable_fname_last_f() -> &'static [(&'static str, usize)] {
22 &[
23 ("ga", 2), ("da", 1), ("do", 1), ("ene", 1), ("ka", 1), ("lik", 1), ("mith", 1),
24 ("ra", 1), ("ri", 1), ("riya", 1), ("rog", 1), ("ruuch", 1), ("ta", 1), ("ti", 1),
25 ("war", 1), ("bla", 1), ("zel", 1),
26 ]
27 }
28
29 fn syllable_fname_count_m() -> &'static [(u8, usize)] {
30 &[(2, 88), (3, 9)]
31 }
32
33 #[rustfmt::skip]
34 fn syllable_fname_first_m() -> &'static [(&'static str, usize)] {
35 &[
36 ("Ha", 3), ("Ko", 2), ("Mu", 2), ("Bi", 1), ("Bru", 1), ("Bry", 1), ("Bu", 1),
37 ("Buh", 1), ("Dae", 1), ("Dul", 1), ("Glom", 1), ("Glor", 1), ("Gool", 1), ("Gre", 1),
38 ("Gri", 1), ("Grim", 1), ("Grom", 1), ("Grum'", 1), ("Gur", 1), ("Har", 1), ("Ho", 1),
39 ("Hrab", 1), ("Hul", 1), ("Inna", 1), ("Jo", 1), ("Khru", 1), ("Lef", 1), ("Log", 1),
40 ("Mak", 1), ("Mar", 1), ("Mo", 1), ("Nau", 1), ("Nor", 1), ("Nyun", 1), ("Rag", 1),
41 ("Raz", 1), ("Se", 1), ("Smae", 1), ("Thra", 1), ("Uryu", 1), ("Vag", 1), ("Ve", 1),
42 ("Vhaz", 1), ("Wur", 1), ("Xa", 1), ("Ala", 1), ("Zi", 1), ("Ashkab", 1), ("Ban", 1),
43 ]
44 }
45
46 #[rustfmt::skip]
47 fn syllable_fname_last_m() -> &'static [(&'static str, usize)] {
48 &[
49 ("red", 2), ("baz", 1), ("bul", 1), ("chan", 1), ("dagh", 1), ("dru", 1), ("fang", 1),
50 ("ga", 1), ("gan", 1), ("gen", 1), ("ghor", 1), ("gog", 1), ("gy", 1), ("hey", 1),
51 ("ka", 1), ("kan", 1), ("kul", 1), ("lan", 1), ("larkh", 1), ("lis", 1), ("low", 1),
52 ("luv", 1), ("moel", 1), ("neire", 1), ("nig", 1), ("nir", 1), ("nos", 1), ("raj", 1),
53 ("rak", 1), ("rakt", 1), ("ram", 1), ("rash", 1), ("rath", 1), ("rell", 1), ("rim", 1),
54 ("rin", 1), ("ris", 1), ("rock", 1), ("rog", 1), ("rok", 1), ("ron", 1), ("ront", 1),
55 ("ror", 1), ("shar", 1), ("shnak", 1), ("thtur", 1), ("tusk", 1), ("ty", 1),
56 ("vak", 1), ("vark", 1),
57 ]
58 }
59
60 fn syllable_fname_count() -> &'static [(u8, usize)] {
61 &[(2, 116), (3, 10)]
62 }
63
64 #[rustfmt::skip]
65 fn syllable_fname_first() -> &'static [(&'static str, usize)] {
66 &[
67 ("Ha", 3), ("Glor", 2), ("Ko", 2), ("Mu", 2), ("Jo", 2), ("Boo", 1), ("Bru", 1),
68 ("Bry", 1), ("Bu", 1), ("Buh", 1), ("Cha", 1), ("Dae", 1), ("Dah", 1), ("Dul", 1),
69 ("Glom", 1), ("Gool", 1), ("Gre", 1), ("Gri", 1), ("Grib", 1), ("Grim", 1),
70 ("Grom", 1), ("Grum'", 1), ("Gur", 1), ("Har", 1), ("Hes", 1), ("Ho", 1), ("Hrab", 1),
71 ("Hul", 1), ("Inna", 1), ("Khru", 1), ("Kreo", 1), ("Lar", 1), ("Lef", 1), ("Lo", 1),
72 ("Log", 1), ("Mak", 1), ("Mar", 1), ("Mo", 1), ("Mut", 1), ("Nag", 1), ("Nau", 1),
73 ("Nor", 1), ("Nyun", 1), ("Oo", 1), ("Quet", 1), ("Rag", 1), ("Rai", 1), ("Rath", 1),
74 ("Raz", 1), ("Ri", 1),
75 ]
76 }
77
78 #[rustfmt::skip]
79 fn syllable_fname_last() -> &'static [(&'static str, usize)] {
80 &[
81 ("ga", 3), ("red", 2), ("rog", 2), ("ka", 2), ("chan", 1), ("da", 1), ("dagh", 1),
82 ("do", 1), ("dru", 1), ("ene", 1), ("fang", 1), ("gan", 1), ("gen", 1), ("ghor", 1),
83 ("gog", 1), ("gy", 1), ("hen", 1), ("hey", 1), ("kan", 1), ("kul", 1), ("lan", 1),
84 ("larkh", 1), ("lik", 1), ("lis", 1), ("low", 1), ("luv", 1), ("ming", 1), ("mith", 1),
85 ("moel", 1), ("neire", 1), ("nig", 1), ("nir", 1), ("nos", 1), ("pal", 1), ("ra", 1),
86 ("raj", 1), ("rak", 1), ("rakt", 1), ("ram", 1), ("rash", 1), ("rath", 1), ("rell", 1),
87 ("ren", 1), ("rgash", 1), ("ri", 1), ("rim", 1), ("rin", 1), ("ris", 1), ("riya", 1),
88 ("rock", 1),
89 ]
90 }
91
92 #[rustfmt::skip]
93 fn syllable_fname_middle() -> &'static [(&'static str, usize)] {
94 &[
95 ("da", 1), ("fal", 1), ("ha", 1), ("la", 1), ("lit", 1), ("mer", 1), ("ra", 1),
96 ("ro", 1), ("ry", 1), ("zi", 1),
97 ]
98 }
99
100 fn syllable_lname_count() -> &'static [(u8, usize)] {
101 &[(2, 34), (3, 8), (4, 1)]
102 }
103
104 #[rustfmt::skip]
105 fn syllable_lname_first() -> &'static [(&'static str, usize)] {
106 &[
107 ("Proud", 3), ("Death", 2), ("Il-", 2), ("Bes", 1), ("Black", 1), ("Blood", 1),
108 ("Crack", 1), ("Elven", 1), ("Eye", 1), ("Fay", 1), ("Gnarl", 1), ("Iron", 1),
109 ("Iso", 1), ("Krin", 1), ("Ma", 1), ("Mes", 1), ("Nev", 1), ("Ni", 1), ("Orc", 1),
110 ("Rar", 1), ("Ren", 1), ("Stone", 1), ("The", 1), ("Three", 1), ("Thun", 1),
111 ("Troll", 1), ("Xerk", 1), ("Zhu", 1), ("Anga", 1), ("Axe-", 1),
112 ]
113 }
114
115 #[rustfmt::skip]
116 fn syllable_lname_middle() -> &'static [(&'static str, usize)] {
117 &[
118 ("bac", 1), ("Bi", 1), ("da", 1), ("der", 1), ("fin", 1), ("gou", 1), ("ka", 1),
119 ("ny-", 1), ("sar", 1), ("sli", 1),
120 ]
121 }
122
123 #[rustfmt::skip]
124 fn syllable_lname_last() -> &'static [(&'static str, usize)] {
125 &[
126 ("fist", 5), ("claw", 2), ("khan", 2), ("cort", 1), ("ger", 1), ("gers", 1),
127 ("hand", 1), ("head", 1), ("kat", 1), ("kel", 1), ("ker", 1), ("len", 1), ("lev", 1),
128 ("lin", 1), ("mos", 1), ("ri", 1), ("rim", 1), ("roth", 1), ("sblood", 1),
129 ("shale", 1), ("spear", 1), ("stil", 1), ("ta", 1), ("ter", 1), ("the", 1),
130 ("Arrows", 1), ("ver", 1), ("bane", 1), ("blade", 1),
131 ]
132 }
133
134 fn compound_word_probability() -> f64 {
135 0.08333333333333333
136 }
137
138 #[rustfmt::skip]
139 fn word_lname_first() -> &'static [(&'static str, usize)] {
140 &[
141 ("Black", 1), ("Blood", 1), ("Crack", 1), ("Death", 1), ("Gnarl", 1), ("Iron", 1),
142 ("Orc", 1), ("Proud", 1), ("Stone", 1), ("Three", 1), ("Thunder", 1),
143 ]
144 }
145
146 #[rustfmt::skip]
147 fn word_lname_last() -> &'static [(&'static str, usize)] {
148 &[
149 ("fist", 3), ("blade", 1), ("claw", 1), ("fingers", 1), ("hand", 1), ("head", 1),
150 ("sliver", 1), ("backer", 1), ("spear", 1),
151 ]
152 }
153}
154
155impl Generate for Ethnicity {
156 fn gen_name(rng: &mut impl Rng, _age: &Age, gender: &Gender) -> String {
157 format!(
158 "{} {}",
159 Self::gen_fname_simple(rng, gender),
160 Self::gen_lname_simple(rng),
161 )
162 }
163}
164
165#[cfg(test)]
166mod test {
167 use super::*;
168 use crate::world::npc::ethnicity::{test_utils as test, Ethnicity};
169
170 use Age::Adult;
171 use Ethnicity::Orcish;
172 use Gender::{Feminine, Masculine, NonBinaryThey};
173
174 #[test]
175 fn gen_name_test() {
176 let mut rng = SmallRng::seed_from_u64(0);
177
178 assert_eq!(
179 [
180 "Harmoel Ironsarkhan",
181 "Modatusk Il-the",
182 "Yagzel Threefist",
183 "Kreolik Ironsblood",
184 "Dahkan Deathfist",
185 "Jofalrak Krinri",
186 ],
187 [
188 test::gen_name(&mut rng, Orcish, Adult, Masculine),
189 test::gen_name(&mut rng, Orcish, Adult, Masculine),
190 test::gen_name(&mut rng, Orcish, Adult, Feminine),
191 test::gen_name(&mut rng, Orcish, Adult, Feminine),
192 test::gen_name(&mut rng, Orcish, Adult, NonBinaryThey),
193 test::gen_name(&mut rng, Orcish, Adult, NonBinaryThey),
194 ],
195 );
196 }
197}