feat: add frenchTypeToEnum function to map French Pokémon types to enums
This commit is contained in:
parent
5bd3b1f18f
commit
e18863cf1c
@ -1,6 +1,31 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../models/pokemon.dart';
|
import '../models/pokemon.dart';
|
||||||
|
|
||||||
|
// Convertit un nom de type français (de l'API Tyradex) en PokemonType
|
||||||
|
PokemonType frenchTypeToEnum(String frenchType) {
|
||||||
|
const Map<String, PokemonType> 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
|
// Permet de mapper un type de Pokémon avec une couleur
|
||||||
Color typeToColor(PokemonType type) {
|
Color typeToColor(PokemonType type) {
|
||||||
Map<PokemonType, Color> typeToColor = {
|
Map<PokemonType, Color> typeToColor = {
|
||||||
@ -32,4 +57,4 @@ Color typeToColor(PokemonType type) {
|
|||||||
String formatedTypeName(PokemonType type) {
|
String formatedTypeName(PokemonType type) {
|
||||||
String typeName = type.toString().split('.').last.replaceAll('PokemonType.', '');
|
String typeName = type.toString().split('.').last.replaceAll('PokemonType.', '');
|
||||||
return typeName[0].toUpperCase() + typeName.substring(1);
|
return typeName[0].toUpperCase() + typeName.substring(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user