faker_rust/games/
minecraft.rs1use crate::base::sample;
4use crate::locale::{fetch_locale_with_context, sample_with_resolve};
5
6pub fn item() -> String {
8 fetch_locale_with_context("games.minecraft.items", "en", Some("games.minecraft"))
9 .map(|v| sample_with_resolve(&v, Some("games.minecraft")))
10 .unwrap_or_else(|| sample(FALLBACK_MINECRAFT_ITEMS).to_string())
11}
12
13pub fn block() -> String {
15 fetch_locale_with_context("games.minecraft.blocks", "en", Some("games.minecraft"))
16 .map(|v| sample_with_resolve(&v, Some("games.minecraft")))
17 .unwrap_or_else(|| sample(&["Stone", "Dirt", "Grass Block"]).to_string())
18}
19
20pub fn biome() -> String {
22 fetch_locale_with_context("games.minecraft.biome", "en", Some("games.minecraft"))
23 .map(|v| sample_with_resolve(&v, Some("games.minecraft")))
24 .unwrap_or_else(|| sample(&["Plains", "Forest", "Desert"]).to_string())
25}
26
27const FALLBACK_MINECRAFT_ITEMS: &[&str] = &[
28 "Iron Pickaxe",
29 "Diamond Sword",
30 "Apple",
31 "Torch",
32 "Crafting Table",
33];
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn test_item() {
41 assert!(!item().is_empty());
42 }
43}