Update champion, enums, and srcgen docs

This commit is contained in:
Mingwei Samuel 2019-11-03 10:36:51 -08:00
parent a074b5ebed
commit f2e70246bf
12 changed files with 385 additions and 561 deletions

View file

@ -16,14 +16,22 @@ pub struct RiotApiConfig {
} }
impl RiotApiConfig { impl RiotApiConfig {
/// `0.99` - `burst_pct` used by `preconfig_burst` (and default `with_key`). /// `0.99`
///
/// `burst_pct` used by `preconfig_burst` (and default `with_key`).
pub const PRECONFIG_BURST_BURST_PCT: f32 = 0.99; pub const PRECONFIG_BURST_BURST_PCT: f32 = 0.99;
/// `989` ms - `duration_overhead` used by `preconfig_burst` (and default `with_key`). /// `989` ms
///
/// `duration_overhead` used by `preconfig_burst` (and default `with_key`).
pub const PRECONFIG_BURST_DURATION_OVERHEAD_MILLIS: u64 = 989; pub const PRECONFIG_BURST_DURATION_OVERHEAD_MILLIS: u64 = 989;
/// `0.47` - `burst_pct` used by `preconfig_throughput`. /// `0.47`
///
/// `burst_pct` used by `preconfig_throughput`.
pub const PRECONFIG_THROUGHPUT_BURST_PCT: f32 = 0.47; pub const PRECONFIG_THROUGHPUT_BURST_PCT: f32 = 0.47;
// `10` ms - `duration_overhead` used by `preconfig_throughput`. /// `10` ms.
///
/// `duration_overhead` used by `preconfig_throughput`.
pub const PRECONFIG_THROUGHPUT_DURATION_OVERHEAD_MILLIS: u64 = 10; pub const PRECONFIG_THROUGHPUT_DURATION_OVERHEAD_MILLIS: u64 = 10;
/// Creates a new `RiotApiConfig` with the given `api_key` with the following /// Creates a new `RiotApiConfig` with the given `api_key` with the following

View file

@ -6,9 +6,9 @@
// // // //
/////////////////////////////////////////////// ///////////////////////////////////////////////
use std::fmt;
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde_repr::{ Serialize_repr, Deserialize_repr }; use serde_repr::{ Serialize_repr, Deserialize_repr };
use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legend's champions. /// League of Legend's champions.
/// ///
@ -18,315 +18,333 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(IntoPrimitive, TryFromPrimitive)] #[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(i16)] #[repr(i16)]
pub enum Champion { pub enum Champion {
/// A champion that doesn't exist. Used in TeamBans when no ban occured. /// A champion that doesn't exist. Used in TeamBans when no champion was banned.
///
/// None (`NONE`, -1).
None = -1, None = -1,
/** Aatrox (`Aatrox`, 266). */ Aatrox = 266, /// Aatrox (`Aatrox`, 266).
/** Ahri (`Ahri`, 103). */ Ahri = 103, #[strum(to_string="Aatrox", serialize="Aatrox")] Aatrox = 266,
/** Akali (`Akali`, 84). */ Akali = 84, /// Ahri (`Ahri`, 103).
/** Alistar (`Alistar`, 12). */ Alistar = 12, #[strum(to_string="Ahri", serialize="Ahri")] Ahri = 103,
/** Amumu (`Amumu`, 32). */ Amumu = 32, /// Akali (`Akali`, 84).
/** Anivia (`Anivia`, 34). */ Anivia = 34, #[strum(to_string="Akali", serialize="Akali")] Akali = 84,
/** Annie (`Annie`, 1). */ Annie = 1, /// Alistar (`Alistar`, 12).
/** Ashe (`Ashe`, 22). */ Ashe = 22, #[strum(to_string="Alistar", serialize="Alistar")] Alistar = 12,
/** Aurelion Sol (`AurelionSol`, 136). */ AurelionSol = 136, /// Amumu (`Amumu`, 32).
/** Azir (`Azir`, 268). */ Azir = 268, #[strum(to_string="Amumu", serialize="Amumu")] Amumu = 32,
/** Bard (`Bard`, 432). */ Bard = 432, /// Anivia (`Anivia`, 34).
/** Blitzcrank (`Blitzcrank`, 53). */ Blitzcrank = 53, #[strum(to_string="Anivia", serialize="Anivia")] Anivia = 34,
/** Brand (`Brand`, 63). */ Brand = 63, /// Annie (`Annie`, 1).
/** Braum (`Braum`, 201). */ Braum = 201, #[strum(to_string="Annie", serialize="Annie")] Annie = 1,
/** Caitlyn (`Caitlyn`, 51). */ Caitlyn = 51, /// Ashe (`Ashe`, 22).
/** Camille (`Camille`, 164). */ Camille = 164, #[strum(to_string="Ashe", serialize="Ashe")] Ashe = 22,
/** Cassiopeia (`Cassiopeia`, 69). */ Cassiopeia = 69, /// Aurelion Sol (`AurelionSol`, 136).
/** Cho'Gath (`Chogath`, 31). */ ChoGath = 31, #[strum(to_string="Aurelion Sol", serialize="AurelionSol")] AurelionSol = 136,
/** Corki (`Corki`, 42). */ Corki = 42, /// Azir (`Azir`, 268).
/** Darius (`Darius`, 122). */ Darius = 122, #[strum(to_string="Azir", serialize="Azir")] Azir = 268,
/** Diana (`Diana`, 131). */ Diana = 131, /// Bard (`Bard`, 432).
/** Dr. Mundo (`DrMundo`, 36). */ DrMundo = 36, #[strum(to_string="Bard", serialize="Bard")] Bard = 432,
/** Draven (`Draven`, 119). */ Draven = 119, /// Blitzcrank (`Blitzcrank`, 53).
/** Ekko (`Ekko`, 245). */ Ekko = 245, #[strum(to_string="Blitzcrank", serialize="Blitzcrank")] Blitzcrank = 53,
/** Elise (`Elise`, 60). */ Elise = 60, /// Brand (`Brand`, 63).
/** Evelynn (`Evelynn`, 28). */ Evelynn = 28, #[strum(to_string="Brand", serialize="Brand")] Brand = 63,
/** Ezreal (`Ezreal`, 81). */ Ezreal = 81, /// Braum (`Braum`, 201).
/** Fiddlesticks (`FiddleSticks`, 9). */ Fiddlesticks = 9, #[strum(to_string="Braum", serialize="Braum")] Braum = 201,
/** Fiora (`Fiora`, 114). */ Fiora = 114, /// Caitlyn (`Caitlyn`, 51).
/** Fizz (`Fizz`, 105). */ Fizz = 105, #[strum(to_string="Caitlyn", serialize="Caitlyn")] Caitlyn = 51,
/** Galio (`Galio`, 3). */ Galio = 3, /// Camille (`Camille`, 164).
/** Gangplank (`Gangplank`, 41). */ Gangplank = 41, #[strum(to_string="Camille", serialize="Camille")] Camille = 164,
/** Garen (`Garen`, 86). */ Garen = 86, /// Cassiopeia (`Cassiopeia`, 69).
/** Gnar (`Gnar`, 150). */ Gnar = 150, #[strum(to_string="Cassiopeia", serialize="Cassiopeia")] Cassiopeia = 69,
/** Gragas (`Gragas`, 79). */ Gragas = 79, /// Cho'Gath (`Chogath`, 31).
/** Graves (`Graves`, 104). */ Graves = 104, #[strum(to_string="Cho'Gath", serialize="Chogath")] ChoGath = 31,
/** Hecarim (`Hecarim`, 120). */ Hecarim = 120, /// Corki (`Corki`, 42).
/** Heimerdinger (`Heimerdinger`, 74). */ Heimerdinger = 74, #[strum(to_string="Corki", serialize="Corki")] Corki = 42,
/** Illaoi (`Illaoi`, 420). */ Illaoi = 420, /// Darius (`Darius`, 122).
/** Irelia (`Irelia`, 39). */ Irelia = 39, #[strum(to_string="Darius", serialize="Darius")] Darius = 122,
/** Ivern (`Ivern`, 427). */ Ivern = 427, /// Diana (`Diana`, 131).
/** Janna (`Janna`, 40). */ Janna = 40, #[strum(to_string="Diana", serialize="Diana")] Diana = 131,
/** Jarvan IV (`JarvanIV`, 59). */ JarvanIV = 59, /// Dr. Mundo (`DrMundo`, 36).
/** Jax (`Jax`, 24). */ Jax = 24, #[strum(to_string="Dr. Mundo", serialize="DrMundo")] DrMundo = 36,
/** Jayce (`Jayce`, 126). */ Jayce = 126, /// Draven (`Draven`, 119).
/** Jhin (`Jhin`, 202). */ Jhin = 202, #[strum(to_string="Draven", serialize="Draven")] Draven = 119,
/** Jinx (`Jinx`, 222). */ Jinx = 222, /// Ekko (`Ekko`, 245).
/** Kai'Sa (`Kaisa`, 145). */ KaiSa = 145, #[strum(to_string="Ekko", serialize="Ekko")] Ekko = 245,
/** Kalista (`Kalista`, 429). */ Kalista = 429, /// Elise (`Elise`, 60).
/** Karma (`Karma`, 43). */ Karma = 43, #[strum(to_string="Elise", serialize="Elise")] Elise = 60,
/** Karthus (`Karthus`, 30). */ Karthus = 30, /// Evelynn (`Evelynn`, 28).
/** Kassadin (`Kassadin`, 38). */ Kassadin = 38, #[strum(to_string="Evelynn", serialize="Evelynn")] Evelynn = 28,
/** Katarina (`Katarina`, 55). */ Katarina = 55, /// Ezreal (`Ezreal`, 81).
/** Kayle (`Kayle`, 10). */ Kayle = 10, #[strum(to_string="Ezreal", serialize="Ezreal")] Ezreal = 81,
/** Kayn (`Kayn`, 141). */ Kayn = 141, /// Fiddlesticks (`FiddleSticks`, 9).
/** Kennen (`Kennen`, 85). */ Kennen = 85, #[strum(to_string="Fiddlesticks", serialize="FiddleSticks")] Fiddlesticks = 9,
/** Kha'Zix (`Khazix`, 121). */ KhaZix = 121, /// Fiora (`Fiora`, 114).
/** Kindred (`Kindred`, 203). */ Kindred = 203, #[strum(to_string="Fiora", serialize="Fiora")] Fiora = 114,
/** Kled (`Kled`, 240). */ Kled = 240, /// Fizz (`Fizz`, 105).
/** Kog'Maw (`KogMaw`, 96). */ KogMaw = 96, #[strum(to_string="Fizz", serialize="Fizz")] Fizz = 105,
/** LeBlanc (`Leblanc`, 7). */ LeBlanc = 7, /// Galio (`Galio`, 3).
/** Lee Sin (`LeeSin`, 64). */ LeeSin = 64, #[strum(to_string="Galio", serialize="Galio")] Galio = 3,
/** Leona (`Leona`, 89). */ Leona = 89, /// Gangplank (`Gangplank`, 41).
/** Lissandra (`Lissandra`, 127). */ Lissandra = 127, #[strum(to_string="Gangplank", serialize="Gangplank")] Gangplank = 41,
/** Lucian (`Lucian`, 236). */ Lucian = 236, /// Garen (`Garen`, 86).
/** Lulu (`Lulu`, 117). */ Lulu = 117, #[strum(to_string="Garen", serialize="Garen")] Garen = 86,
/** Lux (`Lux`, 99). */ Lux = 99, /// Gnar (`Gnar`, 150).
/** Malphite (`Malphite`, 54). */ Malphite = 54, #[strum(to_string="Gnar", serialize="Gnar")] Gnar = 150,
/** Malzahar (`Malzahar`, 90). */ Malzahar = 90, /// Gragas (`Gragas`, 79).
/** Maokai (`Maokai`, 57). */ Maokai = 57, #[strum(to_string="Gragas", serialize="Gragas")] Gragas = 79,
/** Master Yi (`MasterYi`, 11). */ MasterYi = 11, /// Graves (`Graves`, 104).
/** Miss Fortune (`MissFortune`, 21). */ MissFortune = 21, #[strum(to_string="Graves", serialize="Graves")] Graves = 104,
/** Mordekaiser (`Mordekaiser`, 82). */ Mordekaiser = 82, /// Hecarim (`Hecarim`, 120).
/** Morgana (`Morgana`, 25). */ Morgana = 25, #[strum(to_string="Hecarim", serialize="Hecarim")] Hecarim = 120,
/** Nami (`Nami`, 267). */ Nami = 267, /// Heimerdinger (`Heimerdinger`, 74).
/** Nasus (`Nasus`, 75). */ Nasus = 75, #[strum(to_string="Heimerdinger", serialize="Heimerdinger")] Heimerdinger = 74,
/** Nautilus (`Nautilus`, 111). */ Nautilus = 111, /// Illaoi (`Illaoi`, 420).
/** Neeko (`Neeko`, 518). */ Neeko = 518, #[strum(to_string="Illaoi", serialize="Illaoi")] Illaoi = 420,
/** Nidalee (`Nidalee`, 76). */ Nidalee = 76, /// Irelia (`Irelia`, 39).
/** Nocturne (`Nocturne`, 56). */ Nocturne = 56, #[strum(to_string="Irelia", serialize="Irelia")] Irelia = 39,
/** Nunu & Willump (`Nunu`, 20). */ NunuWillump = 20, /// Ivern (`Ivern`, 427).
/** Olaf (`Olaf`, 2). */ Olaf = 2, #[strum(to_string="Ivern", serialize="Ivern")] Ivern = 427,
/** Orianna (`Orianna`, 61). */ Orianna = 61, /// Janna (`Janna`, 40).
/** Ornn (`Ornn`, 516). */ Ornn = 516, #[strum(to_string="Janna", serialize="Janna")] Janna = 40,
/** Pantheon (`Pantheon`, 80). */ Pantheon = 80, /// Jarvan IV (`JarvanIV`, 59).
/** Poppy (`Poppy`, 78). */ Poppy = 78, #[strum(to_string="Jarvan IV", serialize="JarvanIV")] JarvanIV = 59,
/** Pyke (`Pyke`, 555). */ Pyke = 555, /// Jax (`Jax`, 24).
/** Qiyana (`Qiyana`, 246). */ Qiyana = 246, #[strum(to_string="Jax", serialize="Jax")] Jax = 24,
/** Quinn (`Quinn`, 133). */ Quinn = 133, /// Jayce (`Jayce`, 126).
/** Rakan (`Rakan`, 497). */ Rakan = 497, #[strum(to_string="Jayce", serialize="Jayce")] Jayce = 126,
/** Rammus (`Rammus`, 33). */ Rammus = 33, /// Jhin (`Jhin`, 202).
/** Rek'Sai (`RekSai`, 421). */ RekSai = 421, #[strum(to_string="Jhin", serialize="Jhin")] Jhin = 202,
/** Renekton (`Renekton`, 58). */ Renekton = 58, /// Jinx (`Jinx`, 222).
/** Rengar (`Rengar`, 107). */ Rengar = 107, #[strum(to_string="Jinx", serialize="Jinx")] Jinx = 222,
/** Riven (`Riven`, 92). */ Riven = 92, /// Kai'Sa (`Kaisa`, 145).
/** Rumble (`Rumble`, 68). */ Rumble = 68, #[strum(to_string="Kai'Sa", serialize="Kaisa")] KaiSa = 145,
/** Ryze (`Ryze`, 13). */ Ryze = 13, /// Kalista (`Kalista`, 429).
/** Sejuani (`Sejuani`, 113). */ Sejuani = 113, #[strum(to_string="Kalista", serialize="Kalista")] Kalista = 429,
/** Senna (`Senna`, 235). */ Senna = 235, /// Karma (`Karma`, 43).
/** Shaco (`Shaco`, 35). */ Shaco = 35, #[strum(to_string="Karma", serialize="Karma")] Karma = 43,
/** Shen (`Shen`, 98). */ Shen = 98, /// Karthus (`Karthus`, 30).
/** Shyvana (`Shyvana`, 102). */ Shyvana = 102, #[strum(to_string="Karthus", serialize="Karthus")] Karthus = 30,
/** Singed (`Singed`, 27). */ Singed = 27, /// Kassadin (`Kassadin`, 38).
/** Sion (`Sion`, 14). */ Sion = 14, #[strum(to_string="Kassadin", serialize="Kassadin")] Kassadin = 38,
/** Sivir (`Sivir`, 15). */ Sivir = 15, /// Katarina (`Katarina`, 55).
/** Skarner (`Skarner`, 72). */ Skarner = 72, #[strum(to_string="Katarina", serialize="Katarina")] Katarina = 55,
/** Sona (`Sona`, 37). */ Sona = 37, /// Kayle (`Kayle`, 10).
/** Soraka (`Soraka`, 16). */ Soraka = 16, #[strum(to_string="Kayle", serialize="Kayle")] Kayle = 10,
/** Swain (`Swain`, 50). */ Swain = 50, /// Kayn (`Kayn`, 141).
/** Sylas (`Sylas`, 517). */ Sylas = 517, #[strum(to_string="Kayn", serialize="Kayn")] Kayn = 141,
/** Syndra (`Syndra`, 134). */ Syndra = 134, /// Kennen (`Kennen`, 85).
/** Tahm Kench (`TahmKench`, 223). */ TahmKench = 223, #[strum(to_string="Kennen", serialize="Kennen")] Kennen = 85,
/** Taliyah (`Taliyah`, 163). */ Taliyah = 163, /// Kha'Zix (`Khazix`, 121).
/** Talon (`Talon`, 91). */ Talon = 91, #[strum(to_string="Kha'Zix", serialize="Khazix")] KhaZix = 121,
/** Taric (`Taric`, 44). */ Taric = 44, /// Kindred (`Kindred`, 203).
/** Teemo (`Teemo`, 17). */ Teemo = 17, #[strum(to_string="Kindred", serialize="Kindred")] Kindred = 203,
/** Thresh (`Thresh`, 412). */ Thresh = 412, /// Kled (`Kled`, 240).
/** Tristana (`Tristana`, 18). */ Tristana = 18, #[strum(to_string="Kled", serialize="Kled")] Kled = 240,
/** Trundle (`Trundle`, 48). */ Trundle = 48, /// Kog'Maw (`KogMaw`, 96).
/** Tryndamere (`Tryndamere`, 23). */ Tryndamere = 23, #[strum(to_string="Kog'Maw", serialize="KogMaw")] KogMaw = 96,
/** Twisted Fate (`TwistedFate`, 4). */ TwistedFate = 4, /// LeBlanc (`Leblanc`, 7).
/** Twitch (`Twitch`, 29). */ Twitch = 29, #[strum(to_string="LeBlanc", serialize="Leblanc")] LeBlanc = 7,
/** Udyr (`Udyr`, 77). */ Udyr = 77, /// Lee Sin (`LeeSin`, 64).
/** Urgot (`Urgot`, 6). */ Urgot = 6, #[strum(to_string="Lee Sin", serialize="LeeSin")] LeeSin = 64,
/** Varus (`Varus`, 110). */ Varus = 110, /// Leona (`Leona`, 89).
/** Vayne (`Vayne`, 67). */ Vayne = 67, #[strum(to_string="Leona", serialize="Leona")] Leona = 89,
/** Veigar (`Veigar`, 45). */ Veigar = 45, /// Lissandra (`Lissandra`, 127).
/** Vel'Koz (`Velkoz`, 161). */ VelKoz = 161, #[strum(to_string="Lissandra", serialize="Lissandra")] Lissandra = 127,
/** Vi (`Vi`, 254). */ Vi = 254, /// Lucian (`Lucian`, 236).
/** Viktor (`Viktor`, 112). */ Viktor = 112, #[strum(to_string="Lucian", serialize="Lucian")] Lucian = 236,
/** Vladimir (`Vladimir`, 8). */ Vladimir = 8, /// Lulu (`Lulu`, 117).
/** Volibear (`Volibear`, 106). */ Volibear = 106, #[strum(to_string="Lulu", serialize="Lulu")] Lulu = 117,
/** Warwick (`Warwick`, 19). */ Warwick = 19, /// Lux (`Lux`, 99).
/** Wukong (`MonkeyKing`, 62). */ Wukong = 62, #[strum(to_string="Lux", serialize="Lux")] Lux = 99,
/** Xayah (`Xayah`, 498). */ Xayah = 498, /// Malphite (`Malphite`, 54).
/** Xerath (`Xerath`, 101). */ Xerath = 101, #[strum(to_string="Malphite", serialize="Malphite")] Malphite = 54,
/** Xin Zhao (`XinZhao`, 5). */ XinZhao = 5, /// Malzahar (`Malzahar`, 90).
/** Yasuo (`Yasuo`, 157). */ Yasuo = 157, #[strum(to_string="Malzahar", serialize="Malzahar")] Malzahar = 90,
/** Yorick (`Yorick`, 83). */ Yorick = 83, /// Maokai (`Maokai`, 57).
/** Yuumi (`Yuumi`, 350). */ Yuumi = 350, #[strum(to_string="Maokai", serialize="Maokai")] Maokai = 57,
/** Zac (`Zac`, 154). */ Zac = 154, /// Master Yi (`MasterYi`, 11).
/** Zed (`Zed`, 238). */ Zed = 238, #[strum(to_string="Master Yi", serialize="MasterYi")] MasterYi = 11,
/** Ziggs (`Ziggs`, 115). */ Ziggs = 115, /// Miss Fortune (`MissFortune`, 21).
/** Zilean (`Zilean`, 26). */ Zilean = 26, #[strum(to_string="Miss Fortune", serialize="MissFortune")] MissFortune = 21,
/** Zoe (`Zoe`, 142). */ Zoe = 142, /// Mordekaiser (`Mordekaiser`, 82).
/** Zyra (`Zyra`, 143). */ Zyra = 143, #[strum(to_string="Mordekaiser", serialize="Mordekaiser")] Mordekaiser = 82,
/// Morgana (`Morgana`, 25).
#[strum(to_string="Morgana", serialize="Morgana")] Morgana = 25,
/// Nami (`Nami`, 267).
#[strum(to_string="Nami", serialize="Nami")] Nami = 267,
/// Nasus (`Nasus`, 75).
#[strum(to_string="Nasus", serialize="Nasus")] Nasus = 75,
/// Nautilus (`Nautilus`, 111).
#[strum(to_string="Nautilus", serialize="Nautilus")] Nautilus = 111,
/// Neeko (`Neeko`, 518).
#[strum(to_string="Neeko", serialize="Neeko")] Neeko = 518,
/// Nidalee (`Nidalee`, 76).
#[strum(to_string="Nidalee", serialize="Nidalee")] Nidalee = 76,
/// Nocturne (`Nocturne`, 56).
#[strum(to_string="Nocturne", serialize="Nocturne")] Nocturne = 56,
/// Nunu & Willump (`Nunu`, 20).
#[strum(to_string="Nunu & Willump", serialize="Nunu")] NunuWillump = 20,
/// Olaf (`Olaf`, 2).
#[strum(to_string="Olaf", serialize="Olaf")] Olaf = 2,
/// Orianna (`Orianna`, 61).
#[strum(to_string="Orianna", serialize="Orianna")] Orianna = 61,
/// Ornn (`Ornn`, 516).
#[strum(to_string="Ornn", serialize="Ornn")] Ornn = 516,
/// Pantheon (`Pantheon`, 80).
#[strum(to_string="Pantheon", serialize="Pantheon")] Pantheon = 80,
/// Poppy (`Poppy`, 78).
#[strum(to_string="Poppy", serialize="Poppy")] Poppy = 78,
/// Pyke (`Pyke`, 555).
#[strum(to_string="Pyke", serialize="Pyke")] Pyke = 555,
/// Qiyana (`Qiyana`, 246).
#[strum(to_string="Qiyana", serialize="Qiyana")] Qiyana = 246,
/// Quinn (`Quinn`, 133).
#[strum(to_string="Quinn", serialize="Quinn")] Quinn = 133,
/// Rakan (`Rakan`, 497).
#[strum(to_string="Rakan", serialize="Rakan")] Rakan = 497,
/// Rammus (`Rammus`, 33).
#[strum(to_string="Rammus", serialize="Rammus")] Rammus = 33,
/// Rek'Sai (`RekSai`, 421).
#[strum(to_string="Rek'Sai", serialize="RekSai")] RekSai = 421,
/// Renekton (`Renekton`, 58).
#[strum(to_string="Renekton", serialize="Renekton")] Renekton = 58,
/// Rengar (`Rengar`, 107).
#[strum(to_string="Rengar", serialize="Rengar")] Rengar = 107,
/// Riven (`Riven`, 92).
#[strum(to_string="Riven", serialize="Riven")] Riven = 92,
/// Rumble (`Rumble`, 68).
#[strum(to_string="Rumble", serialize="Rumble")] Rumble = 68,
/// Ryze (`Ryze`, 13).
#[strum(to_string="Ryze", serialize="Ryze")] Ryze = 13,
/// Sejuani (`Sejuani`, 113).
#[strum(to_string="Sejuani", serialize="Sejuani")] Sejuani = 113,
/// Senna (`Senna`, 235).
#[strum(to_string="Senna", serialize="Senna")] Senna = 235,
/// Shaco (`Shaco`, 35).
#[strum(to_string="Shaco", serialize="Shaco")] Shaco = 35,
/// Shen (`Shen`, 98).
#[strum(to_string="Shen", serialize="Shen")] Shen = 98,
/// Shyvana (`Shyvana`, 102).
#[strum(to_string="Shyvana", serialize="Shyvana")] Shyvana = 102,
/// Singed (`Singed`, 27).
#[strum(to_string="Singed", serialize="Singed")] Singed = 27,
/// Sion (`Sion`, 14).
#[strum(to_string="Sion", serialize="Sion")] Sion = 14,
/// Sivir (`Sivir`, 15).
#[strum(to_string="Sivir", serialize="Sivir")] Sivir = 15,
/// Skarner (`Skarner`, 72).
#[strum(to_string="Skarner", serialize="Skarner")] Skarner = 72,
/// Sona (`Sona`, 37).
#[strum(to_string="Sona", serialize="Sona")] Sona = 37,
/// Soraka (`Soraka`, 16).
#[strum(to_string="Soraka", serialize="Soraka")] Soraka = 16,
/// Swain (`Swain`, 50).
#[strum(to_string="Swain", serialize="Swain")] Swain = 50,
/// Sylas (`Sylas`, 517).
#[strum(to_string="Sylas", serialize="Sylas")] Sylas = 517,
/// Syndra (`Syndra`, 134).
#[strum(to_string="Syndra", serialize="Syndra")] Syndra = 134,
/// Tahm Kench (`TahmKench`, 223).
#[strum(to_string="Tahm Kench", serialize="TahmKench")] TahmKench = 223,
/// Taliyah (`Taliyah`, 163).
#[strum(to_string="Taliyah", serialize="Taliyah")] Taliyah = 163,
/// Talon (`Talon`, 91).
#[strum(to_string="Talon", serialize="Talon")] Talon = 91,
/// Taric (`Taric`, 44).
#[strum(to_string="Taric", serialize="Taric")] Taric = 44,
/// Teemo (`Teemo`, 17).
#[strum(to_string="Teemo", serialize="Teemo")] Teemo = 17,
/// Thresh (`Thresh`, 412).
#[strum(to_string="Thresh", serialize="Thresh")] Thresh = 412,
/// Tristana (`Tristana`, 18).
#[strum(to_string="Tristana", serialize="Tristana")] Tristana = 18,
/// Trundle (`Trundle`, 48).
#[strum(to_string="Trundle", serialize="Trundle")] Trundle = 48,
/// Tryndamere (`Tryndamere`, 23).
#[strum(to_string="Tryndamere", serialize="Tryndamere")] Tryndamere = 23,
/// Twisted Fate (`TwistedFate`, 4).
#[strum(to_string="Twisted Fate", serialize="TwistedFate")] TwistedFate = 4,
/// Twitch (`Twitch`, 29).
#[strum(to_string="Twitch", serialize="Twitch")] Twitch = 29,
/// Udyr (`Udyr`, 77).
#[strum(to_string="Udyr", serialize="Udyr")] Udyr = 77,
/// Urgot (`Urgot`, 6).
#[strum(to_string="Urgot", serialize="Urgot")] Urgot = 6,
/// Varus (`Varus`, 110).
#[strum(to_string="Varus", serialize="Varus")] Varus = 110,
/// Vayne (`Vayne`, 67).
#[strum(to_string="Vayne", serialize="Vayne")] Vayne = 67,
/// Veigar (`Veigar`, 45).
#[strum(to_string="Veigar", serialize="Veigar")] Veigar = 45,
/// Vel'Koz (`Velkoz`, 161).
#[strum(to_string="Vel'Koz", serialize="Velkoz")] VelKoz = 161,
/// Vi (`Vi`, 254).
#[strum(to_string="Vi", serialize="Vi")] Vi = 254,
/// Viktor (`Viktor`, 112).
#[strum(to_string="Viktor", serialize="Viktor")] Viktor = 112,
/// Vladimir (`Vladimir`, 8).
#[strum(to_string="Vladimir", serialize="Vladimir")] Vladimir = 8,
/// Volibear (`Volibear`, 106).
#[strum(to_string="Volibear", serialize="Volibear")] Volibear = 106,
/// Warwick (`Warwick`, 19).
#[strum(to_string="Warwick", serialize="Warwick")] Warwick = 19,
/// Wukong (`MonkeyKing`, 62).
#[strum(to_string="Wukong", serialize="MonkeyKing")] Wukong = 62,
/// Xayah (`Xayah`, 498).
#[strum(to_string="Xayah", serialize="Xayah")] Xayah = 498,
/// Xerath (`Xerath`, 101).
#[strum(to_string="Xerath", serialize="Xerath")] Xerath = 101,
/// Xin Zhao (`XinZhao`, 5).
#[strum(to_string="Xin Zhao", serialize="XinZhao")] XinZhao = 5,
/// Yasuo (`Yasuo`, 157).
#[strum(to_string="Yasuo", serialize="Yasuo")] Yasuo = 157,
/// Yorick (`Yorick`, 83).
#[strum(to_string="Yorick", serialize="Yorick")] Yorick = 83,
/// Yuumi (`Yuumi`, 350).
#[strum(to_string="Yuumi", serialize="Yuumi")] Yuumi = 350,
/// Zac (`Zac`, 154).
#[strum(to_string="Zac", serialize="Zac")] Zac = 154,
/// Zed (`Zed`, 238).
#[strum(to_string="Zed", serialize="Zed")] Zed = 238,
/// Ziggs (`Ziggs`, 115).
#[strum(to_string="Ziggs", serialize="Ziggs")] Ziggs = 115,
/// Zilean (`Zilean`, 26).
#[strum(to_string="Zilean", serialize="Zilean")] Zilean = 26,
/// Zoe (`Zoe`, 142).
#[strum(to_string="Zoe", serialize="Zoe")] Zoe = 142,
/// Zyra (`Zyra`, 143).
#[strum(to_string="Zyra", serialize="Zyra")] Zyra = 143,
} }
impl Champion { impl Champion {
/// The champion's name (localized `en_US`), or `"NONE"` for the None variant.
pub fn name(self) -> &'static str { pub fn name(self) -> &'static str {
match self { self.into()
Self::None => "None",
Self::Aatrox => "Aatrox",
Self::Ahri => "Ahri",
Self::Akali => "Akali",
Self::Alistar => "Alistar",
Self::Amumu => "Amumu",
Self::Anivia => "Anivia",
Self::Annie => "Annie",
Self::Ashe => "Ashe",
Self::AurelionSol => "Aurelion Sol",
Self::Azir => "Azir",
Self::Bard => "Bard",
Self::Blitzcrank => "Blitzcrank",
Self::Brand => "Brand",
Self::Braum => "Braum",
Self::Caitlyn => "Caitlyn",
Self::Camille => "Camille",
Self::Cassiopeia => "Cassiopeia",
Self::ChoGath => "Cho'Gath",
Self::Corki => "Corki",
Self::Darius => "Darius",
Self::Diana => "Diana",
Self::DrMundo => "Dr. Mundo",
Self::Draven => "Draven",
Self::Ekko => "Ekko",
Self::Elise => "Elise",
Self::Evelynn => "Evelynn",
Self::Ezreal => "Ezreal",
Self::Fiddlesticks => "Fiddlesticks",
Self::Fiora => "Fiora",
Self::Fizz => "Fizz",
Self::Galio => "Galio",
Self::Gangplank => "Gangplank",
Self::Garen => "Garen",
Self::Gnar => "Gnar",
Self::Gragas => "Gragas",
Self::Graves => "Graves",
Self::Hecarim => "Hecarim",
Self::Heimerdinger => "Heimerdinger",
Self::Illaoi => "Illaoi",
Self::Irelia => "Irelia",
Self::Ivern => "Ivern",
Self::Janna => "Janna",
Self::JarvanIV => "Jarvan IV",
Self::Jax => "Jax",
Self::Jayce => "Jayce",
Self::Jhin => "Jhin",
Self::Jinx => "Jinx",
Self::KaiSa => "Kai'Sa",
Self::Kalista => "Kalista",
Self::Karma => "Karma",
Self::Karthus => "Karthus",
Self::Kassadin => "Kassadin",
Self::Katarina => "Katarina",
Self::Kayle => "Kayle",
Self::Kayn => "Kayn",
Self::Kennen => "Kennen",
Self::KhaZix => "Kha'Zix",
Self::Kindred => "Kindred",
Self::Kled => "Kled",
Self::KogMaw => "Kog'Maw",
Self::LeBlanc => "LeBlanc",
Self::LeeSin => "Lee Sin",
Self::Leona => "Leona",
Self::Lissandra => "Lissandra",
Self::Lucian => "Lucian",
Self::Lulu => "Lulu",
Self::Lux => "Lux",
Self::Malphite => "Malphite",
Self::Malzahar => "Malzahar",
Self::Maokai => "Maokai",
Self::MasterYi => "Master Yi",
Self::MissFortune => "Miss Fortune",
Self::Mordekaiser => "Mordekaiser",
Self::Morgana => "Morgana",
Self::Nami => "Nami",
Self::Nasus => "Nasus",
Self::Nautilus => "Nautilus",
Self::Neeko => "Neeko",
Self::Nidalee => "Nidalee",
Self::Nocturne => "Nocturne",
Self::NunuWillump => "Nunu & Willump",
Self::Olaf => "Olaf",
Self::Orianna => "Orianna",
Self::Ornn => "Ornn",
Self::Pantheon => "Pantheon",
Self::Poppy => "Poppy",
Self::Pyke => "Pyke",
Self::Qiyana => "Qiyana",
Self::Quinn => "Quinn",
Self::Rakan => "Rakan",
Self::Rammus => "Rammus",
Self::RekSai => "Rek'Sai",
Self::Renekton => "Renekton",
Self::Rengar => "Rengar",
Self::Riven => "Riven",
Self::Rumble => "Rumble",
Self::Ryze => "Ryze",
Self::Sejuani => "Sejuani",
Self::Senna => "Senna",
Self::Shaco => "Shaco",
Self::Shen => "Shen",
Self::Shyvana => "Shyvana",
Self::Singed => "Singed",
Self::Sion => "Sion",
Self::Sivir => "Sivir",
Self::Skarner => "Skarner",
Self::Sona => "Sona",
Self::Soraka => "Soraka",
Self::Swain => "Swain",
Self::Sylas => "Sylas",
Self::Syndra => "Syndra",
Self::TahmKench => "Tahm Kench",
Self::Taliyah => "Taliyah",
Self::Talon => "Talon",
Self::Taric => "Taric",
Self::Teemo => "Teemo",
Self::Thresh => "Thresh",
Self::Tristana => "Tristana",
Self::Trundle => "Trundle",
Self::Tryndamere => "Tryndamere",
Self::TwistedFate => "Twisted Fate",
Self::Twitch => "Twitch",
Self::Udyr => "Udyr",
Self::Urgot => "Urgot",
Self::Varus => "Varus",
Self::Vayne => "Vayne",
Self::Veigar => "Veigar",
Self::VelKoz => "Vel'Koz",
Self::Vi => "Vi",
Self::Viktor => "Viktor",
Self::Vladimir => "Vladimir",
Self::Volibear => "Volibear",
Self::Warwick => "Warwick",
Self::Wukong => "Wukong",
Self::Xayah => "Xayah",
Self::Xerath => "Xerath",
Self::XinZhao => "Xin Zhao",
Self::Yasuo => "Yasuo",
Self::Yorick => "Yorick",
Self::Yuumi => "Yuumi",
Self::Zac => "Zac",
Self::Zed => "Zed",
Self::Ziggs => "Ziggs",
Self::Zilean => "Zilean",
Self::Zoe => "Zoe",
Self::Zyra => "Zyra",
}
} }
/// The champion's identifier key. Somtimes called "key", "identifier", or "alias".
/// This is mainly used in DDragon paths.
///
/// This is generally the `en_US` name with spaces and punctuation removed,
/// but there are the following exceptions:
/// | Name | Identifier |
/// |------|------------|
/// | None | `"NONE"` (placeholder value) |
/// | Cho'Gath | "Chogath" |
/// | Fiddlesticks | "FiddleSticks" |
/// | Kai'Sa | "Kaisa" |
/// | Kha'Zix | "Khazix" |
/// | LeBlanc | "Leblanc" |
/// | Nunu & Willump | "Nunu" |
/// | Vel'Koz | "Velkoz" |
/// | Wukong | "MonkeyKing" |
pub fn identifier(self) -> &'static str { pub fn identifier(self) -> &'static str {
match self { match self {
Self::None => "None", Self::None => "NONE",
Self::Aatrox => "Aatrox", Self::Aatrox => "Aatrox",
Self::Ahri => "Ahri", Self::Ahri => "Ahri",
Self::Akali => "Akali", Self::Akali => "Akali",
@ -476,181 +494,3 @@ impl Champion {
} }
} }
} }
impl std::str::FromStr for Champion {
type Err = ();
fn from_str(val: &str) -> Result<Self, Self::Err> {
// 4 characters encoded as an int.
match val.chars()
.filter(|c| c.is_ascii_alphabetic())
.take(4)
.map(|c| c.to_ascii_uppercase() as u32)
.fold(0u32, |hash, next| hash * 256 + next)
{
1094800466 /* AATR */ => Ok(Self::Aatrox),
1095258697 /* AHRI */ => Ok(Self::Ahri),
1095450956 /* AKAL */ => Ok(Self::Akali),
1095518547 /* ALIS */ => Ok(Self::Alistar),
1095587149 /* AMUM */ => Ok(Self::Amumu),
1095649622 /* ANIV */ => Ok(Self::Anivia),
1095650889 /* ANNI */ => Ok(Self::Annie),
1095977029 /* ASHE */ => Ok(Self::Ashe),
1096110661 /* AURE */ => Ok(Self::AurelionSol),
1096436050 /* AZIR */ => Ok(Self::Azir),
1111577156 /* BARD */ => Ok(Self::Bard),
1112295764 /* BLIT */ => Ok(Self::Blitzcrank),
1112686926 /* BRAN */ => Ok(Self::Brand),
1112686933 /* BRAU */ => Ok(Self::Braum),
1128352084 /* CAIT */ => Ok(Self::Caitlyn),
1128353097 /* CAMI */ => Ok(Self::Camille),
1128354643 /* CASS */ => Ok(Self::Cassiopeia),
1128812359 /* CHOG */ => Ok(Self::ChoGath),
4409423 /* CHO */ => Ok(Self::ChoGath),
1129271883 /* CORK */ => Ok(Self::Corki),
1145131593 /* DARI */ => Ok(Self::Darius),
1145651534 /* DIAN */ => Ok(Self::Diana),
1146244437 /* DRMU */ => Ok(Self::DrMundo),
17490 /* DR */ => Ok(Self::DrMundo),
1146241366 /* DRAV */ => Ok(Self::Draven),
1162562383 /* EKKO */ => Ok(Self::Ekko),
1162627411 /* ELIS */ => Ok(Self::Elise),
1163281740 /* EVEL */ => Ok(Self::Evelynn),
1163547205 /* EZRE */ => Ok(Self::Ezreal),
1179206724 /* FIDD */ => Ok(Self::Fiddlesticks),
1179209554 /* FIOR */ => Ok(Self::Fiora),
1179212378 /* FIZZ */ => Ok(Self::Fizz),
1195461705 /* GALI */ => Ok(Self::Galio),
1195462215 /* GANG */ => Ok(Self::Gangplank),
1195463237 /* GARE */ => Ok(Self::Garen),
1196310866 /* GNAR */ => Ok(Self::Gnar),
1196572999 /* GRAG */ => Ok(Self::Gragas),
1196573014 /* GRAV */ => Ok(Self::Graves),
1212498753 /* HECA */ => Ok(Self::Hecarim),
1212500301 /* HEIM */ => Ok(Self::Heimerdinger),
1229737025 /* ILLA */ => Ok(Self::Illaoi),
1230128460 /* IREL */ => Ok(Self::Irelia),
1230390610 /* IVER */ => Ok(Self::Ivern),
1245793870 /* JANN */ => Ok(Self::Janna),
1245794902 /* JARV */ => Ok(Self::JarvanIV),
4866392 /* JAX */ => Ok(Self::Jax),
1245796675 /* JAYC */ => Ok(Self::Jayce),
1246251342 /* JHIN */ => Ok(Self::Jhin),
1246318168 /* JINX */ => Ok(Self::Jinx),
1262569811 /* KAIS */ => Ok(Self::KaiSa),
4931913 /* KAI */ => Ok(Self::KaiSa),
1262570569 /* KALI */ => Ok(Self::Kalista),
1262572109 /* KARM */ => Ok(Self::Karma),
1262572116 /* KART */ => Ok(Self::Karthus),
1262572371 /* KASS */ => Ok(Self::Kassadin),
1262572609 /* KATA */ => Ok(Self::Katarina),
1262573900 /* KAYL */ => Ok(Self::Kayle),
1262573902 /* KAYN */ => Ok(Self::Kayn),
1262833230 /* KENN */ => Ok(Self::Kennen),
1263026522 /* KHAZ */ => Ok(Self::KhaZix),
4933697 /* KHA */ => Ok(Self::KhaZix),
1263095364 /* KIND */ => Ok(Self::Kindred),
1263289668 /* KLED */ => Ok(Self::Kled),
1263486797 /* KOGM */ => Ok(Self::KogMaw),
4935495 /* KOG */ => Ok(Self::KogMaw),
1279607372 /* LEBL */ => Ok(Self::LeBlanc),
1279608147 /* LEES */ => Ok(Self::LeeSin),
4998469 /* LEE */ => Ok(Self::LeeSin),
1279610702 /* LEON */ => Ok(Self::Leona),
1279873875 /* LISS */ => Ok(Self::Lissandra),
1280656201 /* LUCI */ => Ok(Self::Lucian),
1280658517 /* LULU */ => Ok(Self::Lulu),
5002584 /* LUX */ => Ok(Self::Lux),
1296125008 /* MALP */ => Ok(Self::Malphite),
1296125018 /* MALZ */ => Ok(Self::Malzahar),
1296125771 /* MAOK */ => Ok(Self::Maokai),
1296126804 /* MAST */ => Ok(Self::MasterYi),
1296651091 /* MISS */ => Ok(Self::MissFortune),
1297044036 /* MORD */ => Ok(Self::Mordekaiser),
1297044039 /* MORG */ => Ok(Self::Morgana),
1312902473 /* NAMI */ => Ok(Self::Nami),
1312904021 /* NASU */ => Ok(Self::Nasus),
1312904532 /* NAUT */ => Ok(Self::Nautilus),
1313162571 /* NEEK */ => Ok(Self::Neeko),
1313424449 /* NIDA */ => Ok(Self::Nidalee),
1313817428 /* NOCT */ => Ok(Self::Nocturne),
1314213461 /* NUNU */ => Ok(Self::NunuWillump),
1330397510 /* OLAF */ => Ok(Self::Olaf),
1330792769 /* ORIA */ => Ok(Self::Orianna),
1330794062 /* ORNN */ => Ok(Self::Ornn),
1346457172 /* PANT */ => Ok(Self::Pantheon),
1347375184 /* POPP */ => Ok(Self::Poppy),
1348029253 /* PYKE */ => Ok(Self::Pyke),
1363761473 /* QIYA */ => Ok(Self::Qiyana),
1364543822 /* QUIN */ => Ok(Self::Quinn),
1380010817 /* RAKA */ => Ok(Self::Rakan),
1380011341 /* RAMM */ => Ok(Self::Rammus),
1380272979 /* REKS */ => Ok(Self::RekSai),
5391691 /* REK */ => Ok(Self::RekSai),
1380273733 /* RENE */ => Ok(Self::Renekton),
1380273735 /* RENG */ => Ok(Self::Rengar),
1380537925 /* RIVE */ => Ok(Self::Riven),
1381322050 /* RUMB */ => Ok(Self::Rumble),
1381587525 /* RYZE */ => Ok(Self::Ryze),
1397049941 /* SEJU */ => Ok(Self::Sejuani),
1397050958 /* SENN */ => Ok(Self::Senna),
1397244227 /* SHAC */ => Ok(Self::Shaco),
1397245262 /* SHEN */ => Ok(Self::Shen),
1397250390 /* SHYV */ => Ok(Self::Shyvana),
1397313095 /* SING */ => Ok(Self::Singed),
1397313358 /* SION */ => Ok(Self::Sion),
1397315145 /* SIVI */ => Ok(Self::Sivir),
1397440850 /* SKAR */ => Ok(Self::Skarner),
1397706305 /* SONA */ => Ok(Self::Sona),
1397707329 /* SORA */ => Ok(Self::Soraka),
1398227273 /* SWAI */ => Ok(Self::Swain),
1398361153 /* SYLA */ => Ok(Self::Sylas),
1398361668 /* SYND */ => Ok(Self::Syndra),
1413564493 /* TAHM */ => Ok(Self::TahmKench),
1413565513 /* TALI */ => Ok(Self::Taliyah),
1413565519 /* TALO */ => Ok(Self::Talon),
1413567049 /* TARI */ => Ok(Self::Taric),
1413825869 /* TEEM */ => Ok(Self::Teemo),
1414025797 /* THRE */ => Ok(Self::Thresh),
1414678867 /* TRIS */ => Ok(Self::Tristana),
1414681934 /* TRUN */ => Ok(Self::Trundle),
1414682958 /* TRYN */ => Ok(Self::Tryndamere),
1415006547 /* TWIS */ => Ok(Self::TwistedFate),
1415006548 /* TWIT */ => Ok(Self::Twitch),
1430542674 /* UDYR */ => Ok(Self::Udyr),
1431455567 /* URGO */ => Ok(Self::Urgot),
1447121493 /* VARU */ => Ok(Self::Varus),
1447123278 /* VAYN */ => Ok(Self::Vayne),
1447381319 /* VEIG */ => Ok(Self::Veigar),
1447382091 /* VELK */ => Ok(Self::VelKoz),
5653836 /* VEL */ => Ok(Self::VelKoz),
22089 /* VI */ => Ok(Self::Vi),
1447643988 /* VIKT */ => Ok(Self::Viktor),
1447838020 /* VLAD */ => Ok(Self::Vladimir),
1448037449 /* VOLI */ => Ok(Self::Volibear),
1463898711 /* WARW */ => Ok(Self::Warwick),
1465207631 /* WUKO */ => Ok(Self::Wukong),
1297043019 /* MONK */ => Ok(Self::Wukong),
1480677697 /* XAYA */ => Ok(Self::Xayah),
1480938049 /* XERA */ => Ok(Self::Xerath),
1481199194 /* XINZ */ => Ok(Self::XinZhao),
5785934 /* XIN */ => Ok(Self::XinZhao),
1497453397 /* YASU */ => Ok(Self::Yasuo),
1498370633 /* YORI */ => Ok(Self::Yorick),
1498764621 /* YUUM */ => Ok(Self::Yuumi),
5914947 /* ZAC */ => Ok(Self::Zac),
5915972 /* ZED */ => Ok(Self::Zed),
1514751815 /* ZIGG */ => Ok(Self::Ziggs),
1514753093 /* ZILE */ => Ok(Self::Zilean),
5918533 /* ZOE */ => Ok(Self::Zoe),
1515803201 /* ZYRA */ => Ok(Self::Zyra),
_ => Err(()),
}
}
}
impl fmt::Display for Champion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}

View file

@ -1,6 +1,6 @@
use std::cmp::Ordering; use std::cmp::Ordering;
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// LoL and TFT rank divisions, I, II, III, IV, and (deprecated) V. /// LoL and TFT rank divisions, I, II, III, IV, and (deprecated) V.
@ -10,7 +10,7 @@ use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// Repr'd as equivalent numeric values, (1, 2, 3, 4, 5). /// Repr'd as equivalent numeric values, (1, 2, 3, 4, 5).
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[derive(IntoPrimitive, TryFromPrimitive)] #[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)] #[repr(u8)]
pub enum Division { pub enum Division {

View file

@ -6,14 +6,14 @@
// // // //
/////////////////////////////////////////////// ///////////////////////////////////////////////
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legends game mode, such as Classic, /// League of Legends game mode, such as Classic,
/// ARAM, URF, One For All, Ascension, etc. /// ARAM, URF, One For All, Ascension, etc.
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(u8)] #[repr(u8)]
pub enum GameMode { pub enum GameMode {
/// Classic Summoner's Rift and Twisted Treeline games /// Classic Summoner's Rift and Twisted Treeline games

View file

@ -6,12 +6,12 @@
// // // //
/////////////////////////////////////////////// ///////////////////////////////////////////////
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legends game type: matched game, custom game, or tutorial game. /// League of Legends game type: matched game, custom game, or tutorial game.
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(u8)] #[repr(u8)]
pub enum GameType { pub enum GameType {
/// Custom games /// Custom games

View file

@ -1,10 +1,10 @@
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// LoL or TFT ranked queue types. /// LoL or TFT ranked queue types.
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
pub enum QueueType { pub enum QueueType {
// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue. // League of Legends, Summoner's Rift (5v5), Ranked Solo Queue.
RANKED_SOLO_5x5, RANKED_SOLO_5x5,
@ -13,6 +13,7 @@ pub enum QueueType {
// League of Legends, Twisted Treeline (3v3), Flex Queue. // League of Legends, Twisted Treeline (3v3), Flex Queue.
RANKED_FLEX_TT, RANKED_FLEX_TT,
// Ranked Teamfight Tactics. // Ranked Teamfight Tactics.
#[deprecated(note = "Teamfight Tactics ranks should be acquired using `TftLeagueV1::get_league_entries`.")]
RANKED_TFT, RANKED_TFT,
} }

View file

@ -1,5 +1,5 @@
use strum_macros::{ EnumString, Display, AsRefStr };
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// LoL and TFT ranked tiers, such as gold, diamond, challenger, etc. /// LoL and TFT ranked tiers, such as gold, diamond, challenger, etc.
/// ///
@ -8,8 +8,8 @@ use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// Repr'd as arbitrary u8 values. /// Repr'd as arbitrary u8 values.
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] #[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(EnumString, Display, AsRefStr)]
#[derive(IntoPrimitive, TryFromPrimitive)] #[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(u8)] #[repr(u8)]
pub enum Tier { pub enum Tier {
IRON = 40, IRON = 40,

View file

@ -9,7 +9,7 @@
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 3bd5ca30e5a7aa15963ca4366e3b6be89defe567 // Version 3bd5ca30e5a7aa15963ca4366e3b6be89defe567
// champion-mastery-v4 /// ChampionMasteryV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod champion_mastery_v4 { pub mod champion_mastery_v4 {
/// ChampionMastery data object. This struct is automatically generated. /// ChampionMastery data object. This struct is automatically generated.
@ -48,7 +48,7 @@ pub mod champion_mastery_v4 {
} }
} }
// champion-v3 /// ChampionV3 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod champion_v3 { pub mod champion_v3 {
/// ChampionInfo data object. This struct is automatically generated. /// ChampionInfo data object. This struct is automatically generated.
@ -64,7 +64,7 @@ pub mod champion_v3 {
} }
} }
// league-exp-v4 /// LeagueExpV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod league_exp_v4 { pub mod league_exp_v4 {
/// LeagueEntry data object. This struct is automatically generated. /// LeagueEntry data object. This struct is automatically generated.
@ -118,7 +118,7 @@ pub mod league_exp_v4 {
} }
} }
// league-v4 /// LeagueV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod league_v4 { pub mod league_v4 {
/// LeagueList data object. This struct is automatically generated. /// LeagueList data object. This struct is automatically generated.
@ -217,7 +217,7 @@ pub mod league_v4 {
} }
} }
// lol-status-v3 /// LolStatusV3 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod lol_status_v3 { pub mod lol_status_v3 {
/// ShardStatus data object. This struct is automatically generated. /// ShardStatus data object. This struct is automatically generated.
@ -295,7 +295,7 @@ pub mod lol_status_v3 {
} }
} }
// match-v4 /// MatchV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod match_v4 { pub mod match_v4 {
/// Match data object. This struct is automatically generated. /// Match data object. This struct is automatically generated.
@ -918,7 +918,7 @@ pub mod match_v4 {
} }
} }
// spectator-v4 /// SpectatorV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod spectator_v4 { pub mod spectator_v4 {
/// CurrentGameInfo data object. This struct is automatically generated. /// CurrentGameInfo data object. This struct is automatically generated.
@ -1120,7 +1120,7 @@ pub mod spectator_v4 {
} }
} }
// summoner-v4 /// SummonerV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod summoner_v4 { pub mod summoner_v4 {
/// Summoner data object. This struct is automatically generated. /// Summoner data object. This struct is automatically generated.
@ -1153,7 +1153,7 @@ pub mod summoner_v4 {
} }
} }
// tft-league-v1 /// TftLeagueV1 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod tft_league_v1 { pub mod tft_league_v1 {
/// LeagueList data object. This struct is automatically generated. /// LeagueList data object. This struct is automatically generated.
@ -1252,7 +1252,7 @@ pub mod tft_league_v1 {
} }
} }
// tft-match-v1 /// TftMatchV1 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod tft_match_v1 { pub mod tft_match_v1 {
/// Match data object. This struct is automatically generated. /// Match data object. This struct is automatically generated.
@ -1391,7 +1391,7 @@ pub mod tft_match_v1 {
} }
} }
// tft-summoner-v1 /// TftSummonerV1 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod tft_summoner_v1 { pub mod tft_summoner_v1 {
/// Summoner data object. This struct is automatically generated. /// Summoner data object. This struct is automatically generated.
@ -1424,7 +1424,7 @@ pub mod tft_summoner_v1 {
} }
} }
// tournament-stub-v4 /// TournamentStubV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod tournament_stub_v4 { pub mod tournament_stub_v4 {
/// TournamentCodeParameters data object. This struct is automatically generated. /// TournamentCodeParameters data object. This struct is automatically generated.
@ -1499,7 +1499,7 @@ pub mod tournament_stub_v4 {
} }
} }
// tournament-v4 /// TournamentV4 data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod tournament_v4 { pub mod tournament_v4 {
/// TournamentCodeParameters data object. This struct is automatically generated. /// TournamentCodeParameters data object. This struct is automatically generated.

View file

@ -14,9 +14,9 @@
const padId = function(id) { return ('' + id).padEnd(3); }; const padId = function(id) { return ('' + id).padEnd(3); };
}}{{= dotUtils.preamble() }} }}{{= dotUtils.preamble() }}
use std::fmt;
use num_enum::{ IntoPrimitive, TryFromPrimitive }; use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde_repr::{ Serialize_repr, Deserialize_repr }; use serde_repr::{ Serialize_repr, Deserialize_repr };
use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legend's champions. /// League of Legend's champions.
/// ///
@ -26,39 +26,50 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(IntoPrimitive, TryFromPrimitive)] #[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(Serialize_repr, Deserialize_repr)] #[derive(Serialize_repr, Deserialize_repr)]
#[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(i16)] #[repr(i16)]
pub enum Champion { pub enum Champion {
/// A champion that doesn't exist. Used in TeamBans when no ban occured. /// A champion that doesn't exist. Used in TeamBans when no champion was banned.
///
/// None (`NONE`, -1).
None = -1, None = -1,
{{ {{
for (let { id, alias, name } of champions) { for (let { id, alias, name } of champions) {
const comment = `${name.padEnd(14)} (\`${alias}\`, ${id}).`.padEnd(36);
const ename = enumName(name).padEnd(12);
}} }}
/** {{= comment }} */ {{= ename }} = {{= id }}, /// {{= name }} (`{{= alias }}`, {{= id }}).
#[strum(to_string="{{= name }}", serialize="{{= alias }}")] {{= enumName(name) }} = {{= id }},
{{ {{
} }
}} }}
} }
impl Champion { impl Champion {
/// The champion's name (localized `en_US`), or `"NONE"` for the None variant.
pub fn name(self) -> &'static str { pub fn name(self) -> &'static str {
match self { self.into()
Self::None => "None",
{{
for (let { id, name } of champions) {
}}
Self::{{= enumName(name).padEnd(12) }} => "{{= name }}",
{{
}
}}
}
} }
/// The champion's identifier key. Somtimes called "key", "identifier", or "alias".
/// This is mainly used in DDragon paths.
///
/// This is generally the `en_US` name with spaces and punctuation removed,
/// but there are the following exceptions:
/// | Name | Identifier |
/// |------|------------|
/// | None | `"NONE"` (placeholder value) |
{{
for (let { name, alias } of champions) {
if (name.replace(/[^a-zA-Z0-9]+/, '') !== alias) {
}}
/// | {{= name }} | "{{= alias }}" |
{{
}
}
}}
pub fn identifier(self) -> &'static str { pub fn identifier(self) -> &'static str {
match self { match self {
Self::None => "None", Self::None => "NONE",
{{ {{
for (let { name, alias } of champions) { for (let { name, alias } of champions) {
}} }}
@ -69,39 +80,3 @@ impl Champion {
} }
} }
} }
impl std::str::FromStr for Champion {
type Err = ();
fn from_str(val: &str) -> Result<Self, Self::Err> {
// 4 characters encoded as an int.
match val.chars()
.filter(|c| c.is_ascii_alphabetic())
.take(4)
.map(|c| c.to_ascii_uppercase() as u32)
.fold(0u32, |hash, next| hash * {{= hashFactor }} + next)
{
{{
let keyStrings = (name, alias) => new Set([].concat(...[ name, alias ].map(s => s.toUpperCase())
.map(s => [
s.replace(/[^A-Z]+/, '').substring(0, 4),
s.split(/[^A-Z]/, 1)[0].substring(0, 4)
])));
for (let { id, alias, name } of champions) {
for (let prefix of keyStrings(name, alias)) {
}}
{{= ('' + strHash(prefix)).padEnd(10) }} /* {{= prefix.padEnd(4) }} */ => Ok(Self::{{= enumName(name) }}),
{{
}
}
}}
_ => Err(()),
}
}
}
impl fmt::Display for Champion {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}

View file

@ -3,14 +3,14 @@
const gameModes = require('./.gameModes.json'); const gameModes = require('./.gameModes.json');
}}{{= dotUtils.preamble() }} }}{{= dotUtils.preamble() }}
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legends game mode, such as Classic, /// League of Legends game mode, such as Classic,
/// ARAM, URF, One For All, Ascension, etc. /// ARAM, URF, One For All, Ascension, etc.
#[non_exhaustive] #[non_exhaustive]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(u8)] #[repr(u8)]
pub enum GameMode { pub enum GameMode {
{{ {{

View file

@ -3,12 +3,12 @@
const gameTypes = require('./.gameTypes.json'); const gameTypes = require('./.gameTypes.json');
}}{{= dotUtils.preamble() }} }}{{= dotUtils.preamble() }}
use strum_macros::{ EnumString, Display, AsRefStr }; use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr };
/// League of Legends game type: matched game, custom game, or tutorial game. /// League of Legends game type: matched game, custom game, or tutorial game.
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash)] #[derive(Eq, PartialEq, Hash)]
#[derive(EnumString, Display, AsRefStr)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)]
#[repr(u8)] #[repr(u8)]
pub enum GameType { pub enum GameType {
{{ {{

View file

@ -14,12 +14,12 @@
for (let [endpoint, schemaKeyGroup] of schemaKeyByEndpoint) { for (let [endpoint, schemaKeyGroup] of schemaKeyByEndpoint) {
}} }}
// {{= endpoint }} /// {{= dotUtils.changeCase.pascalCase(endpoint) }} data objects. This module is automatically generated.
#[allow(dead_code)] #[allow(dead_code)]
pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} { pub mod {{= dotUtils.changeCase.snakeCase(endpoint) }} {
{{ {{
for (let schemaKey of schemaKeyGroup) { for (let schemaKey of schemaKeyGroup) {
const [endpoint, rawSchemaName] = schemaKey.split('.'); const [, rawSchemaName] = schemaKey.split('.');
const schemaName = dotUtils.normalizeSchemaName(rawSchemaName); const schemaName = dotUtils.normalizeSchemaName(rawSchemaName);
const schema = schemas[schemaKey]; const schema = schemas[schemaKey];
const props = schema.properties; const props = schema.properties;