• lol
object and standalone getter function usage
• type validator function usage
import {
// ### Basic constants
MonsterType, // "HORDE" | "DRAGON" | "RIFTHERALD" | "BARON_NASHOR"
DragonType, // "EARTH_DRAGON" | "CHEMTECH_DRAGON" | "AIR_DRAGON" | ...
KillType, // "KILL_FIRST_BLOOD" | "KILL_MULTI" | "KILL_ACE"
BuildingType, // "TOWER_BUILDING" | "INHIBITOR_BUILDING"
TowerType, // "OUTER_TURRET" | "INNER_TURRET" | "BASE_TURRET" | "NEXUS_TURRET"
WardType, // "YELLOW_TRINKET" | "CONTROL_WARD" | "SIGHT_WARD" | ...
QueueType, // "RANKED_SOLO_5x5" | "RANKED_FLEX_SR" | "RANKED_TFT"
GameMode, // "CLASSIC" | "ARAM" | "TUTORIAL" | "URF" | "ONEFORALL" | ...
GameType, // "CUSTOM_GAME" | "TUTORIAL_GAME" | "MATCHED_GAME"
RankedTier, // "CHALLENGER" | "GRANDMASTER" | "MASTER" | "DIAMOND" | ...
RankedRank, // "I" | "II" | "III" | "IV"
Locale, // "cs_CZ" | "el_GR" | "pl_PL" | "ro_RO" | "en_GB" | ...
Position, // "TOP" | "JUNGLE" | "MIDDLE" | "BOTTOM" | "UTILITY"
Role, // "NONE" | "SOLO" | "CARRY" | "SUPPORT"
Lane, // "TOP" | "JUNGLE" | "MIDDLE" | "BOTTOM"
LaneType, // "TOP_LANE" | "MID_LANE" | "BOT_LANE"
TeamId, // 100 | 200
ChampionClass, // "Enchanter" | "Catcher" | "Juggernaut" | "Diver" | ...
// ### Maps, Queues, Regions
MapId, // 3 | 11 | 12 | 10 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 30 | 33
QueueId, // 0 | 420 | 2010 | 2020 | 400 | 430 | 440 | 450 | 700 | ...
Platform, // "BR1" | "EUN1" | "EUW1" | "JP1" | "KR" | "LA1" | "LA2" | ...
Region, // "BR" | "EUNE" | "EUW" | "JP" | "KR" | "LAN" | "LAS" | ...
// ### Champions, Items, Runes, Spells
ChampionId, // 1 | 2 | 3 | 11 | 12 | 13 | 4 | 5 | 6 | 7 | 8 | 9 | ...
ChampionKey, // "Annie" | "Olaf" | "Galio" | "TwistedFate" | "XinZhao" | ...
ChampionName, // "Annie" | "Olaf" | "Galio" | "Twisted Fate" | "Xin Zhao" | ...
ItemId, // 1001 | 1004 | 1006 | 1011 | 1018 | 1026 | 1027 | 1028 | ...
ItemName, // "Boots" | "Faerie Charm" | "Rejuvenation Bead" | "Giant's Belt" | ...
RuneId, // 8005 | 8021 | 8010 | 8009 | 9101 | 9111 | 8014 | 8017 | ...
RuneKey, // "PressTheAttack" | "PresenceOfMind" | "Conqueror" | ...
RuneName, // "Press the Attack" | "Presence of Mind" | "Conqueror" | ...
StatRuneId, // 5001 | 5005 | 5007 | 5008 | 5010 | 5011 | 5013
StatRuneName, // "Health Scaling" | "Attack Speed" | "Ability Haste" | ...
RuneTreeId, // 8000 | 8100 | 8200 | 8400 | 8300
RuneTreeKey, // "Precision" | "Domination" | "Sorcery" | "Inspiration" | "Resolve"
RuneTreeName, // "Precision" | "Domination" | "Sorcery" | "Inspiration" | "Resolve"
SpellId, // 1 | 3 | 11 | 12 | 13 | 4 | 6 | 7 | 14 | 21 | 30 | 31 | ...
SpellKey, // "SummonerBoost" | "SummonerExhaust" | "SummonerFlash" | ...
SpellName, // "Cleanse" | "Exhaust" | "Flash" | "Ghost" | "Heal" | ...
} from 'lol-constants'
Why make getChampion
accept only strict types (i.e. ChampionKey
, ChampionId
, and ChampionName
)?
One clear advantage to this is developer experience and autofilling value. For example, in VS Code it is possible to use the Ctrl + Space
shortcut to bring up a menu of all valid function parameter values for the function you are calling. This can lead to quick debugging or otherwise useful code, like so:
import {getSpell} from 'lol-constants'
// ...
let totalFlashCastsInMatch = 0
for (const ptc of participants) {
// ...
if (ptc.summoner2Id == getSpell('Flash').id) { // ← Quick access to ID by typing Flash!
totalFlashCastsInMatch += ptc.summoner2Casts
}
// ...
}