UNPKG

lol-constants

Version:

League of Legends constants, functions, and types. Provides a plathera of functions to easily convert between ID, Name, and Key for champions, items, summoner spells, and runes.

23 lines (22 loc) 1.02 kB
import { failsafeSpell, spellKeys, spellNames, Spells, } from '../objects/generated/Spells'; /** Get a summoner spell by its **id**, **key** or **name**. */ export function getSpell(id_key_name) { var _a, _b, _c; if (typeof id_key_name == 'number') return (_a = Spells[id_key_name]) !== null && _a !== void 0 ? _a : failsafeSpell; if (isSpellKey(id_key_name)) return (_b = Spells[spellKeys[id_key_name]]) !== null && _b !== void 0 ? _b : failsafeSpell; return (_c = Spells[spellNames[id_key_name]]) !== null && _c !== void 0 ? _c : failsafeSpell; } export function isSpellId(id) { return typeof id == 'number' && id in Spells; } export function isSpellKey(key) { return typeof key == 'string' && key in spellKeys; } export function isSpellName(name) { return typeof name == 'string' && name in spellNames; } export function isSpell(id_key_name) { return typeof id_key_name == 'number' ? isSpellId(id_key_name) : (isSpellKey(id_key_name) || isSpellName(id_key_name)); }