Skip to main content

battler_data/mons/
species_flag.rs

1use serde_string_enum::{
2    DeserializeLabeledStringEnum,
3    SerializeLabeledStringEnum,
4};
5
6/// Species flags, which categorize species for miscellaneous behavior (such as bans or side
7/// effects).
8#[derive(
9    Debug, Clone, PartialEq, Eq, Hash, SerializeLabeledStringEnum, DeserializeLabeledStringEnum,
10)]
11pub enum SpeciesFlag {
12    #[string = "SubLegendary"]
13    #[alias = "Sub-Legendary"]
14    SubLegendary,
15    #[string = "RestrictedLegendary"]
16    #[alias = "Restricted Legendary"]
17    RestrictedLegendary,
18    #[string = "Mythical"]
19    Mythical,
20    #[string = "Paradox"]
21    Paradox,
22    #[string = "UltraBeast"]
23    #[alias = "Ultra Beast"]
24    UltraBeast,
25    /// Cannot be lifted with Telekinesis.
26    #[string = "NoTelekinesis"]
27    NoTelekinesis,
28}
29
30#[cfg(test)]
31mod species_flag_test {
32    use crate::{
33        SpeciesFlag,
34        test_util::{
35            test_string_deserialization,
36            test_string_serialization,
37        },
38    };
39
40    #[test]
41    fn serializes_to_string() {
42        test_string_serialization(SpeciesFlag::RestrictedLegendary, "RestrictedLegendary");
43        test_string_serialization(SpeciesFlag::Mythical, "Mythical");
44    }
45
46    #[test]
47    fn deserializes_lowercase() {
48        test_string_deserialization("restricted legendary", SpeciesFlag::RestrictedLegendary);
49        test_string_deserialization("mythical", SpeciesFlag::Mythical);
50    }
51}