You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.9 KiB

from .data import pokemon_generations, main_line_games
import unicodedata
def format_pokemon_id(national_dex: int, region_code: int, form_index: int, gender_code: int) -> str:
return f"{national_dex:04d}-{region_code:02d}-{form_index:03d}-{gender_code}"
def compare_pokemon_forms(a, b):
if a == None or b == None:
return False
if a == b:
return True
temp_a = a.lower().replace("forme", "").replace("form", "").replace("é", "e").strip()
temp_b = b.lower().replace("forme", "").replace("form", "").replace("é", "e").strip()
# Common spelling mistakes
temp_a = temp_a.replace("deputante", "debutante").replace("p'au", "pa'u").replace("blood moon", "bloodmoon")
temp_b = temp_b.replace("deputante", "debutante").replace("p'au", "pa'u").replace("blood moon", "bloodmoon")
if temp_a == temp_b:
return True
return False
def get_generation_from_national_dex(national_dex_number):
generation = 1
for gen in pokemon_generations:
if pokemon_generations[gen]["min"] <= national_dex_number <= pokemon_generations[gen]["max"]:
generation = gen
break
return generation
def sanitise_pokemon_name_for_url(pokemon_name):
pokemon_url_name = pokemon_name.replace("", "-f").replace("", "-m").replace("'", "").replace(".", "").replace('é', 'e').replace(':', '')
pokemon_url_name = pokemon_url_name.replace(" ", "-")
return pokemon_url_name
def remove_accents(input_str):
nfkd_form = unicodedata.normalize('NFKD', input_str)
return u"".join([c for c in nfkd_form if not unicodedata.combining(c)])
def find_game_generation(game_name: str) -> int:
game_name = game_name.lower()
for game in main_line_games:
if game_name == game["Name"].lower() or game_name in (name.lower() for name in game["AltNames"]):
return game["Generation"]
return None