Skip to main content

faker_rust/games/
witcher.rs

1//! The Witcher game generator
2
3use crate::base::sample;
4use crate::locale::fetch_locale;
5
6/// Generate a random Witcher character
7pub fn character() -> String {
8    fetch_locale("witcher.characters", "en")
9        .map(|v| sample(&v))
10        .unwrap_or_else(|| sample(FALLBACK_CHARACTERS).to_string())
11}
12
13/// Generate a random Witcher location
14pub fn location() -> String {
15    fetch_locale("witcher.locations", "en")
16        .map(|v| sample(&v))
17        .unwrap_or_else(|| sample(FALLBACK_LOCATIONS).to_string())
18}
19
20/// Generate a random Witcher monster
21pub fn monster() -> String {
22    fetch_locale("witcher.monsters", "en")
23        .map(|v| sample(&v))
24        .unwrap_or_else(|| sample(FALLBACK_MONSTERS).to_string())
25}
26
27/// Generate a random Witcher school
28pub fn school() -> String {
29    fetch_locale("witcher.schools", "en")
30        .map(|v| sample(&v))
31        .unwrap_or_else(|| sample(FALLBACK_SCHOOLS).to_string())
32}
33
34/// Generate a random Witcher quote
35pub fn quote() -> String {
36    fetch_locale("witcher.quotes", "en")
37        .map(|v| sample(&v))
38        .unwrap_or_else(|| sample(FALLBACK_QUOTES).to_string())
39}
40
41// Fallback data
42const FALLBACK_CHARACTERS: &[&str] = &[
43    "Geralt of Rivia",
44    "Yennefer of Vengerberg",
45    "Ciri",
46    "Triss Merigold",
47    "Dandelion",
48    "Vesemir",
49    "Zoltan Chivay",
50    "Regis",
51    "Milva",
52    "Cahir",
53    "Angouleme",
54    "Emhyr var Emreis",
55    "Foltest",
56    "Radovid V",
57    "Vernon Roche",
58    "Iorveth",
59    "Philippa Eilhart",
60    "Francesca Findabair",
61    "Eredin Breacc Glas",
62    "Avallac'h",
63    "Keira Metz",
64    "Lambert",
65    "Eskel",
66    "Letho",
67    "Gaunter O'Dimm",
68    "Olgierd von Everec",
69    "Dettlaff van der Eretein",
70    "Sylvia Anna",
71];
72
73const FALLBACK_LOCATIONS: &[&str] = &[
74    "Kaer Morhen",
75    "Novigrad",
76    "Oxenfurt",
77    "Vizima",
78    "Velen",
79    "Skellige",
80    "Toussaint",
81    "Beauclair",
82    "White Orchard",
83    "Flotsam",
84    "Vergen",
85    "Loc Muinne",
86    "Nilfgaard",
87    "Redania",
88    "Temeria",
89    "Aedirn",
90    "Lyria",
91    "Rivia",
92    "Kovir",
93    "Poviss",
94    "Mahakam",
95    "Brokilon",
96    "Thanedd Island",
97];
98
99const FALLBACK_MONSTERS: &[&str] = &[
100    "Drowner",
101    "Nekker",
102    "Ghoul",
103    "Alghoul",
104    "Graveir",
105    "Foglet",
106    "Water Hag",
107    "Griffin",
108    "Cockatrice",
109    "Basilisk",
110    "Wyvern",
111    "Forktail",
112    "Royal Wyvern",
113    "Fiend",
114    "Chort",
115    "Bies",
116    "Leshen",
117    "Leshy",
118    "Kikimore",
119    "Endrega",
120    "Arachas",
121    "Giant Spider",
122    "Wraith",
123    "Noonwraith",
124    "Nightwraith",
125    "Barghest",
126    "Devourer",
127    "Rotfiend",
128    "Scavenger",
129    "Werewolf",
130    "Ulfhedinn",
131    "Fleder",
132    "Garkain",
133    "Katakan",
134    "Ekimma",
135    "Bruxa",
136    "Alp",
137    "Troll",
138    "Ice Troll",
139    "Cyclops",
140    "Golem",
141    "Elemental",
142    "Gargoyle",
143    "Relict",
144    "Necrophage",
145    "Ogroid",
146    "Specter",
147    "Vampire",
148    "Cursed One",
149    "Draconid",
150    "Hybrid",
151    "Insectoid",
152    "Beast",
153];
154
155const FALLBACK_SCHOOLS: &[&str] = &[
156    "Wolf School",
157    "Cat School",
158    "Bear School",
159    "Griffin School",
160    "Viper School",
161    "Manticore School",
162];
163
164const FALLBACK_QUOTES: &[&str] = &[
165    "Wind's howling.",
166    "Damn, a storm.",
167    "Place of power, gotta be.",
168    " medallion's humming.",
169    "How about a round of Gwent?",
170    "Toss a coin to your Witcher.",
171    "I am the butcher of Blaviken.",
172    "Evil is evil. Lesser, greater, middling... Makes no difference.",
173    "The world doesn't need a hero. It needs a professional.",
174];
175
176#[cfg(test)]
177mod tests {
178    use super::*;
179
180    #[test]
181    fn test_character() {
182        assert!(!character().is_empty());
183    }
184
185    #[test]
186    fn test_location() {
187        assert!(!location().is_empty());
188    }
189
190    #[test]
191    fn test_monster() {
192        assert!(!monster().is_empty());
193    }
194
195    #[test]
196    fn test_school() {
197        assert!(!school().is_empty());
198    }
199
200    #[test]
201    fn test_quote() {
202        assert!(!quote().is_empty());
203    }
204}