From 8ca6405bc083d91e80a6f686fae1ebadde0207bc Mon Sep 17 00:00:00 2001 From: Maxiwere45 Date: Tue, 9 Jun 2026 10:56:59 +0200 Subject: [PATCH] feat(domain): add pure Pokemon entity and PokemonType enum Co-Authored-By: Claude Opus 4.8 --- lib/domain/entities/pokemon.dart | 71 ++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lib/domain/entities/pokemon.dart diff --git a/lib/domain/entities/pokemon.dart b/lib/domain/entities/pokemon.dart new file mode 100644 index 0000000..eb73c79 --- /dev/null +++ b/lib/domain/entities/pokemon.dart @@ -0,0 +1,71 @@ +/// Entité métier représentant un Pokémon. Pure : aucun import Flutter / DB / API. +class Pokemon { + final String name; + final int id; + final PokemonType type1; + final PokemonType? type2; + final int hp; + final int atk; + final int def; + final int spd; + final String? description; + final bool isCaught; + final bool isSeen; + + const Pokemon({ + required this.name, + required this.id, + required this.type1, + this.type2, + required this.hp, + required this.atk, + required this.def, + required this.spd, + this.description, + this.isCaught = false, + this.isSeen = false, + }); + + String get imageUrl => + 'https://raw.githubusercontent.com/Yarkis01/TyraDex/images/sprites/$id/regular.png'; + String get shinyImageUrl => + 'https://raw.githubusercontent.com/Yarkis01/TyraDex/images/sprites/$id/shiny.png'; + String get cryUrl => 'https://pokemoncries.com/cries/$id.mp3'; + + String get formatedName => + name.isEmpty ? name : name[0].toUpperCase() + name.substring(1); + + Pokemon copyWith({ + String? name, + int? id, + PokemonType? type1, + PokemonType? type2, + int? hp, + int? atk, + int? def, + int? spd, + String? description, + bool? isCaught, + bool? isSeen, + }) { + return Pokemon( + name: name ?? this.name, + id: id ?? this.id, + type1: type1 ?? this.type1, + type2: type2 ?? this.type2, + hp: hp ?? this.hp, + atk: atk ?? this.atk, + def: def ?? this.def, + spd: spd ?? this.spd, + description: description ?? this.description, + isCaught: isCaught ?? this.isCaught, + isSeen: isSeen ?? this.isSeen, + ); + } +} + +/// Les différents types de Pokémon. +enum PokemonType { + normal, fighting, flying, poison, ground, rock, bug, ghost, steel, fire, + water, grass, electric, psychic, ice, dragon, dark, fairy, unknown, shadow +}