lcinterface
Version:
An easy way to interact with the league client. This module is basically a middle layer between your app and the league client
220 lines (197 loc) • 6.73 kB
Markdown
# League client interface
An easy way to interact with the league client. This module is basically a middle layer between your app and the league client
# Documentation
## Dependencies
- node-fetch@2.6.1
## Importing
```
$ npm install lcinterface
```
```javascript
const { LCIConnector, LCIClient } = require("lcinterface")
const connector = new LCIConnector()
```
## Getting client credentials
```javascript
// optional
// the interval a wich lcinterface checks if the league of legends process is running (default is 1 sec/1000 ms)
connector.setCheckProcessInterval(1000)
// listen for event connect
connector.on("connect", (credentials) => {
// do stuff with our client credentials
// when you are done
connector.disconnect()
})
// start the client connector
connector.connect()
```
### All events
- LCIConnector
- `connect` When lcinterface connects to the league client
- `disconnect` When lcinterface disconnects from the league client
## Using LCIClient
LCIClient is an object with functions and data
### Endpoints
All the built in endpoints in lcinterface
#### Usage
How to use the endpoints
```javascript
await LCIclient.virtualCall(LCIClient.endpoints.user.me, "get")
```
### All endpoints
The built-in endpoints, you cannot make add a new group (ex. user), only new endpoints
- user
- me [get/post] Gets local user data
- game
- gameflow [get] Current gameflow state
- session [get] Current data of the match you are in
- champselect [get] Champion select data
- action (when you [get] session you will see what action means)
- [patch] Needs action id (+`/${actionId}`) and data containing { championId }, doesn't return a body
- [post] Needs action id (+`/${actionId}`) and data containing { championId }, doesn't return a body
- runes
- runes
- [get] All runes of the user
- [put] To change your runes
- spells [patch] Set users active summoner spells, need data { spell1Id, spell2Id }, doesn't return a body
- lobby
- lobby
- [get] Gets all data of the current lobby
- [post] Change lobby data or create a lobby wich needs data { queueId }
- search
- [post] Starts searching a match (if in lobby), doesn't return a body
- [delete] Stops searching a match (if in lobby), doesn't return a body
- partytype [put] Set party to open or closed (string), doesn't return a body
- position [put] Sets your lanes needs data { firstPreference, secondPreference }, doesn't return a body
- matchaccept [post] Accepts a match
- matchdecline [post] Declines a match
#### For all endpoints
[https://lcu.vivide.re/](https://lcu.vivide.re/)
### LCIClient data
All the built in data in lcinterface
#### Usage
```javascript
console.log(LCIClient.game.lanes.UTILITY)
```
### All data
- gameflows
- NONE
- LOBBY
- MATCHMAKING
- READYCHECK
- CHAMPSELECT
- INPROGRESS
- WAITINGFORSTATS
- ENDOFGAME
- lanes
- UNSELECTED
- TOP
- JUNGLE
- MIDDLE
- BOTTOM
- UTILITY
- spells
- Spellname (Barrier, Cleanse, Exhaust, Flash, Ghost, Heal, Smite, Teleport, Clarity, Ignite, Mark)
- [id] Spell id
- [key] Other spell name form (ex. summonerFlash)
- [name] Spellname
- queueId
- normal
- blind
- draft
- ranked
- solo_duo
- flex
- extra
- aram
- partytype
- open
- closed
## States
LCInterface has some built-in "states" that can giv you some information, [how to get states](#getting-a-state) / [how to set/create states](#setting--creating-a-state)
- [hooked] If LCInterfaces is hooked or not (boolean)
- [vcc] Virtual call count, ammount of times a virtual call is made (number)
- [unsafe] Can LCInterface make unsafe virtual calls (boolean), default is true
- + any you add
## Interface functions
### Hooking
"Hook" onto the interface aka initialise the interface, returns false if already hooked <br />
- params
- [credentials] All the credentials
- returns boolean
```typescript
LCIClient.hook(credentials: object): boolean
```
### Unhooking
"Unhook" for the league client, returns false if not yet hooked
- return boolean
```typescript
LCIClient.unhook(): boolean
```
### Unsafe virual calls
You can make [virutal calls](#interacting-with-the-client) if you aren't hooked yet, enabled by default
- params
- [value] Enable or disable the allowing of unsafe call (boolean)
- returns boolean
```typescript
LCIClient.allowUnsafeCalls(value: boolean): boolean
```
### Interacting with the client
Interact with the league client's endpoints **is async**
- params
- [endpoint] Where to make the call to (string)
- [method] What method to use
- [data] (optional) What data to send (object | string), default is empty object
- returns json obj \<T\> | a boolean
```typescript
await LCIClient.virtualCall<T>(endpoint: string, method: methods, data: object | string = {}): Promise<T | boolean>
```
### Getting a state
LCInterface has some built in states (wich you can add to), that you can check
- params
- [state] What state to check (string)
- returns state data \<T\> | false if state doesn't exist
```typescript
LCIClient.getState<T>(state: string): T | boolean
```
### Setting / Creating a state
LCInterface has some built in states, wich you can set or add to
- params
- [state] What state to change / create (string)
- [value] What to set it to
- returns state data \<T\>
```typescript
LCIClient.setState<T>(state: string, value: T): T
```
### Checking a state's value
Here you can check the value of a state
- params
- [state] The state to check (string)
- returns boolean
```typescript
LCIClient.isCorrectValue<T>(state: string, value: T): boolean
```
## Fast interface functions
LCInterface also has a few faster (unsafer) versions of methods
### Fast hook
Same as the default hook but skips any checks, assumes you are unhooked (will overide data) and is still async
- params
- [credentials] Only port and password are required
- returns always true
```typescript
await LCIClient.__fasthook(credentials: base_credentials): boolean
```
### Fast unhook
Same as the default unhook but skips any checks, assumes you are hooked and is still async
- returns always false
```typescript
await LCIClient.__fastunhook(): boolean
```
### Fast virtual call
Same as the default virtual call but skips increasing vcc count, assumes you are hooked and is still async
- returns json obj \<T\>
```typescript
await LCIClient.__fastvirtualCall<T>(endpoint: string, method: methods, data: object | string = {}): Promise<T>
```
## License
[MIT License](LICENSE)