lol-constants 3.0.0-rc.0 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +7 -2
- package/dist/lol.js +7 -2
- package/package.json +12 -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,13 +5,18 @@ 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';
|
12
12
|
import { getMap, isMapId, isMapTitle } from './objects/Maps';
|
13
13
|
import { getQueue, isQueueId, isQueueTitle } from './objects/Queues';
|
14
14
|
import { getRegion, isPlatform, isRegion } from './objects/Regions';
|
15
|
+
/**
|
16
|
+
* # `lol-constants`
|
17
|
+
* + [README](https://github.com/kd0010/lol-constants#readme)
|
18
|
+
* + [`lol` object and shorthand function examples](https://github.com/kd0010/lol-constants/blob/main/examples/examples-with-lol.ts)
|
19
|
+
*/
|
15
20
|
export declare const lol: {
|
16
21
|
/**
|
17
22
|
* ## Current patch version
|
@@ -3149,7 +3154,7 @@ export declare const lol: {
|
|
3149
3154
|
isTrinket: typeof isTrinketItem;
|
3150
3155
|
isBoots: typeof isBootsItem;
|
3151
3156
|
isConsumable: typeof isConsumableItem;
|
3152
|
-
isAvailable: typeof
|
3157
|
+
isAvailable: typeof isItemAvailableOnMap;
|
3153
3158
|
};
|
3154
3159
|
/** ## Runes, Stat Runes, and Rune Trees */
|
3155
3160
|
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';
|
@@ -19,6 +19,11 @@ import { ChampionsArr } from './objects/generated/Champions';
|
|
19
19
|
import { ItemsArr } from './objects/generated/Items';
|
20
20
|
import { RunesArr, RuneTreesArr, StatRunesArr } from './objects/generated/Runes';
|
21
21
|
import { SpellsArr } from './objects/generated/Spells';
|
22
|
+
/**
|
23
|
+
* # `lol-constants`
|
24
|
+
* + [README](https://github.com/kd0010/lol-constants#readme)
|
25
|
+
* + [`lol` object and shorthand function examples](https://github.com/kd0010/lol-constants/blob/main/examples/examples-with-lol.ts)
|
26
|
+
*/
|
22
27
|
export const lol = {
|
23
28
|
/**
|
24
29
|
* ## Current patch version
|
@@ -85,7 +90,7 @@ export const lol = {
|
|
85
90
|
isTrinket: isTrinketItem,
|
86
91
|
isBoots: isBootsItem,
|
87
92
|
isConsumable: isConsumableItem,
|
88
|
-
isAvailable:
|
93
|
+
isAvailable: isItemAvailableOnMap,
|
89
94
|
},
|
90
95
|
/** ## Runes, Stat Runes, and Rune Trees */
|
91
96
|
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.2",
|
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",
|
@@ -22,6 +22,17 @@
|
|
22
22
|
"type": "git",
|
23
23
|
"url": "git+https://github.com/kd0010/lol-constants.git"
|
24
24
|
},
|
25
|
+
"keywords": [
|
26
|
+
"lol",
|
27
|
+
"league",
|
28
|
+
"leagueoflegends",
|
29
|
+
"riot",
|
30
|
+
"constants",
|
31
|
+
"types",
|
32
|
+
"api",
|
33
|
+
"typescript",
|
34
|
+
"ts"
|
35
|
+
],
|
25
36
|
"scripts": {
|
26
37
|
"patch:update": "pnpm run scripts:pull && pnpm run scripts:generate && pnpm run build",
|
27
38
|
"temp": "node --no-warnings --loader ts-node/esm dev/scripts/temp",
|