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, 11), (3, 7), (4, 1)]
9 }
10
11 #[rustfmt::skip]
12 fn syllable_fname_first_f() -> &'static [(&'static str, usize)] {
13 &[
14 ("Alfi", 1), ("Bry", 1), ("Ha", 1), ("He", 1), ("Ka", 1), ("Lo", 1), ("Mac", 1),
15 ("Nar", 1), ("Nee", 1), ("Ny", 1), ("Ora", 1), ("Rae", 1), ("Sfe", 1), ("Syl", 1),
16 ("Te", 1), ("Va", 1), ("Xal", 1),
17 ]
18 }
19
20 #[rustfmt::skip]
21 fn syllable_fname_last_f() -> &'static [(&'static str, usize)] {
22 &[
23 ("na", 2), ("ra", 2), ("fer", 1), ("la", 1), ("lar", 1), ("leen", 1), ("lia", 1),
24 ("lis", 1), ("nosh", 1), ("sa", 1), ("seis", 1), ("shka", 1), ("cath", 1), ("vyre", 1),
25 ("del", 1),
26 ]
27 }
28
29 fn syllable_fname_count_m() -> &'static [(u8, usize)] {
30 &[(2, 18), (3, 2)]
31 }
32
33 #[rustfmt::skip]
34 fn syllable_fname_first_m() -> &'static [(&'static str, usize)] {
35 &[
36 ("Bil", 1), ("Da", 1), ("Go", 1), ("Haer'", 1), ("Her", 1), ("Ia", 1), ("Ka", 1),
37 ("Kad", 1), ("Ma", 1), ("Mor", 1), ("No", 1), ("Pyn", 1), ("Ral", 1), ("Squid", 1),
38 ("Va", 1), ("Vi", 1), ("Zev", 1),
39 ]
40 }
41
42 #[rustfmt::skip]
43 fn syllable_fname_last_m() -> &'static [(&'static str, usize)] {
44 &[
45 ("roth", 2), ("dai", 1), ("dly", 1), ("dos", 1), ("kos", 1), ("len", 1), ("lio", 1),
46 ("lis", 1), ("lor", 1), ("mam", 1), ("mays", 1), ("non", 1), ("rim", 1), ("tuor", 1),
47 ("chorn", 1), ("zgo", 1),
48 ]
49 }
50
51 fn syllable_fname_count() -> &'static [(u8, usize)] {
52 &[(2, 31), (3, 10), (4, 1)]
53 }
54
55 #[rustfmt::skip]
56 fn syllable_fname_first() -> &'static [(&'static str, usize)] {
57 &[
58 ("Va", 2), ("Ka", 2), ("Bry", 1), ("Da", 1), ("Go", 1), ("Ha", 1), ("Haer'", 1),
59 ("He", 1), ("Her", 1), ("Ia", 1), ("Jer", 1), ("Kad", 1), ("Lo", 1), ("Ma", 1),
60 ("Mac", 1), ("Mor", 1), ("Nar", 1), ("Nee", 1), ("No", 1), ("Ny", 1), ("Ora", 1),
61 ("Par", 1), ("Pyn", 1), ("Rae", 1), ("Ral", 1), ("Sfe", 1), ("Squid", 1), ("Syl", 1),
62 ("Te", 1), ("Vi", 1), ("Xal", 1), ("Alfi", 1), ("Zev", 1), ("Bil", 1),
63 ]
64 }
65
66 #[rustfmt::skip]
67 fn syllable_fname_last() -> &'static [(&'static str, usize)] {
68 &[
69 ("lis", 2), ("roth", 2), ("na", 2), ("ra", 2), ("del", 1), ("der", 1), ("dly", 1),
70 ("dos", 1), ("fer", 1), ("kos", 1), ("la", 1), ("lar", 1), ("leen", 1), ("len", 1),
71 ("lia", 1), ("lio", 1), ("lor", 1), ("mam", 1), ("mays", 1), ("non", 1), ("nosh", 1),
72 ("rim", 1), ("sa", 1), ("seis", 1), ("shka", 1), ("tuor", 1), ("vyre", 1), ("bid", 1),
73 ("zgo", 1), ("cath", 1), ("chorn", 1), ("dai", 1),
74 ]
75 }
76
77 #[rustfmt::skip]
78 fn syllable_fname_middle() -> &'static [(&'static str, usize)] {
79 &[
80 ("ra", 2), ("vi", 2), ("lia", 1), ("man", 1), ("mes", 1), ("Da", 1), ("phe", 1),
81 ("ris", 1), ("ni", 1), ("dan", 1),
82 ]
83 }
84
85 fn syllable_lname_count() -> &'static [(u8, usize)] {
86 &[(2, 14), (3, 3)]
87 }
88
89 #[rustfmt::skip]
90 fn syllable_lname_first() -> &'static [(&'static str, usize)] {
91 &[
92 ("Aleg", 1), ("de", 1), ("Gul", 1), ("Imp", 1), ("Ka", 1), ("Rii", 1), ("Sa", 1),
93 ("Sha", 1), ("Vroc", 1),
94 ]
95 }
96
97 #[rustfmt::skip]
98 fn syllable_lname_middle() -> &'static [(&'static str, usize)] {
99 &[
100 ("dow", 1), ("kis", 1), ("vi", 1),
101 ]
102 }
103
104 #[rustfmt::skip]
105 fn syllable_lname_last() -> &'static [(&'static str, usize)] {
106 &[
107 ("breath", 1), ("kas", 1), ("kith", 1), ("kwing", 1), ("maern", 1), ("ni", 1),
108 ("tos", 1), ("Vore", 1), ("zar", 1),
109 ]
110 }
111
112 fn compound_word_probability() -> f64 {
113 0.
114 }
115
116 fn word_lname_first() -> &'static [(&'static str, usize)] {
117 &[]
118 }
119
120 fn word_lname_last() -> &'static [(&'static str, usize)] {
121 &[]
122 }
123}
124
125impl Generate for Ethnicity {
126 fn gen_name(rng: &mut impl Rng, _age: &Age, gender: &Gender) -> String {
127 format!(
128 "{} {}",
129 Self::gen_fname_simple(rng, gender),
130 Self::gen_lname_simple(rng),
131 )
132 }
133}
134
135#[cfg(test)]
136mod test {
137 use super::*;
138 use crate::world::npc::ethnicity::{test_utils as test, Ethnicity};
139
140 use Age::{Adolescent, Adult, Child, Infant, YoungAdult};
141 use Ethnicity::Tiefling;
142 use Gender::{Feminine, Masculine, NonBinaryThey};
143
144 #[test]
145 fn gen_name_test() {
146 let mut rng = SmallRng::seed_from_u64(0);
147
148 assert_eq!(
149 [
150 "Vidandos Shatos",
151 "Hevivyre Alegkwing",
152 "Bilmays Katos",
153 "Narra demaern",
154 "Matuor Shazar",
155 "Norislor Gulkwing",
156 "Tefer Shavitos",
157 "Orara deVore",
158 "Zevlia Sazar",
159 "Goroth Alegtos",
160 ],
161 [
162 test::gen_name(&mut rng, Tiefling, Infant, Masculine),
163 test::gen_name(&mut rng, Tiefling, Child, Feminine),
164 test::gen_name(&mut rng, Tiefling, Adolescent, Masculine),
165 test::gen_name(&mut rng, Tiefling, YoungAdult, Feminine),
166 test::gen_name(&mut rng, Tiefling, Adult, Masculine),
167 test::gen_name(&mut rng, Tiefling, Adult, Masculine),
168 test::gen_name(&mut rng, Tiefling, Adult, Feminine),
169 test::gen_name(&mut rng, Tiefling, Adult, Feminine),
170 test::gen_name(&mut rng, Tiefling, Adult, NonBinaryThey),
171 test::gen_name(&mut rng, Tiefling, Adult, NonBinaryThey),
172 ],
173 );
174 }
175}