feat(domain): add pure Pokemon entity and PokemonType enum
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
8f29f3578a
commit
8ca6405bc0
71
lib/domain/entities/pokemon.dart
Normal file
71
lib/domain/entities/pokemon.dart
Normal file
@ -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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user