From e18863cf1c59887dc474654db395e1dd30e6c1e8 Mon Sep 17 00:00:00 2001 From: Maxiwere45 Date: Tue, 3 Feb 2026 09:47:21 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20add=20frenchTypeToEnum=20function=20to?= =?UTF-8?q?=20map=20French=20Pok=C3=A9mon=20types=20to=20enums?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/pokemon_type.dart | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/utils/pokemon_type.dart b/lib/utils/pokemon_type.dart index 7a27cd2..b3cf57d 100644 --- a/lib/utils/pokemon_type.dart +++ b/lib/utils/pokemon_type.dart @@ -1,6 +1,31 @@ import 'package:flutter/material.dart'; import '../models/pokemon.dart'; +// Convertit un nom de type français (de l'API Tyradex) en PokemonType +PokemonType frenchTypeToEnum(String frenchType) { + const Map frenchToEnglish = { + 'Normal': PokemonType.normal, + 'Combat': PokemonType.fighting, + 'Vol': PokemonType.flying, + 'Poison': PokemonType.poison, + 'Sol': PokemonType.ground, + 'Roche': PokemonType.rock, + 'Insecte': PokemonType.bug, + 'Spectre': PokemonType.ghost, + 'Acier': PokemonType.steel, + 'Feu': PokemonType.fire, + 'Eau': PokemonType.water, + 'Plante': PokemonType.grass, + 'Électrik': PokemonType.electric, + 'Psy': PokemonType.psychic, + 'Glace': PokemonType.ice, + 'Dragon': PokemonType.dragon, + 'Ténèbres': PokemonType.dark, + 'Fée': PokemonType.fairy, + }; + return frenchToEnglish[frenchType] ?? PokemonType.unknown; +} + // Permet de mapper un type de Pokémon avec une couleur Color typeToColor(PokemonType type) { Map typeToColor = { @@ -32,4 +57,4 @@ Color typeToColor(PokemonType type) { String formatedTypeName(PokemonType type) { String typeName = type.toString().split('.').last.replaceAll('PokemonType.', ''); return typeName[0].toUpperCase() + typeName.substring(1); -} \ No newline at end of file +}