poke_data/types/
pokemon_type.rs1use crate::models::pokemon_type::PokemonTypeId;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Default, Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Hash)]
5#[repr(u16)]
6pub enum Type {
7 #[default]
8 None = 0,
9 Normal = 1,
10 Fighting = 2,
11 Flying = 3,
12 Poison = 4,
13 Ground = 5,
14 Rock = 6,
15 Bug = 7,
16 Ghost = 8,
17 Steel = 9,
18 Fire = 10,
19 Water = 11,
20 Grass = 12,
21 Electric = 13,
22 Psychic = 14,
23 Ice = 15,
24 Dragon = 16,
25 Dark = 17,
26 Fairy = 18,
27}
28
29impl From<PokemonTypeId> for Type {
30 fn from(value: PokemonTypeId) -> Self {
31 match value {
32 1 => Self::Normal,
33 2 => Self::Fighting,
34 3 => Self::Flying,
35 4 => Self::Poison,
36 5 => Self::Ground,
37 6 => Self::Rock,
38 7 => Self::Bug,
39 8 => Self::Ghost,
40 9 => Self::Steel,
41 10 => Self::Fire,
42 11 => Self::Water,
43 12 => Self::Grass,
44 13 => Self::Electric,
45 14 => Self::Psychic,
46 15 => Self::Ice,
47 16 => Self::Dragon,
48 17 => Self::Dark,
49 18 => Self::Fairy,
50 _ => Self::None,
51 }
52 }
53}