diff --git a/src/consts/mod.rs b/src/consts/mod.rs index 4793745..08ee694 100644 --- a/src/consts/mod.rs +++ b/src/consts/mod.rs @@ -20,3 +20,6 @@ pub use season::*; mod team; pub use team::*; + +mod tier; +pub use tier::*; diff --git a/src/consts/tier.rs b/src/consts/tier.rs new file mode 100644 index 0000000..e9aeaf7 --- /dev/null +++ b/src/consts/tier.rs @@ -0,0 +1,37 @@ +#![allow(deprecated)] + +use std::fmt::Debug; + +use strum_macros::{ EnumString, Display, AsRefStr }; + +#[derive(Debug, Copy, Clone)] +#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] +#[derive(EnumString, Display, AsRefStr)] +#[repr(u8)] +pub enum Tier { + #[strum(to_string="IRON")] Iron = 40, + #[strum(to_string="BRONZE")] Bronze = 60, + #[strum(to_string="SILVER")] Silver = 80, + #[strum(to_string="GOLD")] Gold = 100, + #[strum(to_string="PLATINUM")] Platinum = 120, + #[strum(to_string="DIAMOND")] Diamond = 140, + #[strum(to_string="MASTER")] Master = 200, + #[strum(to_string="GRANDMASTER")] Grandmaster = 220, + #[strum(to_string="CHALLENGER")] Challenger = 240, +} + +impl Tier { + /// If this tier is "standard". + /// Standard means non-apex (not master+), and not unranked. + /// + /// Only these tiers are queryable by LeagueV4Endpoints::get_league_entries(...). + pub fn is_standard_tier(self) -> bool { + self < Self::Master + } + + /// If this tier is an apex tier. + /// Master and above. + pub fn is_apex_tier(self) -> bool { + Self::Master <= self + } +}