use crate::base::sample;
use crate::locale::fetch_locale;
pub fn hero() -> String {
fetch_locale("dota.hero", "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "Anti-Mage".to_string())
}
pub fn item() -> String {
fetch_locale("dota.item", "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "Blink Dagger".to_string())
}
pub fn team() -> String {
fetch_locale("dota.team", "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "OG".to_string())
}
pub fn player() -> String {
fetch_locale("dota.player", "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "N0tail".to_string())
}
pub fn building() -> String {
fetch_locale("dota.building", "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "Ancient".to_string())
}
pub fn quote(hero_name: &str) -> String {
let key = format!("dota.{}.quote", hero_name.to_lowercase().replace(" ", "_"));
fetch_locale(&key, "en")
.map(|v| sample(&v))
.unwrap_or_else(|| "It's killing time.".to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_dota_generation() {
assert!(!hero().is_empty());
assert!(!item().is_empty());
assert!(!team().is_empty());
assert!(!player().is_empty());
assert!(!building().is_empty());
assert!(!quote("clockwerk").is_empty());
}
}