From 9c4d3608eb25dffb7e032bbfb2f417cdcb8de3c5 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Fri, 25 Oct 2019 19:52:43 -0700 Subject: [PATCH] Adding Map enum --- src/consts/map.rs | 62 ++++++++++++++++++++++++++++++++++++++ src/consts/mod.rs | 3 ++ src/consts/season.rs | 2 +- srcgen/consts/map.rs.dt | 30 ++++++++++++++++++ srcgen/consts/season.rs.dt | 2 +- srcgen/index.js | 4 +++ 6 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/consts/map.rs create mode 100644 srcgen/consts/map.rs.dt diff --git a/src/consts/map.rs b/src/consts/map.rs new file mode 100644 index 0000000..992408a --- /dev/null +++ b/src/consts/map.rs @@ -0,0 +1,62 @@ +// This file is automatically generated. +// Do not directly edit. + +/// League of Legends maps. +#[derive(Debug, Copy, Clone)] +#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] +#[repr(u8)] +pub enum Map { + + /// Summoner's Rift + ///
Original Summer variant + SummonersRiftOriginalSummerVariant = 1, + /// Summoner's Rift + ///
Original Autumn variant + SummonersRiftOriginalAutumnVariant = 2, + /// Summoner's Rift + ///
Current Version + SummonersRift = 11, + + /// The Proving Grounds + ///
Tutorial Map + TheProvingGrounds = 3, + + /// Twisted Treeline + ///
Original Version + TwistedTreelineOriginalVersion = 4, + /// Twisted Treeline + ///
Last TT map + TwistedTreeline = 10, + + /// The Crystal Scar + ///
Dominion map + TheCrystalScar = 8, + + /// Howling Abyss + ///
ARAM map + HowlingAbyss = 12, + + /// Butcher's Bridge + ///
Alternate ARAM map + ButchersBridge = 14, + + /// Cosmic Ruins + ///
Dark Star: Singularity map + CosmicRuins = 16, + + /// Valoran City Park + ///
Star Guardian Invasion map + ValoranCityPark = 18, + + /// Substructure 43 + ///
PROJECT: Hunters map + Substructure43 = 19, + + /// Crash Site + ///
Odyssey: Extraction map + CrashSite = 20, + + /// Nexus Blitz + ///
Nexus Blitz map + NexusBlitz = 21, +} diff --git a/src/consts/mod.rs b/src/consts/mod.rs index 1f5de0d..5b8826b 100644 --- a/src/consts/mod.rs +++ b/src/consts/mod.rs @@ -12,6 +12,9 @@ pub use game_mode::*; mod game_type; pub use game_type::*; +mod map; +pub use map::*; + mod queue_type; pub use queue_type::*; diff --git a/src/consts/season.rs b/src/consts/season.rs index 5a179c8..256429c 100644 --- a/src/consts/season.rs +++ b/src/consts/season.rs @@ -20,4 +20,4 @@ pub enum Season { Season2018 = 11, Preseason2019 = 12, Season2019 = 13, -} \ No newline at end of file +} diff --git a/srcgen/consts/map.rs.dt b/srcgen/consts/map.rs.dt new file mode 100644 index 0000000..a9a57e7 --- /dev/null +++ b/srcgen/consts/map.rs.dt @@ -0,0 +1,30 @@ +{{ + const dotUtils = require('./dotUtils.js'); + const maps = require('./.maps.json'); + const groupedMaps = maps.groupBy(({ mapName }) => + dotUtils.changeCase.pascalCase(mapName.replace(/[ ']+/, ''))); +}}{{= dotUtils.preamble() }} + +/// League of Legends maps. +#[derive(Debug, Copy, Clone)] +#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)] +#[repr(u8)] +pub enum Map { +{{ + for (const [ groupName, colMaps ] of groupedMaps) { +}} + +{{ + for (const [ i, { mapId, mapName, notes } ] of colMaps.entries()) { + let name = groupName; + if (i != colMaps.length - 1) + name += dotUtils.changeCase.pascalCase(notes); +}} + /// {{= mapName }} + ///
{{= notes }} + {{= name }} = {{= mapId }}, +{{ + } + } +}} +} diff --git a/srcgen/consts/season.rs.dt b/srcgen/consts/season.rs.dt index 814901a..08aedbb 100644 --- a/srcgen/consts/season.rs.dt +++ b/srcgen/consts/season.rs.dt @@ -17,4 +17,4 @@ pub enum Season { {{ } }} -} \ No newline at end of file +} diff --git a/srcgen/index.js b/srcgen/index.js index e354ed6..99a11f1 100644 --- a/srcgen/index.js +++ b/srcgen/index.js @@ -30,6 +30,10 @@ const files = [ [ 'http://static.developer.riotgames.com/docs/lol/gameModes.json', '.gameModes.json' + ], + [ + 'http://static.developer.riotgames.com/docs/lol/maps.json', + '.maps.json' ] ]