All checks were successful
Build and Deploy / Build & Push Image (push) Successful in 32s
79 lines
2.4 KiB
Elixir
79 lines
2.4 KiB
Elixir
defmodule CobblemonUi.PokeApiNames do
|
|
@moduledoc """
|
|
Maps Cobblemon species names to PokeAPI-compatible names.
|
|
|
|
Cobblemon stores species names as single lowercase words (e.g. `ironthorns`),
|
|
while PokeAPI expects hyphenated forms (e.g. `iron-thorns`). This module
|
|
provides the translation layer.
|
|
"""
|
|
|
|
# Static map of Cobblemon names that differ from PokeAPI names.
|
|
# Only entries where the name doesn't match need to be listed.
|
|
@name_map %{
|
|
# Paradox Pokémon (Scarlet)
|
|
"greattusk" => "great-tusk",
|
|
"screamtail" => "scream-tail",
|
|
"brutebonnet" => "brute-bonnet",
|
|
"fluttermane" => "flutter-mane",
|
|
"sandyshocks" => "sandy-shocks",
|
|
"slitherwing" => "slither-wing",
|
|
"roaringmoon" => "roaring-moon",
|
|
"walkingwake" => "walking-wake",
|
|
"gougingfire" => "gouging-fire",
|
|
"ragingbolt" => "raging-bolt",
|
|
# Paradox Pokémon (Violet)
|
|
"irontreads" => "iron-treads",
|
|
"ironbundle" => "iron-bundle",
|
|
"ironhands" => "iron-hands",
|
|
"ironjugulis" => "iron-jugulis",
|
|
"ironmoth" => "iron-moth",
|
|
"ironvaliant" => "iron-valiant",
|
|
"ironthorns" => "iron-thorns",
|
|
"ironleaves" => "iron-leaves",
|
|
"ironcrown" => "iron-crown",
|
|
"ironboulder" => "iron-boulder",
|
|
# Tapu guardians
|
|
"tapukoko" => "tapu-koko",
|
|
"tapulele" => "tapu-lele",
|
|
"tapubulu" => "tapu-bulu",
|
|
"tapufini" => "tapu-fini",
|
|
# Hyphenated / special names
|
|
"hooh" => "ho-oh",
|
|
"porygonz" => "porygon-z",
|
|
"typenull" => "type-null",
|
|
"mrmime" => "mr-mime",
|
|
"mrrime" => "mr-rime",
|
|
"mimejr" => "mime-jr",
|
|
"jangmoo" => "jangmo-o",
|
|
"hakamoo" => "hakamo-o",
|
|
"kommoo" => "kommo-o",
|
|
"chiyu" => "chi-yu",
|
|
"chienpao" => "chien-pao",
|
|
"tinglu" => "ting-lu",
|
|
"wochien" => "wo-chien",
|
|
"nidoranf" => "nidoran-f",
|
|
"nidoranm" => "nidoran-m",
|
|
"farfetchd" => "farfetchd",
|
|
"sirfetchd" => "sirfetchd",
|
|
# Flabébé line
|
|
"flabebe" => "flabebe"
|
|
}
|
|
|
|
@doc """
|
|
Converts a Cobblemon species name to the PokeAPI-compatible name.
|
|
|
|
## Examples
|
|
|
|
iex> CobblemonUi.PokeApiNames.normalize("ironthorns")
|
|
"iron-thorns"
|
|
|
|
iex> CobblemonUi.PokeApiNames.normalize("bulbasaur")
|
|
"bulbasaur"
|
|
"""
|
|
@spec normalize(String.t()) :: String.t()
|
|
def normalize(species) when is_binary(species) do
|
|
key = species |> String.downcase() |> String.trim()
|
|
Map.get(@name_map, key, key)
|
|
end
|
|
end
|