From 5b4981f227969ebcd560131082d27252e5e448d7 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Fri, 25 Oct 2019 19:24:08 -0700 Subject: [PATCH] adding tier enum --- src/consts/mod.rs | 3 +++ src/consts/tier.rs | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/consts/tier.rs 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 + } +}