Riven/srcgen/consts/map.rs.dt
Mingwei Samuel 9db4c1a4a5 making some enums
#[non_exhaustive]
2019-10-30 13:29:23 -07:00

36 lines
1 KiB
Text

{{
const dotUtils = require('./dotUtils.js');
const maps = require('./.maps.json');
const groupedMaps = maps.groupBy(({ mapName }) =>
dotUtils.changeCase.constantCase(mapName.replace(/[ ']+/, '')));
}}{{= dotUtils.preamble() }}
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends maps.
#[non_exhaustive]
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[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.constantCase(notes);
}}
/// {{= mapName }}
/// <br>{{= notes }}
{{= name }} = {{= mapId }},
{{
}
}
}}
}