lol-constants 3.0.0-rc.0 → 3.0.0-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -10
- package/dist/helpers/item.d.ts +1 -1
- package/dist/helpers/item.js +1 -1
- package/dist/helpers/riotId.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lol.d.ts +2 -2
- package/dist/lol.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -4,9 +4,9 @@ Provides constants, helper functions, types (and type validator functions) for L
|
|
4
4
|
In this library, you will find the main advantage to be: the ability to ‘convert’ between **Keys**, **IDs**, and **Names** of various game objects, namely champions, items, runes, and spells. Here's an example:
|
5
5
|
|
6
6
|
```typescript
|
7
|
-
import {lol} from 'lol-constants'
|
7
|
+
import {lol, ChampionName} from 'lol-constants'
|
8
8
|
|
9
|
-
let championName = 'Wukong'
|
9
|
+
let championName: ChampionName = 'Wukong'
|
10
10
|
|
11
11
|
lol.champion.get(championName).id // 62
|
12
12
|
lol.champion.get(championName).key // 'MonkeyKing'
|
@@ -19,23 +19,21 @@ import {getChampion} from 'lol-constants'
|
|
19
19
|
getChampion(championName).id // 62
|
20
20
|
getChampion(championName).key // 'MonkeyKing'
|
21
21
|
getChampion(championName).name // 'Wukong'
|
22
|
-
|
23
22
|
```
|
24
23
|
|
25
24
|
That's not all. Such a getter function is also designed to be able to accept not only names, but also keys and ids. Here's how:
|
26
25
|
|
27
26
|
```typescript
|
28
|
-
import {getRune} from 'lol-constants'
|
27
|
+
import {getRune, RuneName, RuneKey, RuneId} from 'lol-constants'
|
29
28
|
|
30
|
-
let runeName = 'Cosmic Insight'
|
31
|
-
let runeKey = 'CosmicInsight'
|
32
|
-
let runeId = 8347
|
29
|
+
let runeName: RuneName = 'Cosmic Insight'
|
30
|
+
let runeKey: RuneKey = 'CosmicInsight'
|
31
|
+
let runeId: RuneId = 8347
|
33
32
|
|
34
33
|
getRune(runeName) // ..
|
35
34
|
getRune(runeKey) // ..
|
36
35
|
getRune(runeId) // ..
|
37
36
|
// All return the same rune object: {id: 8347, key: 'CosmicInsight', name: 'Cosmic Insight', ...}
|
38
|
-
|
39
37
|
```
|
40
38
|
|
41
39
|
This paradigm applies to **4** game areas: champions, items, runes (including stat runes and rune trees), and spells. Functions: `getChampion`, `getItem`, `getRune` (plus `getStatRune` and `getRuneTree`), and `getSpell`. Plus a few other areas.
|
@@ -124,7 +122,9 @@ More types can be found here: [examples/](./examples/)
|
|
124
122
|
# Future plans
|
125
123
|
Besides being an easy-to-update library with each League patch and to stay updated whenever a new patch does come out, there are several areas of interest for this library moving forward:
|
126
124
|
+ Provide tools (functions and such) for front-end work: getting icons and such.
|
127
|
-
+ Enable total backwards compatibility with older patches (i.e. no missing items or something for last couple of patches,
|
125
|
+
+ Enable total backwards compatibility with older patches (i.e. no missing items or something for last couple of patches, preferably two years, which is the limit set by Riot API)
|
128
126
|
+ Fulfill any missing types and constants within the context of Riot API. Perhaps provide interfaces for Riot API responses.
|
129
|
-
+ More detailed champions, items, runes, and spells information. Would require
|
127
|
+
+ More detailed champions, items, runes, and spells information. Would require using an own database of those instead of relying on DataDragon.
|
130
128
|
+ Optimized library size/splitting (currently library should be around ~100KB).
|
129
|
+
|
130
|
+
So, why not give this library a star and see where it goes?
|
package/dist/helpers/item.d.ts
CHANGED
@@ -34,6 +34,6 @@ export declare function isTrinketItem(item_id_name: typeof ItemsArr[number] | It
|
|
34
34
|
export declare function isBootsItem(item_id_name: typeof ItemsArr[number] | ItemId | ItemName): boolean;
|
35
35
|
export declare function isConsumableItem(item_id_name: typeof ItemsArr[number] | ItemId | ItemName): boolean;
|
36
36
|
/** Check whether item is available on a certain map. */
|
37
|
-
export declare function
|
37
|
+
export declare function isItemAvailableOnMap(itemId: ItemId, mapId: MapId): boolean;
|
38
38
|
export declare function isItemId(id: number | null | undefined): id is ItemId;
|
39
39
|
export declare function isItemName(name: string | null | undefined): name is ItemName;
|
package/dist/helpers/item.js
CHANGED
@@ -99,7 +99,7 @@ export function isConsumableItem(item_id_name) {
|
|
99
99
|
return getItem(item_id_name).srType == ItemSrTypes.CONSUMABLE;
|
100
100
|
}
|
101
101
|
/** Check whether item is available on a certain map. */
|
102
|
-
export function
|
102
|
+
export function isItemAvailableOnMap(itemId, mapId) {
|
103
103
|
const mapsObjOrItemId = itemNames[Items[itemId].name];
|
104
104
|
if (typeof mapsObjOrItemId == 'number')
|
105
105
|
return false; // Means item is disabled on all maps
|
package/dist/helpers/riotId.js
CHANGED
@@ -4,9 +4,10 @@ const maxRiotTaglineCharCount = 5;
|
|
4
4
|
export function splitRiotId(riotId,
|
5
5
|
/** @default '#' */
|
6
6
|
splitChar = '#') {
|
7
|
+
var _a, _b;
|
7
8
|
const split = riotId.split(splitChar);
|
8
|
-
let name = split[0]
|
9
|
-
let tag = split[1]
|
9
|
+
let name = (_a = split[0]) !== null && _a !== void 0 ? _a : '';
|
10
|
+
let tag = (_b = split[1]) !== null && _b !== void 0 ? _b : '';
|
10
11
|
if (tag.includes(splitChar))
|
11
12
|
tag = '';
|
12
13
|
return {
|
package/dist/index.d.ts
CHANGED
@@ -9,7 +9,7 @@ export * from './constants/participants';
|
|
9
9
|
export { ItemSrTypes } from './enums/ItemSrTypes';
|
10
10
|
export { StatRuneSlots } from './enums/StatRuneSlots';
|
11
11
|
export { getChampion, isChampionId, isChampionKey, isChampionName, } from './helpers/champion';
|
12
|
-
export { getItem, isStarterItem, isBasicItem, isEpicItem, isLegendaryItem, isTrinketItem, isBootsItem, isConsumableItem,
|
12
|
+
export { getItem, isStarterItem, isBasicItem, isEpicItem, isLegendaryItem, isTrinketItem, isBootsItem, isConsumableItem, isItemAvailableOnMap, isItemId, isItemName, } from './helpers/item';
|
13
13
|
export type { RiotId } from './helpers/riotId';
|
14
14
|
export { makeRiotId, splitRiotId, validateRiotId, } from './helpers/riotId';
|
15
15
|
export { getRune, getStatRune, getRuneTree, isRuneId, isRuneKey, isRuneName, isStatRuneId, isStatRuneName, isRuneTreeId, isRuneTreeKey, isRuneTreeName, } from './helpers/rune';
|
package/dist/index.js
CHANGED
@@ -13,7 +13,7 @@ export { ItemSrTypes } from './enums/ItemSrTypes';
|
|
13
13
|
export { StatRuneSlots } from './enums/StatRuneSlots';
|
14
14
|
// # helpers
|
15
15
|
export { getChampion, isChampionId, isChampionKey, isChampionName, } from './helpers/champion';
|
16
|
-
export { getItem, isStarterItem, isBasicItem, isEpicItem, isLegendaryItem, isTrinketItem, isBootsItem, isConsumableItem,
|
16
|
+
export { getItem, isStarterItem, isBasicItem, isEpicItem, isLegendaryItem, isTrinketItem, isBootsItem, isConsumableItem, isItemAvailableOnMap, isItemId, isItemName, } from './helpers/item';
|
17
17
|
export { makeRiotId, splitRiotId, validateRiotId, } from './helpers/riotId';
|
18
18
|
export { getRune, getStatRune, getRuneTree, isRuneId, isRuneKey, isRuneName, isStatRuneId, isStatRuneName, isRuneTreeId, isRuneTreeKey, isRuneTreeName, } from './helpers/rune';
|
19
19
|
export { getSpell, isSpellId, isSpellKey, isSpellName, } from './helpers/spell';
|
package/dist/lol.d.ts
CHANGED
@@ -5,7 +5,7 @@ import { isRankedRank, isRankedTier } from './constants/leagues';
|
|
5
5
|
import { isLocale } from './constants/locales';
|
6
6
|
import { isLane, isLaneType, isPosition, isRole, isTeamId } from './constants/participants';
|
7
7
|
import { getChampion, isChampionId, isChampionKey, isChampionName } from './helpers/champion';
|
8
|
-
import { getItem, isBasicItem, isBootsItem, isConsumableItem, isEpicItem,
|
8
|
+
import { getItem, isBasicItem, isBootsItem, isConsumableItem, isEpicItem, isItemAvailableOnMap, isItemId, isItemName, isLegendaryItem, isStarterItem, isTrinketItem } from './helpers/item';
|
9
9
|
import { makeRiotId, splitRiotId, validateRiotId } from './helpers/riotId';
|
10
10
|
import { getRune, getRuneTree, getStatRune, isRuneId, isRuneKey, isRuneName, isRuneTreeId, isRuneTreeKey, isRuneTreeName, isStatRuneId, isStatRuneName } from './helpers/rune';
|
11
11
|
import { getSpell, isSpellId, isSpellKey, isSpellName } from './helpers/spell';
|
@@ -3149,7 +3149,7 @@ export declare const lol: {
|
|
3149
3149
|
isTrinket: typeof isTrinketItem;
|
3150
3150
|
isBoots: typeof isBootsItem;
|
3151
3151
|
isConsumable: typeof isConsumableItem;
|
3152
|
-
isAvailable: typeof
|
3152
|
+
isAvailable: typeof isItemAvailableOnMap;
|
3153
3153
|
};
|
3154
3154
|
/** ## Runes, Stat Runes, and Rune Trees */
|
3155
3155
|
rune: {
|
package/dist/lol.js
CHANGED
@@ -8,7 +8,7 @@ import { isLane, isLaneType, isPosition, isRole, isTeamId, Lanes, LaneTypes, Pos
|
|
8
8
|
import { ItemSrTypes } from './enums/ItemSrTypes';
|
9
9
|
import { StatRuneSlots } from './enums/StatRuneSlots';
|
10
10
|
import { getChampion, isChampionId, isChampionKey, isChampionName, } from './helpers/champion';
|
11
|
-
import { getItem, isBasicItem, isBootsItem, isConsumableItem, isEpicItem,
|
11
|
+
import { getItem, isBasicItem, isBootsItem, isConsumableItem, isEpicItem, isItemAvailableOnMap, isItemId, isItemName, isLegendaryItem, isStarterItem, isTrinketItem, } from './helpers/item';
|
12
12
|
import { makeRiotId, splitRiotId, validateRiotId } from './helpers/riotId';
|
13
13
|
import { getRune, getRuneTree, getStatRune, isRuneId, isRuneKey, isRuneName, isRuneTreeId, isRuneTreeKey, isRuneTreeName, isStatRuneId, isStatRuneName, } from './helpers/rune';
|
14
14
|
import { getSpell, isSpellId, isSpellKey, isSpellName, } from './helpers/spell';
|
@@ -85,7 +85,7 @@ export const lol = {
|
|
85
85
|
isTrinket: isTrinketItem,
|
86
86
|
isBoots: isBootsItem,
|
87
87
|
isConsumable: isConsumableItem,
|
88
|
-
isAvailable:
|
88
|
+
isAvailable: isItemAvailableOnMap,
|
89
89
|
},
|
90
90
|
/** ## Runes, Stat Runes, and Rune Trees */
|
91
91
|
rune: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lol-constants",
|
3
|
-
"version": "3.0.0-rc.
|
3
|
+
"version": "3.0.0-rc.1",
|
4
4
|
"description": "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.",
|
5
5
|
"license": "MIT",
|
6
6
|
"type": "module",
|